Commit b3c8e72e authored by Leigh Stoller's avatar Leigh 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($$$)
next
if (ref($sliver) ne "GeniSliver::Node");
my $node = Node->Lookup($sliver->uuid());
my $node = Node->Lookup($sliver->resource_id());
if (!defined($node)) {
print STDERR "Could not map $sliver to a node\n";
return -1;
......@@ -1002,7 +1002,7 @@ sub Stop($$)
next
if (ref($sliver) ne "GeniSliver::Node");
my $node = Node->Lookup($sliver->uuid());
my $node = Node->Lookup($sliver->resource_id());
if (!defined($node)) {
print STDERR "Could not map $sliver to a node\n";
return -1;
......@@ -1413,7 +1413,7 @@ sub Create($$$$$$)
# We need the control network addresses, but it is possible that
# one of the nodes is not on this testbed.
if (defined($node1sliver)) {
my $node1 = Node->Lookup($node1sliver->resource_uuid());
my $node1 = Node->Lookup($node1sliver->resource_id());
if (!defined($node1)) {
print STDERR "Tunnel: Could not lookup node for $node1sliver\n";
goto bad;
......@@ -1429,11 +1429,11 @@ sub Create($$$$$$)
}
}
else {
my $node_uuid = GeniXML::GetNodeId($node1rspec);
my $component = GeniComponent->CreateFromRegistry($node_uuid);
my $component_id = GeniXML::GetNodeId($node1rspec);
my $component = GeniComponent->CreateFromRegistry($component_id);
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;
}
my $blob = $component->Resolve();
......@@ -1448,7 +1448,7 @@ sub Create($$$$$$)
$ctrlip1 = $blob->{'physctrl'};
}
if (defined($node2sliver)) {
my $node2 = Node->Lookup($node2sliver->resource_uuid());
my $node2 = Node->Lookup($node2sliver->resource_id());
if (!defined($node2)) {
print STDERR "Tunnel: Could not lookup node for $node2sliver\n";
goto bad;
......@@ -1464,11 +1464,11 @@ sub Create($$$$$$)
}
}
else {
my $node_uuid = GeniXML::GetNodeId($node2rspec);
my $component = GeniComponent->CreateFromRegistry($node_uuid);
my $component_id = GeniXML::GetNodeId($node2rspec);
my $component = GeniComponent->CreateFromRegistry($component_id);
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;
}
my $blob = $component->Resolve();
......
......@@ -400,7 +400,7 @@ sub GetTicketAuxAux($$$$$$$$$)
#
my $authority = GeniCertificate->LoadFromFile($EMULAB_PEMFILE);
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);
}
......@@ -679,11 +679,11 @@ sub GetTicketAuxAux($$$$$$$$$)
my $node_nickname = GeniXML::GetVirtualId($ref);
my $colocate = GeniXML::GetText("colocate", $ref) ||
GeniXML::GetText("phys_nickname", $ref);
my $resource_uuid = GeniXML::GetNodeId($ref);
my $node = GeniUtil::LookupNode($resource_uuid);
my $component_id = GeniXML::GetNodeId($ref);
my $node = GeniUtil::LookupNode($component_id);
if (!defined($node)) {
$response = GeniResponse->Create(GENIRESPONSE_BADARGS, undef,
"Bad resource $resource_uuid in ticket");
"Bad resource $component_id in ticket");
goto bad;
}
......@@ -712,8 +712,8 @@ sub GetTicketAuxAux($$$$$$$$$)
print GeniXML::Serialize($rspec);
foreach my $ref (GeniXML::FindNodes("n:node", $rspec)->get_nodelist()) {
my $resource_uuid = GeniXML::GetNodeId($ref);
my $manager_uuid = GeniXML::GetManagerId($ref);
my $component_id = GeniXML::GetNodeId($ref);
my $manager_id = GeniXML::GetManagerId($ref);
my $node_nickname = GeniXML::GetVirtualId($ref);
my $colocate = GeniXML::GetText("colocate", $ref) ||
GeniXML::GetText("phys_nickname", $ref);
......@@ -867,7 +867,7 @@ sub GetTicketAuxAux($$$$$$$$$)
#
# Allow wildcarding.
#
if (!defined($resource_uuid) || $resource_uuid eq "*") {
if (!defined($component_id) || $component_id eq "*") {
if (defined($colocate) && exists($colomap{$colocate})) {
$node = $colomap{$colocate};
}
......@@ -884,12 +884,12 @@ sub GetTicketAuxAux($$$$$$$$$)
}
}
else {
$node = GeniUtil::LookupNode($resource_uuid);
$node = GeniUtil::LookupNode($component_id);
if (!defined($node)) {
$response =
GeniResponse->Create(GENIRESPONSE_BADARGS, undef,
"Bad resource $resource_uuid");
"Bad resource $component_id");
goto bad;
}
$pctype = $node->type()
......@@ -999,8 +999,7 @@ sub GetTicketAuxAux($$$$$$$$$)
if (!defined(GeniXML::FindFirst("n:link", $rspec)));
#
# Now deal with links for wildcarded nodes. We need to fill in the
# node_uuid.
# Now deal with links for wildcarded nodes.
#
my $linknum = 1;
......@@ -1286,7 +1285,7 @@ sub GetTicketAuxAux($$$$$$$$$)
foreach my $ref (GeniXML::FindNodes("n:node",
$solution)->get_nodelist()) {
my $virtual_id = GeniXML::GetVirtualId($ref);
my $component_uuid = GeniXML::GetNodeId($ref);
my $component_id = GeniXML::GetNodeId($ref);
if (!exists($nodemap{$virtual_id})) {
$response =
GeniResponse->Create(GENIRESPONSE_ERROR, undef,
......@@ -1295,7 +1294,7 @@ sub GetTicketAuxAux($$$$$$$$$)
}
my $rspec = $nodemap{$virtual_id}->{'rspec'};
my $virtnode = $nodemap{$virtual_id}->{'virtnode'};
my $node = GeniUtil::LookupNode($component_uuid);
my $node = GeniUtil::LookupNode($component_id);
my $colocate = GeniXML::GetText("colocate", $rspec) ||
GeniXML::GetText("phys_nickname", $rspec);
my $subnode_of = GeniXML::GetText("subnode_of", $rspec);
......@@ -1311,7 +1310,7 @@ sub GetTicketAuxAux($$$$$$$$$)
GeniXML::SetText("component_urn", $rspec,
GeniHRN::Generate( $OURDOMAIN, "node",
$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_uuid", $rspec, $ENV{'MYUUID'});
GeniXML::SetText("exclusive", $rspec, $exclusive);
......@@ -1741,9 +1740,9 @@ sub SliverWorkAux($$$$$$$)
#
foreach my $ref (GeniXML::FindNodes("n:node",
$rspec)->get_nodelist()) {
my $resource_uuid = GeniXML::GetNodeId($ref);
my $resource_id = GeniXML::GetNodeId($ref);
my $node_nickname = GeniXML::GetVirtualId($ref);
my $manager_uuid = GeniXML::GetManagerId($ref);
my $manager_id = GeniXML::GetManagerId($ref);
# Let remote nodes pass through.
next
......@@ -1759,9 +1758,9 @@ sub SliverWorkAux($$$$$$$)
next;
}
my $node = GeniUtil::LookupNode($resource_uuid);
my $node = GeniUtil::LookupNode($resource_id);
if (!defined($node)) {
$message = "Bad resource_uuid $resource_uuid";
$message = "Bad resource_id $resource_id";
goto bad;
}
......@@ -1792,12 +1791,12 @@ sub SliverWorkAux($$$$$$$)
$node->Refresh();
}
elsif (!$reservation->SameExperiment($experiment)) {
$message = "$resource_uuid ($node) is not available";
$message = "$resource_id ($node) is not available";
goto bad;
}
}
else {
$message = "$resource_uuid ($node) is not available";
$message = "$resource_id ($node) is not available";
goto bad;
}
......@@ -1986,9 +1985,9 @@ sub SliverWorkAux($$$$$$$)
my %ifacemap = ();
my %rspecmap = ();
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 $manager_uuid = GeniXML::GetManagerId($ref);
my $manager_id = GeniXML::GetManagerId($ref);
$rspecmap{$virtual_id} = $ref;
......@@ -2019,9 +2018,9 @@ sub SliverWorkAux($$$$$$$)
next
if (grep {$_ eq $virtual_id} keys(%nodemap));
my $node = GeniUtil::LookupNode($resource_uuid);
my $node = GeniUtil::LookupNode($resource_id);
if (!defined($node)) {
$message = "Unknown resource_uuid in ticket: $resource_uuid";
$message = "Unknown resource_id in ticket: $resource_id";
goto bad;
}
my $sliver = GeniSliver::Node->Create($slice,
......@@ -2047,7 +2046,7 @@ sub SliverWorkAux($$$$$$$)
# See below; setup all plab nodes at once.
if ($node->isplabphysnode()) {
my $vnode = GeniUtil::LookupNode($sliver->uuid());
my $vnode = GeniUtil::LookupNode($sliver->resource_id());
if (!defined($vnode)) {
print STDERR "Could not locate vnode $sliver\n";
goto bad;
......@@ -2229,7 +2228,7 @@ sub SliverWorkAux($$$$$$$)
#
if ($node->isvirtnode()) {
$vnode = $node;
$node = GeniUtil::LookupNode($nodesliver->resource_uuid());
$node = GeniUtil::LookupNode($nodesliver->resource_id());
if (!defined($node)) {
$message = "Could not find node object for $nodesliver";
goto bad;
......@@ -3304,27 +3303,28 @@ sub SliceStatus($)
next
if ($sliver->resource_type() ne "Node");
my $node_uuid = $sliver->uuid();
my $node = GeniUtil::LookupNode($node_uuid);
my $node_id = $sliver->resource_id();
my $node_uuid = $sliver->resource_uuid();
my $node = GeniUtil::LookupNode($node_id);
if (!defined($node)) {
$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);
}
my $hrn = GeniHRN::Generate($OURDOMAIN, "sliver", $node->node_id());
my $urn = GeniHRN::Generate($OURDOMAIN, "sliver", $node->node_id());
if ($node->IsUp()) {
$details{$node_uuid} = "ready";
$detailsNew{$hrn} = "ready";
$detailsNew{$urn} = "ready";
}
elsif ($node->eventstate() eq TBDB_NODESTATE_TBFAILED()) {
$details{$node_uuid} = "failed";
$detailsNew{$hrn} = "failed";
$detailsNew{$urn} = "failed";
$summary = "failed";
}
else {
$details{$node_uuid} = "notready";
$detailsNew{$hrn} = "notready";
$detailsNew{$urn} = "notready";
$summary = "notready";
}
}
......@@ -3499,22 +3499,23 @@ sub SliverStatus($)
next
if ($sliver->resource_type() ne "Node");
my $node_id = $sliver->resource_id();
my $node_uuid = $sliver->uuid();
my $node = GeniUtil::LookupNode($node_uuid);
my $node = GeniUtil::LookupNode($node_id);
if (!defined($node)) {
$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);
}
my $hrn = GeniHRN::Generate($OURDOMAIN, "sliver", $node->node_id());
my $urn = GeniHRN::Generate($OURDOMAIN, "sliver", $node->node_id());
if ($node->IsUp()) {
$details{$node_uuid} = "ready";
$detailsNew{$hrn} = "ready";
$detailsNew{$urn} = "ready";
}
elsif ($node->eventstate() eq TBDB_NODESTATE_TBFAILED()) {
$details{$node_uuid} = "failed";
$detailsNew{$hrn} = "failed";
$detailsNew{$urn} = "failed";
$summary = "failed";
my $bootlog;
......@@ -3527,7 +3528,7 @@ sub SliverStatus($)
}
else {
$details{$node_uuid} = "notready";
$detailsNew{$hrn} = "notready";
$detailsNew{$urn} = "notready";
$summary = "notready";
}
}
......@@ -3657,7 +3658,7 @@ sub CreateUserFromCertificate($)
return $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());
if (defined($user)) {
#
......@@ -3741,12 +3742,8 @@ sub RegisterAux($$)
}
my $authority = $slice->SliceAuthority();
if (!defined($authority)) {
$authority =
GeniAuthority->CreateFromRegistry("SA", $slice->sa_uuid());
if (!defined($authority)) {
print STDERR "Could not find authority for $slice\n";
return -1;
}
print STDERR "Could not find authority for $slice\n";
return -1;
}
if (!defined($authority->url()) || $authority->url() eq "") {
print STDERR "No url for $authority; skipping registration\n";
......
......@@ -233,7 +233,7 @@ sub Create($$$$$;$$)
my ($ourn) = $query_result->fetchrow_array();
print STDERR "*** Duplicate uuid in geni_certificates table\n";
print STDERR "*** $uuid,$urn : $ourn\n";
#goto bad;
goto bad;
}
if ($certificate->Store() != 0) {
print STDERR "Could not write new certificate to DB\n";
......
......@@ -59,19 +59,15 @@ sub GetVersion()
}
#
# Get a credential for an object. Ignoring the type for now. If no credential
# provided, then return a generic credential for the registered Emulab user.
# This is the easiest way to get credentials to registered users.
# Get a credential for an object. If no credential provided, then return a
# generic credential for the registered Emulab user. This is the easiest
# way to get credentials to registered users.
#
sub GetCredential($)
{
# FIXME once migration to URNs is complete, $uuid should be removed,
# and $type automatically deduced from the URN.
my ($argref) = @_;
my $uuid = $argref->{'uuid'};
my $urn = $argref->{'urn'};
my $cred = $argref->{'credential'};
my $type = $argref->{'type'};
#
# No credential, then return a generic credential giving user permission
......@@ -103,14 +99,8 @@ sub GetCredential($)
return GeniResponse->Create(GENIRESPONSE_SUCCESS,
$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()
if( defined( $urn ) && !GeniHRN::IsValid( $urn ) );
if (! (defined($urn) && GeniHRN::IsValid($urn)));
my $authority = GeniAuthority->Lookup($ENV{'MYURN'});
if (!defined($authority)) {
......@@ -131,13 +121,14 @@ sub GetCredential($)
return GeniResponse->Create(GENIRESPONSE_FORBIDDEN,
undef, "Who are you?");
}
my ($undef, $type, $id) = GeniHRN::Parse($urn);
#
# User provided a credential, and wants a new credential to access
# the object referenced by the URN.
#
if ($type eq "Slice") {
my $slice = GeniSlice->Lookup( defined( $urn ) ? $urn : $uuid );
if (lc($type) eq "slice") {
my $slice = GeniSlice->Lookup($urn);
return GeniResponse->Create(GENIRESPONSE_SEARCHFAILED, undef,
"No such Slice")
......@@ -145,7 +136,7 @@ sub GetCredential($)
if ($slice->Lock() != 0) {
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->UnLock();
return GeniResponse->Create(GENIRESPONSE_FORBIDDEN, undef,
......@@ -171,18 +162,17 @@ sub GetCredential($)
}
#
# Resolve a uuid or HRN to a record.
# Resolve a record.
#
sub Resolve($)
{
my ($argref) = @_;
my $uuid = $argref->{'uuid'};
my $hrn = $argref->{'hrn'};
my $urn = $argref->{'urn'};
my $cred = $argref->{'credential'};
my $type = $argref->{'type'};
if (! (defined($uuid) || defined($hrn) || defined($urn))) {
if (! (defined($hrn) || defined($urn))) {
return GeniResponse->MalformedArgsResponse();
}
# URN always takes precedence and all items should now have URNs
......@@ -190,16 +180,13 @@ sub Resolve($)
if (defined($urn)) {
return GeniResponse->MalformedArgsResponse()
if (!GeniHRN::IsValid($urn));
$hrn = $uuid = undef;
$hrn = undef;
}
elsif (defined($hrn) && GeniHRN::IsValid($hrn)) {
$urn = $hrn;
$hrn = $uuid = undef;
}
elsif (defined($uuid) && !($uuid =~ /^[-\w]*$/)) {
return GeniResponse->MalformedArgsResponse();
$hrn = undef;
}
elsif (defined($hrn) && !($hrn =~ /^[-\w\.]*$/)) {
elsif (defined($hrn) && (!defined($type) || !($hrn =~ /^[-\w\.]*$/))) {
return GeniResponse->MalformedArgsResponse();
}
#
......@@ -207,7 +194,10 @@ sub Resolve($)
# XXX Form hrn from the uid and domain. This is backwards.
#
if (defined($hrn) && !($hrn =~ /\./)) {
$hrn = "${PGENIDOMAIN}.${hrn}";
$hrn = "${PGENIDOMAIN}.${hrn}";
}
else {
(undef,$type,undef) = GeniHRN::Parse($urn);
}
$type = lc($type);
if (! defined($cred)) {
......@@ -238,7 +228,7 @@ sub Resolve($)
return GeniResponse->Create(GENIRESPONSE_FORBIDDEN, undef,
"Who are you? No local record");
}
my $lookup_token = $urn || $hrn || $uuid;
my $lookup_token = $urn || $hrn;
if ($type eq "user") {
my $geniuser = GeniUser->Lookup($lookup_token, 1);
......@@ -437,7 +427,7 @@ sub Register($)
}
#
# Generate a certificate (and uuid) for this new slice.
# Generate a certificate for this new slice.
#
my $certificate = GeniCertificate->Create("slice", $urn, $hrn,
$this_user->email());
......@@ -502,35 +492,26 @@ sub Register($)
sub Remove($)
{
# FIXME once migration to URNs is complete, $type should be removed
# (it's deduced automatically from the URN). $uuid should die, too.
# (it's deduced automatically from the URN).
my ($argref) = @_;
my $uuid = $argref->{'uuid'};
my $hrn = $argref->{'hrn'};
my $urn = $argref->{'urn'};
my $cred = $argref->{'credential'};
my $type = lc( $argref->{'type'} );
my $type = $argref->{'type'};
if (! ((defined($hrn) || defined($urn) || defined($uuid)) &&
defined($cred))) {
if (! ((defined($hrn) || defined($urn)) && defined($cred))) {
return GeniResponse->MalformedArgsResponse();
}
if (defined($urn)) {
return GeniResponse->MalformedArgsResponse()
if (!GeniHRN::IsValid($urn));
$hrn = $uuid = undef;
$hrn = undef;
}
elsif (defined($hrn) && GeniHRN::IsValid($hrn)) {
$urn = $hrn;
$hrn = $uuid = undef;
}
elsif (defined($uuid) && GeniHRN::IsValid($uuid)) {
$urn = $uuid;
$hrn = $uuid = undef;
}
elsif (defined($hrn) && !($hrn =~ /^[-\w\.]*$/)) {
return GeniResponse->MalformedArgsResponse();
$hrn = undef;
}
elsif (defined($uuid) && !($uuid =~ /^[-\w]*$/)) {
elsif (defined($hrn) && (!defined($type) || !($hrn =~ /^[-\w\.]*$/))) {
return GeniResponse->MalformedArgsResponse();
}
#
......@@ -538,23 +519,12 @@ sub Remove($)
# XXX Form hrn from the uid and domain. This is backwards.
#
if (defined($hrn) && !($hrn =~ /\./)) {
$hrn = "${PGENIDOMAIN}.${hrn}";
}
if (defined($urn)) {
my ($auth,$t,$id) = GeniHRN::Parse($urn);
return GeniResponse->Create(GENIRESPONSE_BADARGS, undef,
"Authority mismatch")
if ($auth ne $OURDOMAIN);
#
# If the user supplies a URN, we get the type from it.
#
$type = $t;
$hrn = "${PGENIDOMAIN}.${hrn}";
}
elsif (!defined($type)) {
return GeniResponse->MalformedArgsResponse();
else {
(undef,$type,undef) = GeniHRN::Parse($urn);
}
$type = lc($type);
my $authority = GeniAuthority->Lookup($ENV{'MYURN'});
if (!defined($authority)) {
......@@ -577,7 +547,7 @@ sub Remove($)
}
if ($type eq "slice") {
my $slice = GeniSlice->Lookup($uuid || $urn || $hrn);
my $slice = GeniSlice->Lookup($urn || $hrn);
if (!defined($slice)) {
return GeniResponse->Create(GENIRESPONSE_SEARCHFAILED, undef,
"No such slice");
......@@ -675,15 +645,11 @@ sub BindToSlice($)
{
my ($argref) = @_;
my $cred = $argref->{'credential'};
my $uuid = $argref->{'uuid'};
my $urn = $argref->{'urn'};
my $which = $uuid || $urn;
if (! ((defined($uuid) || defined($urn)) && defined($cred))) {
if (! (defined($urn) && defined($cred))) {
return GeniResponse->MalformedArgsResponse();
}
return GeniResponse->MalformedArgsResponse()
if (defined($uuid) && $uuid !~ /^[-\w]*$/);
return GeniResponse->MalformedArgsResponse()
if (defined($urn) && !GeniHRN::IsValid($urn));
......@@ -716,10 +682,10 @@ sub BindToSlice($)
#
# Locate the target user; must exist locally.
#
my $target_user = GeniUser->Lookup($which, 1);
my $target_user = GeniUser->Lookup($urn, 1);
if (!defined($target_user)) {
return GeniResponse->Create(GENIRESPONSE_SEARCHFAILED,
undef, "No such user $which here");
undef, "No such user here");
}
if ($slice->Lock() != 0) {
return GeniResponse->BusyResponse("slice");
......
......@@ -254,7 +254,7 @@ sub CreateFromLocal($$$)
my $EMULAB_PEMFILE = "@prefix@/etc/genisa.pem";
my $certificate = GeniCertificate->LoadFromFile($EMULAB_PEMFILE);
if (!defined($certificate)) {
print STDERR "Could not get uuid from $EMULAB_PEMFILE\n";
print STDERR "Could not load certificate from $EMULAB_PEMFILE\n";
return undef;
}
......
......@@ -171,9 +171,9 @@ sub Stringify($)
# Create a sliver record in the DB. On the client side we save the credential
# that allows control of it, for later operations.
#
sub Create($$$$$$$$$)
sub Create($$$$$$$$)
{
my ($class, $slice, $owner, $uuid,
my ($class, $slice, $owner,
$resource_uuid, $resource_type, $resource_id,
$hrn, $nickname, $rspec) = @_;
my @insert_data = ();
......@@ -189,7 +189,7 @@ sub Create($$$$$$$$$)
"Already have a certificate for $hrn/$urn\n";
return undef;
}
$certificate = GeniCertificate->Create("sliver", $urn, $hrn, $TBOPS,$uuid);
$certificate = GeniCertificate->Create("sliver", $urn, $hrn, $TBOPS);
if (!defined($certificate)) {
print STDERR "GeniSliver::Create: ".
"Could not generate new certificate for $hrn/$urn\n";
......@@ -197,6 +197,7 @@ sub Create($$$$$$$$$)
}
my $slice_uuid = $slice->uuid();
my $owner_uuid = $owner->uuid();
my $sliver_uuid = $certificate->uuid();
# Now tack on other stuff we need.
push(@insert_data, "created=now()");
......@@ -204,7 +205,7 @@ sub Create($$$$$$$$$)
push(@insert_data, "hrn=" . DBQuoteSpecial($hrn));
push(@insert_data, "nickname=" . DBQuoteSpecial($nickname))
if (defined($nickname));
push(@insert_data, "uuid='$uuid'");
push(@insert_data, "uuid='$sliver_uuid'");
push(@insert_data, "resource_uuid='$resource_uuid'");
push(@insert_data, "resource_type='$resource_type'");
push(@insert_data, "resource_id='$resource_id'");
......@@ -290,10 +291,8 @@ sub Delete($$)
}
DBQueryWarn("delete from geni_credentials where this_uuid='$uuid'")
or return -1;
if ($self->resource_type() ne "Node") {
DBQueryWarn("delete from geni_certificates where uuid='$uuid'")
or return -1;
}
DBQueryWarn("delete from geni_certificates where uuid='$uuid'")
or return -1;
DBQueryWarn("delete from geni_slivers where idx='$idx'")
or return -1;
......@@ -582,7 +581,7 @@ sub ErrorLog($)
my ($self) = @_;
my $bootlog = "";
my $node = Node->Lookup($self->uuid());
my $node = Node->Lookup($self->resource_id());
if (!defined($node)) {
print STDERR "Could not map node $self to its object\n";
return "";
......@@ -656,7 +655,6 @@ sub Create($$$$$$)
my $hostname;
my $phostname;
my $resource_id;
my $sliver_uuid;
#
# The resource UUID refers to the physical node, but the virtualization
......@@ -669,7 +667,6 @@ sub Create($$$$$$)
return undef;
}
$hrn = "${PGENIDOMAIN}." . $vnode->node_id();
$sliver_uuid = $vnode->uuid();
$resource_id = $vnode->node_id();
$hostname = GeniUtil::FindHostname($vnode->node_id());
$phostname = GeniUtil::FindHostname($vnode->phys_nodeid());
......@@ -677,7 +674,6 @@ sub Create($$$$$$)
}
else {
$hrn = "${PGENIDOMAIN}." . $node->node_id();
$sliver_uuid = $node->uuid();
$resource_id = $node->node_id();
$phostname = $hostname = GeniUtil::FindHostname($node->node_id());
}
......@@ -685,7 +681,6 @@ sub Create($$$$$$)
#
# Add this stuff to the rspec (which becomes the manifest).
#
GeniXML::SetText("sliver_uuid", $rspec, $sliver_uuid);
GeniXML::SetText("hostname", $rspec, $hostname);
GeniXML::SetText("sshdport", $rspec, $sshdport) if (defined($sshdport));
......@@ -696,8 +691,13 @@ sub Create($$$$$$)
GeniXML::SetText("hostname", $login, $phostname);
GeniXML::SetText("port", $login, $sshdport);
return GeniSliver->Create($slice, $user, $sliver_uuid, $resource_uuid,
"Node", $resource_id, $hrn, $nickname, $rspec);
my $sliver = GeniSliver->Create($slice, $user, $resource_uuid, "Node",
$resource_id, $hrn, $nickname, $rspec);
return undef
if (!defined($sliver));
GeniXML::SetText("sliver_uuid", $rspec, $sliver->uuid());
return $sliver;
}
#
......@@ -721,15 +721,14 @@ sub Provision($;$)
print STDERR "Could not map $self to its experiment\n";
return -1;
}
my $uuid = $self->uuid();
my $node_id = $self->resource_id();
return 0
if (!defined($uuid));
my $node = Node->Lookup($uuid);
if (!defined($node_id));
my $node = Node->Lookup($node_id);
if (!defined($node)) {
print STDERR "Could not map node $uuid to its object\n";
print STDERR "Could not map node $node_id to its object\n";
return -1;
}
my $node_id = $node->node_id();
my $reservation = $node->Reservation();
if (!defined($reservation)) {
print STDERR "$node was already released from slice\n";
......@@ -793,13 +792,13 @@ sub UnProvision($;$)
print STDERR "Could not map $self to its experiment\n";
return -1;
}
my $uuid = $self->uuid();
my $node_id = $self->resource_id();
return 0
if (!defined($uuid));
my $node = Node->Lookup($uuid);
if (!defined($node_id));
my $node = Node->Lookup($node_id);
if (!defined($node)) {
# Lets call this nonfatal since it might be a virtnode that
print STDERR "Could not map node $uuid to its object\n";
# Lets call this nonfatal since it might be a virtnode that is gone.
print STDERR "Could not map node $node_id to its object\n";
return 0;
}
my $reservation = $node->Reservation();
......@@ -915,12 +914,12 @@ sub ProcessManifest($$)
my $pid = $experiment->pid();
my $eid = $experiment->eid();
my $uuid = $self->uuid();
my $node_id = $self->resource_id();
return 0
if (!defined($uuid));
my $node = Node->Lookup($uuid);
if (!defined($node_id));
my $node = Node->Lookup($node_id);
if (!defined($node)) {
print STDERR "Could not map node $uuid to its object\n";
print STDERR "Could not map node $node_id to its object\n";
return -1;
}
my $reservation = $node->Reservation();
......@@ -934,8 +933,8 @@ sub ProcessManifest($$)
#
foreach my $ref (GeniXML::FindNodes("n:node",
$manifest)->get_nodelist()) {
my $sliver_id = GeniXML::GetText("sliver_uuid", $ref);
if (defined($sliver_id) && $sliver_id eq $uuid) {
my $sliver_urn = GeniXML::GetText("sliver_urn", $ref);
if (defined($sliver_urn) && $sliver_urn eq $self->urn()) {