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