[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]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]regex to find mac address

This is my interface mac address To search for the substring from the lines of string i use the search method. This is the pattern pattern = r"([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}" And in order to return the substring only use the group() method. If you print the re.search result without using group method you will get the entire … Continue reading [python]regex to find mac address

[python]Match most of the Cisco ASA access list patterns with regular expression

Regular expression reference Purchase the course by Sujith George The Complete Regular Expressions Course:Beginner to Advanced from Udemy Study this code from git hub, this code gives a good idea on how you should match access-list, from this course I realize the regex module can convert the matched data to dictionary. Read this documentation about … Continue reading [python]Match most of the Cisco ASA access list patterns with regular expression

[python]Automating OSPF configuration of two routers

Network diagram There are two vIOS which are R1 and R2, they have their gi0/2 and gi0/3 connected to the R5 switch, the configuration is pushed from the cloud through their gi0/2 and gi0/3 to configure their gi0/0 to become OSPF neighbours. Objective To configure the two routers to become ospf neighbors, the OSPF configuration … Continue reading [python]Automating OSPF configuration of two routers

[python]Convert show ip int brief into structured json data

Cisco IOS commands output is unstructured in the perception of scripting, the output format made sense only to engineers, however if you need to program such output is difficult if the output is not processed. One of the better way to structure the unstructured cisco output is to check each row of the output, then … Continue reading [python]Convert show ip int brief into structured json data

[python]Simple web application for storing contacts

Introduction This is a practice mini project for me to get hold of API, sqlite3 and regex. The objective is to capture contact information and store into a sqlite3 database file - contacts.db. This is not a full fledged web application for storing contacts however can be used as a based for additional features. Information … Continue reading [python]Simple web application for storing contacts