extensions: pels: Add PEL path to elog entry

Populate the path property of the error log entry with the path
to the PEL path. This requires making the entries map public.

Restore the value of the path for the entries when the PEL
manager starts up once the Repository has verified each PEL file.

Tested: Verified the PEL path was populated in the path property
        and that it was re-populated after restarting the app.
root@openbmc:~# busctl --no-pager get-property xyz.openbmc_project.Logging \
  /xyz/openbmc_project/logging/entry/884 xyz.openbmc_project.Common.FilePath Path
s "/var/lib/phosphor-logging/extensions/pels/logs/2020120522023306_50000D30"

Change-Id: I2a7315bbc3f0f4699e77aadbc7da05818c0c15e3
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/extensions/openpower-pels/manager.cpp b/extensions/openpower-pels/manager.cpp
index db9f9e3..ca8c54c 100644
--- a/extensions/openpower-pels/manager.cpp
+++ b/extensions/openpower-pels/manager.cpp
@@ -91,6 +91,8 @@
                       associations, ffdc);
         }
     }
+
+    setEntryPath(obmcLogID);
 }
 
 void Manager::addRawPEL(const std::string& rawPelPath, uint32_t obmcLogID)
@@ -612,5 +614,19 @@
     }
 }
 
+void Manager::setEntryPath(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())
+        {
+            entry->second->path(attr.path);
+        }
+    }
+}
+
 } // namespace pels
 } // namespace openpower
diff --git a/extensions/openpower-pels/manager.hpp b/extensions/openpower-pels/manager.hpp
index fa5a469..2354319 100644
--- a/extensions/openpower-pels/manager.hpp
+++ b/extensions/openpower-pels/manager.hpp
@@ -55,6 +55,10 @@
         _event(sdeventplus::Event::get_default()),
         _dataIface(std::move(dataIface))
     {
+        for (const auto& entry : _logManager.entries)
+        {
+            setEntryPath(entry.first);
+        }
         setupPELDeleteWatch();
     }
 
@@ -325,6 +329,14 @@
     void checkPelAndQuiesce(std::unique_ptr<openpower::pels::PEL>& pel);
 
     /**
+     * @brief Sets the FilePath of the specified error log entry to the PEL file
+     *        path.
+     *
+     * @param[in] obmcLogID - The OpenBMC entry log ID
+     */
+    void setEntryPath(uint32_t obmcLogID);
+
+    /**
      * @brief Reference to phosphor-logging's Manager class
      */
     phosphor::logging::internal::Manager& _logManager;
diff --git a/log_manager.cpp b/log_manager.cpp
index 98be0d1..756ee4f 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -239,11 +239,12 @@
         quiesceOnError(entryId);
     }
 
-    doExtensionLogCreate(*e, ffdc);
+    // Add entry before calling the extensions so that they have access to it
+    entries.insert(std::make_pair(entryId, std::move(e)));
+
+    doExtensionLogCreate(*entries.find(entryId)->second, ffdc);
 
     // Note: No need to close the file descriptors in the FFDC.
-
-    entries.insert(std::make_pair(entryId, std::move(e)));
 }
 
 bool Manager::isQuiesceOnErrorEnabled()
diff --git a/log_manager.hpp b/log_manager.hpp
index 2303269..7437f4e 100644
--- a/log_manager.hpp
+++ b/log_manager.hpp
@@ -231,6 +231,9 @@
      */
     void checkAndRemoveBlockingError(uint32_t entryId);
 
+    /** @brief Persistent map of Entry dbus objects and their ID */
+    std::map<uint32_t, std::unique_ptr<Entry>> entries;
+
   private:
     /*
      * @fn _commit()
@@ -311,9 +314,6 @@
     /** @brief Persistent sdbusplus DBus bus connection. */
     sdbusplus::bus::bus& busLog;
 
-    /** @brief Persistent map of Entry dbus objects and their ID */
-    std::map<uint32_t, std::unique_ptr<Entry>> entries;
-
     /** @brief List of error ids for high severity errors */
     std::list<uint32_t> realErrors;