From: Ian Jackson Date: Tue, 22 Jan 2019 17:41:51 +0000 (+0000) Subject: power: Honour approach_re in power_cycle and mg-hosts power X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e42fbdd6181683895e61e01b52df7550914c78cd;p=osstest.git power: Honour approach_re in power_cycle and mg-hosts power Signed-off-by: Ian Jackson --- diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index 8101b73..e45f54b 100644 --- a/Osstest/TestSupport.pm +++ b/Osstest/TestSupport.pm @@ -1028,15 +1028,15 @@ sub power_cycle_sleep ($) { sleep($to); } -sub power_cycle ($) { - my ($ho) = @_; +sub power_cycle ($;$) { + my ($ho, $approach_re) = @_; $mjobdb->host_check_allocated($ho); die "refusing to set power state for host $ho->{Name}". " possibly shared with other jobs\n" if $ho->{SharedMaybeOthers}; - power_state($ho, 0); + power_state($ho, 0, $approach_re); power_cycle_sleep($ho); - power_state($ho, 1); + power_state($ho, 1, $approach_re); } sub power_approach_invoke ($$$) { diff --git a/mg-hosts b/mg-hosts index 5361eb6..2edf121 100755 --- a/mg-hosts +++ b/mg-hosts @@ -24,12 +24,16 @@ # of osstest. Will use "sudo". The HOST(s) must be # allocated (via mg-allocate HOST). # -# ./mg-hosts power HOST ACTION +# ./mg-hosts power HOST ACTION [APPROACH_RE] # Power cycles the host. Host must be allocated to the current # user. Actions are: # "0" or "on" : power on # "1" or "off" : power off # "c" or "r" : reboot +# APPROACH_RE is a regexp specifying which method to +# use. Methods are: Only ILOM PDU SSH +# and the lightest method which matches will be used. +# If not specified, the most reliable method will be used. # # ./mg-hosts create-like SOURCE-HOST NEW-HOST[,NEW-HOST...] # Create new host(s). This does NOT copy the @@ -151,15 +155,15 @@ END } sub cmd_power () { - die unless @ARGV==2; - my ($host,$power) = @ARGV; + die unless @ARGV==2 || @ARGV==3; + my ($host,$power,$approach_re) = @ARGV; $_ = $power; $power = m/^1|^on/ ? 1 : m/^0|^off/ ? 0 : m/^r|^c/ ? -1 : die; my $ho= selecthost("host=$host"); if ($power >= 0) { - power_state($ho, $power); + power_state($ho, $power, $approach_re); } else { - power_cycle($ho); + power_cycle($ho, $approach_re); } }