Commit 0679fe6c authored by Gary Wong's avatar Gary Wong

Another hack to allow URNs in fields which are actually named UUIDs

(for nodes/components this time).

Ultimately, it will be safe to assume that everything both is and is
named a URN, and this mess will go away.
parent 036ab0ca
...@@ -77,6 +77,36 @@ my $SNMPIT = "$TB/bin/snmpit"; ...@@ -77,6 +77,36 @@ my $SNMPIT = "$TB/bin/snmpit";
my $PRERENDER = "$TB/libexec/vis/prerender"; my $PRERENDER = "$TB/libexec/vis/prerender";
my $EMULAB_PEMFILE = "@prefix@/etc/genicm.pem"; my $EMULAB_PEMFILE = "@prefix@/etc/genicm.pem";
# Look up a node by an identifier of unspecified type (perhaps a URN, an
# (obsolete) UUID, or an old-style HRN. Ultimately, all IDs should be
# URNs and this mess will go away, but for now we try not to make
# any assumptions, because of backward compatibility constraints.
sub LookupNode($)
{
my ($nodeid) = @_;
if( GeniHRN::IsValid( $nodeid ) ) {
# Looks like a URN.
my ($auth,$t,$id) = GeniHRN::Parse( $nodeid );
return undef if $auth ne $OURDOMAIN or $t ne "node";
return Node->Lookup( $id );
}
#
# Looks like an old HRN, but we only want the last token for node lookup.
#
if ($nodeid =~ /\./) {
($nodeid) = ($nodeid =~ /\.([-\w]*)$/);
return Node->Lookup($nodeid);
}
# Assume it's a UUID, and pass it on as is.
return Node->Lookup($nodeid);
}
# #
# Respond to a Resolve request. # Respond to a Resolve request.
# #
...@@ -131,16 +161,10 @@ sub Resolve($) ...@@ -131,16 +161,10 @@ sub Resolve($)
my $node; my $node;
if (defined($uuid)) { if (defined($uuid)) {
$node= Node->Lookup($uuid); $node= LookupNode($uuid);
} }
else { else {
# $node= LookupNode($hrn);
# We only want the last token for node lookup.
#
if ($hrn =~ /\./) {
($hrn) = ($hrn =~ /\.([-\w]*)$/);
}
$node= Node->Lookup($hrn);
} }
if (!defined($node)) { if (!defined($node)) {
return GeniResponse->Create(GENIRESPONSE_SEARCHFAILED, return GeniResponse->Create(GENIRESPONSE_SEARCHFAILED,
...@@ -588,7 +612,7 @@ sub GetTicket($;$) ...@@ -588,7 +612,7 @@ sub GetTicket($;$)
!GeniHRN::Equal( $manager_uuid, $ENV{'MYURN'} ) && !GeniHRN::Equal( $manager_uuid, $ENV{'MYURN'} ) &&
$manager_uuid ne $ENV{'MYUUID'}); $manager_uuid ne $ENV{'MYUUID'});
my $node = Node->Lookup($resource_uuid); my $node = LookupNode($resource_uuid);
if (!defined($node)) { if (!defined($node)) {
$response = GeniResponse->Create(GENIRESPONSE_BADARGS, undef, $response = GeniResponse->Create(GENIRESPONSE_BADARGS, undef,
"Bad resource $resource_uuid in ticket"); "Bad resource $resource_uuid in ticket");
...@@ -678,7 +702,7 @@ sub GetTicket($;$) ...@@ -678,7 +702,7 @@ sub GetTicket($;$)
} }
} }
else { else {
$node = Node->Lookup($resource_uuid); $node = LookupNode($resource_uuid);
if (!defined($node)) { if (!defined($node)) {
$response = $response =
...@@ -890,7 +914,7 @@ sub GetTicket($;$) ...@@ -890,7 +914,7 @@ sub GetTicket($;$)
my $component_uuid = $ref->{"component_uuid"}; my $component_uuid = $ref->{"component_uuid"};
my $rspec = $nodemap{$virtual_id}->{'rspec'}; my $rspec = $nodemap{$virtual_id}->{'rspec'};
my $virtnode = $nodemap{$virtual_id}->{'virtnode'}; my $virtnode = $nodemap{$virtual_id}->{'virtnode'};
my $node = Node->Lookup($component_uuid); my $node = LookupNode($component_uuid);
my $colocate = $rspec->{'colocate'} || my $colocate = $rspec->{'colocate'} ||
$rspec->{'phys_nickname'}; $rspec->{'phys_nickname'};
...@@ -1300,7 +1324,7 @@ sub SliverWork($$) ...@@ -1300,7 +1324,7 @@ sub SliverWork($$)
!GeniHRN::Equal( $manager_uuid, $ENV{'MYURN'} ) && !GeniHRN::Equal( $manager_uuid, $ENV{'MYURN'} ) &&
$manager_uuid ne $ENV{'MYUUID'}); $manager_uuid ne $ENV{'MYUUID'});
my $node = Node->Lookup($resource_uuid); my $node = LookupNode($resource_uuid);
if (!defined($node)) { if (!defined($node)) {
$message = "Bad resource_uuid $resource_uuid"; $message = "Bad resource_uuid $resource_uuid";
goto bad; goto bad;
...@@ -1523,7 +1547,7 @@ sub SliverWork($$) ...@@ -1523,7 +1547,7 @@ sub SliverWork($$)
next next
if (grep {$_ eq $virtual_id} keys(%nodemap)); if (grep {$_ eq $virtual_id} keys(%nodemap));
my $node = Node->Lookup($resource_uuid); my $node = LookupNode($resource_uuid);
if (!defined($node)) { if (!defined($node)) {
$message = "Unknown resource_uuid in ticket: $resource_uuid"; $message = "Unknown resource_uuid in ticket: $resource_uuid";
goto bad; goto bad;
...@@ -1551,7 +1575,7 @@ sub SliverWork($$) ...@@ -1551,7 +1575,7 @@ sub SliverWork($$)
# See below; setup all pnodes at once. # See below; setup all pnodes at once.
if ($node->isremotenode()) { if ($node->isremotenode()) {
my $vnode = Node->Lookup($sliver->uuid()); my $vnode = LookupNode($sliver->uuid());
if (!defined($vnode)) { if (!defined($vnode)) {
print STDERR "Could not locate vnode $sliver\n"; print STDERR "Could not locate vnode $sliver\n";
goto bad; goto bad;
...@@ -1674,7 +1698,7 @@ sub SliverWork($$) ...@@ -1674,7 +1698,7 @@ sub SliverWork($$)
$message = "Link $linkname specifies a non-existent node"; $message = "Link $linkname specifies a non-existent node";
goto bad; goto bad;
} }
my $nodeobject= Node->Lookup($nodesliver->resource_uuid()); my $nodeobject= LookupNode($nodesliver->resource_uuid());
if (!defined($nodeobject)) { if (!defined($nodeobject)) {
$message = "Could not find node object for $nodesliver"; $message = "Could not find node object for $nodesliver";
goto bad; goto bad;
...@@ -2689,7 +2713,7 @@ sub SliceStatus($) ...@@ -2689,7 +2713,7 @@ sub SliceStatus($)
if ($sliver->resource_type() ne "Node"); if ($sliver->resource_type() ne "Node");
my $node_uuid = $sliver->uuid(); my $node_uuid = $sliver->uuid();
my $node = Node->Lookup($node_uuid); my $node = LookupNode($node_uuid);
if (!defined($node)) { if (!defined($node)) {
$slice->UnLock(); $slice->UnLock();
print STDERR "Cannot find node by uuid $node_uuid\n"; print STDERR "Cannot find node by uuid $node_uuid\n";
...@@ -2886,7 +2910,7 @@ sub SliverStatus($) ...@@ -2886,7 +2910,7 @@ sub SliverStatus($)
if ($sliver->resource_type() ne "Node"); if ($sliver->resource_type() ne "Node");
my $node_uuid = $sliver->uuid(); my $node_uuid = $sliver->uuid();
my $node = Node->Lookup($node_uuid); my $node = LookupNode($node_uuid);
if (!defined($node)) { if (!defined($node)) {
$slice->UnLock(); $slice->UnLock();
print STDERR "Cannot find node by uuid $node_uuid\n"; print STDERR "Cannot find node by uuid $node_uuid\n";
......
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