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
Tag: asav
[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
[python]TextFSM and TTP
I was testing on another command show run object network, and ttp did not match the word "description" and hence the part about "description" was omitted. This is not a problem as netmiko already has a ready made textFSM template that matches show run object network. Example of ttp with show run object network This … Continue reading [python]TextFSM and TTP
[python]Usage example of ttp
Introduction Thank you Kirill Pletnev for letting me know about ttp module. ttp - Template Text Parser - is an easier to use parser than TextFSM, user does not need to know regex, the regex has already been defined, but how comprehensive is the regex is yet for me to discover. You can refer to … Continue reading [python]Usage example of ttp
[python]Napalm-asa only supports Cisco ASA with REST API
I am using the napalm-asa asa driver, however this driver can only be used if the Cisco ASA installs the REST API package, hence for cisco ASA that does not have REST API, Napalm cannot be used. Instead use netmiko, netmiko is using ssh and has methods to let you send commands. It is not … Continue reading [python]Napalm-asa only supports Cisco ASA with REST API
[python]Use TextFSM to easily get objects you need from unstructured data.
Introduction Netmiko has support of textfsm, however it does not have every template to help the matching, to learn how to use textfsm is useful in this situation which you can create your own template without overly rely on module's limited template. TextFSM is created by google, it provides easier and more structured way of … Continue reading [python]Use TextFSM to easily get objects you need from unstructured data.
[python]How to capture results with nornir
Introduction Nornir is a framework for network automation, it gels popular automation tools such as napalm, netmiko, paramiko and Ansible. However I could not find good examples on how to parse the result if I use show access-list with netmiko_send_command during task.run. There is a built in print_result() function which shows the status and output … Continue reading [python]How to capture results with nornir
[python]Improve on ACL template.
Introduction On previous few posts, the ACL was push to the cisco asa with Nornir, but there was limitation that is only one source ip, one destination ip and one service are allowed, if there is more than one in any of these then only one rule is pushed. But there will be a number … Continue reading [python]Improve on ACL template.