cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1294
Views
0
Helpful
1
Replies

Apply device-template with variable via RESTCONF

RichardD2
Level 1
Level 1

I created a template 'mytemplate' using RESTCONF PATCH

I want to deploy that to device 'router1'

<devices xmlns="http://tail-f.com/ns/ncs">
    <template>
      <name>mytemplate</name>
      <ned-id>
        <id xmlns:cisco-iosxr-cli-7.23="http://tail-f.com/ns/ned-id/cisco-iosxr-cli-7.23">cisco-iosxr-cli-7.23:cisco-iosxr-cli-7.23</id>
        <config>
        <hostname xmlns="http://tail-f.com/ned/cisco-ios-xr">{$hostname}</hostname>
</config>
</ned-id>
</devices>
 
POST
http://{{NSO_IP}}:{{NSO_HTTP_PORT}}/restconf/data/tailf-ncs:devices/device={{SAMPLE_IOSXR_DEVICE}}/apply-template/ with
<input>
    <template-name>mytemplate</template-name>
    <variable>
      <name>
        <hostname> 
          <value>"blah"</value>
        </hostname>
      </name>
    </variable>
</input>

But I get this error:

<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
    <error>
        <error-message>unknown element: hostname in /ncs:devices/ncs:device[ncs:name='router1']/ncs:apply-            template/ncs:hostname</error-message>
        <error-path>/tailf-ncs:devices/device=router1/apply-template</error-path>
        <error-tag>malformed-message</error-tag>
        <error-type>application</error-type>
    </error>
</errors>
 
After more troubleshooting, I looked at tailf-ncs-devices.yang file and saw the structure of the template portion and solved it myself
<input>
	<template-name>mytemplate</template-name>
	<variable>
	  <name>hostname</name> 
		  <value>'blah'</value>
	</variable>
</input>
<output xmlns='http://tail-f.com/ns/ncs'>
    <apply-template-result>
        <device>router1</device>
        <result>ok</result>
    </apply-template-result>
</output>
 
1 Accepted Solution

Accepted Solutions

RichardD2
Level 1
Level 1
1 Reply 1

RichardD2
Level 1
Level 1
Solved