cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
572
Views
10
Helpful
1
Replies

is it possible to set the "tags" xml attribute in a config-template ?

nikos_skalis
Level 1
Level 1

Hi,

 

Given a config-template, for example,

<config-template xmlns="http://tail-f.com/ns/config/1.0">
  <devices xmlns="http://tail-f.com/ns/ncs">
   <device>
     <name>{$host_name}</name>
     <config>
       <configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf">
         <port>
           <port-id tags="replace">{$iface}</port-id>
           <description tags="replace">{$label}</description>
         </port>
       </configure>
     </config>
   </device>
 </devices>
</config-template>

you can see a xml element with the tags xml attribute

<description tags="replace">{$label}</description>

 


 

I would like to set the tags xml attribute programmatically using a variable spec in a action, for example

<description tags="{$spec}">{$label}</description>

Unfortunately, the above does not work. When calling the action through the CLI, this is what is printed in the standard output

@ncs> show configuration devices device __ config conf:configure port 1/1/c30
/* Tags: {$spec} */
description "* ip-spotlight * omega * note: proof-of-concept *";
[ok][2021-11-07 21:40:19]

 


 

I would like your help with the following questions:

  1. is it possible to set the tags xml attribute in a template by using a variable? yes/no?
  2. if yes, how this is done?

PS. it is the first time I am tinkering with NSO so I would appreciate your help on this one.

 

with kind regards,

Niko

1 Reply 1

rogaglia
Cisco Employee
Cisco Employee

I do not believe you can do it exactly as you are asking but something that you can do is to use the "if" template statements:

<?if {expression}?>

    <leaf tags="nocreate">123</leaf>

<?else?>

      <leaf tags="replace">123</leaf>

<?end?>

You can read more about templates statements here: https://developer.cisco.com/docs/nso/guides/#!templates/config-templates