Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Matt Spinler | c8705e2 | 2019-09-11 12:36:07 -0500 | [diff] [blame] | 3 | #include "data_interface.hpp" |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 4 | #include "log_manager.hpp" |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 5 | #include "paths.hpp" |
Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 6 | #include "registry.hpp" |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 7 | #include "repository.hpp" |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 8 | |
| 9 | namespace openpower |
| 10 | { |
| 11 | namespace pels |
| 12 | { |
| 13 | |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 14 | /** |
| 15 | * @brief PEL manager object |
| 16 | */ |
| 17 | class Manager |
| 18 | { |
| 19 | public: |
| 20 | Manager() = delete; |
| 21 | ~Manager() = default; |
| 22 | Manager(const Manager&) = default; |
| 23 | Manager& operator=(const Manager&) = default; |
| 24 | Manager(Manager&&) = default; |
| 25 | Manager& operator=(Manager&&) = default; |
| 26 | |
| 27 | /** |
| 28 | * @brief constructor |
| 29 | * |
| 30 | * @param[in] logManager - internal::Manager object |
| 31 | */ |
Matt Spinler | c8705e2 | 2019-09-11 12:36:07 -0500 | [diff] [blame] | 32 | explicit Manager(phosphor::logging::internal::Manager& logManager, |
| 33 | std::unique_ptr<DataInterfaceBase>&& dataIface) : |
| 34 | _logManager(logManager), |
Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 35 | _repo(getPELRepoPath()), |
| 36 | _registry(getMessageRegistryPath() / message::registryFileName), |
| 37 | _dataIface(std::move(dataIface)) |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 38 | { |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * @brief Creates a PEL based on the OpenBMC event log contents. If |
| 43 | * a PEL was passed in via the RAWPEL specifier in the |
| 44 | * additionalData parameter, use that instead. |
| 45 | * |
| 46 | * @param[in] message - the event log message property |
| 47 | * @param[in] obmcLogID - the corresponding OpenBMC event log id |
| 48 | * @param[in] timestamp - the Timestamp property |
| 49 | * @param[in] severity - the event log severity |
| 50 | * @param[in] additionalData - the AdditionalData property |
| 51 | * @param[in] associations - the Associations property |
| 52 | */ |
| 53 | void create(const std::string& message, uint32_t obmcLogID, |
Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 54 | uint64_t timestamp, phosphor::logging::Entry::Level severity, |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 55 | const std::vector<std::string>& additionalData, |
| 56 | const std::vector<std::string>& associations); |
| 57 | |
| 58 | /** |
| 59 | * @brief Erase a PEL based on its OpenBMC event log ID |
| 60 | * |
| 61 | * @param[in] obmcLogID - the corresponding OpenBMC event log id |
| 62 | */ |
| 63 | void erase(uint32_t obmcLogID); |
| 64 | |
| 65 | /** @brief Says if an OpenBMC event log may not be manually deleted at this |
| 66 | * time because its corresponding PEL cannot be. |
| 67 | * |
| 68 | * There are PEL retention policies that can prohibit the manual deletion |
| 69 | * of PELs (and therefore OpenBMC event logs). |
| 70 | * |
| 71 | * @param[in] obmcLogID - the OpenBMC event log ID |
| 72 | * @return bool - true if prohibited |
| 73 | */ |
| 74 | bool isDeleteProhibited(uint32_t obmcLogID); |
| 75 | |
| 76 | private: |
| 77 | /** |
| 78 | * @brief Adds a received raw PEL to the PEL repository |
| 79 | * |
| 80 | * @param[in] rawPelPath - The path to the file that contains the |
| 81 | * raw PEL. |
| 82 | * @param[in] obmcLogID - the corresponding OpenBMC event log id |
| 83 | */ |
| 84 | void addRawPEL(const std::string& rawPelPath, uint32_t obmcLogID); |
| 85 | |
| 86 | /** |
| 87 | * @brief Creates a PEL based on the OpenBMC event log contents. |
| 88 | * |
| 89 | * @param[in] message - The event log message property |
| 90 | * @param[in] obmcLogID - the corresponding OpenBMC event log id |
| 91 | * @param[in] timestamp - The timestamp property |
| 92 | * @param[in] severity - The event log severity |
| 93 | * @param[in] additionalData - The AdditionalData property |
| 94 | * @param[in] associations - The associations property |
| 95 | */ |
| 96 | void createPEL(const std::string& message, uint32_t obmcLogID, |
Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 97 | uint64_t timestamp, phosphor::logging::Entry::Level severity, |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 98 | const std::vector<std::string>& additionalData, |
| 99 | const std::vector<std::string>& associations); |
| 100 | |
| 101 | /** |
| 102 | * @brief Reference to phosphor-logging's Manager class |
| 103 | */ |
Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 104 | phosphor::logging::internal::Manager& _logManager; |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * @brief The PEL repository object |
| 108 | */ |
| 109 | Repository _repo; |
Matt Spinler | c8705e2 | 2019-09-11 12:36:07 -0500 | [diff] [blame] | 110 | |
| 111 | /** |
Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 112 | * @brief The PEL message registry object |
| 113 | */ |
| 114 | message::Registry _registry; |
| 115 | |
| 116 | /** |
Matt Spinler | c8705e2 | 2019-09-11 12:36:07 -0500 | [diff] [blame] | 117 | * @brief The API the PEL sections use to gather data |
| 118 | */ |
| 119 | std::unique_ptr<DataInterfaceBase> _dataIface; |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 120 | }; |
| 121 | |
| 122 | } // namespace pels |
| 123 | } // namespace openpower |