cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
4558
Views
17
Helpful
8
Replies

Netconf error in IOS-XE 17.3.1a but works fine on IOS-XE 16.12.4: bad-element: config

mark
Level 1
Level 1

Hi all,

I'm just starting my Netconf/Yang journey.  I figured I'd start small - setting the hostname of a CSR1kv.  The following works fine on IOS-XE 16.12.4:

#!/usr/bin/env python3

from ncclient import manager

config_snippet = """
<config>
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
<hostname>AAAROUTERAAA</hostname>
</native>
</config>
"""

with manager.connect(host="<private ip>", port=830, username="<netconf username>",
hostkey_verify=False, device_params={'name': 'csr'}) as m:
result = m.edit_config(target='running', config=config_snippet)
print(result.xml)

As expected, the above changes the router hostname.  (Auth is being done through SSH keys.)

 

I'm spinning up the CSR1kv image using a short script.  All I change is the IOS image to a different version (the base config is loaded during the automated spin-up).  And yet on IOS-XE 17.3.1a when I run the script above I get the following error (reformatted for clarity):

<?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>config</bad-element>
</error-info>

I've compared the output from "show netconf schema" on the two versions and they are identical (running 'diff' between the two returns nothing).

 

It feels like I'm missing something obvious.

There's not much in the "config" section that could have a bad element.  Hostname is still represented the same way, in the same place:

(well, slight difference with '{}' vs ';', but I think that should be fine; please correct me if I'm wrong.)

 

Does anyone have any suggestions as to what I should be looking for?

 

Thanks,

mark

 

1 Accepted Solution

Accepted Solutions

mashrafi
Cisco Employee
Cisco Employee

try this one it works:

config_snippet = """
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<hostname>AAAROUTERAAA</hostname>
</native>
</config>
"""

View solution in original post

8 Replies 8

yangorelik
Spotlight
Spotlight

Have you tried change snippet like this:

config_snippet = """
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
<hostname>AAAROUTERAAA</hostname>
</native>
"""  

 

Yan Gorelik
YDK Solutions

Unfortunately, no.

raise XMLError("Element [%s] does not meet requirement" % ele.tag) ncclient.xml_.XMLError: Element [{http://cisco.com/ns/yang/Cisco-IOS-XE-native}native] does not meet requirement

It seems to require the <config></config> structure.

0_Kiss
Level 1
Level 1

Hi Mark

Seems like I'm having the same issue with a WLC98k running 17.3.1:

https://community.cisco.com/t5/mobility-discussions/wlc98k-configure-ap-tags-through-netconf/td-p/4146361 

Have you been able to find a solution?

Oli

No.  I've tested the same config against earlier versions and the earlier versions work just fine.  This is only broken in 17.3.1.  My only suggestion is to roll-back the version number and test again.

 

I've setup an alert so that I'll be notified when a new version of the CSR1000v is released.  When it comes out I'll be testing it immediately.

Thanks Mark! I have now made the same observation, my scripts run fine on a WLC with version 16.12.4a. Strange!

mashrafi
Cisco Employee
Cisco Employee

try this one it works:

config_snippet = """
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<hostname>AAAROUTERAAA</hostname>
</native>
</config>
"""

How did you figure out those namespace definitions were required?

Your solution works, but now I'm having a similar problem with the <cli-config-data> instruction.

Thank you @mashrafi for helping to point us in the right direction! Created a YouTube video here demonstrating how to fix NETCONF scripts in v17 IOS XE based on your post.

 

profhamachi

Getting Started

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: