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.