]> xenbits.xensource.com Git - people/royger/osstest.git/commitdiff
PDU::ipmi: Do not return until the power state has changed
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 29 Jun 2018 16:11:35 +0000 (16:11 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 4 Jul 2018 15:42:46 +0000 (16:42 +0100)
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Osstest/PDU/ipmi.pm

index bff1143fcbc9a4b8af2422a9549b2170ba00850a..0cbc5b90a80b8d32792e169efb579edd01831c26 100644 (file)
@@ -49,19 +49,29 @@ sub pdu_power_state {
 
     my $cmd = "ipmitool -H $mo->{Mgmt} -U $mo->{User} -P $mo->{Pass}";
 
-    my $status = `$cmd power status`
-       or die "Cannot retrieve current power status";
-    chomp($status);
-    logm("$status (want $onoff)");
-    $status =~ s/^Chassis Power is (on|off)$/$1/
-       or die "Cannot parse current power status: $status";
+    my $getstatus = sub {
+        my $status = `$cmd power status`
+            or die "Cannot retrieve current power status";
+        chomp($status);
+        logm("$status (want $onoff)");
+        $status =~ s/^Chassis Power is (on|off)$/$1/
+            or die "Cannot parse current power status: $status";
+        return $status;
+    };
 
-    if ( $status eq $onoff ) {
+    if ( $getstatus->() eq $onoff ) {
        logm("Current power status is correct");
        return;
     }
 
-    system_checked("$cmd power $onoff")
+    system_checked("$cmd power $onoff");
+
+    my $count = 60;
+    for (;;) {
+        last if $getstatus->() eq $onoff;
+        die "did not power $onoff" unless --$count > 0;
+        sleep(1);
+    }
 }
 
 1;