14e8078c0SMatt Spinler #pragma once
24e8078c0SMatt Spinler 
3c8705e2bSMatt Spinler #include "data_interface.hpp"
44e8078c0SMatt Spinler #include "log_manager.hpp"
589fa082aSMatt Spinler #include "paths.hpp"
6*367144cfSMatt Spinler #include "registry.hpp"
789fa082aSMatt Spinler #include "repository.hpp"
84e8078c0SMatt Spinler 
94e8078c0SMatt Spinler namespace openpower
104e8078c0SMatt Spinler {
114e8078c0SMatt Spinler namespace pels
124e8078c0SMatt Spinler {
134e8078c0SMatt Spinler 
144e8078c0SMatt Spinler /**
154e8078c0SMatt Spinler  * @brief PEL manager object
164e8078c0SMatt Spinler  */
174e8078c0SMatt Spinler class Manager
184e8078c0SMatt Spinler {
194e8078c0SMatt Spinler   public:
204e8078c0SMatt Spinler     Manager() = delete;
214e8078c0SMatt Spinler     ~Manager() = default;
224e8078c0SMatt Spinler     Manager(const Manager&) = default;
234e8078c0SMatt Spinler     Manager& operator=(const Manager&) = default;
244e8078c0SMatt Spinler     Manager(Manager&&) = default;
254e8078c0SMatt Spinler     Manager& operator=(Manager&&) = default;
264e8078c0SMatt Spinler 
274e8078c0SMatt Spinler     /**
284e8078c0SMatt Spinler      * @brief constructor
294e8078c0SMatt Spinler      *
304e8078c0SMatt Spinler      * @param[in] logManager - internal::Manager object
314e8078c0SMatt Spinler      */
32c8705e2bSMatt Spinler     explicit Manager(phosphor::logging::internal::Manager& logManager,
33c8705e2bSMatt Spinler                      std::unique_ptr<DataInterfaceBase>&& dataIface) :
34c8705e2bSMatt Spinler         _logManager(logManager),
35*367144cfSMatt Spinler         _repo(getPELRepoPath()),
36*367144cfSMatt Spinler         _registry(getMessageRegistryPath() / message::registryFileName),
37*367144cfSMatt Spinler         _dataIface(std::move(dataIface))
384e8078c0SMatt Spinler     {
394e8078c0SMatt Spinler     }
404e8078c0SMatt Spinler 
414e8078c0SMatt Spinler     /**
424e8078c0SMatt Spinler      * @brief Creates a PEL based on the OpenBMC event log contents.  If
434e8078c0SMatt Spinler      *        a PEL was passed in via the RAWPEL specifier in the
444e8078c0SMatt Spinler      *        additionalData parameter, use that instead.
454e8078c0SMatt Spinler      *
464e8078c0SMatt Spinler      * @param[in] message - the event log message property
474e8078c0SMatt Spinler      * @param[in] obmcLogID - the corresponding OpenBMC event log id
484e8078c0SMatt Spinler      * @param[in] timestamp - the Timestamp property
494e8078c0SMatt Spinler      * @param[in] severity - the event log severity
504e8078c0SMatt Spinler      * @param[in] additionalData - the AdditionalData property
514e8078c0SMatt Spinler      * @param[in] associations - the Associations property
524e8078c0SMatt Spinler      */
534e8078c0SMatt Spinler     void create(const std::string& message, uint32_t obmcLogID,
54*367144cfSMatt Spinler                 uint64_t timestamp, phosphor::logging::Entry::Level severity,
554e8078c0SMatt Spinler                 const std::vector<std::string>& additionalData,
564e8078c0SMatt Spinler                 const std::vector<std::string>& associations);
574e8078c0SMatt Spinler 
584e8078c0SMatt Spinler     /**
594e8078c0SMatt Spinler      * @brief Erase a PEL based on its OpenBMC event log ID
604e8078c0SMatt Spinler      *
614e8078c0SMatt Spinler      * @param[in] obmcLogID - the corresponding OpenBMC event log id
624e8078c0SMatt Spinler      */
634e8078c0SMatt Spinler     void erase(uint32_t obmcLogID);
644e8078c0SMatt Spinler 
654e8078c0SMatt Spinler     /** @brief Says if an OpenBMC event log may not be manually deleted at this
664e8078c0SMatt Spinler      *         time because its corresponding PEL cannot be.
674e8078c0SMatt Spinler      *
684e8078c0SMatt Spinler      * There are PEL retention policies that can prohibit the manual deletion
694e8078c0SMatt Spinler      * of PELs (and therefore OpenBMC event logs).
704e8078c0SMatt Spinler      *
714e8078c0SMatt Spinler      * @param[in] obmcLogID - the OpenBMC event log ID
724e8078c0SMatt Spinler      * @return bool - true if prohibited
734e8078c0SMatt Spinler      */
744e8078c0SMatt Spinler     bool isDeleteProhibited(uint32_t obmcLogID);
754e8078c0SMatt Spinler 
764e8078c0SMatt Spinler   private:
774e8078c0SMatt Spinler     /**
784e8078c0SMatt Spinler      * @brief Adds a received raw PEL to the PEL repository
794e8078c0SMatt Spinler      *
804e8078c0SMatt Spinler      * @param[in] rawPelPath - The path to the file that contains the
814e8078c0SMatt Spinler      *                         raw PEL.
824e8078c0SMatt Spinler      * @param[in] obmcLogID - the corresponding OpenBMC event log id
834e8078c0SMatt Spinler      */
844e8078c0SMatt Spinler     void addRawPEL(const std::string& rawPelPath, uint32_t obmcLogID);
854e8078c0SMatt Spinler 
864e8078c0SMatt Spinler     /**
874e8078c0SMatt Spinler      * @brief Creates a PEL based on the OpenBMC event log contents.
884e8078c0SMatt Spinler      *
894e8078c0SMatt Spinler      * @param[in] message - The event log message property
904e8078c0SMatt Spinler      * @param[in] obmcLogID - the corresponding OpenBMC event log id
914e8078c0SMatt Spinler      * @param[in] timestamp - The timestamp property
924e8078c0SMatt Spinler      * @param[in] severity - The event log severity
934e8078c0SMatt Spinler      * @param[in] additionalData - The AdditionalData property
944e8078c0SMatt Spinler      * @param[in] associations - The associations property
954e8078c0SMatt Spinler      */
964e8078c0SMatt Spinler     void createPEL(const std::string& message, uint32_t obmcLogID,
97*367144cfSMatt Spinler                    uint64_t timestamp, phosphor::logging::Entry::Level severity,
984e8078c0SMatt Spinler                    const std::vector<std::string>& additionalData,
994e8078c0SMatt Spinler                    const std::vector<std::string>& associations);
1004e8078c0SMatt Spinler 
1014e8078c0SMatt Spinler     /**
1024e8078c0SMatt Spinler      * @brief Reference to phosphor-logging's Manager class
1034e8078c0SMatt Spinler      */
104*367144cfSMatt Spinler     phosphor::logging::internal::Manager& _logManager;
10589fa082aSMatt Spinler 
10689fa082aSMatt Spinler     /**
10789fa082aSMatt Spinler      * @brief The PEL repository object
10889fa082aSMatt Spinler      */
10989fa082aSMatt Spinler     Repository _repo;
110c8705e2bSMatt Spinler 
111c8705e2bSMatt Spinler     /**
112*367144cfSMatt Spinler      * @brief The PEL message registry object
113*367144cfSMatt Spinler      */
114*367144cfSMatt Spinler     message::Registry _registry;
115*367144cfSMatt Spinler 
116*367144cfSMatt Spinler     /**
117c8705e2bSMatt Spinler      * @brief The API the PEL sections use to gather data
118c8705e2bSMatt Spinler      */
119c8705e2bSMatt Spinler     std::unique_ptr<DataInterfaceBase> _dataIface;
1204e8078c0SMatt Spinler };
1214e8078c0SMatt Spinler 
1224e8078c0SMatt Spinler } // namespace pels
1234e8078c0SMatt Spinler } // namespace openpower
124