Ciscomation is a python 2.7 script for pushing commands to SSH2 devices based on xml file. It allows usage of multiprocessing, if maintenance description is compatible.
Support any device that are compatible with Exscript
Multiprocess
Thanks to Exscipt detects errors in command line then you can stop or continue
Support special keywords in command lines.
- --multiline-stop
stops --multiline-start mode and sends the buffered lines to the device then wait for the prompt.
- --sleep-xx
Will sleep for xx seconds
- --multiline-start
start multiline input without waiting for prompt, as example you can use it to set the banner. You have to use --multiline-stop if you are using --multiline-start.
- --pause
After the execution of command block will prompt you to go futher, or stop.
- --ignore-error
Will ignore any error generated by following command.
- --print-next
Will print the result of next command
- save-config keyword (to support extra prompts cisco may generate)
- condition by driver commands
- conf-start conf-stop keywords
- command result matching for extra commands execution
Install first configargparse from github because Pypi is not up to date. Then install with pip. And run the command ciscomate directly
ciscomate -h usage: ciscomate-script.py [-h] -i XML_FILE [--log-level LOG_LEVEL] [--log-dir LOG_DIR] [--procnum PROCNUM] This script takes an XML input file reads the switches from it and plays the commands specified Args that start with '--' (eg. -i) can also be set in a config file (/etc/ciscomation.yml or ~/ciscomation.yml or ./ciscomation.yml). The config file uses YAML syntax and must represent a YAML 'mapping' (for details, see http://learn.getgrav.org/advanced/yaml). If an arg is specified in more than one place, then commandline values override config file values which override defaults. optional arguments: -h, --help show this help message and exit -i XML_FILE, --xml-file XML_FILE Name of the xml file containing maintenance --log-level LOG_LEVEL Choose log level in debug, info, warning, error, critical --log-dir LOG_DIR Path of the directory to put the logfiles --procnum PROCNUM Number of process if maintenance is compatible with multi process. --display-driver Display all drivers available to handle SSH interaction and that can be specified in the XML file
When finished the script will generate in the current directory those files:
|
Contains commands passed to the hosts, and console returns. |
|
Contains json serialized detail feedback of the maintenance. |
|
Excel file with table of hosts succes failures and log statistics |
- Somme special commands are not compatible with multiprocess:
- --print-next : Will print the result of next command
- --pause : After the execution of command block will prompt you to go futher, or stop.
Because they are interactive.
Note
Running a maintenance in multiprocess may lead to a disaster if you did not test it before.
First create the maintenance description in an xml file
<?xml version="1.0" encoding="UTF-8"?>
<switches>
<switch>
<driver>ios</driver>
<name>sw-1.mynet.net</name>
<commands>
show version
--multiline-start
show ip int brief
show int desc
--multiline-stop
--sleep-5
</commands>
</switch>
<switch>
<driver>vrp</driver>
<name>sw-2.mynet.net</name>
<commands>
--print-next
display version
system-view
lldp enable
quit
--multiline-start
save all
Y
--multiline-stop
--sleep-5
</commands>
</switch>
</switches>
*mnt.xml:*
Then play the script using ciscomate.py