cancel
Showing results for 
Search instead for 
Did you mean: 

show vlan and sorting

show vlan and sorting

Antonio_Prado
New Contributor II
Hi,

could be possible to make EXOS sort VLANS by VID?

currently it sorts just by name and in case of hundreds vlans it's pretty annoying.

show vlan | sort VID
show vlan sort VID
thank you
--
antonio

7 REPLIES 7

Dave_Hammers
Extreme Employee
If you have EXOS 15.6.1 or later, then you could use python scripting.
There doesn't seem to be a way to attach the script file so I've included it below with before and after console output.

#!/usr/bin/env python ''' This script is provided free of charge by Extreme. We hope such scripts are helpful when used in conjunction with Extreme products and technology; however, scripts are provided simply as an accommodation and are not supported nor maintained by Extreme. ANY SCRIPTS PROVIDED BY EXTREME ARE HEREBY PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL EXTREME OR ITS THIRD PARTY LICENSORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE USE OR DISTRIBUTION OF SUCH SCRIPTS. print "show vlan" in vlan tag order ''' import exsh def getId(line): return int(line.split()[1]) def main(): state=0 header = [] body = [] trailer = [] vlanDisplay = exsh.clicmd('show vlan', capture=True) # extract the vlan body for line in vlanDisplay.splitlines(): if state == 0 or state == 1: #collect the display header. starts ends with ---- line header.append(line) if line.startswith('---'): state += 1 elif state == 2: #collect the display body until a line wiht ---- if line.startswith('---'): state += 1 trailer.append(line) continue body.append(line) elif state == 3: #collect the remaining lines trailer.append(line) newBody = sorted(body,key=getId) out=header + newBody + trailer #print out the sorted results for line in out: print line if __name__ == '__main__': try: main() except SystemExit: #catch SystemExit to prevent EXOS shell ffrom exiting to the login prompt pass Before: X460G2-24t-10G4.14 # show vlan ----------------------------------------------------------------------------------------------- Name VID Protocol Addr Flags Proto Ports Virtual Active router /Total ----------------------------------------------------------------------------------------------- b 30 ------------------------------------------------- ANY 0 /0 VR-Default c 40 ------------------------------------------------- ANY 0 /0 VR-Default Default 1 --------------------------------T---------------- ANY 6 /34 VR-Default k 50 ------------------------------------------------- ANY 0 /0 VR-Default Mgmt 4095 ------------------------------------------------- ANY 1 /1 VR-Mgmt u 10 ------------------------------------------------- ANY 0 /0 VR-Default v 20 ------------------------------------------------- ANY 0 /0 VR-Default w 5 ------------------------------------------------- ANY 0 /0 VR-Default x 4 ------------------------------------------------- ANY 0 /0 VR-Default y 3 ------------------------------------------------- ANY 0 /0 VR-Default z 2 ------------------------------------------------- ANY 0 /0 VR-Default ----------------------------------------------------------------------------------------------- Flags : (B) BFD Enabled, (c) 802.1ad customer VLAN, (C) EAPS Control VLAN, (d) Dynamically created VLAN, (D) VLAN Admin Disabled, (e) CES Configured, (E) ESRP Enabled, (f) IP Forwarding Enabled, (F) Learning Disabled, (h) TRILL Enabled, (i) ISIS Enabled, (I) Inter-Switch Connection VLAN for MLAG, (k) PTP Configured, (l) MPLS Enabled, (L) Loopback Enabled, (m) IPmc Forwarding Enabled, (M) Translation Member VLAN or Subscriber VLAN, (n) IP Multinetting Enabled, (N) Network Login VLAN, (o) OSPF Enabled, (O) Flooding Disabled, (p) PIM Enabled, (P) EAPS protected VLAN, (r) RIP Enabled, (R) Sub-VLAN IP Range Configured, (s) Sub-VLAN, (S) Super-VLAN, (t) Translation VLAN or Network VLAN, (T) Member of STP Domain, (v) VRRP Enabled, (V) VPLS Enabled, (W) VPWS Enabled, (Z) OpenFlow Enabled Total number of VLAN(s) : 11
After
X460G2-24t-10G4.15 # run script showvlanid.py ----------------------------------------------------------------------------------------------- Name VID Protocol Addr Flags Proto Ports Virtual Active router /Total ----------------------------------------------------------------------------------------------- Default 1 --------------------------------T---------------- ANY 6 /34 VR-Default z 2 ------------------------------------------------- ANY 0 /0 VR-Default y 3 ------------------------------------------------- ANY 0 /0 VR-Default x 4 ------------------------------------------------- ANY 0 /0 VR-Default w 5 ------------------------------------------------- ANY 0 /0 VR-Default u 10 ------------------------------------------------- ANY 0 /0 VR-Default v 20 ------------------------------------------------- ANY 0 /0 VR-Default b 30 ------------------------------------------------- ANY 0 /0 VR-Default c 40 ------------------------------------------------- ANY 0 /0 VR-Default k 50 ------------------------------------------------- ANY 0 /0 VR-Default Mgmt 4095 ------------------------------------------------- ANY 1 /1 VR-Mgmt ----------------------------------------------------------------------------------------------- Flags : (B) BFD Enabled, (c) 802.1ad customer VLAN, (C) EAPS Control VLAN, (d) Dynamically created VLAN, (D) VLAN Admin Disabled, (e) CES Configured, (E) ESRP Enabled, (f) IP Forwarding Enabled, (F) Learning Disabled, (h) TRILL Enabled, (i) ISIS Enabled, (I) Inter-Switch Connection VLAN for MLAG, (k) PTP Configured, (l) MPLS Enabled, (L) Loopback Enabled, (m) IPmc Forwarding Enabled, (M) Translation Member VLAN or Subscriber VLAN, (n) IP Multinetting Enabled, (N) Network Login VLAN, (o) OSPF Enabled, (O) Flooding Disabled, (p) PIM Enabled, (P) EAPS protected VLAN, (r) RIP Enabled, (R) Sub-VLAN IP Range Configured, (s) Sub-VLAN, (S) Super-VLAN, (t) Translation VLAN or Network VLAN, (T) Member of STP Domain, (v) VRRP Enabled, (V) VPLS Enabled, (W) VPWS Enabled, (Z) OpenFlow Enabled Total number of VLAN(s) : 11

Hey Antonio

Yes you are correct and we are working to make new advancements on how the VLANs are created and indexed. I believe 16.1 will provide more focus on VLAN ID numbers.

Scripting provides a way for us to manipulate the OS to provide benefit in a faster perspective versus waiting for a new version of code. It also provides a way for customer to re-write what they see on the screen. If for example you want to capture data from two different screens and show them on with one command then we can accomplish it with scripts.

The Python scripts also allow us to run them as an application on the switch so that as soon as the switch is booted the script is loaded into XOS.

I hope that helps explain the reason for scripting and how it can provide benefit between versions of code

Thanks
P

hi dave,

that's useful.

generally speaking, a basic sorting task on vlans shouldn't require programming skills, though

thank you
--
antonio
GTM-P2G8KFN