Set severity for PELs
This commit adds an option to pass severity while logging PEL.
This will help to classify PELs based on their severity.
By default severity of all the PELs logged for system VPD failure
is set to be unrecoverable where as other failures are flagged as
predictive errors.
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
Change-Id: I9cd10a29252a42f5031b91b9c7ad2e284ed5b861
diff --git a/const.hpp b/const.hpp
index 8130334..69c8107 100644
--- a/const.hpp
+++ b/const.hpp
@@ -85,7 +85,7 @@
constexpr auto errIntfForBusFailure = "com.ibm.VPD.Error.DbusFailure";
constexpr auto motherBoardInterface =
"xyz.openbmc_project.Inventory.Item.Board.Motherboard";
-
+constexpr auto systemVpdFilePath = "/sys/bus/i2c/drivers/at24/8-0050/eeprom";
namespace lengths
{
enum Lengths
@@ -136,6 +136,19 @@
MEMORY_VPD, /**< Memory VPD type */
INVALID_VPD_FORMAT /**< Invalid VPD type */
};
+
+enum PelSeverity
+{
+ NOTICE,
+ INFORMATIONAL,
+ DEBUG,
+ WARNING,
+ CRITICAL,
+ EMERGENCY,
+ ALERT,
+ ERROR
+};
+
} // namespace constants
} // namespace vpd
} // namespace openpower
diff --git a/ibm_vpd_app.cpp b/ibm_vpd_app.cpp
index c677ba2..237d001 100644
--- a/ibm_vpd_app.cpp
+++ b/ibm_vpd_app.cpp
@@ -622,7 +622,7 @@
PelAdditionalData additionalData{};
additionalData.emplace("CALLOUT_INVENTORY_PATH", objectName);
additionalData.emplace("DESCRIPTION", what);
- createPEL(additionalData, errIntfForBusFailure);
+ createPEL(additionalData, PelSeverity::WARNING, errIntfForBusFailure);
}
}
@@ -688,7 +688,8 @@
additionalData.emplace("DESCRIPTION", errMsg);
- createPEL(additionalData, errIntfForInvalidVPD);
+ createPEL(additionalData, PelSeverity::WARNING,
+ errIntfForInvalidVPD);
}
}
else
@@ -724,7 +725,8 @@
additionalData.emplace("DESCRIPTION", errMsg);
// log PEL TODO: Block IPL
- createPEL(additionalData, errIntfForBlankSystemVPD);
+ createPEL(additionalData, PelSeverity::ERROR,
+ errIntfForBlankSystemVPD);
continue;
}
}
@@ -930,6 +932,9 @@
// vpd exception while parsing the file
std::string baseFruInventoryPath = {};
+ // severity for PEL
+ PelSeverity pelSeverity = PelSeverity::WARNING;
+
try
{
App app{"ibm-read-vpd - App to read IPZ format VPD, parse it and store "
@@ -941,6 +946,12 @@
CLI11_PARSE(app, argc, argv);
+ // PEL severity should be ERROR in case of any system VPD failure
+ if (file == systemVpdFilePath)
+ {
+ pelSeverity = PelSeverity::ERROR;
+ }
+
auto jsonToParse = INVENTORY_JSON_DEFAULT;
// If the symlink exists, it means it has been setup for us, switch the
@@ -954,8 +965,7 @@
ifstream inventoryJson(jsonToParse);
if (!inventoryJson)
{
- throw(
- (VpdJsonException("Failed to access Json path", jsonToParse)));
+ throw(VpdJsonException("Failed to access Json path", jsonToParse));
}
try
@@ -964,7 +974,7 @@
}
catch (json::parse_error& ex)
{
- throw((VpdJsonException("Json parsing failed", jsonToParse)));
+ throw(VpdJsonException("Json parsing failed", jsonToParse));
}
if ((js.find("frus") == js.end()) ||
@@ -1029,7 +1039,7 @@
{
additionalData.emplace("JSON_PATH", ex.getJsonPath());
additionalData.emplace("DESCRIPTION", ex.what());
- createPEL(additionalData, errIntfForJsonFailure);
+ createPEL(additionalData, pelSeverity, errIntfForJsonFailure);
cerr << ex.what() << "\n";
rc = -1;
@@ -1039,7 +1049,7 @@
additionalData.emplace("DESCRIPTION", "ECC check failed");
additionalData.emplace("CALLOUT_INVENTORY_PATH",
INVENTORY_PATH + baseFruInventoryPath);
- createPEL(additionalData, errIntfForEccCheckFail);
+ createPEL(additionalData, pelSeverity, errIntfForEccCheckFail);
cerr << ex.what() << "\n";
rc = -1;
@@ -1049,7 +1059,7 @@
additionalData.emplace("DESCRIPTION", "Invalid VPD data");
additionalData.emplace("CALLOUT_INVENTORY_PATH",
INVENTORY_PATH + baseFruInventoryPath);
- createPEL(additionalData, errIntfForInvalidVPD);
+ createPEL(additionalData, pelSeverity, errIntfForInvalidVPD);
cerr << ex.what() << "\n";
rc = -1;
diff --git a/ibm_vpd_utils.cpp b/ibm_vpd_utils.cpp
index d691c84..6577969 100644
--- a/ibm_vpd_utils.cpp
+++ b/ibm_vpd_utils.cpp
@@ -29,6 +29,20 @@
using namespace record;
using namespace openpower::vpd::exceptions;
using namespace common::utility;
+using Severity = openpower::vpd::constants::PelSeverity;
+
+// mapping of severity enum to severity interface
+static std::unordered_map<Severity, std::string> sevMap = {
+ {Severity::INFORMATIONAL,
+ "xyz.openbmc_project.Logging.Entry.Level.Informational"},
+ {Severity::DEBUG, "xyz.openbmc_project.Logging.Entry.Level.Debug"},
+ {Severity::NOTICE, "xyz.openbmc_project.Logging.Entry.Level.Notice"},
+ {Severity::WARNING, "xyz.openbmc_project.Logging.Entry.Level.Warning"},
+ {Severity::CRITICAL, "xyz.openbmc_project.Logging.Entry.Level.Critical"},
+ {Severity::EMERGENCY, "xyz.openbmc_project.Logging.Entry.Level.Emergency"},
+ {Severity::ERROR, "xyz.openbmc_project.Logging.Entry.Level.Error"},
+ {Severity::ALERT, "xyz.openbmc_project.Logging.Entry.Level.Alert"}};
+
namespace inventory
{
@@ -141,17 +155,24 @@
}
void createPEL(const std::map<std::string, std::string>& additionalData,
- const std::string& errIntf)
+ const Severity& sev, const std::string& errIntf)
{
try
{
+ std::string pelSeverity =
+ "xyz.openbmc_project.Logging.Entry.Level.Error";
auto bus = sdbusplus::bus::new_default();
auto service = getService(bus, loggerObjectPath, loggerCreateInterface);
auto method = bus.new_method_call(service.c_str(), loggerObjectPath,
loggerCreateInterface, "Create");
- method.append(errIntf, "xyz.openbmc_project.Logging.Entry.Level.Error",
- additionalData);
+ auto itr = sevMap.find(sev);
+ if (itr != sevMap.end())
+ {
+ pelSeverity = itr->second;
+ }
+
+ method.append(errIntf, pelSeverity, additionalData);
auto resp = bus.call(method);
}
catch (const sdbusplus::exception::SdBusError& e)
diff --git a/ibm_vpd_utils.hpp b/ibm_vpd_utils.hpp
index e21f13d..9b48021 100644
--- a/ibm_vpd_utils.hpp
+++ b/ibm_vpd_utils.hpp
@@ -66,11 +66,12 @@
/**
* @brief API to create PEL entry
- * @param[in] Map holding the additional data
- * @param[in] error interface
+ * @param[in] additionalData - Map holding the additional data
+ * @param[in] sev - Severity
+ * @param[in] errIntf - error interface
*/
void createPEL(const std::map<std::string, std::string>& additionalData,
- const std::string& errIntf);
+ const constants::PelSeverity& sev, const std::string& errIntf);
/**
* @brief getVpdFilePath
diff --git a/vpd_exceptions.hpp b/vpd_exceptions.hpp
index 35c05d4..2ea2cd5 100644
--- a/vpd_exceptions.hpp
+++ b/vpd_exceptions.hpp
@@ -112,13 +112,17 @@
~VpdJsonException() = default;
/** @brief constructor
- * @param[in] - string to define exception
+ * @param[in] msg - string to define exception
+ * @param[in] path - Json path
*/
- explicit VpdJsonException(const std::string& msg, const std::string& Path) :
- VPDException(msg), jsonPath(Path)
+ VpdJsonException(const std::string& msg, const std::string& path) :
+ VPDException(msg), jsonPath(path)
{
}
+ /** @brief Json path getter method.
+ * @return - Json path
+ */
inline std::string getJsonPath() const
{
return jsonPath;