PEL: Support eventId property

Support eventId property to add SRC and the hex words to the property

Tested by creating the PEL log and to make sure that the eventId
property was updated properly with 9 words and then its present in the
right format when the logging daemon is restarted

Test result:
root@rainier# busctl get-property xyz.openbmc_project.Logging
/xyz/openbmc_project/logging/entry/1 xyz.openbmc_project.Logging.Entry EventId
s "BD8D1001 00000055 2E2D0010 00000000 00000000 00000000 00000000
   00000000 00000000"

Also tested with old version of error log and new version with the
eventId property to make sure we don't have issues in serialization

Change-Id: I8e39804cd3d47f0e321c1cf533b97bf165c07518
Signed-off-by: Vijay Lobo <vijaylobo@gmail.com>
diff --git a/extensions/openpower-pels/manager.cpp b/extensions/openpower-pels/manager.cpp
index 33854e2..afd7eb0 100644
--- a/extensions/openpower-pels/manager.cpp
+++ b/extensions/openpower-pels/manager.cpp
@@ -164,6 +164,7 @@
 
         // Check if firmware should quiesce system due to error
         checkPelAndQuiesce(pel);
+        updateEventId(pel);
     }
     else
     {
@@ -360,6 +361,7 @@
 
     // Check if firmware should quiesce system due to error
     checkPelAndQuiesce(pel);
+    updateEventId(pel);
 }
 
 sdbusplus::message::unix_fd Manager::getPEL(uint32_t pelID)
@@ -621,6 +623,42 @@
     }
 }
 
+std::string Manager::getEventId(const openpower::pels::PEL& pel) const
+{
+    std::string str;
+    auto src = pel.primarySRC();
+    if (src)
+    {
+        const auto& hexwords = (*src)->hexwordData();
+
+        std::string refcode = (*src)->asciiString();
+        size_t pos = refcode.find_last_not_of(0x20);
+        if (pos != std::string::npos)
+        {
+            refcode.erase(pos + 1);
+        }
+        str = refcode;
+
+        for (auto& value : hexwords)
+        {
+            str += " ";
+            str += getNumberString("%08X", value);
+        }
+    }
+    return str;
+}
+
+void Manager::updateEventId(std::unique_ptr<openpower::pels::PEL>& pel)
+{
+    std::string eventIdStr = getEventId(*pel);
+
+    auto entryN = _logManager.entries.find(pel->obmcLogID());
+    if (entryN != _logManager.entries.end())
+    {
+        entryN->second->eventId(eventIdStr);
+    }
+}
+
 void Manager::setEntryPath(uint32_t obmcLogID)
 {
     Repository::LogID id{Repository::LogID::Obmc(obmcLogID)};