01-23-2015 04:23 AM
Hi everybody!
I'm working with a regional public health-care provider in Norway, and we have a total of around ~42k access ports in our different campus networks. Access network consists of 3560/3750/3750-X/3850 and 4500 on different HW and SW levels.
Sometimes we se the need to change the vlan on a LOT of ports to get the clients over in another network for one reason or another. To minimize impact for the DHCP-attached clients, I'm looking for some way of doing this on port down event and preferably also on reboot (not all wireing-closets have UPS).
I have not learned to "speak" Tcl yet, and I understand that the file handling in EEM applets is very basic even in EEM v4.
So I'm looking for a script that:
The interface list input file could be constructed anyway needed, but maybe something like this:
Interface<tab>New vlan ID<tab>New Voice vlan <- Not needed in actual file FastEthernet1/0/43<tab>100 Gi2/0/38<tab>110 Gi1/43<tab>120<tab>300
And the logfile could be something like:
Interface Fa1/0/43 changed on interface down from vlan id XX to YY dd.mm.yyyy hh:mm:ss Interface Gi1/43 changed on reload from vlan id XX to YY AND voice vlan ZZ dd.mm.yyyy hh:mm:ss
Soooo.....have anyone made/seen such a script, or something like it that could be adapted? Or do anyone Tcl-fluid people feel like helping me out? :) I can't quite imagine that we are the only one seeing the need for such a script?
Keeping the faith in the community :)
Tommy V
(Edit: Added voice vlan)
Solved! Go to Solution.
01-24-2015 09:53 AM
OK thats what I thought but wanted to make sure. Attached is a policy that meets all your bullet points except for the last one. Not sure what hardware or EEM version would not support the attachment.
There needs to be a prepositioned file on flash that will be used to read in the "interface datavlan voicevlan". If a port transitions from up -> down that will trigger the policy or on reboot the policy will read in the entire file on flash and provision all the ports.
My prepositioned file on flash.
Switch_2#more flash:vlan
FastEthernet0/18 101 301
FastEthernet0/19 101
FastEthernet0/20 100
FastEthernet0/21 101
FastEthernet0/22 102
FastEthernet0/24 104
Tested on
Cisco IOS Software, C3560 Software (C3560-IPSERVICESK9-M), Version 12.2(55)SE1, RELEASE SOFTWARE (fc1)
Log messages to console and also written to a log file on flash on reboot.
00:01:02: %HA_EM-6-LOG: vlanmap.tcl: Interface FastEthernet0/18 changed on reload from vlan id 1 to 101 and voicevlan none changed to 301 00:01:01.723 UTC Mon Mar 1 1993
00:01:03: %HA_EM-6-LOG: vlanmap.tcl: Interface FastEthernet0/19 changed on reload from vlan id 1 to 101 00:01:01.723 UTC Mon Mar 1 1993
00:01:04: %HA_EM-6-LOG: vlanmap.tcl: Interface FastEthernet0/20 changed on reload from vlan id 1 to 100 00:01:01.723 UTC Mon Mar 1 1993
00:01:04: %HA_EM-6-LOG: vlanmap.tcl: Interface FastEthernet0/21 changed on reload from vlan id 1 to 101 00:01:01.723 UTC Mon Mar 1 1993
00:01:05: %HA_EM-6-LOG: vlanmap.tcl: Interface FastEthernet0/22 changed on reload from vlan id 1 to 102 00:01:01.723 UTC Mon Mar 1 1993
00:01:06: %HA_EM-6-LOG: vlanmap.tcl: Interface FastEthernet0/24 changed on reload from vlan id 1 to 104 00:01:01.723 UTC Mon Mar 1 1993
01-23-2015 04:26 PM
Can you explain further on this bullet point? What does running through remaining interfaces mean?
01-23-2015 11:30 PM
If (when) switch reboots, check file and change vlan on all remaining interfaces.
01-24-2015 09:53 AM
OK thats what I thought but wanted to make sure. Attached is a policy that meets all your bullet points except for the last one. Not sure what hardware or EEM version would not support the attachment.
There needs to be a prepositioned file on flash that will be used to read in the "interface datavlan voicevlan". If a port transitions from up -> down that will trigger the policy or on reboot the policy will read in the entire file on flash and provision all the ports.
My prepositioned file on flash.
Switch_2#more flash:vlan
FastEthernet0/18 101 301
FastEthernet0/19 101
FastEthernet0/20 100
FastEthernet0/21 101
FastEthernet0/22 102
FastEthernet0/24 104
Tested on
Cisco IOS Software, C3560 Software (C3560-IPSERVICESK9-M), Version 12.2(55)SE1, RELEASE SOFTWARE (fc1)
Log messages to console and also written to a log file on flash on reboot.
00:01:02: %HA_EM-6-LOG: vlanmap.tcl: Interface FastEthernet0/18 changed on reload from vlan id 1 to 101 and voicevlan none changed to 301 00:01:01.723 UTC Mon Mar 1 1993
00:01:03: %HA_EM-6-LOG: vlanmap.tcl: Interface FastEthernet0/19 changed on reload from vlan id 1 to 101 00:01:01.723 UTC Mon Mar 1 1993
00:01:04: %HA_EM-6-LOG: vlanmap.tcl: Interface FastEthernet0/20 changed on reload from vlan id 1 to 100 00:01:01.723 UTC Mon Mar 1 1993
00:01:04: %HA_EM-6-LOG: vlanmap.tcl: Interface FastEthernet0/21 changed on reload from vlan id 1 to 101 00:01:01.723 UTC Mon Mar 1 1993
00:01:05: %HA_EM-6-LOG: vlanmap.tcl: Interface FastEthernet0/22 changed on reload from vlan id 1 to 102 00:01:01.723 UTC Mon Mar 1 1993
00:01:06: %HA_EM-6-LOG: vlanmap.tcl: Interface FastEthernet0/24 changed on reload from vlan id 1 to 104 00:01:01.723 UTC Mon Mar 1 1993
01-26-2015 03:30 AM
Daniel,
I'm impressed! :) That was a swift response :)
I will test this in my lab and on a few switches in my network :)
A few questions after just browsing the code however, just trying to understand Tlc better:
Regards
Tommy V
01-26-2015 06:20 AM
Its my personal preference to use the syslog ED. I use the syslog detector often and have the regexp built for it as well so it was just a copy/paste for this EEM policy. If all of the environment variables remain static across your network then there is no reason to do this in the CLI and the variables can be addressed in the tcl file.
Add these variables in the tcl file after:
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
set write_filename "your file name"
set read_filename "your file name"
ect... set rest of the variables here ....
When syslog detects a single interface going up -> down it will generate an email, syslog, update the logfile. If you have multiple interfaces going down at once you will get an email, syslog, update logfile per interface. When the device is reloaded it will aggregate all the actions into a single email, generate multiple syslogs, and update the logfile.
Dan
01-26-2015 06:36 AM
Good to know I was reading the code correctly, even with close to none Tcl-experience :)
And I can see the use for mailing on every interface changed, but my goal was to log/syslog these and send a mail only when all interfaces in file was changed/completed.
I don't want several hundred mails during such a change.process, if anything goes wrong I could log onto the switch and check the logfile (or check the syslog) - but I do want to know when everything is completed :)
Regards,
Tommy V
11-18-2015 05:42 AM
Hi All,
I am new to TCL scripting and seeking your help for below requirement
I have to change vlans in training rooms twice in a day (Morning & in evening at particular time frame) and this is hitting me badly as sometime I get late and getting unnecessary escalations. Can someone suggest me if TCL script/Kron can be used and vlans can be changed automatically at particular time frame. If a script can be loaded in tftp and there I can change vlan IDs in any time and when training time start just it triggers and all vlans should be changed!!
Is it possible? I think by EEM its possible but EEM is not supported.
11-18-2015 08:42 AM
Please start a new thread for your question.
11-18-2015 11:26 PM
I have already started a new thread!!
Thanks!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide