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