Commit 326a5628 authored by Weibin Sun's avatar Weibin Sun
Browse files

merge snmpit* to new_snmpit*

parent 2f4c200c
......@@ -2,7 +2,7 @@
#
# EMULAB-LGPL
# Copyright (c) 2000-2009 University of Utah and the Flux Group.
# Copyright (c) 2000-2009, 2011 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -110,7 +110,11 @@ sub new($$$;$) {
$self->{MIN_VLAN} = $options->{'min_vlan'};
$self->{MAX_VLAN} = $options->{'max_vlan'};
if (($self->{MAX_VLAN} > 1024) && ($self->{MIN_VLAN} < 1000)) {
#
# Temporary removal by Leigh.
#
if (0 &&
($self->{MAX_VLAN} > 1024) && ($self->{MIN_VLAN} < 1000)) {
warn "ERROR: Some Cisco switches forbid creation of user vlans ".
"with 1000 < vlan number <= 1024\n";
return undef;
......@@ -1085,7 +1089,9 @@ sub opPortVlan($$$@) {
# Make sure the port didn't get mangled in conversion
#
if (!defined $index) {
print STDERR "Port not found, skipping\n";
my $name = $self->{NAME};
print STDERR "Port ($port) not found on $name, skipping\n";
$errors++;
next;
}
......
......@@ -15,6 +15,7 @@ $| = 1; # Turn off line buffering on output
use English;
use SNMP;
use new_snmpit_lib;
use Data::Dumper;
use libdb;
use libtestbed;
......@@ -165,6 +166,25 @@ sub Stringify($)
return "[Stack ${stack_id}]";
}
sub FlipDebug($$)
{
my $self = shift;
my $debug = shift;
$self->{'DEBUG'} = $debug;
$snmpit_stack_child::child_debug = $debug;
foreach my $devicename (keys %{$self->{DEVICES}}) {
my $device = $self->{DEVICES}{$devicename};
$device->{'DEBUG'} = $debug;
}
foreach my $device (values(%devices)) {
$device->{'DEBUG'} = $debug;
# print Dumper($device);
}
return 0;
}
#
# List all VLANs on all switches in the stack
#
......@@ -577,7 +597,7 @@ sub createVlan($$$$;$$$) {
sub findDeviceVlans($@) {
my $self = shift;
my @vlan_ids = @_;
my ($count, $device, $devicename) = (scalar(@vlan_ids));
my ($device, $devicename);
my %mapping = ();
#
# Each value in the mapping is:
......@@ -846,6 +866,7 @@ sub removeSomePortsFromVlan($$@) {
warn "ERROR: VLAN $vlan_id not found on switch!";
return 0;
}
my %map = mapPortsToDevices(@ports);
#
# Now, we go through each device and remove all ports from the VLAN
......@@ -855,7 +876,7 @@ sub removeSomePortsFromVlan($$@) {
# first, so the other snmpit will not see it free until it's been
# removed from all switches)
#
foreach my $devicename (sort {tbsort($b,$a)} keys %{$self->{DEVICES}}) {
foreach my $devicename (sort {tbsort($b,$a)} keys %map) {
my $device = $self->{DEVICES}{$devicename};
my %vlan_numbers = $device->findVlans($vlan_id);
......@@ -870,9 +891,9 @@ sub removeSomePortsFromVlan($$@) {
print "Removing ports on $devicename from VLAN $vlan_id ($vlan_number)\n"
if $self->{DEBUG};
$errors += $device->removeSomePortsFromVlan($vlan_number, @ports);
$errors += $device->removeSomePortsFromVlan($vlan_number,
@{$map{$devicename}});
}
return ($errors == 0);
}
......@@ -899,6 +920,7 @@ sub removeSomePortsFromTrunk($$@) {
warn "ERROR: VLAN $vlan_id not found on switch!";
return 0;
}
my %map = mapPortsToDevices(@ports);
#
# Now, we go through each device and remove all ports from the trunk
......@@ -908,7 +930,7 @@ sub removeSomePortsFromTrunk($$@) {
# first, so the other snmpit will not see it free until it's been
# removed from all switches)
#
foreach my $devicename (sort {tbsort($b,$a)} keys %{$self->{DEVICES}}) {
foreach my $devicename (sort {tbsort($b,$a)} keys %map) {
my $device = $self->{DEVICES}{$devicename};
my %vlan_numbers = $device->findVlans($vlan_id);
......@@ -920,10 +942,11 @@ sub removeSomePortsFromTrunk($$@) {
my $vlan_number = $vlan_numbers{$vlan_id};
print "Removing ports on $devicename from VLAN $vlan_id ($vlan_number)\n"
print "Removing trunk ports on $devicename from VLAN ".
"$vlan_id ($vlan_number)\n"
if $self->{DEBUG};
foreach my $port (@ports) {
foreach my $port (@{$map{$devicename}}) {
return 0
if (! $device->setVlansOnTrunk($port, 0, $vlan_number));
}
......
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