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 | f60ac27 | 2019-12-11 13:47:50 -0600 | [diff] [blame] | 4 | #include "host_notifier.hpp" |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 5 | #include "log_manager.hpp" |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 6 | #include "paths.hpp" |
Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 7 | #include "registry.hpp" |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 8 | #include "repository.hpp" |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 9 | |
| 10 | namespace openpower |
| 11 | { |
| 12 | namespace pels |
| 13 | { |
| 14 | |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 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 |
Matt Spinler | f60ac27 | 2019-12-11 13:47:50 -0600 | [diff] [blame] | 32 | * @param[in] dataIface - The data interface object |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 33 | */ |
Matt Spinler | f60ac27 | 2019-12-11 13:47:50 -0600 | [diff] [blame] | 34 | Manager(phosphor::logging::internal::Manager& logManager, |
| 35 | std::unique_ptr<DataInterfaceBase> dataIface) : |
Matt Spinler | c8705e2 | 2019-09-11 12:36:07 -0500 | [diff] [blame] | 36 | _logManager(logManager), |
Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 37 | _repo(getPELRepoPath()), |
| 38 | _registry(getMessageRegistryPath() / message::registryFileName), |
| 39 | _dataIface(std::move(dataIface)) |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 40 | { |
| 41 | } |
| 42 | |
| 43 | /** |
Matt Spinler | f60ac27 | 2019-12-11 13:47:50 -0600 | [diff] [blame] | 44 | * @brief constructor that enables host notification |
| 45 | * |
| 46 | * @param[in] logManager - internal::Manager object |
| 47 | * @param[in] dataIface - The data interface object |
| 48 | * @param[in] hostIface - The hostInterface object |
| 49 | */ |
| 50 | Manager(phosphor::logging::internal::Manager& logManager, |
| 51 | std::unique_ptr<DataInterfaceBase> dataIface, |
| 52 | std::unique_ptr<HostInterface> hostIface) : |
| 53 | Manager(logManager, std::move(dataIface)) |
| 54 | { |
| 55 | _hostNotifier = std::make_unique<HostNotifier>( |
| 56 | _repo, *(_dataIface.get()), std::move(hostIface)); |
| 57 | } |
| 58 | |
| 59 | /** |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 60 | * @brief Creates a PEL based on the OpenBMC event log contents. If |
| 61 | * a PEL was passed in via the RAWPEL specifier in the |
| 62 | * additionalData parameter, use that instead. |
| 63 | * |
| 64 | * @param[in] message - the event log message property |
| 65 | * @param[in] obmcLogID - the corresponding OpenBMC event log id |
| 66 | * @param[in] timestamp - the Timestamp property |
| 67 | * @param[in] severity - the event log severity |
| 68 | * @param[in] additionalData - the AdditionalData property |
| 69 | * @param[in] associations - the Associations property |
| 70 | */ |
| 71 | void create(const std::string& message, uint32_t obmcLogID, |
Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 72 | uint64_t timestamp, phosphor::logging::Entry::Level severity, |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 73 | const std::vector<std::string>& additionalData, |
| 74 | const std::vector<std::string>& associations); |
| 75 | |
| 76 | /** |
| 77 | * @brief Erase a PEL based on its OpenBMC event log ID |
| 78 | * |
| 79 | * @param[in] obmcLogID - the corresponding OpenBMC event log id |
| 80 | */ |
| 81 | void erase(uint32_t obmcLogID); |
| 82 | |
| 83 | /** @brief Says if an OpenBMC event log may not be manually deleted at this |
| 84 | * time because its corresponding PEL cannot be. |
| 85 | * |
| 86 | * There are PEL retention policies that can prohibit the manual deletion |
| 87 | * of PELs (and therefore OpenBMC event logs). |
| 88 | * |
| 89 | * @param[in] obmcLogID - the OpenBMC event log ID |
| 90 | * @return bool - true if prohibited |
| 91 | */ |
| 92 | bool isDeleteProhibited(uint32_t obmcLogID); |
| 93 | |
| 94 | private: |
| 95 | /** |
| 96 | * @brief Adds a received raw PEL to the PEL repository |
| 97 | * |
| 98 | * @param[in] rawPelPath - The path to the file that contains the |
| 99 | * raw PEL. |
| 100 | * @param[in] obmcLogID - the corresponding OpenBMC event log id |
| 101 | */ |
| 102 | void addRawPEL(const std::string& rawPelPath, uint32_t obmcLogID); |
| 103 | |
| 104 | /** |
| 105 | * @brief Creates a PEL based on the OpenBMC event log contents. |
| 106 | * |
| 107 | * @param[in] message - The event log message property |
| 108 | * @param[in] obmcLogID - the corresponding OpenBMC event log id |
| 109 | * @param[in] timestamp - The timestamp property |
| 110 | * @param[in] severity - The event log severity |
| 111 | * @param[in] additionalData - The AdditionalData property |
| 112 | * @param[in] associations - The associations property |
| 113 | */ |
| 114 | void createPEL(const std::string& message, uint32_t obmcLogID, |
Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 115 | uint64_t timestamp, phosphor::logging::Entry::Level severity, |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 116 | const std::vector<std::string>& additionalData, |
| 117 | const std::vector<std::string>& associations); |
| 118 | |
| 119 | /** |
| 120 | * @brief Reference to phosphor-logging's Manager class |
| 121 | */ |
Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 122 | phosphor::logging::internal::Manager& _logManager; |
Matt Spinler | 89fa082 | 2019-07-17 13:54:30 -0500 | [diff] [blame] | 123 | |
| 124 | /** |
| 125 | * @brief The PEL repository object |
| 126 | */ |
| 127 | Repository _repo; |
Matt Spinler | c8705e2 | 2019-09-11 12:36:07 -0500 | [diff] [blame] | 128 | |
| 129 | /** |
Matt Spinler | 367144c | 2019-09-19 15:33:52 -0500 | [diff] [blame] | 130 | * @brief The PEL message registry object |
| 131 | */ |
| 132 | message::Registry _registry; |
| 133 | |
| 134 | /** |
Matt Spinler | c8705e2 | 2019-09-11 12:36:07 -0500 | [diff] [blame] | 135 | * @brief The API the PEL sections use to gather data |
| 136 | */ |
| 137 | std::unique_ptr<DataInterfaceBase> _dataIface; |
Matt Spinler | f60ac27 | 2019-12-11 13:47:50 -0600 | [diff] [blame] | 138 | |
| 139 | /** |
| 140 | * @brief The HostNotifier object used for telling the |
| 141 | * host about new PELs |
| 142 | */ |
| 143 | std::unique_ptr<HostNotifier> _hostNotifier; |
Matt Spinler | 4e8078c | 2019-07-09 13:22:32 -0500 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | } // namespace pels |
| 147 | } // namespace openpower |