A year ago or so I posted an article on LinkedIn, How to configure 50000+ CPE routers.
Now I want to go a step further in scripting and share you my way of using Python for scripting Cisco routers. I show you the software and its usage for large scale scripting deployment because I do believe it is an extremely powerful network scripting tool, and all who face similar challenges might find it a good friend. It is not a commercial, I do use the software every day and I develop Pretty Good Terminal as needed to achieve my goals quicker and simpler in a more & more elegant way.
In this article I do not wan to dive deep into scripting details but rather just flash some cool features of PGT worth highlighting. Should you be interested in details, you will find quite detailed descriptions about these features on the website of the software.
A Visual Script using Python
The software I developed for router mass-configuration has evolved a lot since its first publication and now allows the creation of scripts like drawing an active flowchart, called a Visual Script. Both Python or C# can be then chosen as the script language.
This time I was tasked to create a script for updating around 20.000, Cisco 800 series routers. Armed with the aforementioned tool-set, it was easy to transform the requirements to a script flow:
In the flowchart each element have its own Python code to do its humble part of the whole script by dynamically constructing and issuing specific CLI commands, analyze the result, and build an update script accordingly.
For instance, the UpdatePorts element issues the CLI command "sh run int vlan1" and parses the result in order to generate the required IOS commands to transfer the same ip settings of the VLAN1 interface to Vlan10:
For instance, the UpdatePorts element issues the CLI command "sh run int vlan1" and parses the result in order to generate the required IOS commands to transfer the same ip settings of the VLAN1 interface to Vlan10:
Comments
Post a Comment