Patrick Denis > 2020 > August
Monthly Archive: August 2020
admin
August 24, 2020
So in the following example we import template from jinja2 and then we define our template : text1 and bgp_config, Then we use the variable j2_template = and we call the template that we want : in this example config1….
Read more
admin
August 24, 2020
Variables : var: {{ variable_name_here }} Conditionals : ( you can have nested conditional too in your template ) {% if var ==’value’ %} text here {% elif var ==’other value’ %} text here {% else %} text here {%…
Read more
admin
August 11, 2020
https://regex101.com/ <— is a online regex builder ! you can copy your output and then build your expression Medium.com has done an excellent/exceptional work and i did copy the content here for me for fast search, but all credit goes…
Read more
admin
August 11, 2020
Took me a moment to understand 😉 but the Start is how you define where to start from the output fields and then you specified the possible value ( variable ) of each header to create the table to be…
Read more
admin
August 9, 2020
Template should look like this : #Definition Value VARIABLE (regular expression pattern) Value VARIABLE (regular expression pattern) Value VARIABLE (regular expression pattern) #TxtFSM Start Start ….Regex Expression for what you are looking for : ^Device.*ID -> LLDP LLDP ….^${VARIABLE}.* ->…
Read more
admin
August 9, 2020
When calling for library there is different way of doing this . import re Then you need to specify the re.search to be able to use the search function. from re import search Then no need to use the re.search…
Read more
admin
August 4, 2020
This is the methods available for CiscoConfParse : find_all_children(linespec, exactmatch=False, ignore_ws=False) Returns the parents matching the linespec, and all their children. This method is different than find_children(), because find_all_children() finds children of children. find_children() only finds immediate children. Parameters linespecstr Text regular expression for the line to…
Read more
admin
August 4, 2020
CiscoConfParse is a library for Cisco device. : pip install ciscoconfparse Example : from ciscoconfparse import ciscoconfparse Cisco_obj = CiscoConfParse(“show_run.txt”) print(Cisco_obj) <—- this will return all the information about that object If using Netmiko to pull information from any device into a…
Read more
admin
August 4, 2020
JSON is usually use when doing computer to computer communication and network devices API’s. YAML is usually most easier to read for humans , common use in Ansible.
admin
August 4, 2020
This is going to be a example how to create a new dictionary out of an output : 1st the dictionary that we are going to change with only specific items with different key names : from pprint import pprint…
Read more