PEL: Support ServiceProviderNotify property

Redfish API needs to find out if the callhome event occurred in a system
and this support is provided by updating the ServiceProviderNotify
property in D-Bus if the callhome flag in PEL is set.

Tested: Manually created informational and unrecoverable errors directly
on D-Bus using busctl call and verified that the ServiceProviderNotify
property set to false for informational error and its set to true for
unrecoverable error.

Signed-off-by: Vijay Lobo <vijaylobo@gmail.com>
Change-Id: Ia7246bf170f3289400a3b3c947ef9e67c06d2c46
diff --git a/extensions/openpower-pels/manager.cpp b/extensions/openpower-pels/manager.cpp
index 1372bf6..cedb787 100644
--- a/extensions/openpower-pels/manager.cpp
+++ b/extensions/openpower-pels/manager.cpp
@@ -93,6 +93,7 @@
     }
 
     setEntryPath(obmcLogID);
+    setServiceProviderNotifyFlag(obmcLogID);
 }
 
 void Manager::addRawPEL(const std::string& rawPelPath, uint32_t obmcLogID)
@@ -679,5 +680,26 @@
     }
 }
 
+void Manager::setServiceProviderNotifyFlag(uint32_t obmcLogID)
+{
+    Repository::LogID id{Repository::LogID::Obmc(obmcLogID)};
+    if (auto attributes = _repo.getPELAttributes(id); attributes)
+    {
+        auto& attr = attributes.value().get();
+        auto entry = _logManager.entries.find(obmcLogID);
+        if (entry != _logManager.entries.end())
+        {
+            if (attr.actionFlags.test(callHomeFlagBit))
+            {
+                entry->second->serviceProviderNotify(true);
+            }
+            else
+            {
+                entry->second->serviceProviderNotify(false);
+            }
+        }
+    }
+}
+
 } // namespace pels
 } // namespace openpower
diff --git a/extensions/openpower-pels/manager.hpp b/extensions/openpower-pels/manager.hpp
index dbadf9e..b2224cf 100644
--- a/extensions/openpower-pels/manager.hpp
+++ b/extensions/openpower-pels/manager.hpp
@@ -58,6 +58,7 @@
         for (const auto& entry : _logManager.entries)
         {
             setEntryPath(entry.first);
+            setServiceProviderNotifyFlag(entry.first);
         }
         setupPELDeleteWatch();
     }
@@ -354,6 +355,13 @@
     void setEntryPath(uint32_t obmcLogID);
 
     /**
+     * @brief Sets the serviceProviderNotify D-bus property of PEL.
+     *
+     * @param[in] obmcLogID - The OpenBMC entry log ID
+     */
+    void setServiceProviderNotifyFlag(uint32_t obmcLogID);
+
+    /**
      * @brief Reference to phosphor-logging's Manager class
      */
     phosphor::logging::internal::Manager& _logManager;