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
diff --git a/oem/ibm/libpldmresponder/fru_oem_ibm.cpp b/oem/ibm/libpldmresponder/fru_oem_ibm.cpp
index 8cc35d2..2ff9a5a 100644
--- a/oem/ibm/libpldmresponder/fru_oem_ibm.cpp
+++ b/oem/ibm/libpldmresponder/fru_oem_ibm.cpp
@@ -123,6 +123,10 @@
                 entityType == value.entity_type &&
                 containerId == value.entity_container_id)
             {
+                if (!(pldm::responder::utils::checkIfIBMFru(key)))
+                {
+                    pldm::utils::setFruPresence(key, true);
+                }
                 dbus_map_update(key, "Function0VendorId", vendorId);
                 dbus_map_update(key, "Function0DeviceId", deviceId);
                 dbus_map_update(key, "Function0RevisionId", revisionId);
diff --git a/oem/ibm/libpldmresponder/fru_oem_ibm.hpp b/oem/ibm/libpldmresponder/fru_oem_ibm.hpp
index 4323c3f..0959893 100644
--- a/oem/ibm/libpldmresponder/fru_oem_ibm.hpp
+++ b/oem/ibm/libpldmresponder/fru_oem_ibm.hpp
@@ -3,6 +3,7 @@
 #include "common/utils.hpp"
 #include "libpldmresponder/fru.hpp"
 #include "libpldmresponder/oem_handler.hpp"
+#include "oem/ibm/libpldmresponder/utils.hpp"
 
 #include <libpldm/oem/ibm/fru.h>