Commit 2f19a46b authored by Jonathon Duerig's avatar Jonathon Duerig

Fixes for AMv3 API.

parent 167b7937
......@@ -691,15 +691,20 @@ sub Describe
if (GeniResponse::IsResponse($cred));
my ($slice, $aggregate) = GeniCMV2::Credential2SliceAggregate($cred);
return GeniResponse->Create(GENIRESPONSE_REFUSED, undef,
"Slice credential not provided")
if (! defined($slice));
return $slice
if (GeniResponse::IsResponse($slice));
my $ticket = GeniTicket->SliceTicket($slice);
return GeniResponse->Create(GENIRESPONSE_REFUSED, undef,
"No slivers here")
if (! defined($ticket) && ! defined($aggregate));
if (! defined($slice) ||
(! defined($ticket) && ! defined($aggregate))) {
my $blob = {
'geni_rspec' => GeniStd::GenerateEmptyManifest(),
'geni_urn' => $cred->target_urn(),
'geni_slivers' => []
};
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $blob);
}
if (scalar(@urns) != 1 || $urns[0] ne $slice->urn()) {
return GeniResponse->Create(GENIRESPONSE_REFUSED, undef,
......@@ -726,7 +731,7 @@ sub Describe
foreach my $sliver (@slivers) {
$sliver_blob = {
'geni_sliver_urn' => $sliver->sliver_urn(),
'geni_expires' => $aggregate->expires(),
'geni_expires' => $slice->ExpirationUTC(),
'geni_allocation_status' => "geni_provisioned",
'geni_operational_status' => GetOpState($sliver),
'geni_error' => ''
......
......@@ -1019,15 +1019,13 @@ sub CheckCredential($;$$)
if (!ref($credential)) {
$credential = GeniCredential->CreateFromSigned($credential);
if (!defined($credential)) {
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
$GeniCredential::CreateFromSignedError);
return GeniResponse->MalformedArgsResponse($GeniCredential::CreateFromSignedError);
}
}
#
# Well formed credentials must now have URNs.
#
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Malformed credentials; missing URNs")
return GeniResponse->MalformedArgsResponse("Malformed credentials; missing URNs")
if (! (defined($credential->owner_urn()) &&
defined($credential->target_urn()) &&
GeniHRN::IsValid($credential->owner_urn()) &&
......
......@@ -902,6 +902,17 @@ sub ExpirationGMT($)
gmtime(str2time($self->expires())));
}
sub ExpirationUTC($)
{
my ($self) = @_;
return undef
if (!defined($self->expires()));
return POSIX::strftime("20%y-%m-%dT%H:%M:%SZ",
gmtime(str2time($self->expires())));
}
#
# Set the expiration time for a slice.
#
......
......@@ -224,8 +224,7 @@ sub CheckCredentials($)
foreach my $credstring (@credential_strings) {
my $credential = GeniCredential->CreateFromSigned($credstring);
if (!defined($credential)) {
$error = GeniResponse->Create(GENIRESPONSE_ERROR, undef,
$GeniCredential::CreateFromSignedError);
$error = GeniResponse->MalformedArgsResponse($GeniCredential::CreateFromSignedError);
goto bad;
}
if ($credential->type() eq "speaksfor" ||
......@@ -410,3 +409,12 @@ sub getMaybeArray($)
}
return @result;
}
sub GenerateEmptyManifest()
{
return '<rspec xmlns="http://www.geni.net/resources/rspec/3" '.
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '.
'type="manifest" '.
'xsi:schemaLocation="http://www.geni.net/resources/rspec/3 '.
'http://www.geni.net/resources/rspec/3/manifest.xsd ">';
}
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