cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
227
Views
0
Helpful
3
Replies
Mike LWF
Beginner

NETCONF error on CSR 1000v

I was learning NETCONF by following steps on https://developer.cisco.com/learning/tracks/iosxe-programmability/intro-device-level-interfaces/intro-netconf/step/4.

The code worked as expected with CSR 1000v(Version 16.09.03) in Cisco Sandbox, but didn't work with CSR 1000v (Version 17.03.02) in my lab.  The error I'm getting is as below:

$ py get_interface_list.py
Opening NETCONF Connection to 192.168.28.130
Sending a <get-config> operation to the device.

Traceback (most recent call last):
  File "D:\Users\User\git\dne-dna-code\intro-mdp\netconf\get_interface_list.py", line 66, in <module>
    netconf_reply = m.get_config(source = 'running', filter = netconf_filter)
  File "D:\Users\User\git\dne-dna-code\venv\lib\site-packages\ncclient\manager.py", line 212, in execute
    return cls(self._session,
  File "D:\Users\User\git\dne-dna-code\venv\lib\site-packages\ncclient\operations\retrieve.py", line 166, in request
    return self._request(node)
  File "D:\Users\User\git\dne-dna-code\venv\lib\site-packages\ncclient\operations\rpc.py", line 341, in _request
    raise self._reply.error
ncclient.operations.rpc.RPCError: {'type': 'protocol', 'tag': 'unknown-element', 'severity': 'error', 'info': '<?xml version="1.0" encoding="UTF-8"?><error-info xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><bad-element>filter</bad-element>\n</error-info>\n', 'path': '\n    /rpc/get-config\n  ', 'message': None}

Based on the error message, it looks like "filter" is not supported.  For testing purpose, I installed another version of CSR 1000v(version 16.9.6).  It worked like a charm.  Why "filter" is support on 16.9 train but not 17.3 train?

Here's the code snippets from Cisco lab:

 # Create an XML filter for targeted NETCONF queries
 netconf_filter = """
 <filter>
   <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
     <interface></interface>
   </interface>
 </filter>"""
 with manager.connect(
         host=env_lab.IOS_XE_1["host"],
         port=env_lab.IOS_XE_1["netconf_port"],
         username=env_lab.IOS_XE_1["username"],
         password=env_lab.IOS_XE_1["password"],
         hostkey_verify=False
         ) as m:
netconf_reply = m.get_config(source = 'running', filter = netconf_filter)

 

1 ACCEPTED SOLUTION

Accepted Solutions
Mike LWF
Beginner

OK, seems to be IOS XE version related.  Same code works on 16.x train, but doesn't work on 17.x train.

View solution in original post

3 REPLIES 3
wizi
Beginner

I believe you either need to include an interface name inside the <interface> tag or just remove it all together to get an entire list of interfaces.

To be precise, based on the YANG model, you need to specify 'name' of the interface:

 # Create an XML filter for targeted NETCONF queries
 netconf_filter = """
 <filter>
   <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
     <interface>
<name>Loopback0</name>
</interface> </interface> </filter>"""
Yan Gorelik
YDK Solutions
Mike LWF
Beginner

OK, seems to be IOS XE version related.  Same code works on 16.x train, but doesn't work on 17.x train.

View solution in original post

Content for Community-Ad