Process FRU only when present with specific CCIN

Some FRUs are only supported  with specific CCINs in case of PowerVS
configuration.
The commit implements changes to check for presence of the FRU based on
its Present property, if found checks for specific CCIN, if found
updates the PN else skips.

Change-Id: I1f3ff08f82788aed4d8153474cd38352e5cc2394
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/include/utility/dbus_utility.hpp b/vpd-manager/include/utility/dbus_utility.hpp
index 344a637..39a4bf3 100644
--- a/vpd-manager/include/utility/dbus_utility.hpp
+++ b/vpd-manager/include/utility/dbus_utility.hpp
@@ -685,5 +685,31 @@
         return std::string{};
     }
 }
+
+/**
+ * @brief API to read DBus present property for the given inventory.
+ *
+ * @param[in] i_invObjPath - Inventory path.
+ * @return Present property value, false in case of any error.
+ */
+inline bool isInventoryPresent(const std::string& i_invObjPath)
+{
+    if (i_invObjPath.empty())
+    {
+        return false;
+    }
+
+    const auto& l_retValue =
+        dbusUtility::readDbusProperty(constants::pimServiceName, i_invObjPath,
+                                      constants::inventoryItemInf, "Present");
+
+    auto l_ptrPresence = std::get_if<bool>(&l_retValue);
+    if (!l_ptrPresence)
+    {
+        return false;
+    }
+
+    return (*l_ptrPresence);
+}
 } // namespace dbusUtility
 } // namespace vpd
diff --git a/vpd-manager/include/utility/vpd_specific_utility.hpp b/vpd-manager/include/utility/vpd_specific_utility.hpp
index 4fc553d..09c4719 100644
--- a/vpd-manager/include/utility/vpd_specific_utility.hpp
+++ b/vpd-manager/include/utility/vpd_specific_utility.hpp
@@ -727,5 +727,41 @@
     }
     return false;
 }
+
+/**
+ * @brief API to get CCIN for a given FRU from DBus.
+ *
+ * The API reads the CCIN for a FRU based on its inventory path.
+ *
+ * @param[in] i_invObjPath - Inventory path of the FRU.
+ * @return CCIN of the FRU on success, empty string otherwise.
+ */
+inline std::string getCcinFromDbus(const std::string& i_invObjPath)
+{
+    try
+    {
+        if (i_invObjPath.empty())
+        {
+            throw std::runtime_error("Empty EEPROM path, can't read CCIN");
+        }
+
+        const auto& l_retValue = dbusUtility::readDbusProperty(
+            constants::pimServiceName, i_invObjPath, constants::viniInf,
+            constants::kwdCCIN);
+
+        auto l_ptrCcin = std::get_if<types::BinaryVector>(&l_retValue);
+        if (!l_ptrCcin || (*l_ptrCcin).size() != constants::VALUE_4)
+        {
+            throw DbusException("Invalid CCIN read from Dbus");
+        }
+
+        return std::string((*l_ptrCcin).begin(), (*l_ptrCcin).end());
+    }
+    catch (const std::exception& l_ex)
+    {
+        logging::logMessage(l_ex.what());
+        return std::string{};
+    }
+}
 } // namespace vpdSpecificUtility
 } // namespace vpd