Update PELs while parsing FRU

Severity of PEL needs to be updated as informational in case any
of the FRU collection fails for reason other than EEPROM or data
failure, for which the severity will be handled by the specific parser.

This is done as successful collection of a FRU other than system VPD
is not a mandatory condition to bring BMC to ready state.

In case of failure in the processing of pre action, to figure out what
failed in the flow, informational PEL is added while processing
pre-action tags.

No error in case the file is not found and pre-action was not required
as FRU can be actually absent.

Empty map is also not considered for logging PEL in worker as
respective parser should take care of any error and log PEL at their
end.

Change-Id: I4adf5be3adeb5ca556b1b4283e3036361793b108
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/src/worker.cpp b/vpd-manager/src/worker.cpp
index d54b317..ac104bb 100644
--- a/vpd-manager/src/worker.cpp
+++ b/vpd-manager/src/worker.cpp
@@ -1371,24 +1371,30 @@
         {
             throw std::runtime_error(
                 std::string(__FUNCTION__) +
-                "Empty VPD file path passed. Abort processing");
+                " Empty VPD file path passed. Abort processing");
         }
 
+        bool isPreActionRequired = false;
         if (jsonUtility::isActionRequired(m_parsedJson, i_vpdFilePath,
                                           "preAction", "collection"))
         {
+            isPreActionRequired = true;
             if (!processPreAction(i_vpdFilePath, "collection"))
             {
                 throw std::runtime_error(
-                    std::string(__FUNCTION__) + "Pre-Action failed");
+                    std::string(__FUNCTION__) + " Pre-Action failed");
             }
         }
 
         if (!std::filesystem::exists(i_vpdFilePath))
         {
-            throw std::runtime_error(
-                std::string(__FUNCTION__) + "Could not find file path " +
-                i_vpdFilePath + "Skipping parser trigger for the EEPROM");
+            if (isPreActionRequired)
+            {
+                throw std::runtime_error(
+                    std::string(__FUNCTION__) + " Could not find file path " +
+                    i_vpdFilePath + "Skipping parser trigger for the EEPROM");
+            }
+            return types::VPDMapVariant{};
         }
 
         std::shared_ptr<Parser> vpdParser =
@@ -1474,16 +1480,23 @@
         }
 
         const types::VPDMapVariant& parsedVpdMap = parseVpdFile(i_vpdFilePath);
-
-        types::ObjectMap objectInterfaceMap;
-        populateDbus(parsedVpdMap, objectInterfaceMap, i_vpdFilePath);
-
-        // Notify PIM
-        if (!dbusUtility::callPIM(move(objectInterfaceMap)))
+        if (!std::holds_alternative<std::monostate>(parsedVpdMap))
         {
-            throw std::runtime_error(
-                std::string(__FUNCTION__) +
-                "Call to PIM failed while publishing VPD.");
+            types::ObjectMap objectInterfaceMap;
+            populateDbus(parsedVpdMap, objectInterfaceMap, i_vpdFilePath);
+
+            // Notify PIM
+            if (!dbusUtility::callPIM(move(objectInterfaceMap)))
+            {
+                throw std::runtime_error(
+                    std::string(__FUNCTION__) +
+                    "Call to PIM failed while publishing VPD.");
+            }
+        }
+        else
+        {
+            logging::logMessage("Empty parsedVpdMap recieved for path [" +
+                                i_vpdFilePath + "]. Check PEL for reason.");
         }
     }
     catch (const std::exception& ex)
@@ -1521,7 +1534,7 @@
         }
 
         EventLogger::createSyncPel(
-            EventLogger::getErrorType(ex), types::SeverityType::Critical,
+            EventLogger::getErrorType(ex), types::SeverityType::Informational,
             __FILE__, __FUNCTION__, 0, EventLogger::getErrorMsg(ex),
             std::nullopt, std::nullopt, std::nullopt, std::nullopt);