summaryrefslogtreecommitdiffstats
path: root/storageaddsel.cpp
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2017-07-24 23:08:56 +0530
committerPatrick Williams <patrick@stwcx.xyz>2017-07-25 20:42:22 +0000
commit448e74e811d94a70793df9f036ec4d9a1bdb1501 (patch)
tree7139d2c4c42a353d352dc05d03c07754b7a0b78e /storageaddsel.cpp
parent6ec7daab838fd1af86dc35d2c0de8712c8eefa29 (diff)
downloadphosphor-host-ipmid-448e74e811d94a70793df9f036ec4d9a1bdb1501.tar.gz
phosphor-host-ipmid-448e74e811d94a70793df9f036ec4d9a1bdb1501.zip
Add inventory path metadata to host event log entry
The ESEL data contains sensor number to related to the event. The generated code maps sensor number to inventory path. The inventory path is added as metadata to the log entry for the admin to figure out the inventory affected by the system event. The generated header for Host event exception type is generated in the org/open_power/Host/Event/error.hpp. Phosphor repositories should not include open power specific header files. The eventual plan to is to move the code to add ESEL to an OEM repo, till then we would check in the header file in the repo. TODO: openbmc/openbmc#1658 The elog-errors.hpp is checked in for the CI to pass. TODO: openbmc/openbmc#1772 issue would take care, so that CI passes without the checking in elog-errors.hpp. Resolves openbmc/openbmc#1920 Change-Id: I31d68de475ef84b8755c5de6d7ce6d311dd32214 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'storageaddsel.cpp')
-rw-r--r--storageaddsel.cpp53
1 files changed, 34 insertions, 19 deletions
diff --git a/storageaddsel.cpp b/storageaddsel.cpp
index 9cebf9e..bd48edc 100644
--- a/storageaddsel.cpp
+++ b/storageaddsel.cpp
@@ -9,14 +9,17 @@
#include <systemd/sd-bus.h>
#include <mapper.h>
#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/elog-errors-HostEvent.hpp>
#include "host-ipmid/ipmid-api.h"
+#include "elog-errors.hpp"
+#include "error-HostEvent.hpp"
#include "sensorhandler.h"
#include "storagehandler.h"
+#include "types.hpp"
using namespace std;
using namespace phosphor::logging;
+extern const ipmi::sensor::InvObjectIDMap invSensors;
//////////////////////////
struct esel_section_headers_t {
@@ -130,25 +133,29 @@ const char *create_esel_severity(const uint8_t *buffer) {
return sev_lookup(severity);
}
-int create_esel_association(const uint8_t *buffer, char **m) {
-
+int create_esel_association(const uint8_t *buffer, std::string& inventoryPath)
+{
ipmi_add_sel_request_t *p;
- dbus_interface_t dbusint;
uint8_t sensor;
p = ( ipmi_add_sel_request_t *) buffer;
sensor = p->sensornumber;
- find_openbmc_path(sensor, &dbusint);
-
- // Simply no associations if the sensor can not be found
- if (strlen(dbusint.path) < 1) {
- printf("Sensor 0x%x not found\n", sensor);
- memset(dbusint.path,0,sizeof(dbusint.path));
- }
+ inventoryPath = {};
- *m = strdup(dbusint.path);
+ /*
+ * Search the sensor number to inventory path mapping to figure out the
+ * inventory associated with the ESEL.
+ */
+ for (auto const &iter : invSensors)
+ {
+ if (iter.second.sensorID == sensor)
+ {
+ inventoryPath = iter.first;
+ break;
+ }
+ }
return 0;
}
@@ -178,7 +185,12 @@ int create_esel_description(const uint8_t *buffer, const char *sev, char **messa
}
-int send_esel_to_dbus(const char *desc, const char *sev, const char *details, uint8_t *debug, size_t debuglen) {
+int send_esel_to_dbus(const char *desc,
+ const char *sev,
+ const std::string& inventoryPath,
+ uint8_t *debug,
+ size_t debuglen)
+{
// Allocate enough space to represent the data in hex separated by spaces,
// to mimic how IPMI would display the data.
@@ -190,20 +202,24 @@ int send_esel_to_dbus(const char *desc, const char *sev, const char *details, ui
}
selData[debuglen*3] = '\0';
- using error = org::open_power::Error::Host::Event;
- report<error>(error::ESEL(selData.get()));
+ using error = sdbusplus::org::open_power::Host::Event::Error::Event;
+ using metadata = org::open_power::Host::Event::Event;
+
+ report<error>(metadata::ESEL(selData.get()),
+ metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str()));
return 0;
}
void send_esel(uint16_t recordid) {
- char *desc, *assoc;
+ char *desc;
const char *sev;
uint8_t *buffer = NULL;
const char *path = "/tmp/esel";
ssize_t sz;
int r;
+ std::string inventoryPath;
sz = getfilestream(path, &buffer);
if (sz == 0) {
@@ -212,15 +228,14 @@ void send_esel(uint16_t recordid) {
}
sev = create_esel_severity(buffer);
- create_esel_association(buffer, &assoc);
+ create_esel_association(buffer, inventoryPath);
create_esel_description(buffer, sev, &desc);
- r = send_esel_to_dbus(desc, sev, assoc, buffer, sz);
+ r = send_esel_to_dbus(desc, sev, inventoryPath, buffer, sz);
if (r < 0) {
fprintf(stderr, "Failed to send esel to dbus\n");
}
- free(assoc);
free(desc);
delete[] buffer;
OpenPOWER on IntegriCloud