cancel
Showing results for 
Search instead for 
Did you mean: 

Does anyone have a script to get the ports in a VLAN and then create a new VLAN and add those ports to it?

Does anyone have a script to get the ports in a VLAN and then create a new VLAN and add those ports to it?

Stephen_Stormon
Contributor
We routinely create new VLANs that have the same ports as our "golden" VLAN. I was curious if a) it's possible and b) if anyone has a script that would prompt for the name of the new VLAN and tag, and then create a new VLAN that containing the same ports as the ones in our reference VLAN?
4 REPLIES 4

Ludovico_Steven
Extreme Employee
What if your seed VLAN has untagged ports ?

Tomasz
Valued Contributor II
Hi Stephen,

Never tried such script yet, but it would be a nice challenge to create one that could 'clone' a VLAN of specific tag, based on a reference VLAN.
Pseudocode could be as follows:
  1. Show vlan [reference VID from user form in XMC or XOS prompt] | begin "Tag:"
  2. Parse the output string to get a 1-dimensional table with ports
  3. Loop for each port (or for i = 0:length(table)-1): configure vlan [target VID from user form in XMC or XOS prompt] add port [port from the table] tagged
XMC Python script could be the most robust option for that I believe.
If you wanted, you could also create a workflow with XMC 8.2 to determine a switch OS type and run a script for that which is OS-relevant, so you would have such workflow flexible to configure a group of mixed-OS devices.

Hope that helps,
Tomasz

P.S. After a while I see no sense in my "loop for each port". They can rather be merged and comma separated from the table (or spaces removed from the original CLI output without even playing with a table) and one shot to add them all is enough then.

Stephen_Stormon
Contributor
Currently we would be running it on a X460-48t running 16.2.4.5, but that will eventually be replaced by an X440-G2. We do have XMC, so preferable using that but we could also run it via XOS.

Ludovico_Steven
Extreme Employee
What switch ? XOS ?
And where would you run the script from ? XMC or XOS ?
GTM-P2G8KFN