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