Skip to main content

The CLI that doesn't impose you any language

Project description

[![Build Status](https://travis-ci.org/chadell/netcli.svg?branch=master)](https://travis-ci.org/chadell/netcli)

# NETCLI

netcli is the CLI for the people who doesn't want to remember every command from every vendor gear.

Networking nowadays is moving away from traditional CLI operation, but there is still some debugging use-cases when a CLI interaction gives some benefits. However, when you spend more time coding than CLIing, you end up forgetting about specific CLI syntax, still necessary when you are managing a multi-vendor fleet.

To ovecome this issue, **netcli** lets you create your own CLI language, for interact with any device using your own custom commands.

netcli solves this problem using a simple approach:
* You have a **config** mode to handle your custom commands and the translation for all the specific vendors you are interested in.
* You have a **connect** mode to run an interactive CLI against your devices and enjoy your commands

## Installation

```
pip install netcli
```

## How to run it

## Config

> Your customs commands will be stored in `~/.my_netcli_commands.json`

### Add

```
$ netcli config add "bgp received routes neighbor:192.0.2.1"
```

Note:
* Use quotes to add your command
* Arguments should come at the end, using the pattern `<arg_name>:<default_value>`

This will enter an interactive mode to provide:
* Description: Useful to remember what this command is doing
* Vendor specific implementations, using this format: `<vendor_type> - <vendor_command>`
* **important** within `<vendorcommand>` you can place the arguments provided using `[arg_name]`
* Example: `show bgp summary [instance (vrf)]`
* Every argument is between square brackets `[]`
* Within the brackets, the parenthesis `()` is the keyword that will be replaced
* If an argument keyword has the string value "None", the argument (and related text) will be omitted
* `<vendor_type>` comes from [Netmiko library](https://github.com/ktbyers/netmiko/blob/develop/netmiko/ssh_dispatcher.py#L76)

### Delete

```
$ netcli config delete "bgp received routes"
```

### Show

```
$ netcli config show
```

It listes the custom commands with the description and ports.
If you need the vendor implementation, use `--verbose`


## Interactive CLI

```
$ netcli connect <target> -v <vendor_type>
```

Enjoy it!

Notes:
* To overwrite a default value use `[<arg_name>:<new_value>]`
* Execution of **raw commands** is possible starting the command with `r- `
* **Matching output** of custom commands can be achieved by adding ` | ` and the string to match
* Use `help`/`h` to get extra help

### Default options

You can overwrite default behaviours by using file `~/.netcli.cfg` to define some custom values to easy your operation:

```
{
"dns_suffix": ".opendns.com",
"global_delay_factor": 6,
"max_lines": 20
}
```

Supported values:

* **dns_suffix** is concatenated at the end of your target name
* **max_lines** limit the maximum number of lines to be returned to the CLI (this doesn't affect the logs)
* **log_path** full path to store the logging of the session. By default is the current directory with the timestamp (i.e. netcli_20190303-194937)
* **timeout** Netmiko timeout
* **global_delay_factor** Netmiko global_delay_factor

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netcli-0.0.8.tar.gz (12.2 kB view details)

Uploaded Source

File details

Details for the file netcli-0.0.8.tar.gz.

File metadata

  • Download URL: netcli-0.0.8.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for netcli-0.0.8.tar.gz
Algorithm Hash digest
SHA256 67fb7ecd8530522a3e19ea5d0d939873714b2ff0504d1d5f3d41851807e2c42b
MD5 25690c7ad049530a855159a4006b3ed2
BLAKE2b-256 e3c0f5ecef640ced5a2161093f54d2df79abb883fd81b9cfc944702983c7da82

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page