From: Ian Jackson Date: Fri, 29 Jun 2018 16:11:35 +0000 (+0000) Subject: PDU::ipmi: Do not return until the power state has changed X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5c0b7c4e4d85e7fcaea6f9f4429a858392b619ef;p=people%2Froyger%2Fosstest.git PDU::ipmi: Do not return until the power state has changed Signed-off-by: Ian Jackson --- diff --git a/Osstest/PDU/ipmi.pm b/Osstest/PDU/ipmi.pm index bff1143..0cbc5b9 100644 --- a/Osstest/PDU/ipmi.pm +++ b/Osstest/PDU/ipmi.pm @@ -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;