0

I am trying to fetch details from the device in Devnet sandbox using the netconf protocol as below, but I am not able to get the details as it is returning me None.

Could someone help me understand if I am doing something wrong?

import xmltodict

router = {
    "host" : "sandbox-iosxe-latest-1.cisco.com",
    "port" : "830",
    "username" : "developer",
    "password" : "C1sco12345"
}

intf_filter = '''
<filter>
    <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
        <interface>
            <name>GigabitEthernet1</name>
        </interface>
    </interfaces>
    <interfaces-state xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
        <interface>
            <name>GigabitEthernet1</name>
        </interface>
    </interfaces-state>
</filter>
'''

with manager.connect(**router, hostkey_verify=False) as m:
    #result = m.get(intf_filter)
    result = m.get(('subtree', intf_filter))
python_response = xmltodict.parse(result.xml)["rpc-reply"]["data"]
print(python_response)


user380696
  • 91
  • 1
  • 3
  • 10

1 Answers1

1

If you use multiple filters you need to do it with a list. (because how the RPC XML is created by ncclient (code)

intf_config = '''
    <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
        <interface>
            <name>GigabitEthernet1</name>
        </interface>
    </interfaces>
'''
intf_state = '''
    <interfaces-state xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
        <interface>
            <name>GigabitEthernet1</name>
        </interface>
    </interfaces-state>
'''
inft_filter = [intf_config, intf_state]

with manager.connect(**router, hostkey_verify=False) as m:
    result = m.get(inft_filter )
ubaumann
  • 180
  • 1
  • 7