Commit 8753bf09 authored by Leigh B Stoller's avatar Leigh B Stoller

Fixes and updates for wire/card/port changes.

parent 1019baf9
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2003-2017 University of Utah and the Flux Group. # Copyright (c) 2003-2018 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -214,6 +214,7 @@ my $nodecard; ...@@ -214,6 +214,7 @@ my $nodecard;
my $switchid; my $switchid;
my $switchcard; my $switchcard;
my $switchport; my $switchport;
my $switchiface;
if (!$impotent && $node->IsReserved() && if (!$impotent && $node->IsReserved() &&
$node->erole() eq "sharedhost" && $notrunk && !$force) { $node->erole() eq "sharedhost" && $notrunk && !$force) {
...@@ -234,13 +235,19 @@ if ($iface_id =~ /^[^\d]*(\d*)$/) { ...@@ -234,13 +235,19 @@ if ($iface_id =~ /^[^\d]*(\d*)$/) {
else { else {
fatal("iface_id is not in the proper format"); fatal("iface_id is not in the proper format");
} }
if (Interface->Lookup($node, $nodecard)) { if (Interface->LookupByIface($node, $iface_id)) {
fatal("Node already has an interface with card=$nodecard"); fatal("Node already has an interface with iface=$iface_id");
}
# But also need to look for any thing using this card,port;
my $wire = Interface::Wire->LookupAny($node, $nodecard, 1);
if (defined($wire)) {
fatal("Node $node_id already has a wire: $wire");
} }
if ($switchinfo =~ /^([-\w]+),(\d+),(\d+)$/) { if ($switchinfo =~ /^([-\w]+),(\d+),(\d+)$/) {
$switchid = $1; $switchid = $1;
$switchcard = $2; $switchcard = $2;
$switchport = $3; $switchport = $3;
$switchiface= $switchcard . "/" . $switchport;
} }
else { else {
fatal("Invalid switch info"); fatal("Invalid switch info");
...@@ -249,12 +256,12 @@ my $switch = Node->Lookup($switchid); ...@@ -249,12 +256,12 @@ my $switch = Node->Lookup($switchid);
if (!defined($switch)) { if (!defined($switch)) {
fatal("Switch $switchid does not exist"); fatal("Switch $switchid does not exist");
} }
if (Interface->Lookup($node, $switchcard, $switchport)) { if (Interface->LookupByIface($node, $switchiface)) {
fatal("Switch $switchid already has an interface with ". fatal("Switch $switchid already has an interface with ".
"card=$switchcard,port=$switchport"); "iface=$switchiface");
} }
# But also need to look for any thing using this port; # But also need to look for any thing using this card,port;
my $wire = Interface::Wire->LookupAny($switchid, $switchcard, $switchport); $wire = Interface::Wire->LookupAny($switchid, $switchcard, $switchport);
if (defined($wire)) { if (defined($wire)) {
fatal("Switch $switchid already using this interface: $wire"); fatal("Switch $switchid already using this interface: $wire");
} }
...@@ -273,7 +280,7 @@ if (!defined($type)) { ...@@ -273,7 +280,7 @@ if (!defined($type)) {
my $ifaceargs1 = { my $ifaceargs1 = {
"card" => $switchcard, "card" => $switchcard,
"port" => $switchport, "port" => $switchport,
"iface" => $switchcard . "/" . $switchport, "iface" => $switchiface,
"role" => TBDB_IFACEROLE_OTHER(), "role" => TBDB_IFACEROLE_OTHER(),
"type" => $type->type(), "type" => $type->type(),
"max_speed" => $type->max_speed(), "max_speed" => $type->max_speed(),
...@@ -304,13 +311,13 @@ if (!$impotent) { ...@@ -304,13 +311,13 @@ if (!$impotent) {
} }
if (!$impotent) { if (!$impotent) {
my $wireargs = { my $wireargs = {
"card1" => $switchcard, "card1" => $nodecard,
"port1" => $switchport, "port1" => 1,
"card2" => $nodecard, "card2" => $switchcard,
"port2" => 1, "port2" => $switchport,
}; };
print "Creating wire for $interface1,$interface2:\n"; print "Creating wire for $interface1,$interface2:\n";
$wire = Interface::Wire->Create($interface1, $interface2, 'Node', {}) $wire = Interface::Wire->Create($interface1, $interface2, 'Node', $wireargs)
or fatal("Could not create wire"); or fatal("Could not create wire");
} }
if (!$impotent && if (!$impotent &&
......
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