]> xenbits.xensource.com Git - osstest.git/commitdiff
Planner: client side: $mayalloc parameter to $resourcecall->()
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 1 Sep 2015 13:50:52 +0000 (14:50 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 8 Sep 2015 10:29:06 +0000 (11:29 +0100)
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.)

Osstest/Executive.pm
mg-allocate
mg-blockage
ts-hosts-allocate-Executive

index ab015d29e16b9bc96ed2fff7571f21de6d02ab99..f9be0a02b65f886824d5c285c31caea22210b985 100644 (file)
@@ -604,7 +604,7 @@ sub plan_search ($$$$) {
 }
 
 sub alloc_resources {
-    my ($resourcecall) = pop @_; # $resourcecall->($plan);
+    my ($resourcecall) = pop @_; # $resourcecall->($plan, $mayalloc);
     my (%xparams) = @_;
     # $resourcecall should die (abort) or return ($ok, $bookinglist)
     #
@@ -720,7 +720,7 @@ sub alloc_resources {
                $plan= from_json($jplan);
            }, sub {
                if (!eval {
-                   ($ok, $bookinglist) = $resourcecall->($plan);
+                   ($ok, $bookinglist) = $resourcecall->($plan, 1);
                    1;
                }) {
                    warn "resourcecall $@";
index fc1b3943074c854fee0864cd05b663145c2e47f0..6dc7dddfb5147f802e06bc754a0f7399053c8f25 100755 (executable)
@@ -270,7 +270,7 @@ sub showposs ($) {
 sub plan () {
     my @got;
     alloc_resources(sub {
-        my ($plan) = @_;
+        my ($plan, $mayalloc) = @_;
 
        @got = ();
         my @possmatrix = ([]);
@@ -310,7 +310,7 @@ sub plan () {
        die unless $planned;
 
         my $allok=0;
-        if (!$planned->{Start}) {
+        if ($mayalloc && !$planned->{Start}) {
             $allok=1;
 
             alloc_prep();
index a21f15bca94eab45dd052177b0d99ff1786f073c..1f66d8e5d20c53ee9f0e0c97ea5f2c7931c565c7 100755 (executable)
@@ -40,7 +40,7 @@ sub max { (reverse sort @_)[0]; }
 
 sub plan () {
     alloc_resources(sub {
-       my ($plan) = @_;
+       my ($plan, $mayalloc) = @_;
 
        my $now = time;
        if ($now > $end) { return (1, { Bookings => [ ] }); }
index 6583191042f4219ef4b71bcd7638a65a2e963d00..781ddafa54ba4f25b662bebf1e8dfe81719c3fb6 100755 (executable)
@@ -606,7 +606,8 @@ sub alloc_hosts () {
 }
 
 sub attempt_allocation {
-    ($plan) = @_;
+    my $mayalloc;
+    ($plan, $mayalloc) = @_;
     undef $best;
 
     logm("allocating hosts: ".join(' ', map { $_->{Ident} } @hids));
@@ -632,7 +633,7 @@ sub attempt_allocation {
 
     my $retval=0;
 
-    if (!$best->{Start}) {
+    if ($mayalloc && !$best->{Start}) {
        $retval= 1;
        foreach my $hid (@hids) {
            my $got= actual_allocation($hid);