oem-ibm: Add util API for setting the present property
This commit adds a common function to set the present property
to true for all the present FRUs.
Signed-off-by: Pavithra Barithaya <pavithra.b@ibm.com>
Change-Id: Ia218f0de7883ff399e9dec60f03d88c27afed3e9
diff --git a/common/utils.cpp b/common/utils.cpp
index 2ef0d32..076cd5c 100644
--- a/common/utils.cpp
+++ b/common/utils.cpp
@@ -810,5 +810,25 @@
return !(containerId & 0x8000);
}
+void setFruPresence(const std::string& fruObjPath, bool present)
+{
+ pldm::utils::PropertyValue value{present};
+ pldm::utils::DBusMapping dbusMapping;
+ dbusMapping.objectPath = fruObjPath;
+ dbusMapping.interface = "xyz.openbmc_project.Inventory.Item";
+ dbusMapping.propertyName = "Present";
+ dbusMapping.propertyType = "bool";
+ try
+ {
+ pldm::utils::DBusHandler().setDbusProperty(dbusMapping, value);
+ }
+ catch (const std::exception& e)
+ {
+ error(
+ "Failed to set the present property on path: '{PATH}' with {ERROR} ",
+ "PATH", fruObjPath, "ERROR", e);
+ }
+}
+
} // namespace utils
} // namespace pldm
diff --git a/common/utils.hpp b/common/utils.hpp
index cdc539b..5f24322 100644
--- a/common/utils.hpp
+++ b/common/utils.hpp
@@ -464,5 +464,12 @@
* @return true or false based on the logic bit set
*/
bool checkIfLogicalBitSet(const uint16_t& containerId);
+
+/** @brief setting the present property
+ *
+ * @param[in] objPath - the object path of the fru
+ * @param[in] present - status to set either true/false
+ */
+void setFruPresence(const std::string& fruObjPath, bool present);
} // namespace utils
} // namespace pldm