10-05-2022 08:33 AM
Hi, I am trying to create a location identifier in IOS-XE using python and xml.
The yang schema is here: https://github.com/YangModels/yang/blob/main/vendor/cisco/xe/1671/Cisco-IOS-XE-native.yang
This is my try to write the xml file based on the yang schema
my_try = '''
<config>
<location xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
<civic-location>
<identifier>
<identifier>"Hello"</identifier>
<building>"Amsterdam Building"</building>
<floor>"4th floor"</floor>
<landmark>"IKEA"</landmark>
<name>"Abdulmohsen"</name>
</identifier>
</civic-location>
</location>
</config>
'''
And this the python code I used to edit the config in IOS-XE:
with manager.connect(**router,hostkey_verify=False) as m:
response1 = m.edit_config(my_try,target='running')
result_dict = xmltodict.parse(response1.xml)
print(result_dict)
But I get this error:
Traceback (most recent call last):
File "/Users/aalnemer/DevNetPractise/ENAUTO/IOS-XE.py", line 84, in <module>
response1 = m.edit_config(my_try,target='running')
File "/Users/aalnemer/DevNetPractise/ENAUTO/lib/python3.9/site-packages/ncclient/manager.py", line 246, in execute
return cls(self._session,
File "/Users/aalnemer/DevNetPractise/ENAUTO/lib/python3.9/site-packages/ncclient/operations/edit.py", line 76, in request
return self._request(node)
File "/Users/aalnemer/DevNetPractise/ENAUTO/lib/python3.9/site-packages/ncclient/operations/rpc.py", line 375, in _request
raise self._reply.error
ncclient.operations.rpc.RPCError: {'type': 'application', 'tag': 'unknown-element', 'app_tag': None, 'severity': 'error', 'info': '<?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>location</bad-element>\n</error-info>\n', 'path': '\n /nc:rpc/nc:edit-config/nc:config/ios:location\n ', 'message': None}
Solved! Go to Solution.
10-06-2022 05:35 AM
I found my mistake. Thanks!
10-06-2022 05:35 AM
I found my mistake. Thanks!
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: