QuestionQ54

Device-Level Network Automation

Refer to the exhibit.

Question Image

Complete the ncclient request that captures operational interface data from a Cisco IOS XE device. Options may be used once, more than once, or not at all.

Drag & Drop
from ncclient import manager
import xml.dom.minidom

USERNAME = 'cisco'
PASSWORD = 'cisco'
HOST = '10.10.20.181'

data = '''
    < xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
        <>
            <statistics></statistics>
        </>
    </>
'''

with manager.connect(host=HOST, password=PASSWORD, port=830, username=USERNAME,
                     hostkey_verify=False, device_params={'name':'iosxe'}) as m:

    c = m.get(filter=('', data)).data_xml

    xml = xml.dom.minidom.parseString(c)
    xml_pretty_str = xml.toprettyxml()
    print(xml_pretty_str)
Explanation

interfaces-state is the read-only operational-state container in the IETF interfaces YANG model. A subtree filter nests interface beneath that container and selects its statistics child, so a NETCONF get returns the requested operational counters. interfaces is the configuration container, while interface-state is not a node in the displayed model.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!