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