From: Ian Jackson <ian.jack...@eu.citrix.com>

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.jack...@eu.citrix.com>
---
 Osstest/TestSupport.pm | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 7292a329..3d5f0be3 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -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/^(.*)://) {
-- 
2.20.1


Reply via email to