Commit f6663a3a authored by Leigh Stoller's avatar Leigh Stoller

Add support/check to make sure switch device not already in use.

parent 47e4605e
#!/usr/bin/perl -wT
#
# Copyright (c) 2005-2013 University of Utah and the Flux Group.
# Copyright (c) 2005-2014 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -1155,6 +1155,29 @@ sub logical($) { return $_[0]->field('logical'); }
sub trunkid($) { return $_[0]->field('trunkid'); }
sub IsActive($) { return ($_[0]->type() eq "Unused" ? 0 : 1); }
#
# Find me a wire from either side using nodeid,card,port.
#
sub LookupAny($$$$)
{
my ($class, $nodeid, $card, $port) = @_;
my $query_result =
DBQueryWarn("select * from wires ".
"where (node_id1='$nodeid' and ".
" card1='$card' and port1='$port') or ".
" (node_id2='$nodeid' and ".
" card2='$card' and port2='$port')");
return undef
if (!$query_result || !$query_result->numrows);
my $wire = {};
$wire->{"DBROW"} = $query_result->fetchrow_hashref();
bless($wire, $class);
return $wire;
}
#
# Delete a logical wire and its interfaces.
#
......
#!/usr/bin/perl -w
#
# Copyright (c) 2003-2013 University of Utah and the Flux Group.
# Copyright (c) 2003-2014 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -223,6 +223,12 @@ if (Interface->Lookup($node, $switchcard, $switchport)) {
fatal("Switch $switchid already has an interface with ".
"card=$switchcard,port=$switchport");
}
# But also need to look for any thing using this port;
my $wire = Package::Wire->LookupAny($switchid, $switchcard, $switchport);
if (defined($wire)) {
fatal("Switch $switchid already using this interface: $wire");
}
#
# Add the interface.
#
......
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