summaryrefslogtreecommitdiffstats
path: root/selutility.cpp
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2017-06-30 18:52:56 +0530
committerTom Joseph <tomjoseph@in.ibm.com>2017-07-08 09:06:47 +0530
commit6edc8a0406bc31fc24f46f15b4db6f7ed0453f8a (patch)
tree62ed91c3c6bbcb3665574c4c60399ec1567e571f /selutility.cpp
parent6b7a14376a46e73b61df9c78771e2063bc0f4008 (diff)
downloadphosphor-host-ipmid-6edc8a0406bc31fc24f46f15b4db6f7ed0453f8a.zip
phosphor-host-ipmid-6edc8a0406bc31fc24f46f15b4db6f7ed0453f8a.tar.gz
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 <tomjoseph@in.ibm.com>
Diffstat (limited to 'selutility.cpp')
-rw-r--r--selutility.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/selutility.cpp b/selutility.cpp
index 68226f1..0107515 100644
--- a/selutility.cpp
+++ b/selutility.cpp
@@ -3,6 +3,7 @@
#include <phosphor-logging/elog-errors.hpp>
#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<level::ERR>("Error in reading Associations interface");
+ elog<InternalFailure>();
+ }
+
+ using AssociationList = std::vector<std::tuple<
+ std::string, std::string, std::string>>;
+
+ sdbusplus::message::variant<AssociationList> list;
+ reply.read(list);
+
+ auto& assocs = sdbusplus::message::variant_ns::get<AssociationList>
+ (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<level::ERR>("Motherboard sensor not found");
+ elog<InternalFailure>();
+ }
+ }
+
+ 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<level::ERR>("System event sensor not found");
+ elog<InternalFailure>();
+ }
+
+ return internal::prepareSELEntry(objPath, iter);
+}
+
} // namespace sel
} // namespace ipmi
OpenPOWER on IntegriCloud