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/utils.cpp b/utils.cpp
index cad8ffd..95760cb 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -244,6 +244,20 @@
return true;
}
+bool waitBmcReady(sdbusplus::bus_t& bus, std::chrono::seconds timeout)
+{
+ while (timeout.count() != 0)
+ {
+ timeout--;
+ if (isBmcReady(bus))
+ {
+ return true;
+ }
+ std::this_thread::sleep_for(std::chrono::seconds(1));
+ }
+ return false;
+}
+
} // namespace utils
} // namespace manager
} // namespace state