cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
234
Views
0
Helpful
6
Replies
Highlighted
Beginner
Beginner

<bad-element>cli-config-data</bad-element>

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

Everyone's tags (1)
6 REPLIES 6
Highlighted
Collaborator
Collaborator

Re: <bad-element>cli-config-data</bad-element>

Hi

I think .. should be ..

<cmd>hostname test</cmd>

 

Highlighted
Collaborator
Collaborator

Re: <bad-element>cli-config-data</bad-element>

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/cns/configuration/15-s/cns-15-s-book/cns-netconf.html#GUID-D925E60E-D1F6-42B3-BBF8-E51505CD5518

 

<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>
Highlighted
Beginner
Beginner

Re: <bad-element>cli-config-data</bad-element>

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 

Highlighted
Collaborator
Collaborator

Re: <bad-element>cli-config-data</bad-element>

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>

 

Highlighted
Collaborator
Collaborator

Re: <bad-element>cli-config-data</bad-element>

You can use an XML validator to validate your XML - 

https://www.liquid-technologies.com/online-xml-validator

Screenshot 2020-05-24 at 15.42.32.pngScreenshot 2020-05-24 at 15.43.20.png

Highlighted
Beginner
Beginner

Re: <bad-element>cli-config-data</bad-element>

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

This widget could not be displayed.