From 6edc8a0406bc31fc24f46f15b4db6f7ed0453f8a Mon Sep 17 00:00:00 2001 From: Tom Joseph Date: Fri, 30 Jun 2017 18:52:56 +0530 Subject: Convert a log entry into a SEL record Check the DBUS logging entry for callout associations, if there is a mapping between the inventory path and sensor number then populate the SEL record. Otherwise log a SEL against the sytem event sensor. Resolves openbmc/openbmc#1516 Change-Id: I516bdac70cf39260af1744a9cdb118d763009bd5 Signed-off-by: Tom Joseph --- selutility.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) (limited to 'selutility.cpp') diff --git a/selutility.cpp b/selutility.cpp index 68226f1..0107515 100644 --- a/selutility.cpp +++ b/selutility.cpp @@ -3,6 +3,7 @@ #include #include "host-ipmid/ipmid-api.h" #include "xyz/openbmc_project/Common/error.hpp" +#include "config.h" #include "selutility.hpp" #include "types.hpp" #include "utils.hpp" @@ -112,6 +113,75 @@ GetSELEntryResponse prepareSELEntry( } // namespace internal +GetSELEntryResponse convertLogEntrytoSEL(const std::string& objPath) +{ + sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; + + static constexpr auto assocIntf = "org.openbmc.Associations"; + static constexpr auto assocProp = "associations"; + + auto service = ipmi::getService(bus, assocIntf, objPath); + + // Read the Associations interface. + auto methodCall = bus.new_method_call(service.c_str(), + objPath.c_str(), + propIntf, + "Get"); + methodCall.append(assocIntf); + methodCall.append(assocProp); + + auto reply = bus.call(methodCall); + if (reply.is_method_error()) + { + log("Error in reading Associations interface"); + elog(); + } + + using AssociationList = std::vector>; + + sdbusplus::message::variant list; + reply.read(list); + + auto& assocs = sdbusplus::message::variant_ns::get + (list); + + /* + * Check if the log entry has any callout associations, if there is a + * callout association try to match the inventory path to the corresponding + * IPMI sensor. + */ + for (const auto& item : assocs) + { + if (std::get<0>(item).compare(CALLOUT_FWD_ASSOCIATION) == 0) + { + auto iter = invSensors.find(std::get<2>(item)); + if (iter == invSensors.end()) + { + iter = invSensors.find(BOARD_SENSOR); + if (iter == invSensors.end()) + { + log("Motherboard sensor not found"); + elog(); + } + } + + return internal::prepareSELEntry(objPath, iter); + } + } + + // If there are no callout associations link the log entry to system event + // sensor + auto iter = invSensors.find(SYSTEM_SENSOR); + if (iter == invSensors.end()) + { + log("System event sensor not found"); + elog(); + } + + return internal::prepareSELEntry(objPath, iter); +} + } // namespace sel } // namespace ipmi -- cgit v1.2.1