Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include <sdbusplus/server/object.hpp> |
| 5 | #include "xyz/openbmc_project/Logging/Entry/server.hpp" |
Deepak Kodihalli | 36db46c | 2017-03-31 06:28:44 -0500 | [diff] [blame] | 6 | #include "xyz/openbmc_project/Object/Delete/server.hpp" |
Deepak Kodihalli | b388da6 | 2017-02-27 00:47:12 -0600 | [diff] [blame] | 7 | #include "org/openbmc/Associations/server.hpp" |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 8 | |
| 9 | namespace phosphor |
| 10 | { |
| 11 | namespace logging |
| 12 | { |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 13 | |
Deepak Kodihalli | b388da6 | 2017-02-27 00:47:12 -0600 | [diff] [blame] | 14 | using EntryIfaces = sdbusplus::server::object::object< |
| 15 | sdbusplus::xyz::openbmc_project::Logging::server::Entry, |
Deepak Kodihalli | 36db46c | 2017-03-31 06:28:44 -0500 | [diff] [blame] | 16 | sdbusplus::xyz::openbmc_project::Object::server::Delete, |
Deepak Kodihalli | b388da6 | 2017-02-27 00:47:12 -0600 | [diff] [blame] | 17 | sdbusplus::org::openbmc::server::Associations>; |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 18 | |
Deepak Kodihalli | 35b4637 | 2017-02-27 04:58:18 -0600 | [diff] [blame] | 19 | using AssociationList = |
| 20 | std::vector<std::tuple<std::string, std::string, std::string>>; |
| 21 | |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 22 | namespace internal |
| 23 | { |
Deepak Kodihalli | 8110ca6 | 2017-04-10 02:11:54 -0500 | [diff] [blame] | 24 | class Manager; |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 25 | } |
Deepak Kodihalli | 8110ca6 | 2017-04-10 02:11:54 -0500 | [diff] [blame] | 26 | |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 27 | /** @class Entry |
| 28 | * @brief OpenBMC logging entry implementation. |
| 29 | * @details A concrete implementation for the |
Deepak Kodihalli | b388da6 | 2017-02-27 00:47:12 -0600 | [diff] [blame] | 30 | * xyz.openbmc_project.Logging.Entry and |
| 31 | * org.openbmc.Associations DBus APIs. |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 32 | */ |
Deepak Kodihalli | b388da6 | 2017-02-27 00:47:12 -0600 | [diff] [blame] | 33 | class Entry : public EntryIfaces |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 34 | { |
| 35 | public: |
| 36 | Entry() = delete; |
| 37 | Entry(const Entry&) = delete; |
| 38 | Entry& operator=(const Entry&) = delete; |
| 39 | Entry(Entry&&) = delete; |
| 40 | Entry& operator=(Entry&&) = delete; |
| 41 | virtual ~Entry() = default; |
| 42 | |
Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 43 | /** @brief Constructor to put object onto bus at a dbus path. |
Adriana Kobylak | 4ea7f31 | 2017-01-10 12:52:34 -0600 | [diff] [blame] | 44 | * Defer signal registration (pass true for deferSignal to the |
| 45 | * base class) until after the properties are set. |
Adriana Kobylak | df995fa | 2017-01-08 15:14:02 -0600 | [diff] [blame] | 46 | * @param[in] bus - Bus to attach to. |
| 47 | * @param[in] path - Path to attach at. |
Adriana Kobylak | c5f0bbd | 2017-01-22 14:56:04 -0600 | [diff] [blame] | 48 | * @param[in] idErr - The error entry id. |
| 49 | * @param[in] timestampErr - The commit timestamp. |
| 50 | * @param[in] severityErr - The severity of the error. |
| 51 | * @param[in] msgErr - The message of the error. |
| 52 | * @param[in] additionalDataErr - The error metadata. |
Deepak Kodihalli | 8110ca6 | 2017-04-10 02:11:54 -0500 | [diff] [blame] | 53 | * @param[in] parent - The error's parent. |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 54 | */ |
Adriana Kobylak | 4ea7f31 | 2017-01-10 12:52:34 -0600 | [diff] [blame] | 55 | Entry(sdbusplus::bus::bus& bus, |
| 56 | const std::string& path, |
| 57 | uint32_t idErr, |
Adriana Kobylak | c5f0bbd | 2017-01-22 14:56:04 -0600 | [diff] [blame] | 58 | uint64_t timestampErr, |
Adriana Kobylak | 4ea7f31 | 2017-01-10 12:52:34 -0600 | [diff] [blame] | 59 | Level severityErr, |
| 60 | std::string&& msgErr, |
Deepak Kodihalli | 35b4637 | 2017-02-27 04:58:18 -0600 | [diff] [blame] | 61 | std::vector<std::string>&& additionalDataErr, |
Deepak Kodihalli | 8110ca6 | 2017-04-10 02:11:54 -0500 | [diff] [blame] | 62 | AssociationList&& objects, |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 63 | internal::Manager& parent) : |
Deepak Kodihalli | 8110ca6 | 2017-04-10 02:11:54 -0500 | [diff] [blame] | 64 | EntryIfaces(bus, path.c_str(), true), |
| 65 | parent(parent) |
Adriana Kobylak | 4ea7f31 | 2017-01-10 12:52:34 -0600 | [diff] [blame] | 66 | { |
| 67 | id(idErr); |
| 68 | severity(severityErr); |
Adriana Kobylak | c5f0bbd | 2017-01-22 14:56:04 -0600 | [diff] [blame] | 69 | timestamp(timestampErr); |
Adriana Kobylak | 4ea7f31 | 2017-01-10 12:52:34 -0600 | [diff] [blame] | 70 | message(std::move(msgErr)); |
| 71 | additionalData(std::move(additionalDataErr)); |
Deepak Kodihalli | 35b4637 | 2017-02-27 04:58:18 -0600 | [diff] [blame] | 72 | associations(std::move(objects)); |
Deepak Kodihalli | 16aed11 | 2017-03-31 00:11:46 -0500 | [diff] [blame] | 73 | // Store a copy of associations in case we need to recreate |
| 74 | assocs = associations(); |
Deepak Kodihalli | 9743189 | 2017-06-12 09:14:57 -0500 | [diff] [blame] | 75 | sdbusplus::xyz::openbmc_project:: |
| 76 | Logging::server::Entry::resolved(false); |
Adriana Kobylak | 4ea7f31 | 2017-01-10 12:52:34 -0600 | [diff] [blame] | 77 | |
| 78 | // Emit deferred signal. |
| 79 | this->emit_object_added(); |
| 80 | }; |
| 81 | |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 82 | /** @brief Constructor that puts an "empty" error object on the bus, |
| 83 | * with only the id property populated. Rest of the properties |
| 84 | * to be set by the caller. Caller should emit the added signal. |
| 85 | * @param[in] bus - Bus to attach to. |
| 86 | * @param[in] path - Path to attach at. |
| 87 | * @param[in] id - The error entry id. |
| 88 | * @param[in] parent - The error's parent. |
| 89 | */ |
| 90 | Entry(sdbusplus::bus::bus& bus, |
| 91 | const std::string& path, |
| 92 | uint32_t entryId, |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 93 | internal::Manager& parent) : |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 94 | EntryIfaces(bus, path.c_str(), true), |
| 95 | parent(parent) |
| 96 | { |
| 97 | id(entryId); |
| 98 | }; |
| 99 | |
Deepak Kodihalli | 90abed6 | 2017-03-27 03:56:44 -0500 | [diff] [blame] | 100 | /** @brief Set resolution status of the error. |
| 101 | * @param[in] value - boolean indicating resolution |
| 102 | * status (true = resolved) |
| 103 | * @returns value of 'Resolved' property |
| 104 | */ |
Deepak Kodihalli | 9743189 | 2017-06-12 09:14:57 -0500 | [diff] [blame] | 105 | bool resolved(bool value) override; |
Deepak Kodihalli | 90abed6 | 2017-03-27 03:56:44 -0500 | [diff] [blame] | 106 | |
Deepak Kodihalli | 72654f1 | 2017-06-12 04:33:29 -0500 | [diff] [blame] | 107 | using sdbusplus::xyz::openbmc_project:: |
| 108 | Logging::server::Entry::resolved; |
Deepak Kodihalli | 90abed6 | 2017-03-27 03:56:44 -0500 | [diff] [blame] | 109 | |
Deepak Kodihalli | 36db46c | 2017-03-31 06:28:44 -0500 | [diff] [blame] | 110 | /** @brief Delete this d-bus object. |
| 111 | */ |
| 112 | void delete_() override; |
| 113 | |
Nagaraju Goruganti | f8a5a79 | 2017-10-13 08:09:52 -0500 | [diff] [blame^] | 114 | /** @brief Severity level to check in cap. |
| 115 | * @details Errors with severity lesser than this will be |
| 116 | * considered as low priority and maximum ERROR_INFO_CAP |
| 117 | * number errors of this category will be captured. |
| 118 | */ |
| 119 | static constexpr auto sevLowerLimit = Entry::Level::Informational; |
| 120 | |
Deepak Kodihalli | 16aed11 | 2017-03-31 00:11:46 -0500 | [diff] [blame] | 121 | private: |
| 122 | /** @brief This entry's associations */ |
| 123 | AssociationList assocs = {}; |
Deepak Kodihalli | 8110ca6 | 2017-04-10 02:11:54 -0500 | [diff] [blame] | 124 | |
| 125 | /** @brief This entry's parent */ |
Nagaraju Goruganti | 05aae8b | 2017-08-30 07:56:12 -0500 | [diff] [blame] | 126 | internal::Manager& parent; |
Adriana Kobylak | 88d7cf8 | 2017-01-24 12:30:15 -0600 | [diff] [blame] | 127 | }; |
| 128 | |
| 129 | } // namespace logging |
| 130 | } // namespace phosphor |