cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
101
Views
1
Helpful
1
Replies
khgrant
Cisco Employee

Template Xpath question

 

I would like to not have to drop down into a Java based service and wanted to check to make sure it wasn’t possible to do what I need without that.

 

 

Given the following:

 

admin@ncs% show services svn ACME vlan-id

 

vlan-id 400;

 



 



 

admin@ncs% show devices device pulse0 config idirect-pulse:site | display-level 1

 

idirect-pulse:site lab-eap;

 

idirect-pulse:site lab-noc;

 

idirect-pulse:site lab-sat01;

 

idirect-pulse:site lab-sat02;

 

 



  

I would like to have a section of config generate based on both the site name (when it starts with “lab-sat”) and the clan   The result in the debug output would be something like this if it worked:

 

Result: "lab-sat01-site-svn400”

 

Result: "lab-sat02-site-svn400"

 

 

Is this possible given that NSO only support XPATH 1.0? I have tried the following 2 variations with no success.

 



 

Service template code (variation 1):

 

 

      <sitesvn xmlns="http://tail-f.com/ned/idirect-pulse">

 

<obj_name>{concat(ncs:config/idirect-pulse:site[starts-with(obj_name,'lab-sat')]/idirect-pulse:obj_name, "-site-svn", /vlan-id)}</obj_name>

 

  <ripv2redistributionospf>false</ripv2redistributionospf>

 

 

Service template code (variation 2):

 

 

      <sitesvn xmlns="http://tail-f.com/ned/idirect-pulse">

 

<obj_name>{ncs:config/idirect-pulse:site[starts-with(obj_name,'lab-sat')]/idirect-pulse:obj_name}-site-svn{/vlan-id}</obj_name>

 

  <ripv2redistributionospf>false</ripv2redistributionospf>

 

 



  

Thanks,

Johan

 

1 REPLY 1
khgrant
Cisco Employee

 

Hello,

 

unfortunately this will not work today as you want the selection:

 

 

ncs:config/idirect-pulse:site[starts-with(obj_name,'lab-sat')]/idirect-pulse:obj_name

 

 

which results in a node-set with the nodes lab-sat01 and lab-sat02 each to be concatenated with the string '-site-svn400', there is no such operator or function is XPath 1.0

 

 

In NSO 4.2 we have added a 'foreach' attribute to the template which lets you write:

 

 

<sitesvn xmlns="http://tail-f.com/ned/idirect-pulse" foreach="{ncs:config/idirect-pulse:site[starts-with(obj_name,'lab-sat')]}">

 

<obj_name>{obj_name}-site-svn{/vlan-id}</obj_name>

 

<ripv2redistributionospf>false</ripv2redistributionospf>

 

 

/Dag

 

Content for Community-Ad