ncclient get_config subtree filter not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 01:48 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2023 07:10 AM
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"
Connect with me https://bigevilbeard.github.io
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2023 02:09 PM
Sorry to bring this thread back from the dead but did you ever find an answer to the empty dataset issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 12:01 AM
Hi
Not really, well I think it's related to the IOS version - Seems like it's working with the newest versions.
Marcel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2023 06:11 AM
Awesome. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2023 11:03 AM
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.
