2

I am trying to execute CLI commands using NETONF RPC in IOS XE 16.04.01. I got the schema for the NETCONF RPC from the device CLI "show netconf schema". Below is the schema specific to edit-config,

<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

is seen in the schema. I tried to execute the below RPC but it throws error as cli-config-data. How to execute CLI commands using NETCONF for IOS XE?

RPC request

<rpc message-id="2323" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<edit-config>
<target>
<running/>
</target>
<config>
<cli-config-data>
<cmd>hostname CSR1000V</cmd>
</cli-config-data>
</config>
</edit-config>
</rpc>

RPC reply

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2323">
<rpc-error>
<error-type>protocol</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>
vishnukumar
  • 399
  • 1
  • 3
  • 11
  • 1
    I'm pretty sure that `cli-config-data` and `cmd` elements belong to a namespace that is not `urn:ietf:params:xml:ns:netconf:base:1.0`, which is reserved for the NETCONF messages layer. – predi Apr 19 '17 at 13:45
  • which namespace to be used for ? – vishnukumar Apr 25 '17 at 10:19

1 Answers1

1

In IOS-XE you have the option to enable netconf ssh or netconf-yang in the configuration - 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>

I just now need to work out how to send multiline strings as the following doesn't work and there isn't a valid YANG model for this under IOS-XE:

menu test title $
this is a title
$
chrixm
  • 942
  • 6
  • 26