cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1263
Views
0
Helpful
3
Replies

Prime Infrastructure 2.2 Velocity Template for adding VLANs

Scott Plank
Level 1
Level 1

I have the following Velocity template that I run on new devices for adding VLANs. It defines and names up to 10 VLANs. The variables vlanIDList and vlanNameList are defined as text fields in Prime. VLAN IDs and Names are entered as comma-separated values, and VLAN names can contain spaces if they are enclosed in quotes. I am by no means a Velocity expert - this was all done in a trial-and-error method. Is there a better way to define and name VLANs with the Velocity tools? Perhaps one that doesn't place a limit on the number of VLANs that can be defined?

 

#set ($vlanIDs = $vlanIDList.split(","))
#set ($vlanNames = $vlanNameList.split(","))
#foreach ($vlanID in $vlanIDs)
#if ($velocityCount < 10)
vlan $vlanID
#if ($velocityCount == 0)
name $vlanNames.get(0)
#elseif ($velocityCount == 1)
name $vlanNames.get(1)
#elseif ($velocityCount == 2)
name $vlanNames.get(2)
#elseif ($velocityCount == 3)
name $vlanNames.get(3)
#elseif ($velocityCount == 4)
name $vlanNames.get(4)
#elseif ($velocityCount == 5)
name $vlanNames.get(5)
#elseif ($velocityCount == 6)
name $vlanNames.get(6)
#elseif ($velocityCount == 7)
name $vlanNames.get(7)
#elseif ($velocityCount == 8)
name $vlanNames.get(8)
#elseif ($velocityCount == 9)
name $vlanNames.get(9)
#end
#else
#break
#end
#end
3 Replies 3

Ashok Kumar
Cisco Employee
Cisco Employee

Hi 

1. Open the System CLI Template

2. Click on the Deply button

3. Select the Device on which you want apply the template

4. Now fill the Various details of the Template in the window


- Ashok

******************************************************************************************************

Please rate the post or mark as correct answer as it will help others looking for similar information

******************************************************************************************************

Hi Ashok,

 

Thanks for the reply, however, you seem to have misunderstood my post. I am familiar with how to deploy the config templates to devices. My intent for posting was two-fold. First, since I am not an expert with Velocity, I was hoping that some of the more experienced coders might be able to take a look at my code and let me know if there is a better, more efficient way to code this. The way it works now, it can only define and name up to 10 VLANs. Perhaps there is a way to do it that won't include a limit to the number? Secondly, I wanted to share the code for others to use, should they find it useful.

Any progress on this?

How about (I'm not sure how you input your variables):

#set ($vlanIDList = ['10', '20', '30'] )
#set ($vlanNameList = ['VL10', 'VL20', 'VL30'] )
#set($iter = 0)
#foreach ($vlanID in $vlanIDList)
vlan $vlanID
name $vlanNameList[ $iter ]
#set($iter = $iter + 1)
#{end}end

PS - warning: no error check that the lists are the same length!

Review Cisco Networking for a $25 gift card