Skip to content

Commit

Permalink
Enable PEL in worker class
Browse files Browse the repository at this point in the history
This commit adds code to log a PEL in worker class, in case of error
where PEL is required.

output:
'''
root@rainvpdteam:~# peltool -i 0x50007534
{
"Private Header": {
    "Section Version":          "1",
    "Sub-section type":         "0",
    "Created by":               "bmc vpd",
    "Created at":               "10/04/2024 09:02:47",
    "Committed at":             "10/04/2024 09:02:47",
    "Creator Subsystem":        "BMC",
    "CSSVER":                   "",
    "Platform Log Id":          "0x50007534",
    "Entry Id":                 "0x50007534",
    "BMC Event Log Id":         "1320"
},
"User Header": {
    "Section Version":          "1",
    "Sub-section type":         "0",
    "Log Committed by":         "bmc error logging",
    "Subsystem":                "CEC Hardware - VPD Interface",
    "Event Scope":              "Entire Platform",
    "Event Severity":           "Predictive Error",
    "Event Type":               "Not Applicable",
    "Action Flags": [
                                "Service Action Required",
                                "Report Externally",
                                "HMC Call Home"
    ],
    "Host Transmission":        "Not Sent",
    "HMC Transmission":         "Not Sent"
},
"Primary SRC": {
    "Section Version":          "1",
    "Sub-section type":         "1",
    "Created by":               "bmc vpd",
    "SRC Version":              "0x02",
    "SRC Format":               "0x55",
    "Virtual Progress SRC":     "False",
    "I5/OS Service Event Bit":  "False",
    "Hypervisor Dump Initiated":"False",
    "Backplane CCIN":           "07B5",
    "Terminate FW Error":       "False",
    "Deconfigured":             "False",
    "Guarded":                  "False",
    "Error Details": {
        "Message":              "A VPD data exception occurred."
    },
    "Valid Word Count":         "0x09",
    "Reference Code":           "BD554001",
    "Hex Word 2":               "00080455",
    "Hex Word 3":               "07B50010",
    "Hex Word 4":               "00000000",
    "Hex Word 5":               "00000000",
    "Hex Word 6":               "00000000",
    "Hex Word 7":               "00000000",
    "Hex Word 8":               "00000000",
    "Hex Word 9":               "00000000",
    "Callout Section": {
        "Callout Count":        "1",
        "Callouts": [{
            "FRU Type":         "Normal Hardware FRU",
            "Priority":         "Mandatory, replace all with this type as a unit",
            "Location Code":    "U78DA.ND0.WZS0065-P0-C40",
            "Part Number":      "78P6575",
            "CCIN":             "327B",
            "Serial Number":    "YH30MS05N008"
        }]
    }
},
"Extended User Header": {
    "Section Version":          "1",
    "Sub-section type":         "0",
    "Created by":               "bmc error logging",
    "Reporting Machine Type":   "9105-22A",
    "Reporting Serial Number":  "139F1F0",
    "FW Released Ver":          "NL1110_013",
    "FW SubSys Version":        "fw1110.00-3.10",
    "Common Ref Time":          "00/00/0000 00:00:00",
    "Symptom Id Len":           "20",
    "Symptom Id":               "BD554001_07B50010"
},
"Failing MTMS": {
    "Section Version":          "1",
    "Sub-section type":         "0",
    "Created by":               "bmc error logging",
    "Machine Type Model":       "9105-22A",
    "Serial Number":            "139F1F0"
},
"User Data 0": {
    "Section Version": "1",
    "Sub-section type": "1",
    "Created by": "bmc error logging",
    "BMCLoad": "2.68 1.10 0.84",
    "BMCState": "Ready",
    "BMCUptime": "0y 0d 2h 57m 11s",
    "BootState": "Unspecified",
    "ChassisState": "Off",
    "FW Version ID": "fw1110.00-3.10-1110.2439.20240927a (NL1110_013)",
    "HostState": "Off",
    "System IM": "50001001"
},
"User Data 1": {
    "Section Version": "1",
    "Sub-section type": "1",
    "Created by": "bmc error logging",
    "CALLOUT_INVENTORY_PATH": "/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm19",
    "CALLOUT_PRIORITY": "H",
    "DESCRIPTION": "vpd parsing failed for /sys/bus/i2c/drivers/at24/313-0050/eeprom with error: Unable to determine VPD format",
    "FileName": "/usr/src/debug/openpower-fru-vpd/1.0+git/src/worker.cpp",
    "FunctionName": "parseAndPublishVPD",
    "InternalRc": "0",
    "UserData1": "",
    "UserData2": ""
},
"User Data 2": {
    "Section Version": "1",
    "Sub-section type": "1",
    "Created by": "bmc error logging",
    "PEL Internal Debug Data": {
        "DIMMs Info Fetch Error": [
            "Failed reading DI property from VINI Interface for the LocationCode:[U78DA.ND0.WZS0065-P0-C40]"
        ]
    }
}
}
'''

Signed-off-by: RekhaAparna01 <[email protected]>
  • Loading branch information
RekhaAparna01 committed Oct 18, 2024
1 parent 6796854 commit f2f33d8
Showing 1 changed file with 136 additions and 33 deletions.
169 changes: 136 additions & 33 deletions src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "backup_restore.hpp"
#include "configuration.hpp"
#include "constants.hpp"
#include "event_logger.hpp"
#include "exceptions.hpp"
#include "logger.hpp"
#include "parser.hpp"
Expand Down Expand Up @@ -65,6 +66,13 @@ void Worker::enableMuxChips()
if (m_parsedJson.empty())
{
// config JSON should not be empty at this point of execution.
EventLogger::createAsyncPel(
types::ErrorType::JsonFailure, types::SeverityType::Error, __FILE__,
__FUNCTION__, 0,
std::string("Empty config JSON " + m_configJsonPath +
" Can't enable muxes"),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);

throw std::runtime_error("Config JSON is empty. Can't enable muxes");
return;
}
Expand All @@ -89,6 +97,7 @@ void Worker::enableMuxChips()
continue;
}

// ToDo -- log an Information PEL.
logging::logMessage(
"Mux Entry does not have hold idle path. Can't enable the mux");
}
Expand All @@ -112,6 +121,12 @@ static bool isChassisPowerOn()
return false;
}

EventLogger::createAsyncPel(
types::ErrorType::DbusFailure, types::SeverityType::Informational,
__FILE__, __FUNCTION__, 0,
std::string("Dbus call to get chassis power state failed"),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);

throw std::runtime_error("Dbus call to get chassis power state failed");
}

Expand All @@ -138,15 +153,37 @@ void Worker::performInitialSetup()
{
if (typeid(ex) == std::type_index(typeid(DataException)))
{
// TODO:Catch logic to be implemented once PEL code goes in.
EventLogger::createAsyncPelWithInventoryCallout(
types::ErrorType::InvalidVpdMessage,
types::SeverityType::Warning,
{{jsonUtility::getInventoryObjPathFromJson(
m_parsedJson, SYSTEM_VPD_FILE_PATH),
types::CalloutPriority::High}},
__FILE__, __FUNCTION__, 0,
std::string("performInitialSetup failed , reason: " +
ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
}
else if (typeid(ex) == std::type_index(typeid(EccException)))
{
// TODO:Catch logic to be implemented once PEL code goes in.
EventLogger::createAsyncPelWithInventoryCallout(
types::ErrorType::EccCheckFailed, types::SeverityType::Warning,
{{jsonUtility::getInventoryObjPathFromJson(
m_parsedJson, SYSTEM_VPD_FILE_PATH),
types::CalloutPriority::High}},
__FILE__, __FUNCTION__, 0,
std::string("performInitialSetup failed , reason: " +
ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
}
else if (typeid(ex) == std::type_index(typeid(JsonException)))
{
// TODO:Catch logic to be implemented once PEL code goes in.
EventLogger::createAsyncPel(
types::ErrorType::JsonFailure, types::SeverityType::Warning,
__FILE__, __FUNCTION__, 0,
std::string("performInitialSetup failed , reason: " +
ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
}

logging::logMessage(ex.what());
Expand Down Expand Up @@ -208,6 +245,13 @@ std::string Worker::getIMValue(const types::IPZVpdMap& parsedVpd) const
{
if (parsedVpd.empty())
{
EventLogger::createAsyncPelWithInventoryCallout(
types::ErrorType::InvalidVpdMessage, types::SeverityType::Warning,
{{jsonUtility::getInventoryObjPathFromJson(m_parsedJson,
SYSTEM_VPD_FILE_PATH),
types::CalloutPriority::High}},
__FILE__, __FUNCTION__, 0, "Empty VPD map. Can't Extract IM value",
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
throw std::runtime_error("Empty VPD map. Can't Extract IM value");
}

Expand Down Expand Up @@ -241,6 +285,13 @@ std::string Worker::getHWVersion(const types::IPZVpdMap& parsedVpd) const
{
if (parsedVpd.empty())
{
EventLogger::createAsyncPelWithInventoryCallout(
types::ErrorType::InvalidVpdMessage, types::SeverityType::Warning,
{{jsonUtility::getInventoryObjPathFromJson(m_parsedJson,
SYSTEM_VPD_FILE_PATH),
types::CalloutPriority::High}},
__FILE__, __FUNCTION__, 0, "Empty VPD map. Can't Extract HW value",
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
throw std::runtime_error("Empty VPD map. Can't Extract IM value");
}

Expand Down Expand Up @@ -301,18 +352,16 @@ void Worker::fillVPDMap(const std::string& vpdFilePath,
if (typeid(ex) == std::type_index(typeid(DataException)))
{
// TODO: Do what needs to be done in case of Data exception.
// Uncomment when PEL implementation goes in.
/* string errorMsg =
"VPD file is either empty or invalid. Parser failed for [";
errorMsg += m_vpdFilePath;
errorMsg += "], with error = " + std::string(ex.what());
additionalData.emplace("DESCRIPTION", errorMsg);
additionalData.emplace("CALLOUT_INVENTORY_PATH",
INVENTORY_PATH + baseFruInventoryPath);
createPEL(additionalData, pelSeverity, errIntfForInvalidVPD,
nullptr);*/

EventLogger::createAsyncPelWithInventoryCallout(
types::ErrorType::InvalidVpdMessage,
types::SeverityType::Warning,
{{jsonUtility::getInventoryObjPathFromJson(m_parsedJson,
vpdFilePath),
types::CalloutPriority::High}},
__FILE__, __FUNCTION__, 0,
std::string("VPD parsing failed for " + vpdFilePath +
" with error " + ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
// throw generic error from here to inform main caller about
// failure.
logging::logMessage(ex.what());
Expand All @@ -323,13 +372,15 @@ void Worker::fillVPDMap(const std::string& vpdFilePath,
if (typeid(ex) == std::type_index(typeid(EccException)))
{
// TODO: Do what needs to be done in case of ECC exception.
// Uncomment when PEL implementation goes in.
/* additionalData.emplace("DESCRIPTION", "ECC check failed");
additionalData.emplace("CALLOUT_INVENTORY_PATH",
INVENTORY_PATH + baseFruInventoryPath);
createPEL(additionalData, pelSeverity, errIntfForEccCheckFail,
nullptr);
*/
EventLogger::createAsyncPelWithInventoryCallout(
types::ErrorType::EccCheckFailed, types::SeverityType::Warning,
{{jsonUtility::getInventoryObjPathFromJson(m_parsedJson,
vpdFilePath),
types::CalloutPriority::High}},
__FILE__, __FUNCTION__, 0,
std::string("VPD parsing failed for " + vpdFilePath +
" with error " + ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);

logging::logMessage(ex.what());
// Need to decide once all error handling is implemented.
Expand Down Expand Up @@ -442,6 +493,11 @@ void Worker::setDeviceTreeAndJson()
// JSON is madatory for processing of this API.
if (m_parsedJson.empty())
{
EventLogger::createAsyncPel(
types::ErrorType::JsonFailure, types::SeverityType::Warning,
__FILE__, __FUNCTION__, 0,
std::string("Empty Json file " + m_configJsonPath), std::nullopt,
std::nullopt, std::nullopt, std::nullopt);
throw std::runtime_error("JSON is empty");
}

Expand All @@ -457,7 +513,11 @@ void Worker::setDeviceTreeAndJson()

if (!systemJson.compare(JSON_ABSOLUTE_PATH_PREFIX))
{
// TODO: Log a PEL saying that "System type not supported"
EventLogger::createAsyncPel(
types::ErrorType::InvalidSystem, types::SeverityType::Error,
__FILE__, __FUNCTION__, 0, "Error in getting system JSON.",
std::nullopt, std::nullopt, std::nullopt, std::nullopt);

throw DataException("Error in getting system JSON.");
}

Expand Down Expand Up @@ -579,13 +639,15 @@ void Worker::populateKwdVPDpropertyMap(const types::KeywordVpdMap& keyordVPDMap,
}
else
{
// ToDo -- log an Information PEL.
logging::logMessage("Unknown Keyword =" + kwd +
" found in keyword VPD map");
continue;
}
}
else
{
// ToDo -- log an Information PEL.
logging::logMessage(
"Unknown variant type found in keyword VPD map.");
continue;
Expand Down Expand Up @@ -708,6 +770,7 @@ void Worker::populateInterfaces(const nlohmann::json& interfaceJson,
}
else
{
// ToDo -- log an Information PEL.
logging::logMessage(
"Unknown keyword found, Keywrod = " + keyword);
}
Expand Down Expand Up @@ -1163,6 +1226,7 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath)
}
}

// ToDo --log an information PEL.
throw std::runtime_error("Could not find file path " + i_vpdFilePath +
"Skipping parser trigger for the EEPROM");
}
Expand Down Expand Up @@ -1214,17 +1278,45 @@ std::tuple<bool, std::string>
// based on status of execution.
if (typeid(ex) == std::type_index(typeid(DataException)))
{
// TODO: Add custom handling
EventLogger::createAsyncPelWithInventoryCallout(
types::ErrorType::InvalidVpdMessage,
types::SeverityType::Warning,
{{jsonUtility::getInventoryObjPathFromJson(m_parsedJson,
i_vpdFilePath),
types::CalloutPriority::High}},
__FILE__, __FUNCTION__, 0,
std::string("VPD parsing failed for " + i_vpdFilePath +
" with error: " + ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);

logging::logMessage(ex.what());
}
else if (typeid(ex) == std::type_index(typeid(EccException)))
{
// TODO: Add custom handling
EventLogger::createAsyncPelWithInventoryCallout(
types::ErrorType::EccCheckFailed, types::SeverityType::Warning,
{{jsonUtility::getInventoryObjPathFromJson(m_parsedJson,
i_vpdFilePath),
types::CalloutPriority::High}},
__FILE__, __FUNCTION__, 0,
std::string("VPD parsing failed for " + i_vpdFilePath +
" with error: " + ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);

logging::logMessage(ex.what());
}
else if (typeid(ex) == std::type_index(typeid(JsonException)))
{
// TODO: Add custom handling
EventLogger::createAsyncPelWithInventoryCallout(
types::ErrorType::JsonFailure, types::SeverityType::Warning,
{{jsonUtility::getInventoryObjPathFromJson(m_parsedJson,
i_vpdFilePath),
types::CalloutPriority::High}},
__FILE__, __FUNCTION__, 0,
std::string("VPD parsing failed for " + i_vpdFilePath +
" with error: " + ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);

logging::logMessage(ex.what());
}
else
Expand All @@ -1236,6 +1328,17 @@ std::tuple<bool, std::string>
// are not present/processing had some error.
if (!primeInventory(i_vpdFilePath))
{
EventLogger::createAsyncPelWithInventoryCallout(
types::ErrorType::InvalidVpdMessage,
types::SeverityType::Informational,
{{jsonUtility::getInventoryObjPathFromJson(m_parsedJson,
i_vpdFilePath),
types::CalloutPriority::Low}},
__FILE__, __FUNCTION__, 0,
std::string("Priming of inventory failed for FRU " +
i_vpdFilePath),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);

logging::logMessage("Priming of inventory failed for FRU " +
i_vpdFilePath);
}
Expand Down Expand Up @@ -1344,15 +1447,15 @@ void Worker::performBackupAndRestore(types::VPDMapVariant& io_srcVpdMap)
catch (const std::exception& ex)
{
logging::logMessage(ex.what());
// ToDo: Uncomment when PEL implementation goes in.
/*std::string l_errorMsg(

std::string l_errorMsg(
"Exception caught while backup and restore VPD keyword's. Error: " +
std::string(ex.what()));
inventory::PelAdditionalData l_additionalData{};
l_additionalData.emplace("DESCRIPTION", l_errorMsg);
createPEL(l_additionalData,
PelSeverity::ERROR, errBackupAndRestore, nullptr);
*/

EventLogger::createAsyncPel(types::ErrorType::JsonFailure,
types::SeverityType::Warning, __FILE__,
__FUNCTION__, 0, l_errorMsg, std::nullopt,
std::nullopt, std::nullopt, std::nullopt);
}
}
} // namespace vpd

0 comments on commit f2f33d8

Please sign in to comment.