]> xenbits.xensource.com Git - osstest.git/commitdiff
power: Honour approach_re in power_cycle and mg-hosts power
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 22 Jan 2019 17:41:51 +0000 (17:41 +0000)
committerIan Jackson <ian.jackson@eu.citrix.com>
Thu, 24 Jan 2019 18:40:21 +0000 (18:40 +0000)
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Osstest/TestSupport.pm
mg-hosts

index 8101b739389bd4bb0527526fc155d94e576f2256..e45f54b296e4992ae0e743908ff25a1c51d746df 100644 (file)
@@ -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 ($$$) {
index 5361eb639a7a41704ad88810c2dc0355eb595651..2edf12164ea248238ab4dff170e8f0f90eafecb4 100755 (executable)
--- a/mg-hosts
+++ b/mg-hosts
 #               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);
     }
 }