Skip to main content

Network Automation from the Command Line

Project description

CLA

PyPI Python Version

The CLA Command Line interface Automation is an Async Typer Python-based application designed to automate infrastructure directly from the command line. With CLA, there is no need to write a single line of code, users simply follow the options presented in the help menu. When I thought about building CLA, I considered those network engineers who have not yet acquired the necessary software knowledge, so CLA was specifically designed to enable engineers who have not yet acquired software knowledge to progress in the practice of automation. CLA lets you both extract configurations and set up networking devices. You can enter connection and configuration parameters either via the command line or using JSON files. Another reason I decided to develop CLA is to enable its commands to be invoked from any programming language, once again, without requiring a single line of code for automation. CLA version 1.X.X focuses exclusively on Network Automation, while version 2.X.X will introduce Cloud Automation capabilities.

Supported devices:

  • Cisco IOS
  • Cisco XR
  • Cisco XE
  • Cisco NXOS
  • Juniper
  • Arista
  • Huawei
  • Extreme
  • Alcatel
  • Vyos
  • Generic Telnet

Instalation:

Since CLA generates working files, it is recommended to create a virtual environment (to avoid potential conflicts between Python libraries) and install it there. Alternatively, if you prefer a global installation, you only need to create a working directory. Once installed, it is advisable to run the cla --install-completion command so that the TAB key helps navigate the options menu. Additionally, while typing a command, the --help parameter can be used anywhere to obtain context-based assistance.

From PyPY:

$ pip install cli-automation

Project Repository

Usage:

CLA Video Tutorial

Navigation Map

$ cla [OPTIONS] COMMAND [ARGS]...

Options:

  • -V, --version
  • --install-completion: Install completion for the current shell.
  • --show-completion: Show completion for the current shell, to copy it or customize the installation.
  • --help: Show this message and exit.

Commands:

  • templates: Create examples of configuration files
  • ssh: Accesses devices via the SSH protocol
  • telnet: Accesses devices via the Telnet protocol
  • tunnel: Manage tunnel with Bastion Host

cla templates

The cla templates command generates example files, which can be used to create working files, both for connection parameters and for device configuration commands

Usage:

$ cla templates [OPTIONS]

Options:

  • -v, --verbose: Verbose level [default: 1; 0<=x<=2]
  • --help: Show this message and exit.

cla ssh

The cla ssh command allows access to devices via the SSH protocol. The command can be used to pull or push configurations to devices. To structure the output data when retrieving configurations, the cla ssh pullconfig command uses TextFSM templates. If the query command is included in the templates, the output will be in JSON format; otherwise, the output will be in TXT format.

Usage:

$ cla ssh [OPTIONS] COMMAND [ARGS]...

Options:

  • --help: Show this message and exit.

Commands:

  • onepull: Pull config from a single host
  • pullconfig: Pull config from multiple hosts
  • onepush: Push config to a single host
  • pushconfig: Push config to multiple hosts

cla ssh onepull

Pull config from a single host

Usage:

$ cla ssh onepull [OPTIONS]

Options:

  • -h, --host TEXT: host name or ip address [required]
  • -u, --user TEXT: username [required]
  • -c, --cmd Multiple -c parameter: commands to execute on the device [required]
  • -t, --type [cisco_ios|cisco_xr|cisco_xe|cisco_nxos|juniper|juniper_junos|arista_eos|huawei|huawei_vrp|alcatel_sros|vyos|vyatta_vyos|extreme_exos|extreme]: device type [required]
  • -p, --port INTEGER: port [default: 22]
  • -v, --verbose: verbose level [default: 0; 0<=x<=2]
  • -o, --output FILENAME Json file: output file [default: output.json]
  • -d, --delay FLOAT RANGE: global delay [default: 0.1; 0.1<=x<=4]
  • -s, --cfg TEXT: ssh config file
  • --help: Show this message and exit.

cla ssh pullconfig

the commands can be entered via the command line or through a JSON file

Usage:

$ cla ssh pullconfig [OPTIONS]

Options:

  • -h, --hosts FILENAME Json file: group of hosts [required]
  • -c, --cmd Multiple -c parameter: commands to execute on the device
  • -f, --cmdf FILENAME Json file: commands to configure on the device
  • -v, --verbose: verbose level [default: 0; 0<=x<=2]
  • -o, --output FILENAME Json file: output file [default: output.json]
  • --help: Show this message and exit.

cla ssh onepush

the commands can be entered via the command line or through a JSON file

Usage:

$ cla ssh onepush [OPTIONS]

Options:

  • -h, --host TEXT: host name or ip address [required]
  • -u, --user TEXT: username [required]
  • -t, --type [cisco_ios|cisco_xr|cisco_xe|cisco_nxos|juniper|juniper_junos|arista_eos|huawei|huawei_vrp|alcatel_sros|vyos|vyatta_vyos|extreme_exos|extreme]: device type [required]
  • -c, --cmd Multiple -c parameter: commands to configure the device
  • -f, --cmdf FILENAME Json file: commands to configure the device
  • -p, --port INTEGER: port [default: 22]
  • -v, --verbose: verbose level [default: 0; 0<=x<=2]
  • -o, --output FILENAME Json file: output file [default: output.json]
  • -d, --delay FLOAT RANGE: global delay factor [default: 0.1; 0.1<=x<=4]
  • -s, --cfg TEXT: ssh config file
  • --help: Show this message and exit.

cla ssh pushconfig

the commands must be provided through a JSON file

Usage:

$ cla ssh pushconfig [OPTIONS]

Options:

  • -h, --hosts FILENAME Json file: group of hosts [required]
  • -f, --cmd FILENAME Json file: commands to configure the device [required]
  • -v, --verbose: verbose level [default: 0; 0<=x<=2]
  • -o, --output FILENAME Json file: output file [default: output.json]
  • --help: Show this message and exit.

cla telnet

Telnet was added to CLA to access older devices that, for some reason, do not support SSH. Telnet operates in a generic way, and configuration commands must follow the structure explained in the telnet_commands_structure.json file, file generated by the cla templates command. However, whenever possible, SSH remains the preferred protocol.

Usage:

$ cla telnet [OPTIONS] COMMAND [ARGS]...

Options:

  • --help: Show this message and exit.

Commands:

  • pullconfig: Pull config from multiple hosts
  • pushconfig: Push config file to multiple hosts

cla telnet pullconfig

Pull config from multiple hosts

Usage:

$ cla telnet pullconfig [OPTIONS]

Options:

  • -h, --hosts FILENAME Json file: group of hosts [required]
  • -c, --cmd Single -c parameter: command to execute on the device [required]
  • -v, --verbose: verbose level [default: 0; 0<=x<=2]
  • -o, --output FILENAME text file: output file [default: output.txt]
  • --help: Show this message and exit.

cla telnet pushconfig

Push config file to multiple hosts

Usage:

$ cla telnet pushconfig [OPTIONS]

Options:

  • -h, --hosts FILENAME Json file: group of hosts [required]
  • -f, --cmdf FILENAME Json file: commands to configure on the device [required]
  • -v, --verbose: verbose level [default: 0; 0<=x<=2]
  • -o, --output FILENAME text file: output file [default: output.txt]
  • --help: Show this message and exit.

cla tunnel

Sometimes, the machine running CLA doesn’t have direct access to the devices and must go through a Bastion Host or Jump Host. To connect via a Bastion Host, you can either configure SSH specifically or set up a tunnel (CLA supports both modes of operation). Personally, I think creating a tunnel is more efficient since it avoids SSH configuration, specially when using Telnet commands. Using cla tunnel, you can create or remove a SOCKS5 tunnel. For cla tunnel to function properly, the host running CLA must have easy access to the Bastion Host (it should be listed in the Bastion Host's known_hosts file). CLA constantly monitors the tunnel’s status, but you can also manually check it using the Linux command lsof -i:{local_port}.

Usage:

$ cla tunnel [OPTIONS] COMMAND [ARGS]...

Options:

  • --help: Show this message and exit.

Commands:

  • setup: Setup a tunnel to the Bastion Host
  • kill: Kill the tunnel to the bastion Host
  • status: Check the tunnel status

cla tunnel setup

Usage:

$ cla tunnel setup [OPTIONS]

Options:

  • -u, --user TEXT: bastion host username [required]
  • -b, --bastion TEXT: bastion name or ip address [required]
  • -p, --port INTEGER RANGE: local port [default: 1080; 1000<=x<=1100]
  • -t, --timeout INTEGER RANGE: timeout in seconds for the tunnel startup [default: 10; 3<=x<=25]
  • -v, --verbose: verbose level [default: 1; 0<=x<=2]
  • --help: Show this message and exit.

cla tunnel kill

Usage:

$ cla tunnel kill [OPTIONS]

Options:

  • -v, --verbose: verbose level [default: 1; 0<=x<=2]
  • --help: Show this message and exit.

cla tunnel status

Usage:

$ cla tunnel status [OPTIONS]

Options:

  • -p, --port INTEGER RANGE: local port [default: 1080; 1000<=x<=1100]
  • -t, --timeout INTEGER RANGE: timeout in seconds for the tunnel return its status [default: 10; 3<=x<=20]
  • -r, --test INTEGER: remote port for testing the tunnel [default: 22]
  • -v, --verbose: verbose level [default: 1; 0<=x<=2]
  • --help: Show this message and exit.

Logging:

CLA includes an efficient Log System that allows you to view INFO, DEBUG, CRITICAL, and ERROR details for each operation performed by CLA. The Log System includes a log file rotation based on file size. Each time the log file exceeds 5 MB, a new log file will be created.

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

cli_automation-1.6.2.tar.gz (349.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cli_automation-1.6.2-py3-none-any.whl (363.1 kB view details)

Uploaded Python 3

File details

Details for the file cli_automation-1.6.2.tar.gz.

File metadata

  • Download URL: cli_automation-1.6.2.tar.gz
  • Upload date:
  • Size: 349.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.9 Darwin/24.3.0

File hashes

Hashes for cli_automation-1.6.2.tar.gz
Algorithm Hash digest
SHA256 58f137ba7706b6a458611e50e610953b2b3558b03141aaf2d9234b38bb718a23
MD5 83383ff5c3d910291ae29a64ed845a75
BLAKE2b-256 0e41668c07fe2403b862584ed6eb5f9299181ca526d8b7bedceb868e1c8b6122

See more details on using hashes here.

File details

Details for the file cli_automation-1.6.2-py3-none-any.whl.

File metadata

  • Download URL: cli_automation-1.6.2-py3-none-any.whl
  • Upload date:
  • Size: 363.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.9 Darwin/24.3.0

File hashes

Hashes for cli_automation-1.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1703670c6a5944b9b3413b91718ed96929ace073c8ac9312d4aef76b25875df2
MD5 d0656059304a27ffe69541367574950a
BLAKE2b-256 778dba8088be666c7e968ccef894a6670623f318b5b579bc5bca6f223d105542

See more details on using hashes here.

Supported by

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