Commit b3c8e72e authored by Leigh B Stoller's avatar Leigh B Stoller

More purging of UUIDs. Reminder, we still use them all over the place

internally, as the primary key in the tables, but the CM/SA APIs no
longer use them. The CH still accepts them for now. We can probably
stop putting them into manifests and advertisements at this point as
well. 

For slivers, stop using the uuid of the node as the uuid of the sliver
itself; generate a new one. As above, this is cause the uuid is the
primary key in the table, but the URN is what we use for lookups,
etc.
parent 92c57986
...@@ -752,7 +752,7 @@ sub Start($$$) ...@@ -752,7 +752,7 @@ sub Start($$$)
next next
if (ref($sliver) ne "GeniSliver::Node"); if (ref($sliver) ne "GeniSliver::Node");
my $node = Node->Lookup($sliver->uuid()); my $node = Node->Lookup($sliver->resource_id());
if (!defined($node)) { if (!defined($node)) {
print STDERR "Could not map $sliver to a node\n"; print STDERR "Could not map $sliver to a node\n";
return -1; return -1;
...@@ -1002,7 +1002,7 @@ sub Stop($$) ...@@ -1002,7 +1002,7 @@ sub Stop($$)
next next
if (ref($sliver) ne "GeniSliver::Node"); if (ref($sliver) ne "GeniSliver::Node");
my $node = Node->Lookup($sliver->uuid()); my $node = Node->Lookup($sliver->resource_id());
if (!defined($node)) { if (!defined($node)) {
print STDERR "Could not map $sliver to a node\n"; print STDERR "Could not map $sliver to a node\n";
return -1; return -1;
...@@ -1413,7 +1413,7 @@ sub Create($$$$$$) ...@@ -1413,7 +1413,7 @@ sub Create($$$$$$)
# We need the control network addresses, but it is possible that # We need the control network addresses, but it is possible that
# one of the nodes is not on this testbed. # one of the nodes is not on this testbed.
if (defined($node1sliver)) { if (defined($node1sliver)) {
my $node1 = Node->Lookup($node1sliver->resource_uuid()); my $node1 = Node->Lookup($node1sliver->resource_id());
if (!defined($node1)) { if (!defined($node1)) {
print STDERR "Tunnel: Could not lookup node for $node1sliver\n"; print STDERR "Tunnel: Could not lookup node for $node1sliver\n";
goto bad; goto bad;
...@@ -1429,11 +1429,11 @@ sub Create($$$$$$) ...@@ -1429,11 +1429,11 @@ sub Create($$$$$$)
} }
} }
else { else {
my $node_uuid = GeniXML::GetNodeId($node1rspec); my $component_id = GeniXML::GetNodeId($node1rspec);
my $component = GeniComponent->CreateFromRegistry($node_uuid); my $component = GeniComponent->CreateFromRegistry($component_id);
if (!defined($component)) { if (!defined($component)) {
print STDERR "Could not create component for $node_uuid\n"; print STDERR "Could not create component for $component_id\n";
goto bad; goto bad;
} }
my $blob = $component->Resolve(); my $blob = $component->Resolve();
...@@ -1448,7 +1448,7 @@ sub Create($$$$$$) ...@@ -1448,7 +1448,7 @@ sub Create($$$$$$)
$ctrlip1 = $blob->{'physctrl'}; $ctrlip1 = $blob->{'physctrl'};
} }
if (defined($node2sliver)) { if (defined($node2sliver)) {
my $node2 = Node->Lookup($node2sliver->resource_uuid()); my $node2 = Node->Lookup($node2sliver->resource_id());
if (!defined($node2)) { if (!defined($node2)) {
print STDERR "Tunnel: Could not lookup node for $node2sliver\n"; print STDERR "Tunnel: Could not lookup node for $node2sliver\n";
goto bad; goto bad;
...@@ -1464,11 +1464,11 @@ sub Create($$$$$$) ...@@ -1464,11 +1464,11 @@ sub Create($$$$$$)
} }
} }
else { else {
my $node_uuid = GeniXML::GetNodeId($node2rspec); my $component_id = GeniXML::GetNodeId($node2rspec);
my $component = GeniComponent->CreateFromRegistry($node_uuid); my $component = GeniComponent->CreateFromRegistry($component_id);
if (!defined($component)) { if (!defined($component)) {
print STDERR "Could not create component for $node_uuid\n"; print STDERR "Could not create component for $component_id\n";
goto bad; goto bad;
} }
my $blob = $component->Resolve(); my $blob = $component->Resolve();
......
...@@ -400,7 +400,7 @@ sub GetTicketAuxAux($$$$$$$$$) ...@@ -400,7 +400,7 @@ sub GetTicketAuxAux($$$$$$$$$)
# #
my $authority = GeniCertificate->LoadFromFile($EMULAB_PEMFILE); my $authority = GeniCertificate->LoadFromFile($EMULAB_PEMFILE);
if (!defined($authority)) { if (!defined($authority)) {
print STDERR " Could not get uuid from $EMULAB_PEMFILE\n"; print STDERR " Could not load authority for $EMULAB_PEMFILE\n";
return GeniResponse->Create(GENIRESPONSE_ERROR); return GeniResponse->Create(GENIRESPONSE_ERROR);
} }
...@@ -679,11 +679,11 @@ sub GetTicketAuxAux($$$$$$$$$) ...@@ -679,11 +679,11 @@ sub GetTicketAuxAux($$$$$$$$$)
my $node_nickname = GeniXML::GetVirtualId($ref); my $node_nickname = GeniXML::GetVirtualId($ref);
my $colocate = GeniXML::GetText("colocate", $ref) || my $colocate = GeniXML::GetText("colocate", $ref) ||
GeniXML::GetText("phys_nickname", $ref); GeniXML::GetText("phys_nickname", $ref);
my $resource_uuid = GeniXML::GetNodeId($ref); my $component_id = GeniXML::GetNodeId($ref);
my $node = GeniUtil::LookupNode($resource_uuid); my $node = GeniUtil::LookupNode($component_id);
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 $component_id in ticket");
goto bad; goto bad;
} }
...@@ -712,8 +712,8 @@ sub GetTicketAuxAux($$$$$$$$$) ...@@ -712,8 +712,8 @@ sub GetTicketAuxAux($$$$$$$$$)
print GeniXML::Serialize($rspec); print GeniXML::Serialize($rspec);
foreach my $ref (GeniXML::FindNodes("n:node", $rspec)->get_nodelist()) { foreach my $ref (GeniXML::FindNodes("n:node", $rspec)->get_nodelist()) {
my $resource_uuid = GeniXML::GetNodeId($ref); my $component_id = GeniXML::GetNodeId($ref);
my $manager_uuid = GeniXML::GetManagerId($ref); my $manager_id = GeniXML::GetManagerId($ref);
my $node_nickname = GeniXML::GetVirtualId($ref); my $node_nickname = GeniXML::GetVirtualId($ref);
my $colocate = GeniXML::GetText("colocate", $ref) || my $colocate = GeniXML::GetText("colocate", $ref) ||
GeniXML::GetText("phys_nickname", $ref); GeniXML::GetText("phys_nickname", $ref);
...@@ -867,7 +867,7 @@ sub GetTicketAuxAux($$$$$$$$$) ...@@ -867,7 +867,7 @@ sub GetTicketAuxAux($$$$$$$$$)
# #
# Allow wildcarding. # Allow wildcarding.
# #
if (!defined($resource_uuid) || $resource_uuid eq "*") { if (!defined($component_id) || $component_id eq "*") {
if (defined($colocate) && exists($colomap{$colocate})) { if (defined($colocate) && exists($colomap{$colocate})) {
$node = $colomap{$colocate}; $node = $colomap{$colocate};
} }
...@@ -884,12 +884,12 @@ sub GetTicketAuxAux($$$$$$$$$) ...@@ -884,12 +884,12 @@ sub GetTicketAuxAux($$$$$$$$$)
} }
} }
else { else {
$node = GeniUtil::LookupNode($resource_uuid); $node = GeniUtil::LookupNode($component_id);
if (!defined($node)) { if (!defined($node)) {
$response = $response =
GeniResponse->Create(GENIRESPONSE_BADARGS, undef, GeniResponse->Create(GENIRESPONSE_BADARGS, undef,
"Bad resource $resource_uuid"); "Bad resource $component_id");
goto bad; goto bad;
} }
$pctype = $node->type() $pctype = $node->type()
...@@ -999,8 +999,7 @@ sub GetTicketAuxAux($$$$$$$$$) ...@@ -999,8 +999,7 @@ sub GetTicketAuxAux($$$$$$$$$)
if (!defined(GeniXML::FindFirst("n:link", $rspec))); if (!defined(GeniXML::FindFirst("n:link", $rspec)));
# #
# Now deal with links for wildcarded nodes. We need to fill in the # Now deal with links for wildcarded nodes.
# node_uuid.
# #
my $linknum = 1; my $linknum = 1;
...@@ -1286,7 +1285,7 @@ sub GetTicketAuxAux($$$$$$$$$) ...@@ -1286,7 +1285,7 @@ sub GetTicketAuxAux($$$$$$$$$)
foreach my $ref (GeniXML::FindNodes("n:node", foreach my $ref (GeniXML::FindNodes("n:node",
$solution)->get_nodelist()) { $solution)->get_nodelist()) {
my $virtual_id = GeniXML::GetVirtualId($ref); my $virtual_id = GeniXML::GetVirtualId($ref);
my $component_uuid = GeniXML::GetNodeId($ref); my $component_id = GeniXML::GetNodeId($ref);
if (!exists($nodemap{$virtual_id})) { if (!exists($nodemap{$virtual_id})) {
$response = $response =
GeniResponse->Create(GENIRESPONSE_ERROR, undef, GeniResponse->Create(GENIRESPONSE_ERROR, undef,
...@@ -1295,7 +1294,7 @@ sub GetTicketAuxAux($$$$$$$$$) ...@@ -1295,7 +1294,7 @@ sub GetTicketAuxAux($$$$$$$$$)
} }
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 = GeniUtil::LookupNode($component_uuid); my $node = GeniUtil::LookupNode($component_id);
my $colocate = GeniXML::GetText("colocate", $rspec) || my $colocate = GeniXML::GetText("colocate", $rspec) ||
GeniXML::GetText("phys_nickname", $rspec); GeniXML::GetText("phys_nickname", $rspec);
my $subnode_of = GeniXML::GetText("subnode_of", $rspec); my $subnode_of = GeniXML::GetText("subnode_of", $rspec);
...@@ -1311,7 +1310,7 @@ sub GetTicketAuxAux($$$$$$$$$) ...@@ -1311,7 +1310,7 @@ sub GetTicketAuxAux($$$$$$$$$)
GeniXML::SetText("component_urn", $rspec, GeniXML::SetText("component_urn", $rspec,
GeniHRN::Generate( $OURDOMAIN, "node", GeniHRN::Generate( $OURDOMAIN, "node",
$node->node_id() )); $node->node_id() ));
GeniXML::SetText("component_uuid", $rspec, $component_uuid); GeniXML::SetText("component_uuid", $rspec, $component_id);
GeniXML::SetText("component_manager_urn", $rspec, $ENV{'MYURN'}); GeniXML::SetText("component_manager_urn", $rspec, $ENV{'MYURN'});
GeniXML::SetText("component_manager_uuid", $rspec, $ENV{'MYUUID'}); GeniXML::SetText("component_manager_uuid", $rspec, $ENV{'MYUUID'});
GeniXML::SetText("exclusive", $rspec, $exclusive); GeniXML::SetText("exclusive", $rspec, $exclusive);
...@@ -1741,9 +1740,9 @@ sub SliverWorkAux($$$$$$$) ...@@ -1741,9 +1740,9 @@ sub SliverWorkAux($$$$$$$)
# #
foreach my $ref (GeniXML::FindNodes("n:node", foreach my $ref (GeniXML::FindNodes("n:node",
$rspec)->get_nodelist()) { $rspec)->get_nodelist()) {
my $resource_uuid = GeniXML::GetNodeId($ref); my $resource_id = GeniXML::GetNodeId($ref);
my $node_nickname = GeniXML::GetVirtualId($ref); my $node_nickname = GeniXML::GetVirtualId($ref);
my $manager_uuid = GeniXML::GetManagerId($ref); my $manager_id = GeniXML::GetManagerId($ref);
# Let remote nodes pass through. # Let remote nodes pass through.
next next
...@@ -1759,9 +1758,9 @@ sub SliverWorkAux($$$$$$$) ...@@ -1759,9 +1758,9 @@ sub SliverWorkAux($$$$$$$)
next; next;
} }
my $node = GeniUtil::LookupNode($resource_uuid); my $node = GeniUtil::LookupNode($resource_id);
if (!defined($node)) { if (!defined($node)) {
$message = "Bad resource_uuid $resource_uuid"; $message = "Bad resource_id $resource_id";
goto bad; goto bad;
} }
...@@ -1792,12 +1791,12 @@ sub SliverWorkAux($$$$$$$) ...@@ -1792,12 +1791,12 @@ sub SliverWorkAux($$$$$$$)
$node->Refresh(); $node->Refresh();
} }
elsif (!$reservation->SameExperiment($experiment)) { elsif (!$reservation->SameExperiment($experiment)) {
$message = "$resource_uuid ($node) is not available"; $message = "$resource_id ($node) is not available";
goto bad; goto bad;
} }
} }
else { else {
$message = "$resource_uuid ($node) is not available"; $message = "$resource_id ($node) is not available";
goto bad; goto bad;
} }
...@@ -1986,9 +1985,9 @@ sub SliverWorkAux($$$$$$$) ...@@ -1986,9 +1985,9 @@ sub SliverWorkAux($$$$$$$)
my %ifacemap = (); my %ifacemap = ();
my %rspecmap = (); my %rspecmap = ();
foreach my $ref (GeniXML::FindNodes("n:node", $rspec)->get_nodelist()) { foreach my $ref (GeniXML::FindNodes("n:node", $rspec)->get_nodelist()) {
my $resource_uuid = GeniXML::GetNodeId($ref); my $resource_id = GeniXML::GetNodeId($ref);
my $virtual_id = GeniXML::GetVirtualId($ref); my $virtual_id = GeniXML::GetVirtualId($ref);
my $manager_uuid = GeniXML::GetManagerId($ref); my $manager_id = GeniXML::GetManagerId($ref);
$rspecmap{$virtual_id} = $ref; $rspecmap{$virtual_id} = $ref;
...@@ -2019,9 +2018,9 @@ sub SliverWorkAux($$$$$$$) ...@@ -2019,9 +2018,9 @@ sub SliverWorkAux($$$$$$$)
next next
if (grep {$_ eq $virtual_id} keys(%nodemap)); if (grep {$_ eq $virtual_id} keys(%nodemap));
my $node = GeniUtil::LookupNode($resource_uuid); my $node = GeniUtil::LookupNode($resource_id);
if (!defined($node)) { if (!defined($node)) {
$message = "Unknown resource_uuid in ticket: $resource_uuid"; $message = "Unknown resource_id in ticket: $resource_id";
goto bad; goto bad;
} }
my $sliver = GeniSliver::Node->Create($slice, my $sliver = GeniSliver::Node->Create($slice,
...@@ -2047,7 +2046,7 @@ sub SliverWorkAux($$$$$$$) ...@@ -2047,7 +2046,7 @@ sub SliverWorkAux($$$$$$$)
# See below; setup all plab nodes at once. # See below; setup all plab nodes at once.
if ($node->isplabphysnode()) { if ($node->isplabphysnode()) {
my $vnode = GeniUtil::LookupNode($sliver->uuid()); my $vnode = GeniUtil::LookupNode($sliver->resource_id());
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;
...@@ -2229,7 +2228,7 @@ sub SliverWorkAux($$$$$$$) ...@@ -2229,7 +2228,7 @@ sub SliverWorkAux($$$$$$$)
# #
if ($node->isvirtnode()) { if ($node->isvirtnode()) {
$vnode = $node; $vnode = $node;
$node = GeniUtil::LookupNode($nodesliver->resource_uuid()); $node = GeniUtil::LookupNode($nodesliver->resource_id());
if (!defined($node)) { if (!defined($node)) {
$message = "Could not find node object for $nodesliver"; $message = "Could not find node object for $nodesliver";
goto bad; goto bad;
...@@ -3304,27 +3303,28 @@ sub SliceStatus($) ...@@ -3304,27 +3303,28 @@ sub SliceStatus($)
next next
if ($sliver->resource_type() ne "Node"); if ($sliver->resource_type() ne "Node");
my $node_uuid = $sliver->uuid(); my $node_id = $sliver->resource_id();
my $node = GeniUtil::LookupNode($node_uuid); my $node_uuid = $sliver->resource_uuid();
my $node = GeniUtil::LookupNode($node_id);
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 $node_id\n";
return GeniResponse->Create(GENIRESPONSE_ERROR); return GeniResponse->Create(GENIRESPONSE_ERROR);
} }
my $hrn = GeniHRN::Generate($OURDOMAIN, "sliver", $node->node_id()); my $urn = GeniHRN::Generate($OURDOMAIN, "sliver", $node->node_id());
if ($node->IsUp()) { if ($node->IsUp()) {
$details{$node_uuid} = "ready"; $details{$node_uuid} = "ready";
$detailsNew{$hrn} = "ready"; $detailsNew{$urn} = "ready";
} }
elsif ($node->eventstate() eq TBDB_NODESTATE_TBFAILED()) { elsif ($node->eventstate() eq TBDB_NODESTATE_TBFAILED()) {
$details{$node_uuid} = "failed"; $details{$node_uuid} = "failed";
$detailsNew{$hrn} = "failed"; $detailsNew{$urn} = "failed";
$summary = "failed"; $summary = "failed";
} }
else { else {
$details{$node_uuid} = "notready"; $details{$node_uuid} = "notready";
$detailsNew{$hrn} = "notready"; $detailsNew{$urn} = "notready";
$summary = "notready"; $summary = "notready";
} }
} }
...@@ -3499,22 +3499,23 @@ sub SliverStatus($) ...@@ -3499,22 +3499,23 @@ sub SliverStatus($)
next next
if ($sliver->resource_type() ne "Node"); if ($sliver->resource_type() ne "Node");
my $node_id = $sliver->resource_id();
my $node_uuid = $sliver->uuid(); my $node_uuid = $sliver->uuid();
my $node = GeniUtil::LookupNode($node_uuid); my $node = GeniUtil::LookupNode($node_id);
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 $node_id\n";
return GeniResponse->Create(GENIRESPONSE_ERROR); return GeniResponse->Create(GENIRESPONSE_ERROR);
} }
my $hrn = GeniHRN::Generate($OURDOMAIN, "sliver", $node->node_id()); my $urn = GeniHRN::Generate($OURDOMAIN, "sliver", $node->node_id());
if ($node->IsUp()) { if ($node->IsUp()) {
$details{$node_uuid} = "ready"; $details{$node_uuid} = "ready";
$detailsNew{$hrn} = "ready"; $detailsNew{$urn} = "ready";
} }
elsif ($node->eventstate() eq TBDB_NODESTATE_TBFAILED()) { elsif ($node->eventstate() eq TBDB_NODESTATE_TBFAILED()) {
$details{$node_uuid} = "failed"; $details{$node_uuid} = "failed";
$detailsNew{$hrn} = "failed"; $detailsNew{$urn} = "failed";
$summary = "failed"; $summary = "failed";
my $bootlog; my $bootlog;
...@@ -3527,7 +3528,7 @@ sub SliverStatus($) ...@@ -3527,7 +3528,7 @@ sub SliverStatus($)
} }
else { else {
$details{$node_uuid} = "notready"; $details{$node_uuid} = "notready";
$detailsNew{$hrn} = "notready"; $detailsNew{$urn} = "notready";
$summary = "notready"; $summary = "notready";
} }
} }
...@@ -3657,7 +3658,7 @@ sub CreateUserFromCertificate($) ...@@ -3657,7 +3658,7 @@ sub CreateUserFromCertificate($)
return $user return $user
if (defined($user)); if (defined($user));
# Try using the uuid, in case we have a stale certificate. # Try using the uuid, in case we have a stale (pre-urn) certificate.
$user = GeniUser->Lookup($certificate->uuid()); $user = GeniUser->Lookup($certificate->uuid());
if (defined($user)) { if (defined($user)) {
# #
...@@ -3741,12 +3742,8 @@ sub RegisterAux($$) ...@@ -3741,12 +3742,8 @@ sub RegisterAux($$)
} }
my $authority = $slice->SliceAuthority(); my $authority = $slice->SliceAuthority();
if (!defined($authority)) { if (!defined($authority)) {
$authority = print STDERR "Could not find authority for $slice\n";
GeniAuthority->CreateFromRegistry("SA", $slice->sa_uuid()); return -1;
if (!defined($authority)) {
print STDERR "Could not find authority for $slice\n";
return -1;
}
} }
if (!defined($authority->url()) || $authority->url() eq "") { if (!defined($authority->url()) || $authority->url() eq "") {
print STDERR "No url for $authority; skipping registration\n"; print STDERR "No url for $authority; skipping registration\n";
......
...@@ -233,7 +233,7 @@ sub Create($$$$$;$$) ...@@ -233,7 +233,7 @@ sub Create($$$$$;$$)
my ($ourn) = $query_result->fetchrow_array(); my ($ourn) = $query_result->fetchrow_array();
print STDERR "*** Duplicate uuid in geni_certificates table\n"; print STDERR "*** Duplicate uuid in geni_certificates table\n";
print STDERR "*** $uuid,$urn : $ourn\n"; print STDERR "*** $uuid,$urn : $ourn\n";
#goto bad; goto bad;
} }
if ($certificate->Store() != 0) { if ($certificate->Store() != 0) {
print STDERR "Could not write new certificate to DB\n"; print STDERR "Could not write new certificate to DB\n";
......
...@@ -59,19 +59,15 @@ sub GetVersion() ...@@ -59,19 +59,15 @@ sub GetVersion()
} }
# #
# Get a credential for an object. Ignoring the type for now. If no credential # Get a credential for an object. If no credential provided, then return a
# provided, then return a generic credential for the registered Emulab user. # generic credential for the registered Emulab user. This is the easiest
# This is the easiest way to get credentials to registered users. # way to get credentials to registered users.
# #
sub GetCredential($) sub GetCredential($)
{ {
# FIXME once migration to URNs is complete, $uuid should be removed,
# and $type automatically deduced from the URN.
my ($argref) = @_; my ($argref) = @_;
my $uuid = $argref->{'uuid'};
my $urn = $argref->{'urn'}; my $urn = $argref->{'urn'};
my $cred = $argref->{'credential'}; my $cred = $argref->{'credential'};
my $type = $argref->{'type'};
# #
# No credential, then return a generic credential giving user permission # No credential, then return a generic credential giving user permission
...@@ -103,14 +99,8 @@ sub GetCredential($) ...@@ -103,14 +99,8 @@ sub GetCredential($)
return GeniResponse->Create(GENIRESPONSE_SUCCESS, return GeniResponse->Create(GENIRESPONSE_SUCCESS,
$credential->asString()); $credential->asString());
} }
# Currently accept either a UUID or a URN, but not both. Once we
# have migrated the federation to URNs, UUID support will be removed.
return GeniResponse->MalformedArgsResponse()
if( defined( $uuid ) == defined( $urn ) );
return GeniResponse->MalformedArgsResponse()
if( defined( $uuid ) && $uuid !~ /^[-\w]*$/ );
return GeniResponse->MalformedArgsResponse() return GeniResponse->MalformedArgsResponse()
if( defined( $urn ) && !GeniHRN::IsValid( $urn ) ); if (! (defined($urn) && GeniHRN::IsValid($urn)));
my $authority = GeniAuthority->Lookup($ENV{'MYURN'}); my $authority = GeniAuthority->Lookup($ENV{'MYURN'});
if (!defined($authority)) { if (!defined($authority)) {
...@@ -131,13 +121,14 @@ sub GetCredential($) ...@@ -131,13 +121,14 @@ sub GetCredential($)
return GeniResponse->Create(GENIRESPONSE_FORBIDDEN, return GeniResponse->Create(GENIRESPONSE_FORBIDDEN,
undef, "Who are you?"); undef, "Who are you?");
} }
my ($undef, $type, $id) = GeniHRN::Parse($urn);
# #
# User provided a credential, and wants a new credential to access # User provided a credential, and wants a new credential to access
# the object referenced by the URN. # the object referenced by the URN.
# #
if ($type eq "Slice") { if (lc($type) eq "slice") {
my $slice = GeniSlice->Lookup( defined( $urn ) ? $urn : $uuid ); my $slice = GeniSlice->Lookup($urn);
return GeniResponse->Create(GENIRESPONSE_SEARCHFAILED, undef, return GeniResponse->Create(GENIRESPONSE_SEARCHFAILED, undef,
"No such Slice") "No such Slice")
...@@ -145,7 +136,7 @@ sub GetCredential($) ...@@ -145,7 +136,7 @@ sub GetCredential($)
if ($slice->Lock() != 0) { if ($slice->Lock() != 0) {
return GeniResponse->BusyResponse("slice"); return GeniResponse->BusyResponse("slice");
} }
if ($slice->creator_uuid() ne $this_user->uuid() && if ($slice->creator_urn() ne $this_user->urn() &&
!$slice->IsBound($this_user)) { !$slice->IsBound($this_user)) {
$slice->UnLock(); $slice->UnLock();
return GeniResponse->Create(GENIRESPONSE_FORBIDDEN, undef, return GeniResponse->Create(GENIRESPONSE_FORBIDDEN, undef,
...@@ -171,18 +162,17 @@ sub GetCredential($) ...@@ -171,18 +162,17 @@ sub GetCredential($)
} }
# #
# Resolve a uuid or HRN to a record. # Resolve a record.
# #
sub Resolve($) sub Resolve($)
{ {
my ($argref) = @_; my ($argref) = @_;
my $uuid = $argref->{'uuid'};
my $hrn = $argref->{'hrn'}; my $hrn = $argref->{'hrn'};
my $urn = $argref->{'urn'}; my $urn = $argref->{'urn'};
my $cred = $argref->{'credential'}; my $cred = $argref->{'credential'};
my $type = $argref->{'type'}; my $type = $argref->{'type'};
if (! (defined($uuid) || defined($hrn) || defined($urn))) { if (! (defined($hrn) || defined($urn))) {
return GeniResponse->MalformedArgsResponse(); return GeniResponse->MalformedArgsResponse();
} }
# URN always takes precedence and all items should now have URNs # URN always takes precedence and all items should now have URNs
...@@ -190,16 +180,13 @@ sub Resolve($) ...@@ -190,16 +180,13 @@ sub Resolve($)
if (defined($urn)) { if (defined($urn)) {
return GeniResponse->MalformedArgsResponse() return GeniResponse->MalformedArgsResponse()
if (!GeniHRN::IsValid($urn)); if (!GeniHRN::IsValid($urn));
$hrn = $uuid = undef; $hrn = undef;
} }
elsif (defined($hrn) && GeniHRN::IsValid($hrn)) { elsif (defined($hrn) && GeniHRN::IsValid($hrn)) {
$urn = $hrn; $urn = $hrn;
$hrn = $uuid = undef; $hrn = undef;
}
elsif (defined($uuid) && !($uuid =~ /^[-\w]*$/)) {
return GeniResponse->MalformedArgsResponse();
} }
elsif (defined($hrn) && !($hrn =~ /^[-\w\.]*$/)) { elsif (defined($hrn) && (!defined($type) || !($hrn =~ /^[-\w\.]*$/))) {
return GeniResponse->MalformedArgsResponse(); return GeniResponse->MalformedArgsResponse();
} }
# #
...@@ -207,7 +194,10 @@ sub Resolve($) ...@@ -207,7 +194,10 @@ sub Resolve($)
# XXX Form hrn from the uid and domain. This is backwards. # XXX Form hrn from the uid and domain. This is backwards.
# #
if (defined($hrn) && !($hrn =~ /\./)) { if (defined($hrn) && !($hrn =~ /\./)) {
$hrn = "${PGENIDOMAIN}.${hrn}";