Commit e1826c11 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Add support for geni_extend_slap and non-unique slice names/project.

For the latter, we now look to see if we already have an experiment
with the provide slice ID, and if we do and the URN indicates a sub
project, generate a new unique experiment name for the backend emulab
experiment.
parent c5c20f42
......@@ -564,8 +564,14 @@ sub RenewSliver()
my $renew_args = {
'slice_urn' => $slice_urn,
'expiration' => $expiration_time,
'credentials' => $credentials
'credentials' => $credentials,
'alap' => 0,
};
# extend as long as possible.
if (exists($options->{'geni_extend_alap'}) &&
$options->{'geni_extend_alap'}) {
$renew_args->{'alap'} = 1;
}
my $response = GeniCMV2::RenewSlice($renew_args);
if (GeniResponse::IsError($response)) {
return $response;
......@@ -573,7 +579,9 @@ sub RenewSliver()
# Return an XML-RPC boolean
my $coder = Frontier::RPC2->new();
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $coder->boolean(1));
return GeniResponse->Create(GENIRESPONSE_SUCCESS,
GeniResponse::value($response),
GeniResponse::value($response));
}
sub Shutdown()
......@@ -933,8 +941,14 @@ sub Renew
my $args = {
'slice_urn' => $urns[0],
'expiration' => $expiration_time,
'credentials' => $credentials
'credentials' => $credentials,
'alap' => 0,
};
# extend as long as possible.
if (exists($options->{'geni_extend_alap'}) &&
$options->{'geni_extend_alap'}) {
$args->{'alap'} = 1;
}
my $response = GeniCMV2::RenewSlice($args);
if (! GeniResponse::IsError($response)) {
my $description = Describe($urn_args, $credential_args, []);
......
......@@ -615,7 +615,7 @@ sub GetTicketAuxAux($$$$$$$$$$)
}
# Note "checkonly" flag; we do not actually change the slice
# until the ticket is redeemed.
my $tmp = SetSliceExpiration($slice, $expires, 1, @{ $credentials });
my $tmp = SetSliceExpiration($slice, $expires, 1, 0, @{ $credentials });
if (GeniResponse::IsResponse($tmp)) {
return $tmp;
}
......@@ -2862,7 +2862,7 @@ sub SliverWorkAux($$$$$$$$)
$message = "Illegal valid_until in rspec";
goto bad;
}
my $tmp = SetSliceExpiration($slice, $expires, 0, $credential);
my $tmp = SetSliceExpiration($slice, $expires, 0, 0, $credential);
if (GeniResponse::IsResponse($tmp)) {
$message = GeniResponse::output($tmp);
goto bad;
......@@ -3943,12 +3943,12 @@ sub RenewSlice($)
return $credential
if (GeniResponse::IsResponse($credential));
return RenewSliverAux([$credential], $expires);
return RenewSliverAux([$credential], $expires, 0);
}
sub RenewSliverAux($$)
sub RenewSliverAux($$$)
{
my ($credentials, $expires) = @_;
my ($credentials, $expires, $alap) = @_;
my $credential = $credentials->[0];
my $message = "Error renewing aggregate";
my $when;
......@@ -3971,7 +3971,8 @@ sub RenewSliverAux($$)
$message = "Slice has been shutdown";
goto bad;
}
my $response = SetSliceExpiration($slice, $expires, 0, @{ $credentials });
my $response = SetSliceExpiration($slice,
$expires, 0, $alap, @{ $credentials });
if (GeniResponse::IsError($response)) {
$slice->UnLock();
return $response;
......@@ -3984,7 +3985,7 @@ sub RenewSliverAux($$)
GeniCredential->DeleteForTarget($aggregate);
}
$slice->UnLock();
return GeniResponse->Create(GENIRESPONSE_SUCCESS);
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $slice->ExpirationGMT());
bad:
$slice->UnLock();
......@@ -5858,8 +5859,20 @@ sub GeniExperiment($;$)
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Slice name already exists");
}
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
my $digest = sha1_hex($urn);
$digest = substr($digest, 0, 8);
$eid = lc("e${digest}");
if (! Experiment->ValidEID($eid)) {
print STDERR "Cannot form a unique eid for $urn\n";
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Cannot form a unique eid");
}
$experiment = Experiment->Lookup($project->pid(), $eid);
if (defined($experiment)) {
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Slice name already exists");
}
print STDERR "Converted $urn to unique eid $eid\n";
}
#
......@@ -6356,9 +6369,11 @@ sub KillMonitor($)
#
# Helper function to compute expiration time.
#
sub SetSliceExpiration($$$@)
# alap => extend as long as possible
#
sub SetSliceExpiration($$$$@)
{
my ($slice, $expiration, $checkonly, @credentials) = @_;
my ($slice, $expiration, $checkonly, $alap, @credentials) = @_;
my $message = "Error renewing sliver";
my $when;
......@@ -6463,9 +6478,14 @@ sub SetSliceExpiration($$$@)
}
}
elsif ($diff > (3600 * 24 * $max_sliver_lifetime)) {
$message = "expiration increment is greater then the maximum number ".
"(" . (60 * 24 * $max_sliver_lifetime) . ") of minutes";
goto bad;
if ($alap) {
$when = time() + (3600 * 24 * $max_sliver_lifetime);
}
else {
$message = "expiration increment is greater then the maximum ".
"number (" . (60 * 24 * $max_sliver_lifetime) . ") of minutes";
goto bad;
}
}
if (!$checkonly && $slice->SetExpiration($when) != 0) {
$message = "could not set expiration time";
......
......@@ -1234,6 +1234,9 @@ sub RenewSlice($)
my $slice_urn = $argref->{'slice_urn'};
my $valid_until = $argref->{'valid_until'} || $argref->{'expiration'};
my $credentials = $argref->{'credentials'};
my $alap = 0;
# extend as long as possible.
$alap = $argref->{'alap'} if (exists($argref->{'alap'}));
if (! (defined($credentials) && defined($slice_urn))) {
return GeniResponse->MalformedArgsResponse("Missing arguments");
......@@ -1262,7 +1265,8 @@ sub RenewSlice($)
return GeniResponse->Create(GENIRESPONSE_FORBIDDEN(), undef,
"Credential does not match the URN");
}
return GeniCM::RenewSliverAux([$credential, @morecreds], $valid_until);
return GeniCM::RenewSliverAux([$credential, @morecreds],
$valid_until, $alap);
}
#
......
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