01-13-2021 03:05 PM
I am trying to get config from an IOS-XE device in CML2 and keep hitting the same issue when I try to filter the config elements I want to return.
I am trying to simply filter the hostname of the device in the first instance using a python script copied from the DevNet examples online.
Script:
from device_info import rdc1a from ncclient import manager # NETCONF filter to use netconf_filter = """ <filter> <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native"> <hostname></hostname> </native> </filter> """ if __name__ == '__main__': # format = "%(asctime)s: %(message)s" # logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S") with manager.connect(host=rdc1a["address"], port=rdc1a["port"], username=rdc1a["username"], password=rdc1a["password"], hostkey_verify=False) as m: # Get Configuration and State Info for Interface netconf_reply = m.get_config('running', netconf_filter) print(netconf_reply)
This is exactly like examples I find online but in every instance if I try to use a filter I get the following error:
<?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>
It saying "filter" is a bad element? What am I missing here?
Thanks in advance.
12-18-2021 10:34 PM
<filter xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native"> <hostname></hostname> </native> </filter>
About this Error, you could see
<bad-element>filter</bad-element>
bad-element means "An attribute value is not correct"
You can get more error type detail here:
https://www.bookstack.cn/read/rfc6241-zh/appendix-netconf-error-list.md
11-14-2022 12:09 PM
Try the below in your filter:
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native"> <hostname/> </native>
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: