cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2355
Views
20
Helpful
4
Replies

NSO device template referencing to device model values

robalvar
Cisco Employee
Cisco Employee

Hi experts!!

 

Is it possible to create a device template with variables and apply it so the template variables are self populated from certain data of device model (xpath to device model)?

 

For example, we have a snmp template that sets the read community value to the device hostname value, is this doable using device templates and applying it to the bulk of devices?

 

Could you please share an example of it?

 

thanks a lot in advance

regards

Rob

1 Accepted Solution

Accepted Solutions

I agree with Victor. This is certainly possible, and I have done it occasionally. The thing is that these XPath expressions quickly get quite complex, and you either need to get hold of a real XPath expert, or become one yourself. Your time is probably better invested in writing a simple template based service instead.

View solution in original post

4 Replies 4

vleijon
Cisco Employee
Cisco Employee

It is possible, but perhaps that is the kind of situation where you want to consider a service. Also, since this is not properly documented I am not entirely sure how supported it is. But, you do have access to a variable $DEVICE that points to the current device, thus you can do something like this:

admin@ncs% show devices device jun0 config junos:configuration interfaces interface description                       
interface xe-0/0/0 {
    description Test;
}
interface xe-0/0/1 {
    description A;
}
interface xe-0/0/2 {
    description Good;
}
[ok][2018-11-30 12:05:09]
 
[edit]
admin@ncs% show devices template                                                                                      
template templ1 {
    config {
        junos:configuration {
            interfaces {
                interface "{/devices/device[name=$DEVICE]/config/junos:configuration/interfaces/interface[description='A']/name}" {
                    hold-time {
                        up   30;
                        down 30;
                    }
                }
            }
        }
    }
}
[ok][2018-11-30 12:05:12]
 
[edit]
admin@ncs% request devices device jun0 apply-template template-name templ1                                  
apply-template-result {                                                        
    device jun0
    result ok
}
[ok][2018-11-30 12:05:22]
 
[edit]
admin@ncs% commit dry-run
cli {
    local-node {
        data  devices {
                  device jun0 {
                      config {
                          junos:configuration {
                              interfaces {
                                  interface xe-0/0/1 {
             +                        hold-time {
             +                            up 30;
             +                            down 30;
             +                        }
                                  }
                              }
                          }
                      }
                  }
              }
    }
}
[ok][2018-11-30 12:05:25]
 

(This examples sets parameters for all interfaces that have the description 'A') 

 

 

I agree with Victor. This is certainly possible, and I have done it occasionally. The thing is that these XPath expressions quickly get quite complex, and you either need to get hold of a real XPath expert, or become one yourself. Your time is probably better invested in writing a simple template based service instead.

Thanks a lot Viktor

 

I was looking for a solution oriented to compliance reports where the templates have variables and devices have different variable values. I was willing to create a bulk compliance report (for devices with different variable values) doing either:

1) Fulling the variable value from each device mode data (running config)

2) Defining arrays of variables that match with the device grouping order

 

is any of this possible?

 

thanks a lot

regards

Rob

Totally agree, I gave it a go with a small example and compliance report works

 

devices template SNMP-OSP

config

  vrp:snmp-agent community cipher-name-replace {/devices/device[name=$DEVICE]/config/vrp:sysname}

  !

 

Not sure if we can define the variable generic and define an array of values too

device-group [r1 r2 ... rn]

variable [v1 v2 ... vn]

 

thanks a lot

Helpful indeed