Skip to content

Commit c383f56

Browse files
committed
PEL for Worker class
This commit adds code to log informational PEL in worker class, in case of exceptions occurred during creating asset tag and initiating backup & restore. output: ''' root@testhostname:~# peltool -i 0x5000ED96 { "Private Header": { "Section Version": "1", "Sub-section type": "0", "Created by": "bmc vpd", "Created at": "01/10/2025 15:48:55", "Committed at": "01/10/2025 15:48:55", "Creator Subsystem": "BMC", "CSSVER": "", "Platform Log Id": "0x5000ED96", "Entry Id": "0x5000ED96", "BMC Event Log Id": "783" }, "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": "Informational Event", "Event Type": "Miscellaneous, Informational Only", "Action Flags": [ "Event not customer viewable", "Report Externally" ], "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": "2E2D", "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": "00000055", "Hex Word 3": "2E2D0010", "Hex Word 4": "00000000", "Hex Word 5": "00000000", "Hex Word 6": "00000000", "Hex Word 7": "00000000", "Hex Word 8": "00000000", "Hex Word 9": "00000000" }, "Extended User Header": { "Section Version": "1", "Sub-section type": "0", "Created by": "bmc error logging", "Reporting Machine Type": "9105-22A", "Reporting Serial Number": "139F230", "FW Released Ver": "", "FW SubSys Version": "fw1110.00-3.37", "Common Ref Time": "00/00/0000 00:00:00", "Symptom Id Len": "20", "Symptom Id": "BD554001_2E2D0010" }, "Failing MTMS": { "Section Version": "1", "Sub-section type": "0", "Created by": "bmc error logging", "Machine Type Model": "9105-22A", "Serial Number": "139F230" }, "User Data 0": { "Section Version": "1", "Sub-section type": "1", "Created by": "bmc error logging", "BMCLoad": "0.51 0.80 0.80", "BMCState": "Ready", "BMCUptime": "0y 0d 0h 26m 28s", "BootState": "Unspecified", "ChassisState": "Off", "FW Version ID": "fw1110.00-3.37-85-g35b06323a2-dirty", "HostState": "Off", "System IM": "50001001" }, "User Data 1": { "Section Version": "1", "Sub-section type": "1", "Created by": "bmc error logging", "DESCRIPTION": "Exception caught while backup and restore VPD keyword's.Test error", "FileName": "/usr/src/debug/openpower-fru-vpd/1.0+git/vpd-manager/src/worker.cpp", "FunctionName": "performBackupAndRestore", "InteranlRc": "0", "UserData1": "", "UserData2": "" } ''' Signed-off-by: RekhaAparna01 <[email protected]>
1 parent f92c478 commit c383f56

File tree

2 files changed

+41
-46
lines changed

2 files changed

+41
-46
lines changed

vpd-manager/include/worker.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,10 @@ class Worker
473473
* @brief API to form asset tag string for the system.
474474
*
475475
* @param[in] i_parsedVpdMap - Parsed VPD map.
476-
* @return - Formed asset tag string. Empty in case of any error.
476+
*
477+
* @throw std::runtime_error
478+
*
479+
* @return - Formed asset tag string.
477480
*/
478481
std::string
479482
createAssetTagString(const types::VPDMapVariant& i_parsedVpdMap);

vpd-manager/src/worker.cpp

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "backup_restore.hpp"
66
#include "configuration.hpp"
77
#include "constants.hpp"
8+
#include "event_logger.hpp"
89
#include "exceptions.hpp"
910
#include "logger.hpp"
1011
#include "parser.hpp"
@@ -252,7 +253,7 @@ std::string Worker::getHWVersion(const types::IPZVpdMap& parsedVpd) const
252253
{
253254
if (parsedVpd.empty())
254255
{
255-
throw std::runtime_error("Empty VPD map. Can't Extract IM value");
256+
throw std::runtime_error("Empty VPD map. Can't Extract HW value");
256257
}
257258

258259
const auto& itrToVINI = parsedVpd.find("VINI");
@@ -1150,43 +1151,33 @@ std::string
11501151
{
11511152
std::string l_assetTag;
11521153

1153-
try
1154+
// system VPD will be in IPZ format.
1155+
if (auto l_parsedVpdMap = std::get_if<types::IPZVpdMap>(&i_parsedVpdMap))
11541156
{
1155-
// system VPD will be in IPZ format.
1156-
if (auto l_parsedVpdMap =
1157-
std::get_if<types::IPZVpdMap>(&i_parsedVpdMap))
1157+
auto l_itrToVsys = (*l_parsedVpdMap).find(constants::recVSYS);
1158+
if (l_itrToVsys != (*l_parsedVpdMap).end())
11581159
{
1159-
auto l_itrToVsys = (*l_parsedVpdMap).find(constants::recVSYS);
1160-
if (l_itrToVsys != (*l_parsedVpdMap).end())
1161-
{
1162-
std::string l_tmKwdValue;
1163-
vpdSpecificUtility::getKwVal(l_itrToVsys->second,
1164-
constants::kwdTM, l_tmKwdValue);
1160+
std::string l_tmKwdValue;
1161+
vpdSpecificUtility::getKwVal(l_itrToVsys->second, constants::kwdTM,
1162+
l_tmKwdValue);
11651163

1166-
std::string l_seKwdValue;
1167-
vpdSpecificUtility::getKwVal(l_itrToVsys->second,
1168-
constants::kwdSE, l_seKwdValue);
1164+
std::string l_seKwdValue;
1165+
vpdSpecificUtility::getKwVal(l_itrToVsys->second, constants::kwdSE,
1166+
l_seKwdValue);
11691167

1170-
l_assetTag = std::string{"Server-"} + l_tmKwdValue +
1171-
std::string{"-"} + l_seKwdValue;
1172-
}
1173-
else
1174-
{
1175-
throw std::runtime_error(
1176-
"VSYS record not found in parsed VPD map to create Asset tag.");
1177-
}
1168+
l_assetTag = std::string{"Server-"} + l_tmKwdValue +
1169+
std::string{"-"} + l_seKwdValue;
11781170
}
11791171
else
11801172
{
11811173
throw std::runtime_error(
1182-
"Invalid VPD type recieved to create Asset tag.");
1174+
"VSYS record not found in parsed VPD map to create Asset tag.");
11831175
}
11841176
}
1185-
catch (const std::exception& l_ex)
1177+
else
11861178
{
1187-
// TODO:Log PEL with below description.
1188-
logging::logMessage("Asset tag can't be formed. Error = " +
1189-
std::string(l_ex.what()));
1179+
throw std::runtime_error(
1180+
"Invalid VPD type recieved to create Asset tag.");
11901181
}
11911182

11921183
return l_assetTag;
@@ -1224,10 +1215,12 @@ void Worker::publishSystemVPD(const types::VPDMapVariant& parsedVpdMap)
12241215
}
12251216
catch (const std::exception& l_ex)
12261217
{
1227-
// TODO Log PEL with below description
1228-
logging::logMessage(
1218+
EventLogger::createSyncPel(
1219+
types::ErrorType::InvalidVpdMessage,
1220+
types::SeverityType::Informational, __FILE__, __FUNCTION__, 0,
12291221
"Asset tag update failed with following error: " +
1230-
std::string(l_ex.what()));
1222+
std::string(l_ex.what()),
1223+
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
12311224
}
12321225

12331226
// Notify PIM
@@ -1557,6 +1550,8 @@ void Worker::performBackupAndRestore(types::VPDMapVariant& io_srcVpdMap)
15571550
auto [l_srcVpdVariant,
15581551
l_dstVpdVariant] = l_backupAndRestoreObj.backupAndRestore();
15591552

1553+
throw std::runtime_error("Test error");
1554+
15601555
// ToDo: Revisit is this check is required or not.
15611556
if (auto l_srcVpdMap =
15621557
std::get_if<types::IPZVpdMap>(&l_srcVpdVariant);
@@ -1566,18 +1561,15 @@ void Worker::performBackupAndRestore(types::VPDMapVariant& io_srcVpdMap)
15661561
}
15671562
}
15681563
}
1569-
catch (const std::exception& ex)
1564+
catch (const std::exception& l_ex)
15701565
{
1571-
logging::logMessage(ex.what());
1572-
// ToDo: Uncomment when PEL implementation goes in.
1573-
/*std::string l_errorMsg(
1574-
"Exception caught while backup and restore VPD keyword's. Error: " +
1575-
std::string(ex.what()));
1576-
inventory::PelAdditionalData l_additionalData{};
1577-
l_additionalData.emplace("DESCRIPTION", l_errorMsg);
1578-
createPEL(l_additionalData,
1579-
PelSeverity::ERROR, errBackupAndRestore, nullptr);
1580-
*/
1566+
EventLogger::createSyncPel(
1567+
types::ErrorType::InvalidVpdMessage,
1568+
types::SeverityType::Informational, __FILE__, __FUNCTION__, 0,
1569+
std::string(
1570+
"Exception caught while backup and restore VPD keyword's.") +
1571+
l_ex.what(),
1572+
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
15811573
}
15821574
}
15831575

@@ -1643,9 +1635,7 @@ void Worker::deleteFruVpd(const std::string& i_dbusObjPath)
16431635

16441636
if (!dbusUtility::callPIM(std::move(l_objectMap)))
16451637
{
1646-
throw std::runtime_error(
1647-
"Can't process delete VPD for FRU [" + i_dbusObjPath +
1648-
"] as unable to read present property");
1638+
throw std::runtime_error("Call to PIM failed.");
16491639
}
16501640

16511641
if (jsonUtility::isActionRequired(m_parsedJson, l_fruPath,
@@ -1660,7 +1650,9 @@ void Worker::deleteFruVpd(const std::string& i_dbusObjPath)
16601650
}
16611651
else
16621652
{
1663-
logging::logMessage("DBus read failed");
1653+
logging::logMessage("Can't process delete VPD for FRU [" +
1654+
i_dbusObjPath +
1655+
"] as unable to read present property");
16641656
return;
16651657
}
16661658

0 commit comments

Comments
 (0)