blob: 5f092f456a25c9f41879365e4aabeb8da151a142 [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 Spinler4e8078c2019-07-09 13:22:32 -05004#include "log_manager.hpp"
Matt Spinler89fa0822019-07-17 13:54:30 -05005#include "paths.hpp"
Matt Spinler367144c2019-09-19 15:33:52 -05006#include "registry.hpp"
Matt Spinler89fa0822019-07-17 13:54:30 -05007#include "repository.hpp"
Matt Spinler4e8078c2019-07-09 13:22:32 -05008
9namespace openpower
10{
11namespace pels
12{
13
Matt Spinler4e8078c2019-07-09 13:22:32 -050014/**
15 * @brief PEL manager object
16 */
17class 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 Spinlerc8705e22019-09-11 12:36:07 -050032 explicit Manager(phosphor::logging::internal::Manager& logManager,
33 std::unique_ptr<DataInterfaceBase>&& dataIface) :
34 _logManager(logManager),
Matt Spinler367144c2019-09-19 15:33:52 -050035 _repo(getPELRepoPath()),
36 _registry(getMessageRegistryPath() / message::registryFileName),
37 _dataIface(std::move(dataIface))
Matt Spinler4e8078c2019-07-09 13:22:32 -050038 {
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 Spinler367144c2019-09-19 15:33:52 -050054 uint64_t timestamp, phosphor::logging::Entry::Level severity,
Matt Spinler4e8078c2019-07-09 13:22:32 -050055 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 Spinler367144c2019-09-19 15:33:52 -050097 uint64_t timestamp, phosphor::logging::Entry::Level severity,
Matt Spinler4e8078c2019-07-09 13:22:32 -050098 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 Spinler367144c2019-09-19 15:33:52 -0500104 phosphor::logging::internal::Manager& _logManager;
Matt Spinler89fa0822019-07-17 13:54:30 -0500105
106 /**
107 * @brief The PEL repository object
108 */
109 Repository _repo;
Matt Spinlerc8705e22019-09-11 12:36:07 -0500110
111 /**
Matt Spinler367144c2019-09-19 15:33:52 -0500112 * @brief The PEL message registry object
113 */
114 message::Registry _registry;
115
116 /**
Matt Spinlerc8705e22019-09-11 12:36:07 -0500117 * @brief The API the PEL sections use to gather data
118 */
119 std::unique_ptr<DataInterfaceBase> _dataIface;
Matt Spinler4e8078c2019-07-09 13:22:32 -0500120};
121
122} // namespace pels
123} // namespace openpower