Add helper functions to retrieve chassis paths/IDs
- Implemented chassis helper functions that retrieve all system chassis
and return them as a vector of chassis.
- Implemented a helper function to retrieve a chassis unique ID from the
inventory manager.
- Implemented a helper function to retrieve the parent object path
unique ID from the entity manager.
Tested:
- Simulated several chassis in a system and verified all chassis
within the vector.
- Simulated chassis ID in the inventory manager and verified the
chassis ID is as expected.
- Simulated power supply path verified the parent ID retrieved from
entity manager.
Change-Id: I1da380f05b71af2e629729ea5ea054e7573f2d58
Signed-off-by: Faisal Awada <faisal@us.ibm.com>
diff --git a/utility.hpp b/utility.hpp
index d2d9365..f4a7d73 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -22,6 +22,7 @@
constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
constexpr auto POWEROFF_TARGET = "obmc-chassis-hard-poweroff@0.target";
constexpr auto PROPERTY_INTF = "org.freedesktop.DBus.Properties";
+constexpr auto ENTITY_MGR_SERVICE = "xyz.openbmc_project.EntityManager";
using DbusPath = std::string;
using DbusProperty = std::string;
@@ -230,6 +231,43 @@
*/
std::vector<std::string> getPSUInventoryPaths(sdbusplus::bus_t& bus);
+/**
+ * @detail Get all chassis inventory paths from D-Bus
+ *
+ * @param[in] bus - D-Bus object
+ *
+ * @return The list of chassis inventory paths
+ */
+std::vector<std::string> getChassisInventoryPaths(sdbusplus::bus_t& bus);
+
+/**
+ * @brief Retrieve the chassis ID for the given D-Bus inventory path.
+ * Query the D-Bus interface for inventory object path and retrieve its unique
+ * ID (ID specified by SlotNumber)
+ *
+ * @param[in] bus - D-Bus object
+ * @param[in] path - The inventory manager D-Bus path for a chassis.
+ *
+ * @return uint64_t - Chassis unique ID
+ */
+uint64_t getChassisInventoryUniqueId(sdbusplus::bus_t& bus,
+ const std::string& path);
+/**
+ * @brief Retrieve the parent chassis unique ID from the Entity Manager.
+ * Given a D-Bus object path, this function extracts the parent path (board or
+ * chassis) and retrieve the chassis unique ID from Entity Manager.
+ *
+ * @param[in] bus - D-Bus object
+ * @param[in] path - The EntityManager D-Bus path for hardware within a chassis
+ * or board.
+ *
+ * @return uint64_t - Chassis unique ID
+ *
+ * @note This function assumes the parent object path contains property in
+ * Entity Manager.
+ */
+uint64_t getParentEMUniqueId(sdbusplus::bus_t& bus, const std::string& path);
+
} // namespace util
} // namespace power
} // namespace phosphor