08-22-2020 06:33 PM
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
Solved! Go to Solution.
10-10-2020 08:14 AM - edited 10-10-2020 08:15 AM
try this one it works:
08-24-2020 09:21 AM
Have you tried change snippet like this:
config_snippet = """
<native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
<hostname>AAAROUTERAAA</hostname>
</native>
"""
08-24-2020 11:24 AM
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.
09-04-2020 09:00 AM
Hi Mark
Seems like I'm having the same issue with a WLC98k running 17.3.1:
Have you been able to find a solution?
Oli
09-04-2020 09:07 AM
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.
09-07-2020 05:56 AM
Thanks Mark! I have now made the same observation, my scripts run fine on a WLC with version 16.12.4a. Strange!
10-10-2020 08:14 AM - edited 10-10-2020 08:15 AM
try this one it works:
10-12-2020 02:13 PM
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.
01-08-2022 08:54 PM - edited 01-08-2022 08:56 PM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide