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.