...
 
Commits (1)
......@@ -1195,35 +1195,26 @@ sub ExtendSlice($$$;$$$) {
#
# Estimate an upper bound for permissible expiry times on a slice.
#
# Reservation->MaxSliceExtension( $slice, $max, $error )
# Reservation->MaxSliceExtension( $slice, $max, $error, $granularity )
#
# Will put the unix time stamp in $$max and return 0 if the slice can be
# extended, or -1 with $$error set.
# extended, or -1 with $$error set. If $granularity is set, the returned
# time will be lowered to a multiple of $granularity (e.g.,
# $granularity = 3600 would give a time on an hour boundary).
#
# Of course, this comes with no guarantees... for instance, somebody else
# could make a conflicting reservation/extension before this call returns,
# or before the caller has a chance to do anything useful with the result...
sub MaxSliceExtension($$$;$) {
sub MaxSliceExtension($$$;$$) {
my ($class, $slice, $max, $error) = @_;
my ($class, $slice, $max, $error, $granularity) = @_;
my $cur_expire = str2time( $slice->expires() );
my $max_expire = $cur_expire + 60 * 60 * 24 * 180;
my $expt = $slice->GetExperiment();
if (!defined($expt)) {
if( ref( $error ) ) {
$$error = "No experiment for slice, cannot compute max.";
}
return -1;
}
if (! $expt->NodeList(1)) {
if( ref( $error ) ) {
$$error = "No physical nodes, no max to compute.";
}
return -1;
}
my $exptidx = $expt->idx();
my $exptidx = $slice->exptidx();
my $expt = Experiment->Lookup( $exptidx );
my @types = ExptTypes( $exptidx );
foreach my $type ( @types ) {
......@@ -1246,6 +1237,12 @@ sub MaxSliceExtension($$$;$) {
return -1;
} else {
$$max = $max_expire;
if( defined( $granularity ) && $granularity > 1 ) {
$$max--;
$$max -= $$max % $granularity;
}
return 0;
}
}
......