04-07-2020 12:54 PM
In Exos, you can issue a “show port xx vlan” to get a short, simple list of vlan’s on a port. Is there a similar way to get a brief list of ports within a vlan (as opposed to “show vlan xx”, where it’s a small block of info at the bottom? I want to see all ports in V90 for example, nothing else. Would be cool with something like “show vlan xx members”.
Thanks!
Solved! Go to Solution.
04-15-2020 01:35 PM
I did a thing
#!/usr/bin/env python
'''
Shows ports in a vlan
Tested on EXOS 22.6.1.4
Execute with:
- run script vlanports.py
or
- Make an alias: alias vlanport "run script vlanports.py"
'''
import re
import sys
exsh.clicmd('disable clipaging', False)
# Input the tag or complete name of the vlan.
if len(sys.argv) < 2:
input_tag = raw_input("Vlan: ")
else:
input_tag = sys.argv[1]
# Get vlan name
vlan_name = exsh.clicmd('show vlan {} | inc name'.format(input_tag), True)
if not vlan_name:
print 'Error: No <vlan_list> found with ID {}'.format(input_tag)
exit()
vlan_name = vlan_name.split()[4]
# Extract vlan secction of the configuration
config_lines = exsh.clicmd('show configuration vlan', True).splitlines()
# Find the first line that matches "configure vlan <vlan_name> add ports"
regex = re.compile('configure vlan {} add ports'.format(vlan_name), re.IGNORECASE)
for i, line in enumerate(config_lines):
if regex.match(line):
line_field = line.split()
print 'Ports {tag}: {ports}'.format(tag = line_field[-1], ports = line_field[5])
# If there are tagged and untagged ports configured in the vlan, the next line in the configuration has them
if regex.match(config_lines[i+1]):
line_field = config_lines[i+1].split()
print 'Ports {tag}: {ports}'.format(tag = line_field[-1], ports = line_field[5])
exit()
print 'No ports in this vlan'
04-15-2020 01:35 PM
I did a thing
#!/usr/bin/env python
'''
Shows ports in a vlan
Tested on EXOS 22.6.1.4
Execute with:
- run script vlanports.py
or
- Make an alias: alias vlanport "run script vlanports.py"
'''
import re
import sys
exsh.clicmd('disable clipaging', False)
# Input the tag or complete name of the vlan.
if len(sys.argv) < 2:
input_tag = raw_input("Vlan: ")
else:
input_tag = sys.argv[1]
# Get vlan name
vlan_name = exsh.clicmd('show vlan {} | inc name'.format(input_tag), True)
if not vlan_name:
print 'Error: No <vlan_list> found with ID {}'.format(input_tag)
exit()
vlan_name = vlan_name.split()[4]
# Extract vlan secction of the configuration
config_lines = exsh.clicmd('show configuration vlan', True).splitlines()
# Find the first line that matches "configure vlan <vlan_name> add ports"
regex = re.compile('configure vlan {} add ports'.format(vlan_name), re.IGNORECASE)
for i, line in enumerate(config_lines):
if regex.match(line):
line_field = line.split()
print 'Ports {tag}: {ports}'.format(tag = line_field[-1], ports = line_field[5])
# If there are tagged and untagged ports configured in the vlan, the next line in the configuration has them
if regex.match(config_lines[i+1]):
line_field = config_lines[i+1].split()
print 'Ports {tag}: {ports}'.format(tag = line_field[-1], ports = line_field[5])
exit()
print 'No ports in this vlan'
04-13-2020 10:40 AM
I’m still waiting for a portation of EOS command
show vlan portinfo vlan xxx
that would solve your question…
If anyone is familiar with python it should be possible to modify following script for this.
https://github.com/extremenetworks/ExtremeScripting/tree/master/EXOS/Python/show_port_vid
04-09-2020 09:44 AM
This is quite easy but verbose:
* X440G2-12p.8 # show ports vlan port-number
Untagged
Port /Tagged VLAN Name(s)
-------- -------- ------------------------------------------------------------
1 Untagged Default
2 Untagged Default
3 Untagged Default
4 Untagged Default
5 Untagged Default
Tagged VLAN10
6 Untagged Default
7 Untagged Default
8 Untagged Default
9 Untagged Default
10 Untagged Default
11 Untagged Default
Tagged VLAN10
12 Untagged Default
13 Untagged Default
14 Untagged Default
15 Untagged Default
16 Untagged Default
04-07-2020 06:40 PM
If you would like a feature request opened for this, please open a case with GTAC and we can do so.
Thanks
Brad