diff options
-rw-r--r-- | elog-errors.hpp | 88 | ||||
-rw-r--r-- | fault-monitor/fru-fault-monitor.cpp | 55 | ||||
-rw-r--r-- | xyz/openbmc_project/Led/Fru/Monitor.errors.yaml | 4 | ||||
-rw-r--r-- | xyz/openbmc_project/Led/Fru/Monitor.metadata.yaml | 5 |
4 files changed, 19 insertions, 133 deletions
diff --git a/elog-errors.hpp b/elog-errors.hpp index 1cc6f4a..95c80e7 100644 --- a/elog-errors.hpp +++ b/elog-errors.hpp @@ -9,28 +9,6 @@ #include <phosphor-logging/log.hpp> #include <phosphor-logging/elog.hpp> -namespace sdbusplus -{ -namespace xyz -{ -namespace openbmc_project -{ -namespace Led -{ -namespace Fru -{ -namespace Monitor -{ -namespace Error -{ - struct AssociationRetrieveError; -} // namespace Error -} // namespace Monitor -} // namespace Fru -} // namespace Led -} // namespace openbmc_project -} // namespace xyz -} // namespace sdbusplus namespace sdbusplus { @@ -174,72 +152,6 @@ namespace openbmc_project { namespace Led { -namespace Fru -{ -namespace Monitor -{ -namespace _AssociationRetrieveError -{ - -struct ELOG_ENTRY_PATH -{ - static constexpr auto str = "ELOG_ENTRY_PATH=%s"; - static constexpr auto str_short = "ELOG_ENTRY_PATH"; - using type = std::tuple<std::decay_t<decltype(str)>,const char*>; - explicit constexpr ELOG_ENTRY_PATH(const char* a) : _entry(entry(str, a)) {}; - type _entry; -}; - -} // namespace _AssociationRetrieveError - -struct AssociationRetrieveError : public sdbusplus::exception_t -{ - static constexpr auto errName = "xyz.openbmc_project.Led.Fru.Monitor.AssociationRetrieveError"; - static constexpr auto errDesc = "Error in retrieving the associations from elog entry."; - static constexpr auto L = level::INFO; - using ELOG_ENTRY_PATH = _AssociationRetrieveError::ELOG_ENTRY_PATH; - using metadata_types = std::tuple<ELOG_ENTRY_PATH>; - - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } -}; - -} // namespace Monitor -} // namespace Fru -} // namespace Led -} // namespace openbmc_project -} // namespace xyz - - -namespace details -{ - -template <> -struct map_exception_type<sdbusplus::xyz::openbmc_project::Led::Fru::Monitor::Error::AssociationRetrieveError> -{ - using type = xyz::openbmc_project::Led::Fru::Monitor::AssociationRetrieveError; -}; - -} - -namespace xyz -{ -namespace openbmc_project -{ -namespace Led -{ namespace Mapper { namespace _MethodError diff --git a/fault-monitor/fru-fault-monitor.cpp b/fault-monitor/fru-fault-monitor.cpp index 8bf27f2..dc2f231 100644 --- a/fault-monitor/fru-fault-monitor.cpp +++ b/fault-monitor/fru-fault-monitor.cpp @@ -26,13 +26,17 @@ constexpr auto LOG_PATH = "/xyz/openbmc_project/logging"; using AssociationList = std::vector<std::tuple< std::string, std::string, std::string>>; +using Attributes = sdbusplus::message::variant<bool,AssociationList>; +using AttributeName = std::string; +using AttributeMap = std::map<AttributeName, Attributes>; +using PropertyName = std::string; +using PropertyMap = std::map<PropertyName, AttributeMap>; +using LogEntryMsg = std::pair<sdbusplus::message::object_path, PropertyMap>; + using MethodErr = sdbusplus::xyz::openbmc_project::Led::Mapper::Error::MethodError; using ObjectNotFoundErr = sdbusplus::xyz::openbmc_project::Led::Mapper::Error::ObjectNotFoundError; -using AssociationRetrieveErr = - sdbusplus::xyz::openbmc_project:: - Led::Fru::Monitor::Error::AssociationRetrieveError; using InventoryPathErr = sdbusplus::xyz::openbmc_project:: Led::Fru::Monitor::Error::InventoryPathError; @@ -121,9 +125,9 @@ void Add::created(sdbusplus::message::message& msg) { auto bus = msg.get_bus(); - sdbusplus::message::object_path obPath; - msg.read(obPath); - std::string objectPath(std::move(obPath)); + LogEntryMsg logEntry; + msg.read(logEntry); + std::string objectPath(std::move(logEntry.first)); std::size_t found = objectPath.find(ELOG_ENTRY); if (found == std::string::npos) @@ -131,44 +135,22 @@ void Add::created(sdbusplus::message::message& msg) //Not a new error entry skip return; } + log<level::ERR>(objectPath.c_str()); - std::string service; - try - { - service = getService(bus, LOG_PATH); - } - catch (MethodErr& e) - { - commit<MethodErr>(); - return; - } - catch (ObjectNotFoundErr& e) + auto iter = logEntry.second.find("org.openbmc.Associations"); + if (iter == logEntry.second.end()) { - commit<ObjectNotFoundErr>(); return; } - auto method = bus.new_method_call(service.c_str(), objectPath.c_str(), - "org.freedesktop.DBus.Properties", - "Get"); - - method.append("org.openbmc.Associations"); - method.append("associations"); - auto reply = bus.call(method); - if (reply.is_method_error()) + auto attr = iter->second.find("associations"); + if (attr == iter->second.end()) { - using namespace xyz::openbmc_project::Led::Fru::Monitor; - report<AssociationRetrieveErr>( - AssociationRetrieveError::ELOG_ENTRY_PATH( - objectPath.c_str())); return; } - sdbusplus::message::variant<AssociationList> assoc; - reply.read(assoc); - - auto assocs = - sdbusplus::message::variant_ns::get<AssociationList>(assoc); + auto& assocs = + sdbusplus::message::variant_ns::get<AssociationList>(attr->second); if (assocs.empty()) { //No associations skip @@ -181,9 +163,10 @@ void Add::created(sdbusplus::message::message& msg) { action(bus, std::get<2>(item), true); removeWatches.emplace_back( - std::make_unique<Remove>(bus, std::get<2>(item))); + std::make_unique<Remove>(bus, std::get<2>(item))); } } + return; } diff --git a/xyz/openbmc_project/Led/Fru/Monitor.errors.yaml b/xyz/openbmc_project/Led/Fru/Monitor.errors.yaml index bb77f45..e949513 100644 --- a/xyz/openbmc_project/Led/Fru/Monitor.errors.yaml +++ b/xyz/openbmc_project/Led/Fru/Monitor.errors.yaml @@ -1,7 +1,3 @@ #xyz.openbmc_project.Led.Fru.Monitor.InventoryPathError - name: InventoryPathError description: Invalid Inventory Path. - -#xyz.openbmc_project.Led.Fru.Monitor.AssociationRetrieveError -- name: AssociationRetrieveError - description: Error in retrieving the associations from elog entry. diff --git a/xyz/openbmc_project/Led/Fru/Monitor.metadata.yaml b/xyz/openbmc_project/Led/Fru/Monitor.metadata.yaml index bd59e5f..57e0fd5 100644 --- a/xyz/openbmc_project/Led/Fru/Monitor.metadata.yaml +++ b/xyz/openbmc_project/Led/Fru/Monitor.metadata.yaml @@ -2,8 +2,3 @@ meta: - str: "PATH=%s" type: string - -- name: AssociationRetrieveError - meta: - - str: "ELOG_ENTRY_PATH=%s" - type: string |