Commit aac1b96d authored by Robert Ricci's avatar Robert Ricci
Browse files

Add a '-O' option to find only orphaned VLANs - VLANs that seem to

belong to an experiment that no longer exists or is not swapped in.
parent 7babbabf
......@@ -62,7 +62,7 @@ my $quiet = 0;
sub usage {
print << "END";
Usage: $0 [-h] [-v] [-q] [-n] [-i device] [-S stack]
[-l] [-s] [-g]
[-l] [-s] [-g] [-O]
[-m name [ports]]
[-T port name]
[-U port]
......@@ -90,6 +90,7 @@ VLAN Control:
-l List all VLANs
-w Used with -l, includes device-specific VLAN number
-M Used with -l, print MAC addresses instead of port numbers
-O Used with -l, list only orphaned VLANs
-L <out#in[,o2#i2,...]> stylized -l for snmpit.proxy of specific vlans
-m <name> [ports] Create a new VLAN with name <name>, if it doesn't exist,
and put [ports] in it
......@@ -134,7 +135,7 @@ my %opt = ();
GetOptions(\%opt, 'a','c','d','e','b','B=s@','g','h','i=s@','l','m=s@','M','n',
'N=s@','o=s@','p=s','q','r','s', 'S=s@','t','E=s','T=s','u=s','U','v=s','w',
# Unused: f,j
if ($opt{h}) {
......@@ -863,14 +864,26 @@ $vlan_id,$ddep, $pideid, $vname, $members
# Permissions check - people only get to see their own VLANs
if ((!$eid) || (!$pid)) {
# If only printing orphaned VLANs, consider only ones that have IDs
# that look like the ones we assign in the database
if ($opt{O} && $vid !~ /^\d+$/) {
if (!TBAdmin()) {
&debug("Failed TBAdmin check\n");
} elsif ($UID && !TBExptAccessCheck($UID,$pid,$eid,TB_EXPT_READINFO)) {
&debug("Failed TBExptAccessCheck($UID,$pid,$eid)\n");
} else {
# If only printing orphaned VLANs, skip ones for which we know the
# pid and ied
if ($opt{O}) {
if ($UID && !TBExptAccessCheck($UID,$pid,$eid,TB_EXPT_READINFO)) {
&debug("Failed TBExptAccessCheck($UID,$pid,$eid)\n");
if (!$vname) { $vname = ""; }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment