Add a new parameter to $resourcecall which allows the alloc_resources
loop in Osstest::Executive to specify to its clients that on this
occasion they should not make any actual allocations.
The callers of alloc_resources are all adjusted to honour this new
parameter:
* ts-hosts-allocate-Executive avoids allocating unless $mayalloc
* mg-allocate avoids allocating unless $mayalloc
* mg-blockage never allocates anyway.
Currently we always pass 1, so no functional change.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v3: Add missing my $mayalloc. ($plan is global.)
}
sub alloc_resources {
- my ($resourcecall) = pop @_; # $resourcecall->($plan);
+ my ($resourcecall) = pop @_; # $resourcecall->($plan, $mayalloc);
my (%xparams) = @_;
# $resourcecall should die (abort) or return ($ok, $bookinglist)
#
$plan= from_json($jplan);
}, sub {
if (!eval {
- ($ok, $bookinglist) = $resourcecall->($plan);
+ ($ok, $bookinglist) = $resourcecall->($plan, 1);
1;
}) {
warn "resourcecall $@";
sub plan () {
my @got;
alloc_resources(sub {
- my ($plan) = @_;
+ my ($plan, $mayalloc) = @_;
@got = ();
my @possmatrix = ([]);
die unless $planned;
my $allok=0;
- if (!$planned->{Start}) {
+ if ($mayalloc && !$planned->{Start}) {
$allok=1;
alloc_prep();
sub plan () {
alloc_resources(sub {
- my ($plan) = @_;
+ my ($plan, $mayalloc) = @_;
my $now = time;
if ($now > $end) { return (1, { Bookings => [ ] }); }
}
sub attempt_allocation {
- ($plan) = @_;
+ my $mayalloc;
+ ($plan, $mayalloc) = @_;
undef $best;
logm("allocating hosts: ".join(' ', map { $_->{Ident} } @hids));
my $retval=0;
- if (!$best->{Start}) {
+ if ($mayalloc && !$best->{Start}) {
$retval= 1;
foreach my $hid (@hids) {
my $got= actual_allocation($hid);