bmc-ready: utility function to check bmc state

Add a utility function that chassis and host code can call to determine
if the BMC is in a Ready state.

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: Ibf11a3f160c57a9a1570ee639e0b9c4ab020bf45
diff --git a/utils.cpp b/utils.cpp
index 20ebc4b..5af63c0 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -231,6 +231,19 @@
     return false;
 }
 
+bool isBmcReady(sdbusplus::bus_t& bus)
+{
+    auto bmcState = getProperty(bus, "/xyz/openbmc_project/state/bmc0",
+                                "xyz.openbmc_project.State.BMC",
+                                "CurrentBMCState");
+    if (bmcState != "xyz.openbmc_project.State.BMC.BMCState.Ready")
+    {
+        debug("BMC State is {BMC_STATE}", "BMC_STATE", bmcState);
+        return false;
+    }
+    return true;
+}
+
 } // namespace utils
 } // namespace manager
 } // namespace state
diff --git a/utils.hpp b/utils.hpp
index febcb6a..dd229d6 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -89,6 +89,12 @@
  */
 bool checkACLoss(size_t& chassisId);
 
+/** @brief Determine if the BMC is at its Ready state
+ *
+ * @param[in] bus          - The Dbus bus object
+ */
+bool isBmcReady(sdbusplus::bus_t& bus);
+
 } // namespace utils
 } // namespace manager
 } // namespace state