PEL: Implement CreatePELWithFFDCFiles

This D-Bus method on the org.open_power.Logging.PEL interface is the
same as the already existing createWithFFDCFiles method on the
xyz.openbmc_project.Logging.Create interface, except it also returns the
IDs of the newly created OpenBMC event log and PEL.

Code was added to track the IDs of the most recently added event log and
PEL so they they can be returned by the function.

Change-Id: I3a1e0d93f97aa1953ff8b10293b47e28f79edfb1
diff --git a/extensions/openpower-pels/manager.cpp b/extensions/openpower-pels/manager.cpp
index 3c9b2cb..db9f9e3 100644
--- a/extensions/openpower-pels/manager.cpp
+++ b/extensions/openpower-pels/manager.cpp
@@ -583,7 +583,9 @@
         uint8_t, uint8_t, sdbusplus::message::unix_fd>>
         fFDC)
 {
-    return {0, 0};
+    _logManager.createWithFFDC(message, severity, additionalData, fFDC);
+
+    return {_logManager.lastEntryID(), _repo.lastPelID()};
 }
 
 void Manager::checkPelAndQuiesce(std::unique_ptr<openpower::pels::PEL>& pel)
diff --git a/extensions/openpower-pels/manager.hpp b/extensions/openpower-pels/manager.hpp
index e726812..fa5a469 100644
--- a/extensions/openpower-pels/manager.hpp
+++ b/extensions/openpower-pels/manager.hpp
@@ -10,12 +10,12 @@
 #include "pel.hpp"
 #include "registry.hpp"
 #include "repository.hpp"
-#include "xyz/openbmc_project/Logging/Create/server.hpp"
 
 #include <org/open_power/Logging/PEL/server.hpp>
 #include <sdbusplus/server.hpp>
 #include <sdeventplus/event.hpp>
 #include <sdeventplus/source/event.hpp>
+#include <xyz/openbmc_project/Logging/Create/server.hpp>
 
 namespace openpower
 {
@@ -171,13 +171,26 @@
      */
     void hostReject(uint32_t pelID, RejectionReason reason) override;
 
+    /**
+     * @brief D-Bus method to create a PEL/OpenBMC event log and
+     *        return the created OpenBMC and PEL log IDs.
+     *
+     * The same as the CreateWithFFDCFiles method on the
+     * xyz.openbmc_project.Logging.Create interface, except for
+     * the return values.
+     *
+     * @param[in] message - The event log message property
+     * @param[in] severity - The event log severity
+     * @param[in] additionalData - The AdditionalData property
+     * @param[in] ffdc - A vector of FFDC file information
+     */
     std::tuple<uint32_t, uint32_t> createPELWithFFDCFiles(
         std::string message, phosphor::logging::Entry::Level severity,
         std::map<std::string, std::string> additionalData,
         std::vector<std::tuple<sdbusplus::xyz::openbmc_project::Logging::
                                    server::Create::FFDCFormat,
                                uint8_t, uint8_t, sdbusplus::message::unix_fd>>
-            fFDC);
+            fFDC) override;
 
     /**
      * @brief Converts the ESEL field in an OpenBMC event log to a
diff --git a/extensions/openpower-pels/repository.cpp b/extensions/openpower-pels/repository.cpp
index e9e5a18..e044e1d 100644
--- a/extensions/openpower-pels/repository.cpp
+++ b/extensions/openpower-pels/repository.cpp
@@ -171,6 +171,8 @@
     _pelAttributes.emplace(LogID(pelID(pel->id()), obmcID(pel->obmcLogID())),
                            attributes);
 
+    _lastPelID = pel->id();
+
     updateRepoStats(attributes, true);
 
     processAddCallbacks(*pel);
diff --git a/extensions/openpower-pels/repository.hpp b/extensions/openpower-pels/repository.hpp
index 9bb71e4..e2f497b 100644
--- a/extensions/openpower-pels/repository.hpp
+++ b/extensions/openpower-pels/repository.hpp
@@ -415,6 +415,16 @@
         return _logPath;
     }
 
+    /**
+     * @brief Returns the ID of the most recently added PEL.
+     *
+     * @return uint32_t - The PEL ID
+     */
+    uint32_t lastPelID() const
+    {
+        return _lastPelID;
+    }
+
   private:
     using PELUpdateFunc = std::function<void(PEL&)>;
 
@@ -560,6 +570,11 @@
      * @brief Statistics on the sizes of the stored PELs.
      */
     SizeStats _sizes;
+
+    /**
+     * @brief The ID of the most recently added PEL.
+     */
+    uint32_t _lastPelID = 0;
 };
 
 } // namespace pels