cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2471
Views
0
Helpful
5
Replies

Another Cisco prime template Q. Adding numbers to vlan

Carstenlymann
Level 1
Level 1

Hi

Im fidling with these templates. Got some good help in the last one, and some fine input and got that solved. So now im on to the next issue i have.

I will make some automation to adding VLAN.

Each location i have, has 20 vlan.

Location 1 has vlan 20-39

Location 2 has vlan 40-59

Location 3 has vlan 60-79 and so on.

The naming of my vlan is always the same.

Vlan 20 (40 and 60 etc) is: ADM

Vlan 21 (41 and 61 etc) is: ALARM

Vlan 22 (42 and 62 etc) is: WIFI

Vlan 23 (43 and 63 etc) is: INT

and so on. 

What i would like to have is if the template could be so i just enter the vlan number for the first vlan.

So if i enter vlan 20 in the template, it will automatic name that ADM as well.

And then it will make a (20+1) vlan 21 named alarm and so on and so on.

Is that even possible ?

Would save me a ton of time :)

Thx

/ Carsten

1 Accepted Solution

Accepted Solutions

You don't really have to be much of a programmer.  The Apache VTL language does not require much in the way of usage.  The extent of what I wrote above could be attributed to pulling a lever to trigger certain cli configs to be applied.  Based upon what you posted about your vlan structure, if you want one cli template to take care of what you have you would use the #if and #end to tell PI where it needs to look.

What happens between those particular pieces is really no different then what you would do logging into the individual switches yourself.  By default, PI starts all cli templates from global config (conf t) so if you want it to go and apply specific configs you have to tell it where to go essentially.

If you are asking PI to configure 20 vlans per switch, and assign those 20 vlans to specific interfaces, it may take a bit to get initially coded.  But if you use the format listed above, mostly to be mindful of making sure there is an #if at the beginning of each block of cli config and an #end to said block of cli config, you could drive it out a lot quicker then you think. I've also attached a sample that you can use in notepad to see where I added interfaces for a test switch in my lab.  Feel free to modify for your switches, and add the additional interfaces and vlans that would be needed for your application.

HTH,

Brandon

View solution in original post

5 Replies 5

Ashok Kumar
Cisco Employee
Cisco Employee

Hi 

I think below can help you.

Creating VLANs and WLANs Using Templates (Advance Mode)

http://www.cisco.com/c/en/us/products/collateral/cloud-systems-management/prime-infrastructure/guide-c07-731626.html#_Toc386763711


- Ashok

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

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

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

bkennedy97
Level 1
Level 1

Carsten,

 

What you have listed could be scripted using Apache VTL with a few #if statements.

Example:

#if  ($vlanid eq "20")

       vlan $vlanid

       name ADM

       exit

       vlan 21

       name ALARM

       exit

       vlan22

       name WIFI

       exit

....and so forth to completion.  You might try setting this up using the foreach loop until it stops that way.  For my variable I used a drop down variable for $vlanid in this example.  So if your vlan ids jump by 20s as you have shown you could define the drop down variable as 20,40,60, so that it is point and click.  Be advised though that if you want to assign specific vlans to specific ports you will have to add that in there.  But again if those ports are always the same in your network that could be included in the same template by adding the interface, and switchport configs.  Here is the output of my test config based on your details minus the interface assignments.

============================================================================

#if ($vlanid eq "20")
      vlan $vlanid
      name ADM
      exit
      vlan 21
      name ALARM
      exit
      vlan 22
      name WIFI
      exit
#end
#if ($vlanid eq "40")
      vlan $vlanid
      name ADM
      exit
      vlan 41
      name ALARM
      exit
      vlan 42
      name WIFI
      exit
#end

 

=============================================================================

HTH,

Brandon

thx. Im not a programmer, so might be to big a job for me. Doing if, and , or commands in excel is just about where i can follow :D

But as mentioned in other thread. I have aprox 400 locations. That will be a lot of programming.

But i will try this out tomorow and see how it pans out :)

 

/ Carsten

You don't really have to be much of a programmer.  The Apache VTL language does not require much in the way of usage.  The extent of what I wrote above could be attributed to pulling a lever to trigger certain cli configs to be applied.  Based upon what you posted about your vlan structure, if you want one cli template to take care of what you have you would use the #if and #end to tell PI where it needs to look.

What happens between those particular pieces is really no different then what you would do logging into the individual switches yourself.  By default, PI starts all cli templates from global config (conf t) so if you want it to go and apply specific configs you have to tell it where to go essentially.

If you are asking PI to configure 20 vlans per switch, and assign those 20 vlans to specific interfaces, it may take a bit to get initially coded.  But if you use the format listed above, mostly to be mindful of making sure there is an #if at the beginning of each block of cli config and an #end to said block of cli config, you could drive it out a lot quicker then you think. I've also attached a sample that you can use in notepad to see where I added interfaces for a test switch in my lab.  Feel free to modify for your switches, and add the additional interfaces and vlans that would be needed for your application.

HTH,

Brandon

Thx. Gotta try it out. :)