2.9 Lab - NETCONF WPython Get Operational Data
2.9 Lab - NETCONF WPython Get Operational Data
Objectives
Part 1: Retrieve the IOS XE VM’s Operational Data - Statistics
Background / Scenario
In this lab, you will learn how to use NETCONF to retrieve operational data from the network device.
Required Resources
Access to a router with the IOS XE operating system version 16.6 or higher
Python 3.x environment
Instructions
b. In the new Python script file editor, import the “manager” class from the ncclient module and the
xml.dom.minidom module:
a. Set up an m connection object using the manager.connect() function to the IOS XE device.
b. After a successful NETCONF connection, using the “get()” function of the “m” NETCONF session object
to retrieve and print the device’s operational data. The get() function expects a “filter” string parameter
that defines the NETCONF filter.
The following filter retrieves the interfaces-state operational data (statistics), as defined in the ietf-
interfaces YANG model:
Note: Executing the get() function without a filter is similar to execute “debug all”.
netconf_filter = """
<filter>
<interfaces-state xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"/>
2017 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 1 of 2 www.netacad.com
Lab – NETCONF w/Python: Get Operational Data
</filter>
"""
2017 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 2 of 2 www.netacad.com