Commit 6621a67d authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Add a function to map a tag to its vlan, so we can say something

useful when a tag reservation fails.
parent d89cde03
......@@ -430,7 +430,11 @@ sub newVlanNumber($$) {
#
if ((grep {$_ == $number} @numbers) ||
!defined(reserveVlanTag($vlan_id, $number))) {
print STDERR "desired vlan tag for $vlan_id already in use!\n";
my $vlan_using_tag = $self->findVlanUsingTag($number);
print STDERR
"*** desired vlan tag $number for vlan $vlan_id already in " .
"use" . ($vlan_using_tag ? " by vlan $vlan_using_tag" : "") .
"\n";
# Indicates no tag assigned.
return 0;
}
......@@ -444,7 +448,11 @@ sub newVlanNumber($$) {
$number = getReservedVlanTag($vlan_id);
if ($number) {
if (grep {$_ == $number} @numbers) {
print STDERR "reserved vlan tag for $vlan_id already in use!\n";
my $vlan_using_tag = $self->findVlanUsingTag($number);
print STDERR
"*** reserved vlan tag $number for vlan $vlan_id already in " .
"use" . ($vlan_using_tag ? " by vlan $vlan_using_tag" : "") .
"\n";
return 0;
}
return $number;
......@@ -608,6 +616,37 @@ sub findVlan($$) {
return 0;
}
#
# Find what vlan a tag is associated with.
#
# usage: findVlanUsingTag($self, $number)
# returns the vlan_id if found
# 0 otherwise;
#
sub findVlanUsingTag($$) {
my ($self, $number) = @_;
$self->debug("snmpit_stack::findVlanUsingTag( $number )\n");
if ($parallelized) {
my %dev_map = $self->findVlans();
foreach my $vlan_id (keys(%dev_map)) {
return $vlan_id
if ($number == $dev_map{$vlan_id});
}
return 0;
}
foreach my $devicename (sort {tbsort($a,$b)} keys %{$self->{DEVICES}}) {
my $device = $self->{DEVICES}->{$devicename};
my %dev_map = $device->findVlans();
foreach my $vlan_id (keys(%dev_map)) {
return $vlan_id
if ($number == $dev_map{$vlan_id});
}
return 0;
}
return 0;
}
#
# Check to see if the given VLAN exists in the stack
#
......
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