Commit 3e3a4ea1 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Pass -q (quiet) flag through the the stack and cisco modules to cut

down on the output. Used in Geni mode.
parent 11ce4b1d
......@@ -645,20 +645,21 @@ COMMAND: foreach my $command (@commands) {
SWITCH: for ($stack_type) {
(/cisco/ || /catalyst/) && do {
require snmpit_cisco_stack;
$stack = new snmpit_cisco_stack($stack_id,$debug,$single_domain,
@{$stacks{$stack_id}});
$stack = new snmpit_cisco_stack($stack_id,$debug,$quiet,
$single_domain,
@{$stacks{$stack_id}});
last;
}; # /cisco/
/intel/ && do {
require snmpit_intel_stack;
$stack = new snmpit_intel_stack($stack_id,$debug,
@{$stacks{$stack_id}});
@{$stacks{$stack_id}});
last;
};
/generic/ && do {
require snmpit_stack;
$stack = new snmpit_stack($stack_id,$debug,
@{$stacks{$stack_id}});
$stack = new snmpit_stack($stack_id,$debug,$quiet,
@{$stacks{$stack_id}});
last;
}; # /generic/
......
......@@ -2,7 +2,7 @@
#
# EMULAB-LGPL
# Copyright (c) 2000-2007 University of Utah and the Flux Group.
# Copyright (c) 2000-2009 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -62,7 +62,7 @@ my $PORT_FORMAT_NODEPORT = 3;
# usage: new($classname,$devicename,$debuglevel,$community)
# returns a new object, blessed into the snmpit_cisco class.
#
sub new($$$;$) {
sub new($$$$;$) {
# The next two lines are some voodoo taken from perltoot(1)
my $proto = shift;
......@@ -70,6 +70,7 @@ sub new($$$;$) {
my $name = shift;
my $debugLevel = shift;
my $quiet = shift;
my $community = shift;
#
......@@ -85,6 +86,11 @@ sub new($$$;$) {
} else {
$self->{DEBUG} = 0;
}
if (defined($quiet)) {
$self->{QUIET} = $quiet;
} else {
$self->{QUIET} = 0;
}
$self->{BLOCK} = 1;
$self->{BULK} = 1;
$self->{NAME} = $name;
......@@ -492,7 +498,8 @@ sub vlanUnlock($) {
my $EditOp = 'vtpVlanEditOperation'; # use index 1
my $ApplyStatus = 'vtpVlanApplyStatus'; # use index 1
print " Applying VLAN changes on $self->{NAME} ...";
print " Applying VLAN changes on $self->{NAME} ..."
if (! $self->{QUIET});
#
# Send the command to apply what's in the edit buffer
......@@ -506,7 +513,7 @@ sub vlanUnlock($) {
if (!defined($ApplyRetVal) || $ApplyRetVal != 1) {
print " FAILED\n";
warn("**** ERROR: Failure attempting to apply VLAN changes ($ApplyRetVal)\n");
warn("**** ERROR: Failure attempting to apply VLAN changes ($ApplyRetVal) on $self->{NAME}\n");
} else {
#
......@@ -534,10 +541,13 @@ sub vlanUnlock($) {
# Tell the caller what happened
#
if ($ApplyRetVal ne "succeeded") {
print " FAILED\n";
warn("**** ERROR: Failure applying VLAN changes: $ApplyRetVal\n");
print " FAILED\n"
if (! $self->{QUIET});
warn("**** ERROR: Failure applying VLAN changes on $self->{NAME}:".
" $ApplyRetVal\n");
} else {
print " Succeeded\n";
print " Succeeded\n"
if (! $self->{QUIET});
$self->debug("Apply Succeeded.\n");
}
}
......@@ -549,7 +559,8 @@ sub vlanUnlock($) {
my $snmpvar = [$EditOp,1,"release",'INTEGER'];
my $RetVal = snmpitSetWarn($self->{SESS},$snmpvar);
if (! $RetVal ) {
warn("*** ERROR: Failed to unlock VLAN edit buffer\n");
warn("*** ERROR: ".
"Failed to unlock VLAN edit buffer on $self->{NAME}\n");
return 0;
}
$self->debug("Release: '$RetVal'\n");
......@@ -729,7 +740,7 @@ sub createVlan($$;$$$) {
# Try to wait out transient failures
#
if ($tries_remaining != $max_tries) {
print STDERR "VLAN creation failed, trying again " .
print STDERR "VLAN $vlan_id creation failed, trying again " .
"($tries_remaining tries left)\n";
sleep 5;
}
......@@ -780,7 +791,7 @@ sub createVlan($$;$$$) {
my $SAID = pack("H*",sprintf("%08x",$vlan_number + 100000));
print " Creating VLAN $vlan_id as VLAN #$vlan_number on " .
"$self->{NAME} ... ";
"$self->{NAME} ... " if (! $self->{QUIET});
#
# Perform the actual creation. Yes, this next line MUST happen all in
......@@ -791,7 +802,7 @@ sub createVlan($$;$$$) {
[$VlanType,"1.$vlan_number","ethernet","INTEGER"],
[$VlanName,"1.$vlan_number",$vlan_id,"OCTETSTR"],
[$VlanSAID,"1.$vlan_number",$SAID,"OCTETSTR"]]);
print "",($RetVal? "Succeeded":"Failed"), ".\n";
print "",($RetVal? "Succeeded":"Failed"), ".\n" if (! $self->{QUIET});
#
# Check for success
......@@ -1167,13 +1178,20 @@ sub removeVlan($@) {
#
my $VlanRowStatus = 'vtpVlanEditRowStatus'; # vlan is index
print " Removing VLAN #$vlan_number on $self->{NAME} ... ";
print " Removing VLAN #$vlan_number on $self->{NAME} ... "
if (! $self->{QUIET});
my $RetVal = snmpitSetWarn($self->{SESS},
[$VlanRowStatus,"1.$vlan_number","destroy","INTEGER"]);
if ($RetVal) {
print "Succeeded.\n";
print "Succeeded.\n" if (! $self->{QUIET});
} else {
print "Failed.\n";
if ($self->{QUIET}) {
print " Removing VLAN #$vlan_number on ".
"$self->{NAME} failed.\n";
}
else {
print "Failed.\n";
}
$errors++;
}
......
......@@ -32,7 +32,7 @@ use libdb;
# usage: new(string name, string stack_id, int debuglevel, list of devicenames)
# returns a new object blessed into the snmpit_cisco_stack class
#
sub new($$$$@) {
sub new($$$$$@) {
# The next two lines are some voodoo taken from perltoot(1)
my $proto = shift;
......@@ -40,6 +40,7 @@ sub new($$$$@) {
my $stack_id = shift;
my $debuglevel = shift;
my $quiet = shift;
my $uses_vtp = shift;
my @devicenames = @_;
......@@ -56,6 +57,11 @@ sub new($$$$@) {
} else {
$self->{DEBUG} = 0;
}
if (defined $quiet) {
$self->{QUIET} = $quiet;
} else {
$self->{QUIET} = 0;
}
#
# The ID of this stack
......
......@@ -2,7 +2,7 @@
#
# EMULAB-LGPL
# Copyright (c) 2000-2008 University of Utah and the Flux Group.
# Copyright (c) 2000-2009 University of Utah and the Flux Group.
# Copyright (c) 2004-2008 Regents, University of California.
# All rights reserved.
#
......@@ -28,7 +28,7 @@ use libtestbed;
# returns a new object blessed into the snmpit_stack class
#
sub new($$$@) {
sub new($$$$@) {
# The next two lines are some voodoo taken from perltoot(1)
my $proto = shift;
......@@ -36,6 +36,7 @@ sub new($$$@) {
my $stack_id = shift;
my $debuglevel = shift;
my $quiet = shift;
my @devicenames = @_;
#
......@@ -52,6 +53,11 @@ sub new($$$@) {
} else {
$self->{DEBUG} = 0;
}
if (defined $quiet) {
$self->{QUIET} = $quiet;
} else {
$self->{QUIET} = 0;
}
$self->{STACKID} = $stack_id;
$self->{MAX_VLAN} = 4095;
......@@ -108,7 +114,8 @@ sub new($$$@) {
SWITCH: for ($type) {
(/cisco/) && do {
use snmpit_cisco;
$device = new snmpit_cisco($devicename,$self->{DEBUG});
$device = new snmpit_cisco($devicename,
$self->{DEBUG},$self->{QUIET});
last;
}; # /cisco/
(/foundry1500/ || /foundry9604/)
......@@ -453,7 +460,7 @@ sub createVlan($$$;$$$) {
$vlan_number = $self->newVlanNumber($vlan_id);
if ($vlan_number == 0) { last LOCKBLOCK;}
print "Creating VLAN $vlan_id as VLAN #$vlan_number on stack " .
"$self->{STACKID} ... \n";
"$self->{STACKID} ... \n" if (! $self->{QUIET});
if ($self->{ALLVLANSONLEADER}) {
$res = $self->{LEADER}->createVlan($vlan_id, $vlan_number);
$self->unlock();
......@@ -470,8 +477,14 @@ sub createVlan($$$;$$$) {
#
# Ooops, failed. Don't try any more
#
if ($self->{QUIET}) {
print "Creating VLAN $vlan_id as VLAN #$vlan_number on ".
"stack $self->{STACKID} failed\n";
}
else {
print "Failed\n";
}
$vlan_number = 0;
print "Failed\n";
last LOCKBLOCK;
}
}
......@@ -485,7 +498,7 @@ sub createVlan($$$;$$$) {
goto failed;
}
}
print "Succeeded\n";
print "Succeeded\n" if (! $self->{QUIET});
}
$self->unlock();
......
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