05-22-2020 04:34 PM
Hi everybody,
thank you for a great resource!
I'm attempting at configuring a CSR router (16.09.05) with netconf - however not with xml, rather with cli stuff. I'm getting this error message:
<?xml version="1.0" encoding="UTF-8"?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101" xmlns:cpi="http://www.cisco.com/cpi_10/schema"><rpc-error> <error-type>application</error-type> <error-tag>unknown-element</error-tag> <error-severity>error</error-severity> <error-path> /rpc/edit-config/config </error-path><error-info><bad-element>cli-config-data</bad-element> </error-info> </rpc-error> </rpc-reply>
The snippet i'm trying to send to the router is the following:
<?xml version="1.0" encoding="UTF-8"?> <rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:cpi="http://www.cisco.com/cpi_10/schema"> <edit-config> <target> <running/> </target> <config> <cli-config-data> hostname test interface loo1000 ip address 192.168.1.1 255.255.255.0 <cli-config-data> </config> </edit-config> </rpc>
Just some garbage config to see if i could get it to work. I'm trying to get my head wrapped around the CPI name space but it is not working.
Has anyone had any success with this?
Thanks in advance.
/Kim
05-23-2020 01:56 AM
Hi
I think .. should be ..
<cmd>hostname test</cmd>
05-23-2020 01:59 AM
<cli-config-data> <cmd>hostname test</cmd> <cmd>interface fastEthernet0/1</cmd> <cmd>ip address 192.168.1.1 255.255.255.0</cmd> </cli-config-data>
OR
<cli-config-data-block> hostname bob interface fastEthernet0/1 ip address 192.168.1.1 255.255.255.0 </cli-config-data-block>
05-24-2020 07:03 AM
Hi guys :)
Thank you for helping out!
I went back and had a look at my code, your suggestions are right according to the namespace in the document you suggest.
This is the part of the namespace that i use:
Device# show netconf schema New Name Space 'urn:ietf:params:xml:ns:netconf:base:1.0' <VirtualRootTag> [0, 1] required <rpc> [0, 1] required <close-session> [0, 1] required <commit> [0, 1] required <confirmed> [0, 1] required <confirm-timeout> [0, 1] required <edit-config> [0, 1] required <target> 1 required <candidate> [0, 1] required <running> [0, 1] required <startup> [0, 1] required <url> [0, 1] required <default-operation> [0, 1] required <test-option> [0, 1] required <error-option> [0, 1] required <config> 1 required <cli-config-data> [0, 1] required <cmd> 1+ required <cli-config-data-block> [0, 1] required <xml-config-data> [0, 1] required <Device-Configuration> [0, 1] required <> any subtree is allowed
This is what my script sends to the CSR1000v (16.9.5):
<?xml version="1.0" encoding="UTF-8"?> <rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <edit-config> <target> <running/> </target> <config> <cli-config-data-block> hostname test interface loo1000 ip address 192.168.1.1 255.255.255.0 <cli-config-data-block> </config> </edit-config> </rpc>
But i still get the error message...:
<?xml version="1.0" encoding="UTF-8"?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101" xmlns:cpi="http://www.cisco.com/cpi_10/schema"><rpc-error> <error-type>application</error-type> <error-tag>unknown-element</error-tag> <error-severity>error</error-severity> <error-path> /rpc/edit-config/config </error-path><error-info><bad-element>cli-config-data-block</bad-element> </error-info> </rpc-error> </rpc-reply>
Can you guys help me figure out what is missing?
Thanks in advance.
Cheers
/Kim
05-24-2020 07:34 AM
Hi
Missing / in the closing tag .. try with putting / in </cli-config-data-block>
<cli-config-data-block> hostname test interface loo1000 ip address 192.168.1.1 255.255.255.0 </cli-config-data-block>
05-24-2020 07:44 AM
You can use an XML validator to validate your XML -
https://www.liquid-technologies.com/online-xml-validator
05-24-2020 09:17 AM - edited 05-24-2020 12:35 PM
Hey :)
Thanks... Typos! And thanks for the tip about the syntax checker.
However, i still get an error... cli-config-data and cli-config-data-block triggers a bad-element response.
The elements should, from what i can find, be part of this namespace
xmlns:cpi="http://www.cisco.com/cpi_10/schema"
But that throws an unknown namespace error. Does anyone have a working example for the CSR1000v on how to send config in cli format with the cli-config-data-block?
NOTE: I've done some additional testing - i have an 1100 router and a couple of CSR's in my lab. When ssh'ing to them the namespace mentioned above seems to be accepted. BUT the cli-config-data-block and cli-config-data throw an error - bad element. I've found some examples but none that actually work.
Any input appreciated!
Cheers and thanks :)
Best regards
/Kim
11-10-2020 04:26 PM
Did you have any luck? I am suffering from the same issue in that I can't send CLI based configuration to an ISR running IOS-XE 16.9.6 (with "netconf-yang" enabled) - I keep on getting "<bad-element>config-text</bad-element>" when trying to use the "netconf_config" module with Ansible.
Ansible Playbook is fairly simple:
- netconf_config: content: "build/{{ inventory_hostname }}.cfg" target: "running" format: "text"
I have tried defining the configuration in various different ways with different tags without any luck:
<cli-config-data-block> hostname bob </cli-config-data-block>
Spent 5 hours so far trying to get Ansible to push config changes to an IOS-XE device using Ansible! Unfortunately "debug netconf-yang level debug" doesn't help at all
/Chris
11-12-2020 03:47 PM
Many hours later I think I have worked it out - posting here so hopefully no one else spends as much time as I did trying to get this to work. In IOS-XE you have the option to enable "netconf ssh" or "netconf-yang" - I made the mistake of enabling "netconf-yang" and then tried to use "cli-config-data-block" as I assumed it was valid as I saw it in "show netconf schema".
If you enable "netconf-yang" then it expects a valid YANG model, but "netconf ssh" enables legacy NETCONF support which uses the schema as output by "show netconf schema". Once you enable "netconf ssh" then the following can be sent to the device to update the configuration:
<?xml version='1.0' encoding='UTF-8'?> <rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="100"> <edit-config> <target> <running/> </target> <config> <cli-config-data-block> hostname test </cli-config-data-block> </config> </edit-config> </rpc>
Now I just need to work out how to send multiline strings as the above doesn't seem to support the following syntax
menu test title $ this is a title $
08-20-2022 10:33 PM
If anyone has still this issue with ncclient/ansible netconf_config module and IOS 17, the solution is to explicit declare the top level namespace. Some Tasks and labs about NETCONF in Devnet site still use the syntax of older ncclient versions. In my case, for edit-config rpc calls my working config has
For filtering
03-19-2024 09:35 AM
worked for me when i had a bad element error. Thanks @frbello !
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