cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
1899
Views
3
Helpful
5
Replies

ncclient get_config subtree filter not working

Marcel Zehnder
Spotlight
Spotlight

Hi everyone

Does anybody else facing issues when using ncclient's get_config method with a subtree filter? On most XE-boxes I get empty data for my calls:

 

<snip>
 with manager.connect(host=device,port=830,username=user,password=password,hostkey_verify=False) as m:
    subtree = """
    <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
        <interface>
            <Loopback>
                <name>0</name>
            </Loopback>
        </interface>
    </native>
    """
    reply = m.get_config(filter=("subtree", subtree), source="running")
    return reply.data_xml
<snip>

 

is just returning an empty data element:

 

<?xml version="1.0" encoding="UTF-8"?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"/>

 

(yes, the Lo0 is configured on all of the boxes)

Python 3.9.13
ncclient==0.6.13

5 Replies 5

Be good to see what the box is seeing, pop a eem in and run it

event manager applet catchall
event cli pattern ".*" sync no skip no
action 1 syslog msg "$_cli_msg"

 

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

brybyrne
Cisco Employee
Cisco Employee

Sorry to bring this thread back from the dead but did you ever find an answer to the empty dataset issue?

Hi 

Not really, well I think it's related to the IOS version - Seems like it's working with the newest versions.

Marcel

Awesome. Thank you!

I was running into the same issue with my XR. This is my version I am running. Note this deployed on a whitebox, so its cisco ios v-xr

Tue Jun  6 12:59:42.986 ECT
Cisco IOS XR Software, Version 7.4.16
Copyright (c) 2013-2021 by Cisco Systems, Inc.

Build Information:
 Built By     : ingunawa
 Built On     : Mon Nov 29 03:56:27 PST 2021
 Built Host   : iox-ucs-069
 Workspace    : /auto/srcarchive17/prod/7.4.16/iosxrwbd/ws
 Version      : 7.4.16
 Location     : /opt/cisco/XR/packages/
 Label        : 7.4.16

The problem I was running into was at first I as including `<filter></filter>` in my subtree statement, also tried including cisco get-config prefix and suffixes like this (note I was looking for an object group contents)

  <get-config>
    <source>
      <running/>
    </source>
    <filter>
      <object-group xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-um-object-group-cfg">
        <network>
          <ipv4s>
            <ipv4>
              <ipv4-object-group-name>TEST_BLOCK_LIST</ipv4-object-group-name>
            </ipv4>
          </ipv4s>
        </network>
      </object-group>
    </filter>
  </get-config>
</rpc>


Both returned the same result that OP shows. In the end it was to only to include the parent string name like this 

      <object-group xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-um-object-group-cfg">
        <network>
          <ipv4s>
            <ipv4>
              <ipv4-object-group-name>ONG_V4_COMMON_BLOCK</ipv4-object-group-name>
            </ipv4>
          </ipv4s>
        </network>
      </object-group>

If you include anything else the filter wont know where to start and return nothing. However OP seemed to be doing this so not sure why it started working for him.