]> xenbits.xensource.com Git - osstest.git/commitdiff
host allocation: selecthost: allow sort-of-selection of prospective hosts
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 27 Oct 2017 16:52:49 +0000 (17:52 +0100)
committerIan Jackson <iwj@xenproject.org>
Fri, 2 Oct 2020 15:49:13 +0000 (16:49 +0100)
If one passes a trueish value for $prospective, selecthost does not
worry about whether any host has actually been selected.  It does a
limited amount of prep work.

This will be useful if we want to know some of the non-host-specific
information selecthost computes - in particular, $ho->{Suite} etc.

No functional change with existing callers.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Osstest/TestSupport.pm

index 7292a329e76abe3872dddc217d614d90d8523f1d..3d5f0be3984e5f31837f1c200cb386645c99f6d6 100644 (file)
@@ -1170,9 +1170,9 @@ sub power_state ($$;$) {
 
 #---------- host selection and properties ----------
 
-sub selecthost ($;$);
-sub selecthost ($;$) {
-    my ($ident, $none_ok) = @_;
+sub selecthost ($;$$);
+sub selecthost ($;$$) {
+    my ($ident, $none_ok, $prospective) = @_;
     # must be run outside transaction
 
     # $ident is <identspec>
@@ -1199,7 +1199,7 @@ sub selecthost ($;$) {
         $r{$ident}= $name;
     } else {
         $name= $r{$ident};
-       if (!defined $name) {
+       if (!defined $name and !$prospective) {
            return undef if $none_ok;
            die "no specified $ident";
        }
@@ -1220,6 +1220,8 @@ sub selecthost ($;$) {
         $ho->{OS} = target_var($ho, "os") // "debian";
     }
 
+    return $ho if $prospective;
+
     #----- handle hosts which are themselves guests (nested) -----
 
     if ($name =~ s/^(.*)://) {