cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a simple way to see ports in a VLAN, like you can see vlan's on a port?

Is there a simple way to see ports in a VLAN, like you can see vlan's on a port?

Eric_Burke
New Contributor III

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!

1 ACCEPTED SOLUTION

AdrianO
Contributor

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'


9081b663ecef4158b4c20c193b890191_ff527d8e-a11b-422b-a00a-03ad1c458f5d.png

 

View solution in original post

7 REPLIES 7

AdrianO
Contributor

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'


9081b663ecef4158b4c20c193b890191_ff527d8e-a11b-422b-a00a-03ad1c458f5d.png

 

PeterK
Contributor III

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

Miguel-Angel_RO
Valued Contributor II

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

BradP
Extreme Employee

If you would like a feature request opened for this, please open a case with GTAC and we can do so.

 

Thanks
Brad

GTM-P2G8KFN