Gathering facts using netmiko
In the previous recipe (Retrieving command outputs as structured Python data using netmiko and Genie), we saw how to retrieve the output of a command as structured data in Python. In this recipe, we will build upon this functionality to get a profile of all our interfaces. This will show you how to use the parsed data to quickly print out and identify the relevant information.
For this example, we'll be using the show interfaces
command again and, for each interface, we will retrieve and print out the following:
- The interface name
- The status of the interface (enabled or not enabled)
- The physical address of the interface
- The duplex mode
- Any counters that are above 0
Getting ready
Open your code editor and start by creating a file called get_facts.py
. Next, navigate your terminal to the same directory that you just created the get_facts.py
file in.
When installing netmiko via pip, it does not come preinstalled...