blob: 731dd16ec334266d3042c1b8dfade79c0e42df2b [file] [log] [blame]
Matt Spinler4e8078c2019-07-09 13:22:32 -05001#pragma once
2
Matt Spinlerc8705e22019-09-11 12:36:07 -05003#include "data_interface.hpp"
Matt Spinlerf60ac272019-12-11 13:47:50 -06004#include "host_notifier.hpp"
Matt Spinler4e8078c2019-07-09 13:22:32 -05005#include "log_manager.hpp"
Matt Spinler89fa0822019-07-17 13:54:30 -05006#include "paths.hpp"
Matt Spinler367144c2019-09-19 15:33:52 -05007#include "registry.hpp"
Matt Spinler89fa0822019-07-17 13:54:30 -05008#include "repository.hpp"
Matt Spinler4e8078c2019-07-09 13:22:32 -05009
10namespace openpower
11{
12namespace pels
13{
14
Matt Spinler4e8078c2019-07-09 13:22:32 -050015/**
16 * @brief PEL manager object
17 */
18class 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 Spinlerf60ac272019-12-11 13:47:50 -060032 * @param[in] dataIface - The data interface object
Matt Spinler4e8078c2019-07-09 13:22:32 -050033 */
Matt Spinlerf60ac272019-12-11 13:47:50 -060034 Manager(phosphor::logging::internal::Manager& logManager,
35 std::unique_ptr<DataInterfaceBase> dataIface) :
Matt Spinlerc8705e22019-09-11 12:36:07 -050036 _logManager(logManager),
Matt Spinler367144c2019-09-19 15:33:52 -050037 _repo(getPELRepoPath()),
38 _registry(getMessageRegistryPath() / message::registryFileName),
39 _dataIface(std::move(dataIface))
Matt Spinler4e8078c2019-07-09 13:22:32 -050040 {
41 }
42
43 /**
Matt Spinlerf60ac272019-12-11 13:47:50 -060044 * @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 Spinler4e8078c2019-07-09 13:22:32 -050060 * @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 Spinler367144c2019-09-19 15:33:52 -050072 uint64_t timestamp, phosphor::logging::Entry::Level severity,
Matt Spinler4e8078c2019-07-09 13:22:32 -050073 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 Spinler367144c2019-09-19 15:33:52 -0500115 uint64_t timestamp, phosphor::logging::Entry::Level severity,
Matt Spinler4e8078c2019-07-09 13:22:32 -0500116 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 Spinler367144c2019-09-19 15:33:52 -0500122 phosphor::logging::internal::Manager& _logManager;
Matt Spinler89fa0822019-07-17 13:54:30 -0500123
124 /**
125 * @brief The PEL repository object
126 */
127 Repository _repo;
Matt Spinlerc8705e22019-09-11 12:36:07 -0500128
129 /**
Matt Spinler367144c2019-09-19 15:33:52 -0500130 * @brief The PEL message registry object
131 */
132 message::Registry _registry;
133
134 /**
Matt Spinlerc8705e22019-09-11 12:36:07 -0500135 * @brief The API the PEL sections use to gather data
136 */
137 std::unique_ptr<DataInterfaceBase> _dataIface;
Matt Spinlerf60ac272019-12-11 13:47:50 -0600138
139 /**
140 * @brief The HostNotifier object used for telling the
141 * host about new PELs
142 */
143 std::unique_ptr<HostNotifier> _hostNotifier;
Matt Spinler4e8078c2019-07-09 13:22:32 -0500144};
145
146} // namespace pels
147} // namespace openpower