discover_system_state: apply power restore policy as early as BMC ready
Add a waitBmcReady() to monitor BMC state every second, this function
returns true if BMC enters ready state early or returns flase if
timeout reached.
This allows phosphor-diecover-system-state service can perform power
restore policy as early as BMC enters ready state.
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: I3f1ef2957c9c8218d094b0e7643dc2eec03535b4
diff --git a/discover_system_state.cpp b/discover_system_state.cpp
index 789e876..0a9c728 100644
--- a/discover_system_state.cpp
+++ b/discover_system_state.cpp
@@ -166,7 +166,7 @@
info(
"power_policy=ALWAYS_POWER_ON, powering host on ({DELAY}s delay)",
"DELAY", powerRestoreDelaySec.count());
- std::this_thread::sleep_for(powerRestoreDelayUsec);
+ utils::waitBmcReady(bus, powerRestoreDelaySec);
phosphor::state::manager::utils::setProperty(
bus, hostPath, HOST_BUSNAME, "RestartCause",
convertForMessage(
@@ -192,7 +192,7 @@
info(
"power_policy=ALWAYS_POWER_OFF, set requested state to off ({DELAY}s delay)",
"DELAY", powerRestoreDelaySec.count());
- std::this_thread::sleep_for(powerRestoreDelayUsec);
+ utils::waitBmcReady(bus, powerRestoreDelaySec);
// Read last requested state and re-request it to execute it
auto hostReqState = phosphor::state::manager::utils::getProperty(
bus, hostPath, HOST_BUSNAME, "RequestedHostTransition");
@@ -209,7 +209,7 @@
{
info("power_policy=RESTORE, restoring last state ({DELAY}s delay)",
"DELAY", powerRestoreDelaySec.count());
- std::this_thread::sleep_for(powerRestoreDelayUsec);
+ utils::waitBmcReady(bus, powerRestoreDelaySec);
// Read last requested state and re-request it to execute it
auto hostReqState = phosphor::state::manager::utils::getProperty(
bus, hostPath, HOST_BUSNAME, "RequestedHostTransition");