Retrieving an interface configuration using NETCONF and ncclient
In the previous recipes (for example, the Using NETCONF and ncclient to retrieve the running configuration recipe), we have always dealt with the entire running configuration of our device. While this can be useful in some cases, often, we want to focus on one aspect of our network device such as the list of interfaces. NETCONF has support for this through a concept called filters. Filters allow us to specify criteria on which to filter. Following this, NETCONF will only return entries that match the filter criterion. Filters in NETCONF are, as with everything, defined by an XML document and can be passed on to ncclient
to be sent to the device.
In this recipe, we will examine how to filter our running configuration to only return the interface configuration.
Getting ready
Open your code editor and create a file called get_interface.py
. Next, in your Terminal, navigate to the same directory that you just created...