API to read IM from DBus

The commit implements utility method to read IM value from the DBus.

For now, it will be used to detect the system type before updating the
VPD for power VS systems.

Change-Id: I425ebfc51721396cc1ca5f07d5725ef6617f4419
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 0cb8151..f849f89 100644
--- a/vpd-manager/include/utility/dbus_utility.hpp
+++ b/vpd-manager/include/utility/dbus_utility.hpp
@@ -592,5 +592,25 @@
 
     return true;
 }
+
+/**
+ * @brief API to read IM keyword from Dbus.
+ *
+ * @return IM value read from Dbus, Empty in case of any error.
+ */
+inline types::BinaryVector getImFromDbus()
+{
+    const auto& l_retValue = dbusUtility::readDbusProperty(
+        constants::pimServiceName, constants::systemVpdInvPath,
+        constants::vsbpInf, constants::kwdIM);
+
+    auto l_imValue = std::get_if<types::BinaryVector>(&l_retValue);
+    if (!l_imValue || (*l_imValue).size() != constants::VALUE_4)
+    {
+        return types::BinaryVector{};
+    }
+
+    return *l_imValue;
+}
 } // namespace dbusUtility
 } // namespace vpd
diff --git a/vpd-manager/src/manager.cpp b/vpd-manager/src/manager.cpp
index 7b22a69..3ab6ec1 100644
--- a/vpd-manager/src/manager.cpp
+++ b/vpd-manager/src/manager.cpp
@@ -327,6 +327,19 @@
 {
     // This API should check for required powerVS configuration and will
     // update the VPD accordingly.
+
+    try
+    {
+        types::BinaryVector l_imValue = dbusUtility::getImFromDbus();
+        if (l_imValue.empty())
+        {
+            throw DbusException("Invalid IM value read from Dbus");
+        }
+    }
+    catch (const std::exception& l_ex)
+    {
+        // TODO log appropriate PEL
+    }
 }
 #endif