Scripting vPC and trunk changes

I currently have a large-ish vPC/UCS environment. To add a VLAN I have to touch quite a few switches. Since there is little consistency I also have to reference my visio of the environment so I get the port channels correct or correlate CDP neighbors and port channel summaries. I finally got sick of doing all that so I wrote a python script that will do it for me. Like I noted, the port channel numbering is not consistent and I’m not proficient with Jinja2 (yet) so it’s a bit tedious referencing every switch. You should however get a good framework if this is something you are looking to accomplish.

In this example we only added the VLAN to two switches, but different port channels on each. If you want to add additional switches, you just need to copy-n-past this section and change the parameters to meet the switches name and port-channels.