From 0c77892f0bada36ff0be0f10710c960dbb335e40 Mon Sep 17 00:00:00 2001 From: Keith Sklower Date: Tue, 21 Apr 2009 17:07:45 +0000 Subject: [PATCH] can't go to the middle of a loop, move common error case out. --- tbsetup/snmpit_stack.pm | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tbsetup/snmpit_stack.pm b/tbsetup/snmpit_stack.pm index ef836fae4..a49b12b1b 100755 --- a/tbsetup/snmpit_stack.pm +++ b/tbsetup/snmpit_stack.pm @@ -3,7 +3,7 @@ # # EMULAB-LGPL # Copyright (c) 2000-2009 University of Utah and the Flux Group. -# Copyright (c) 2004-2008 Regents, University of California. +# Copyright (c) 2004-2009 Regents, University of California. # All rights reserved. # @@ -446,6 +446,7 @@ sub createVlan($$$;$$$) { my @otherargs = @_; my $vlan_number; my %map; + my $errortype = "Creating"; # We ignore other args for now, since generic stacks don't support @@ -473,12 +474,23 @@ sub createVlan($$$;$$$) { $device = $self->{DEVICES}{$devicename}; $res = $device->createVlan($vlan_id, $vlan_number); if (!$res) { + goto failed; + } + } + + # + # We need to populate each VLAN on each switch. + # + $self->debug( "adding ports @ports to VLAN $vlan_id \n"); + if (@ports) { + if ($self->setPortVlan($vlan_id,@ports)) { + $errortype = "Adding Ports to"; failed: # # Ooops, failed. Don't try any more # - if ($self->{QUIET}) { - print "Creating VLAN $vlan_id as VLAN #$vlan_number on ". + if (! $self->{QUIET}) { + print "$errortype VLAN $vlan_id as VLAN #$vlan_number on ". "stack $self->{STACKID} failed\n"; } else { @@ -488,16 +500,6 @@ sub createVlan($$$;$$$) { last LOCKBLOCK; } } - - # - # We need to populate each VLAN on each switch. - # - $self->debug( "adding ports @ports to VLAN $vlan_id \n"); - if (@ports) { - if ($self->setPortVlan($vlan_id,@ports)) { - goto failed; - } - } print "Succeeded\n" if (! $self->{QUIET}); } -- GitLab