cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

Who Me Too'd this topic

IOS-XE NetConf Filter Issue

Gerard2012
Level 1
Level 1

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.

Who Me Too'd this topic