cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
297
Views
0
Helpful
4
Replies

Template show commands fro stack switching

a.short
Level 1
Level 1

Does anyone know of a way to run a show command from a template & creating a variable from a the output (depending on the output format)  to be used elsewhere in the template.

I am trying to determin te number of switches in a stack to allow interface configs to be generated & applied.

Or is this not possible in templating?

4 Replies 4

Preston Chilcote
Cisco Employee
Cisco Employee

You can't really run a show command, but you can leverage system variables.  The system variable $__device.serialNumber will give you a list of all the serial numbers.  You can then do a "for loop" to loop through the list and generate interface commands on each iteration. 

Will it tell me the number of switches in a stack?

I can't find anything the systems vars that could help me .

Preston Chilcote
Cisco Employee
Cisco Employee

The number of switches in the stack is the number of serial numbers listed in the  $__device.serialNumber system variable.

Preston Chilcote
Cisco Employee
Cisco Employee

@a.short 

Here's some VTL code to get you started:

#set( $stack_serial_numbers = $__device.serialNumber.split(",") )

#set( $stack_member_count = $stack_serial_numbers.size() )