]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
ts-hosts-allocate-Executive: Allow dry-run
authorIan Campbell <ian.campbell@citrix.com>
Wed, 16 Sep 2015 11:47:41 +0000 (12:47 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 18 Sep 2015 15:15:41 +0000 (16:15 +0100)
Provide a new -n command line option which causes no allocations to be
done, for debugging.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
ts-hosts-allocate-Executive

index 781ddafa54ba4f25b662bebf1e8dfe81719c3fb6..c9aae885edd49bd977d1b11314690b69a45df45a 100755 (executable)
@@ -30,6 +30,7 @@ tsreadconfig();
 open DEBUG, ">/dev/null" or die $!;
 
 our $compressdebug=1;
+our $fake; # never allocate
 
 while (@ARGV and $ARGV[0] =~ m/^-/) {
     $_= shift @ARGV;
@@ -37,6 +38,8 @@ while (@ARGV and $ARGV[0] =~ m/^-/) {
     while (m/^-./) {
         if (s/^-U/-/) {
            $compressdebug=0;
+       } elsif (s/^-n/-/) {
+           $fake=1;
         } else {
             die "$_ ?";
         }
@@ -610,6 +613,8 @@ sub attempt_allocation {
     ($plan, $mayalloc) = @_;
     undef $best;
 
+    $mayalloc = undef if $fake;
+
     logm("allocating hosts: ".join(' ', map { $_->{Ident} } @hids));
 
     prepare_statements();
@@ -654,6 +659,11 @@ sub attempt_allocation {
        logm("host allocation: planned start in $best->{Start} seconds.");
     }
 
+    if ($fake) {
+       logm("Fake allocation, returning error");
+       $retval = -1;
+    }
+
     my $booklist= compute_booking_list();
 
     return ($retval, $booklist);