manager:CollectionStatus property update

This commit updates the CollectionStatus during single FRU VPD
collection execution.

Test:
1. busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager
com.ibm.VPD.Manager CollectFRUVPD o /xyz/openbmc_project/
inventory/system/chassis/motherboard/lcd_op_panel_hill

CollectionStatus property value on success vpd collection:
s "com.ibm.VPD.Collection.Status.Success"

2. busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager
com.ibm.VPD.Manager CollectFRUVPD o /xyz/openbmc_project/
inventory/system/chassis/motherboard

Given FRU is neither replaceable at standby nor replaceable at runtime.
Single FRU VPD collection is not performed for
/xyz/openbmc_project/inventory/system/chassis/motherboard

3. busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager
 com.ibm.VPD.Manager CollectFRUVPD o /xyz/openbmc_project/
inventory/system/chassis/motherboard/pcieslot0/pcie_card0

CollectionStatus property value when pcie_card not found:
s "com.ibm.VPD.Collection.Status.Failure"

Change-Id: I776edd0c5002ec516f656281d0325ecdc6acf00e
Signed-off-by: Priyanga Ramasamy <priyanga24@in.ibm.com>
diff --git a/vpd-manager/src/manager.cpp b/vpd-manager/src/manager.cpp
index 8b162e9..87fcc30 100644
--- a/vpd-manager/src/manager.cpp
+++ b/vpd-manager/src/manager.cpp
@@ -457,9 +457,10 @@
     {
         if (m_vpdCollectionStatus != "Completed")
         {
-            throw std::runtime_error(
+            logging::logMessage(
                 "Currently VPD CollectionStatus is not completed. Cannot perform single FRU VPD collection for " +
                 std::string(i_dbusObjPath));
+            return;
         }
 
         // Get system config JSON object from worker class
@@ -473,9 +474,10 @@
         // Check if system config JSON is present
         if (l_sysCfgJsonObj.empty())
         {
-            throw std::runtime_error(
-                "System config JSON object not present. Single FRU VPD collection failed for " +
+            logging::logMessage(
+                "System config JSON object not present. Single FRU VPD collection is not performed for " +
                 std::string(i_dbusObjPath));
+            return;
         }
 
         // Get FRU path for the given D-bus object path from JSON
@@ -484,9 +486,10 @@
 
         if (l_fruPath.empty())
         {
-            throw std::runtime_error(
-                "D-bus object path not present in JSON. Single FRU VPD collection failed for " +
+            logging::logMessage(
+                "D-bus object path not present in JSON. Single FRU VPD collection is not performed for " +
                 std::string(i_dbusObjPath));
+            return;
         }
 
         // Check if host is up and running
@@ -495,9 +498,10 @@
             if (!jsonUtility::isFruReplaceableAtRuntime(l_sysCfgJsonObj,
                                                         l_fruPath))
             {
-                throw std::runtime_error(
-                    "Given FRU is not replaceable at host runtime. Single FRU VPD collection failed for " +
+                logging::logMessage(
+                    "Given FRU is not replaceable at host runtime. Single FRU VPD collection is not performed for " +
                     std::string(i_dbusObjPath));
+                return;
             }
         }
         else if (dbusUtility::isBMCReady())
@@ -507,12 +511,33 @@
                 (!jsonUtility::isFruReplaceableAtRuntime(l_sysCfgJsonObj,
                                                          l_fruPath)))
             {
-                throw std::runtime_error(
-                    "Given FRU is neither replaceable at standby nor replaceable at runtime. Single FRU VPD collection failed for " +
+                logging::logMessage(
+                    "Given FRU is neither replaceable at standby nor replaceable at runtime. Single FRU VPD collection is not performed for " +
                     std::string(i_dbusObjPath));
+                return;
             }
         }
 
+        // Set CollectionStatus as InProgress. Since it's an intermediate state
+        // D-bus set-property call is good enough to update the status.
+        try
+        {
+            const std::string& l_collStatusProp = "CollectionStatus";
+            dbusUtility::writeDbusProperty(
+                jsonUtility::getServiceName(l_sysCfgJsonObj,
+                                            std::string(i_dbusObjPath)),
+                std::string(i_dbusObjPath), constants::vpdCollectionInterface,
+                l_collStatusProp,
+                types::DbusVariantType{constants::vpdCollectionInProgress});
+        }
+        catch (const std::exception& e)
+        {
+            logging::logMessage(
+                "Unable to set CollectionStatus as InProgress for " +
+                std::string(i_dbusObjPath) +
+                ". Continue single FRU VPD collection.");
+        }
+
         // Parse VPD
         types::VPDMapVariant l_parsedVpd = m_worker->parseVpdFile(l_fruPath);
 
@@ -544,6 +569,15 @@
     }
     catch (const std::exception& l_error)
     {
+        // Notify FRU's VPD CollectionStatus as Failure
+        if (!dbusUtility::notifyFRUCollectionStatus(
+                std::string(i_dbusObjPath), constants::vpdCollectionFailure))
+        {
+            logging::logMessage(
+                "Call to PIM Notify method failed to update Collection status as Failure for " +
+                std::string(i_dbusObjPath));
+        }
+
         // TODO: Log PEL
         logging::logMessage(std::string(l_error.what()));
     }