11-07-2021 01:24 PM - edited 11-07-2021 01:25 PM
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:
PS. it is the first time I am tinkering with NSO so I would appreciate your help on this one.
with kind regards,
Niko
11-10-2021 10:42 AM - edited 11-10-2021 10:42 AM
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
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