From: Ian Jackson Date: Fri, 27 Oct 2017 16:52:49 +0000 (+0100) Subject: host allocation: selecthost: allow sort-of-selection of prospective hosts X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=be19280f24d80166c7df3f9e50d3f38ccb1cf92f;p=osstest.git host allocation: selecthost: allow sort-of-selection of prospective hosts 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 --- diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index 7292a32..3d5f0be 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 @@ -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/^(.*)://) {