Commit 1f16d7ae authored by Jonathon Duerig's avatar Jonathon Duerig

Modify CM to accept stitching URNs as advertised.

parent bbc26e5b
......@@ -1062,25 +1062,33 @@ sub Lookup($$)
{
my ($class, $interface) = @_;
if (!ref($interface)) {
# Allow "nodeid:card:port" argument.
if ($interface =~ /^([-\w]*):(\w+):(\w+)$/) {
$interface = Interface->Lookup($1, $2, $3);
return undef
if (!defined($interface));
}
else {
return undef;
my $query_result;
if (!ref($interface) && $interface =~ /^urn:publicid:IDN+/) {
# Allow lookup by remote interface URN
$query_result =
DBQueryWarn("select * from wires ".
"where external_interface='$interface'");
} else {
if (!ref($interface)) {
# Allow "nodeid:card:port" argument.
if ($interface =~ /^([-\w]*):(\w+):(\w+)$/) {
$interface = Interface->Lookup($1, $2, $3);
return undef
if (!defined($interface));
}
else {
return undef;
}
}
my $node_id1 = $interface->node_id();
my $card1 = $interface->card();
my $port1 = $interface->port();
$query_result =
DBQueryWarn("select * from wires ".
"where node_id1='$node_id1' and ".
" card1='$card1' and port1='$port1'");
}
my $node_id1 = $interface->node_id();
my $card1 = $interface->card();
my $port1 = $interface->port();
my $query_result =
DBQueryWarn("select * from wires ".
"where node_id1='$node_id1' and ".
" card1='$card1' and port1='$port1'");
return undef
if (!$query_result || !$query_result->numrows);
......
......@@ -1697,8 +1697,39 @@ sub GetTicketAuxAux($$$$$$$$$)
# which corresponds to our "fake" nodes.
#
my $edgeurn = GetHopLinkID($edgehop);
my (undef,undef,$edgestuff) = GeniHRN::Parse($edgeurn);
my (undef,$ifaceid,$edgenodeid) = split('//', $edgestuff);
my $edgewire = Interface::Wire->Lookup($edgeurn);
if (!defined($edgewire)) {
GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"$lanname: unknown ".
"external_interface for ".
$edgeurn);
goto bad;
}
#
# Look in the external networks table to get the hop
# details.
#
my $edgenodeid = $edgewire->node_id1();
my $edgecard = $edgewire->card1();
my $edgeport = $edgewire->port1();
my $network = ExternalNetwork->Lookup($edgenodeid);
# The external network may be attached to node_id2
if (! defined($network)) {
$edgenodeid = $edgewire->node_id2();
$edgecard = $edgewire->card2();
$edgeport = $edgewire->port2();
$network = ExternalNetwork->Lookup($edgenodeid);
}
if (!defined($network)) {
$response =
GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"$lanname: unknown network for ".
$edgewire->node_id1() . " and ".
$edgewire->node_id2());
goto bad;
}
#
# The edge node and the interface on that node must exist.
......@@ -1708,29 +1739,19 @@ sub GetTicketAuxAux($$$$$$$$$)
$response =
GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"$lanname: unknown node ".
"$edgenodeid in $edgestuff");
"$edgenodeid");
goto bad;
}
my $edgeiface = Interface->LookupByIface($edgenode,
$ifaceid);
my $edgeiface = Interface->Lookup($edgenodeid, $edgecard,
$edgeport);
if (!defined($edgeiface)) {
$response =
GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"$lanname: unknown iface in $edgeurn");
"$lanname: unknown iface for ".
"$edgenodeid:$edgecard.$edgeport");
goto bad;
}
#
# Look in the external networks table to get the hop
# details.
#
my $network = ExternalNetwork->Lookup($edgenodeid);
if (!defined($network)) {
$response =
GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"$lanname: unknown network for $edgenodeid");
goto bad;
}
# Stash for later. We need to allocate a vlan tag, and
# this stores the min/max vlan numbers we have to use.
$stitching_paths{$lanname}->{'network'} = $network;
......@@ -2295,7 +2316,7 @@ sub GetTicketAuxAux($$$$$$$$$)
# Chainmode
#
while ($retries) {
my $edgeurn = $stitching_paths{$linkname}->{'edgeurn'};
my $network = $stitching_paths{$linkname}->{'network'};
#
# Already have a reserved tag? This could happen if the other CM
......@@ -2318,8 +2339,9 @@ sub GetTicketAuxAux($$$$$$$$$)
}
print $fh GeniXML::Serialize($rspec);
close($fh);
my $networkid = $network->node_id();
system("$RESERVEVLANS ".
"'$slice_urn' '$linkname' '$edgeurn' $filename");
"'$slice_urn' '$linkname' '$networkid' $filename");
if ($CHILD_ERROR) {
unlink($filename);
......
......@@ -16,7 +16,7 @@ use Data::Dumper;
sub usage()
{
print STDERR
"Usage: reservevlans <slice_urn> <linkname> <hopurn> <rspec>\n";
"Usage: reservevlans <slice_urn> <linkname> <networkid> <rspec>\n";
exit(1);
}
my $optlist = "";
......@@ -77,7 +77,7 @@ usage()
my $slice_urn = $ARGV[0];
my $linkname = $ARGV[1];
my $hopurn = $ARGV[2];
my $networkid = $ARGV[2];
my $rspecfile = $ARGV[3];
#
......@@ -141,11 +141,9 @@ if (!defined($other_manager)) {
fatal("Who is the other manager?");
}
my (undef,undef,$network_stuff) = GeniHRN::Parse($hopurn);
my (undef,undef,$network_id) = split('//', $network_stuff);
my $network = ExternalNetwork->Lookup($network_id);
my $network = ExternalNetwork->Lookup($networid);
if (!defined($network)) {
fatal("$hopurn is not an external network");
fatal("$networkid is not an external network");
}
# The bounds of the vlan tags we can use for this network point.
my $mintag = $network->min_vlan();
......
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