[python]Creating vlans on multiple switches

Introduction The entire script demo can be found here. The script reads from an excel sheet named as "vlans.xlsx" and extracts the information, the information is then converted into vlan commands with a jinja2 template, the script is able to send to multiple switches by using threading, on each thread a new Switch instance is … Continue reading [python]Creating vlans on multiple switches

Advertisement

[python]Understanding how to capture the result you need with Nornir

Introduction The documentation has illustrated how to display the output to the console screen, however it did not explicitly show how to capture the data you need. It does document about what is AggregatedResult object and Result object, but still using examples will be easier to understand and also to encourage more people to use … Continue reading [python]Understanding how to capture the result you need with Nornir

[python]Nornir framework usage example 1 – show ip int brief

Introduction Before using Nornir, I was using netmiko, netmiko is a steady module which makes configuring, getting information from cisco based devices easily. Of course netmiko is not limited to just Cisco, it is a multi-vendor module. Napalm is another network module which does the same thing as netmiko, however when dealing with Cisco ios … Continue reading [python]Nornir framework usage example 1 – show ip int brief

[python]TextFSM to match show interface summary

The Cisco ASAv has a command show interface summary, this command output has a lot of information, these are the interesting information I need from this command: Interface id including the sub interface if available nameif, which is the name interface which must be configured administrative status protocol status vlan id if available ip address … Continue reading [python]TextFSM to match show interface summary

Do not update netmiko to version 5 if you are using it with nornir

I have been using nornir to call netmiko, the netmiko version used by nornir is version 2.4.2, netmiko has just updated to version 3.0, before I upgraded the netmiko, I could push config set. After I upgraded netmiko to 3.0, my script started raised netmiko timeout, but the commands were sent to the firewall. From … Continue reading Do not update netmiko to version 5 if you are using it with nornir

[python]Comparing execution time without threading, with threadpoolexecutor and threading subclass

3 round results to print out the execution time of calling the functions This is a comparison in execution time by sending show version to three Cisco ASA - fw01, fw02 and fw03. All connections with netmiko.ConnectHandler has a global_delay_factor of 0.5s. I have made three functions: connect_device_type_1: This function does not use threading but … Continue reading [python]Comparing execution time without threading, with threadpoolexecutor and threading subclass

[python]Grow commands from a template with jinja2

Problem I made a template to push object network configuration to Cisco ASA, this is how the template looks like: conf_attr is the keyword to store the payload I sent to Cisco ASA via Nornir/netmiko, the problem with this template is only one command is sent per session. In order to commands to be sent … Continue reading [python]Grow commands from a template with jinja2

[python]Capture return values after threads are finished.

Return value lost after threads finished I have made two functions: The jinja template for preparing the object network {name} command: Then I create a test code to push multiple object network {name} commands to a single cisco asa - fw02. To achieve concurrency I use the threading.Thread module, however my return value of send_net_objs_to_asa_host … Continue reading [python]Capture return values after threads are finished.

[python]show run object network

Cisco ASA's show run object network will show the subnet, host and range objects, netmiko has a textfsm template to match the result in dictionary, however there is no template to match show run object service hence for the service part you will need to write your own textfsm template. On this example I will … Continue reading [python]show run object network

[python]Convert TextFSM nested list data into dictionary

Introduction Reference: http://gratuitousarp.info/a-quick-example-of-using-textfsm-to-parse-data-from-cisco-show-commands/ The reference article alluded a method known as value_map, I immediately knew it is possible to change to dictionary easily when I saw the output of value_map. This is how the output of value_map looks like, and this explains how the variable maps to the regex, if you are using re module … Continue reading [python]Convert TextFSM nested list data into dictionary