<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic NETCONF error on CSR 1000v in Tools</title>
    <link>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4264458#M1518</link>
    <description>&lt;P&gt;I was learning NETCONF by following steps on&amp;nbsp;&lt;A href="https://developer.cisco.com/learning/tracks/iosxe-programmability/intro-device-level-interfaces/intro-netconf/step/4" target="_blank" rel="noopener"&gt;https://developer.cisco.com/learning/tracks/iosxe-programmability/intro-device-level-interfaces/intro-netconf/step/4&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;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.&amp;nbsp; The error I'm getting is as below:&lt;/P&gt;&lt;PRE&gt;&lt;FONT size="2"&gt;$ py get_interface_list.py
Opening NETCONF Connection to 192.168.28.130
Sending a &amp;lt;get-config&amp;gt; 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 &amp;lt;module&amp;gt;
    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': '&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&amp;lt;error-info xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"&amp;gt;&amp;lt;bad-element&amp;gt;filter&amp;lt;/bad-element&amp;gt;\n&amp;lt;/error-info&amp;gt;\n', 'path': '\n    /rpc/get-config\n  ', 'message': None}&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;Based on the error message, it looks like "filter" is not supported.&amp;nbsp; For testing purpose, I installed another version of CSR 1000v(version 16.9.6).&amp;nbsp; It worked like a charm.&amp;nbsp; Why "filter" is support on 16.9 train but not 17.3 train?&lt;/P&gt;&lt;P&gt;Here's the code snippets from Cisco lab:&lt;/P&gt;&lt;PRE&gt;&lt;FONT size="2"&gt; # Create an XML filter for targeted NETCONF queries
 netconf_filter = """
 &amp;lt;filter&amp;gt;
   &amp;lt;interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"&amp;gt;
     &amp;lt;interface&amp;gt;&amp;lt;/interface&amp;gt;
   &amp;lt;/interface&amp;gt;
 &amp;lt;/filter&amp;gt;"""&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE&gt; 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:&lt;/PRE&gt;&lt;PRE&gt;netconf_reply = m.get_config(source = 'running', filter = netconf_filter)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Dec 2020 22:20:10 GMT</pubDate>
    <dc:creator>Mike LWF</dc:creator>
    <dc:date>2020-12-28T22:20:10Z</dc:date>
    <item>
      <title>NETCONF error on CSR 1000v</title>
      <link>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4264458#M1518</link>
      <description>&lt;P&gt;I was learning NETCONF by following steps on&amp;nbsp;&lt;A href="https://developer.cisco.com/learning/tracks/iosxe-programmability/intro-device-level-interfaces/intro-netconf/step/4" target="_blank" rel="noopener"&gt;https://developer.cisco.com/learning/tracks/iosxe-programmability/intro-device-level-interfaces/intro-netconf/step/4&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;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.&amp;nbsp; The error I'm getting is as below:&lt;/P&gt;&lt;PRE&gt;&lt;FONT size="2"&gt;$ py get_interface_list.py
Opening NETCONF Connection to 192.168.28.130
Sending a &amp;lt;get-config&amp;gt; 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 &amp;lt;module&amp;gt;
    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': '&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&amp;lt;error-info xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"&amp;gt;&amp;lt;bad-element&amp;gt;filter&amp;lt;/bad-element&amp;gt;\n&amp;lt;/error-info&amp;gt;\n', 'path': '\n    /rpc/get-config\n  ', 'message': None}&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;Based on the error message, it looks like "filter" is not supported.&amp;nbsp; For testing purpose, I installed another version of CSR 1000v(version 16.9.6).&amp;nbsp; It worked like a charm.&amp;nbsp; Why "filter" is support on 16.9 train but not 17.3 train?&lt;/P&gt;&lt;P&gt;Here's the code snippets from Cisco lab:&lt;/P&gt;&lt;PRE&gt;&lt;FONT size="2"&gt; # Create an XML filter for targeted NETCONF queries
 netconf_filter = """
 &amp;lt;filter&amp;gt;
   &amp;lt;interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"&amp;gt;
     &amp;lt;interface&amp;gt;&amp;lt;/interface&amp;gt;
   &amp;lt;/interface&amp;gt;
 &amp;lt;/filter&amp;gt;"""&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE&gt; 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:&lt;/PRE&gt;&lt;PRE&gt;netconf_reply = m.get_config(source = 'running', filter = netconf_filter)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2020 22:20:10 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4264458#M1518</guid>
      <dc:creator>Mike LWF</dc:creator>
      <dc:date>2020-12-28T22:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: NETCONF error on CSR 1000v</title>
      <link>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4264515#M1519</link>
      <description>&lt;P&gt;I believe you either need to include an interface name inside the &amp;lt;interface&amp;gt; tag or just remove it all together to get an entire list of interfaces.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2020 02:27:13 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4264515#M1519</guid>
      <dc:creator>neteng1</dc:creator>
      <dc:date>2020-12-29T02:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: NETCONF error on CSR 1000v</title>
      <link>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4264807#M1520</link>
      <description>&lt;P&gt;To be precise, based on the YANG model, you need to specify 'name' of the interface:&lt;/P&gt;&lt;PRE&gt;&lt;FONT size="2"&gt; # Create an XML filter for targeted NETCONF queries
 netconf_filter = """
 &amp;lt;filter&amp;gt;
   &amp;lt;interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"&amp;gt;
     &amp;lt;interface&amp;gt;&lt;BR /&gt;       &amp;lt;name&amp;gt;Loopback0&amp;lt;/name&amp;gt;&lt;BR /&gt;     &amp;lt;/interface&amp;gt;
   &amp;lt;/interface&amp;gt;
 &amp;lt;/filter&amp;gt;"""&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Dec 2020 18:02:10 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4264807#M1520</guid>
      <dc:creator>yangorelik</dc:creator>
      <dc:date>2020-12-29T18:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: NETCONF error on CSR 1000v</title>
      <link>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4265251#M1521</link>
      <description>&lt;P&gt;OK, seems to be IOS XE version related.&amp;nbsp; Same code works on 16.x train, but doesn't work on 17.x train.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2020 14:31:41 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4265251#M1521</guid>
      <dc:creator>Mike LWF</dc:creator>
      <dc:date>2020-12-30T14:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: NETCONF error on CSR 1000v</title>
      <link>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4437180#M1522</link>
      <description>&lt;P&gt;Any idea how to build the netconf_filter on &lt;SPAN&gt;IOS XE&amp;nbsp;&lt;/SPAN&gt;1&lt;SPAN&gt;7.x ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 07:42:16 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4437180#M1522</guid>
      <dc:creator>EvanC</dc:creator>
      <dc:date>2021-07-22T07:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: NETCONF error on CSR 1000v</title>
      <link>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4437468#M1523</link>
      <description>&lt;P&gt;The &lt;EM&gt;ietf-interfaces&lt;/EM&gt; model did not change in 17.x comparing to 16.x, therefore the filter should be the same. What might be not working for you is the interface name, possibly the interfaces names are different on your 17.x router. So try first to get all interfaces with the filter:&lt;/P&gt;&lt;PRE&gt;&lt;FONT size="2"&gt;# Create an XML filter for targeted NETCONF queries
 netconf_filter = """
 &amp;lt;filter&amp;gt;
   &amp;lt;interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces" /&amp;gt;
 &amp;lt;/filter&amp;gt;"""&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;If that is not working, then you have model implementation issue in Netconf on 17.x.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 18:11:10 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4437468#M1523</guid>
      <dc:creator>yangorelik</dc:creator>
      <dc:date>2021-07-22T18:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: NETCONF error on CSR 1000v</title>
      <link>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4571512#M1524</link>
      <description>&lt;P&gt;So I hit this same issue and tried to understand why its failing. I am on the path to learn netconf with ncclient and Cisco CSR.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;When you use this in your code&lt;/P&gt;&lt;LI-CODE lang="python"&gt;netconf_reply = m.get_config(source = 'running', filter=netconf_filter)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The function that converts that into an RPC xml structure looks like this. Note that nc: is not in front of the filter. This works in 16.x but fails in 17.x&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:c8b7b93b-da4f-4139-8153-7275ea80f5f3"&amp;gt;
&amp;lt;nc:get-config&amp;gt;
&amp;lt;nc:source&amp;gt;&amp;lt;nc:running/&amp;gt;&amp;lt;/nc:source&amp;gt;
&amp;lt;filter type="subtree"&amp;gt;
&amp;lt;interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"&amp;gt;
&amp;lt;interface/&amp;gt;
&amp;lt;/interfaces&amp;gt;
&amp;lt;/filter&amp;gt;
&amp;lt;/nc:get-config&amp;gt;
&amp;lt;/nc:rpc&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when you create a filter with this and use the ("subtree", netconf_filter2) as your filter&lt;/P&gt;&lt;LI-CODE lang="python"&gt;netconf_filter2 = """
&amp;lt;interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"&amp;gt;
&amp;lt;interface&amp;gt;&amp;lt;/interface&amp;gt;
&amp;lt;/interfaces&amp;gt;
"""
.......

netconf_reply = m.get_config(source = 'running',filter=("subtree", netconf_filter2))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The xml payload looks like this. This works on the 16.x and 17.x codes&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:03c8d1e9-62b9-4ee7-a460-4cb501e6ef74"&amp;gt;
&amp;lt;nc:get-config&amp;gt;
&amp;lt;nc:source&amp;gt;&amp;lt;nc:running/&amp;gt;&amp;lt;/nc:source&amp;gt;
&amp;lt;nc:filter type="subtree"&amp;gt;
&amp;lt;interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"&amp;gt;
&amp;lt;interface/&amp;gt;
&amp;lt;/interfaces&amp;gt;
&amp;lt;/nc:filter&amp;gt;&amp;lt;/nc:get-config&amp;gt;&amp;lt;/nc:rpc&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;After testing the above, I came across&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.cisco.com/t5/yang-tools/netconf-error-in-ios-xe-on-csr-latest-code-always-on-devnet/m-p/4451438" target="_blank" rel="noopener"&gt;https://community.cisco.com/t5/yang-tools/netconf-error-in-ios-xe-on-csr-latest-code-always-on-devnet/m-p/4451438&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Changing your original filter with the xmlns entry like this.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;netconf_filter = """
 &amp;lt;filter xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"&amp;gt;
   &amp;lt;interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"&amp;gt;
     &amp;lt;interface&amp;gt;&amp;lt;/interface&amp;gt;
   &amp;lt;/interfaces&amp;gt;
 &amp;lt;/filter&amp;gt;"""&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The xml payload is correct with the correct &amp;lt;nc:filter&amp;gt; tags. This works on the 16.x and 17.x codes&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:6622f1d8-1e20-4ed5-aa63-568aaeff32ed"&amp;gt;
&amp;lt;nc:get-config&amp;gt;&amp;lt;nc:source&amp;gt;&amp;lt;nc:running/&amp;gt;&amp;lt;/nc:source&amp;gt;
&amp;lt;nc:filter&amp;gt;
   &amp;lt;interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"&amp;gt;
     &amp;lt;interface/&amp;gt;
   &amp;lt;/interfaces&amp;gt;
&amp;lt;/nc:filter&amp;gt;&amp;lt;/nc:get-config&amp;gt;&amp;lt;/nc:rpc&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopefully that clarifies the ncclient/netconf issue and helps someone else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wayne&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 11:56:50 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4571512#M1524</guid>
      <dc:creator>Wayne Knight</dc:creator>
      <dc:date>2022-03-16T11:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: NETCONF error on CSR 1000v</title>
      <link>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4940655#M3409</link>
      <description>&lt;P&gt;How do I get the operation state of all the interfaces for this. Strangely it is not showing all the sub interfaces. How do I get that also.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Oct 2023 18:51:28 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/netconf-error-on-csr-1000v/m-p/4940655#M3409</guid>
      <dc:creator>kn2022</dc:creator>
      <dc:date>2023-10-15T18:51:28Z</dc:date>
    </item>
  </channel>
</rss>

