Skip to content

Commit

Permalink
PEL for Manager class
Browse files Browse the repository at this point in the history
This commit adds code to log informational PELs in Manager class, in
case of exceptions occurred while reading host state, performing vpd
recollection and for public API's exposed under vpd-manager service.

Also removed try catch block in manager constructor, as we are not doing
any error handling.

output:
'''
root@p10bmc:/tmp# peltool -i 0x5000213a
{
"Private Header": {
    "Section Version":          "1",
    "Sub-section type":         "0",
    "Created by":               "bmc vpd",
    "Created at":               "01/02/2025 12:01:10",
    "Committed at":             "01/02/2025 12:01:10",
    "Creator Subsystem":        "BMC",
    "CSSVER":                   "",
    "Platform Log Id":          "0x5000213A",
    "Entry Id":                 "0x5000213A",
    "BMC Event Log Id":         "522"
},
"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":   "        ",
    "Reporting Serial Number":  "       ",
    "FW Released Ver":          "",
    "FW SubSys Version":        "fw1110.00-3.34",
    "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":       "        ",
    "Serial Number":            "       "
},
"User Data 0": {
    "Section Version": "1",
    "Sub-section type": "1",
    "Created by": "bmc error logging",
    "BMCLoad": "0.86 0.94 0.82",
    "BMCState": "Quiesced",
    "BMCUptime": "0y 0d 0h 28m 13s",
    "BootState": "Unspecified",
    "ChassisState": "Off",
    "FW Version ID": "fw1110.00-3.34-2-g45a17a06f3-dirty",
    "HostState": "Off",
    "System IM": "50001001"
},
"User Data 1": {
    "Section Version": "1",
    "Sub-section type": "1",
    "Created by": "bmc error logging",
    "DESCRIPTION": "Test Error",
    "FileName": "/usr/src/debug/openpower-fru-vpd/1.0+git/vpd-manager/src/manager.cpp",
    "FunctionName": "deleteSingleFruVpd",
    "InteranlRc": "0",
    "UserData1": "",
    "UserData2": ""
}
}
'''

Signed-off-by: RekhaAparna01 <[email protected]>
  • Loading branch information
RekhaAparna01 committed Jan 13, 2025
1 parent 70a1a3f commit 9ec42b1
Showing 1 changed file with 128 additions and 122 deletions.
250 changes: 128 additions & 122 deletions vpd-manager/src/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "backup_restore.hpp"
#include "constants.hpp"
#include "event_logger.hpp"
#include "exceptions.hpp"
#include "logger.hpp"
#include "parser.hpp"
Expand All @@ -26,121 +27,109 @@ Manager::Manager(
const std::shared_ptr<sdbusplus::asio::connection>& asioConnection) :
m_ioContext(ioCon), m_interface(iFace), m_asioConnection(asioConnection)
{
try
{
#ifdef IBM_SYSTEM
m_worker = std::make_shared<Worker>(INVENTORY_JSON_DEFAULT);
m_worker = std::make_shared<Worker>(INVENTORY_JSON_DEFAULT);

// Set up minimal things that is needed before bus name is claimed.
m_worker->performInitialSetup();
// Set up minimal things that is needed before bus name is claimed.
m_worker->performInitialSetup();

// set callback to detect any asset tag change
registerAssetTagChangeCallback();
// set callback to detect any asset tag change
registerAssetTagChangeCallback();

// set async timer to detect if system VPD is published on D-Bus.
SetTimerToDetectSVPDOnDbus();
// set async timer to detect if system VPD is published on D-Bus.
SetTimerToDetectSVPDOnDbus();

// set async timer to detect if VPD collection is done.
SetTimerToDetectVpdCollectionStatus();
// set async timer to detect if VPD collection is done.
SetTimerToDetectVpdCollectionStatus();

// Instantiate GpioMonitor class
m_gpioMonitor = std::make_shared<GpioMonitor>(
m_worker->getSysCfgJsonObj(), m_worker, m_ioContext);
// Instantiate GpioMonitor class
m_gpioMonitor = std::make_shared<GpioMonitor>(m_worker->getSysCfgJsonObj(),
m_worker, m_ioContext);

#endif
// set callback to detect host state change.
registerHostStateChangeCallback();

// For backward compatibility. Should be depricated.
iFace->register_method(
"WriteKeyword",
[this](const sdbusplus::message::object_path i_path,
const std::string i_recordName, const std::string i_keyword,
const types::BinaryVector i_value) -> int {
return this->updateKeyword(
i_path, std::make_tuple(i_recordName, i_keyword, i_value));
});

// Register methods under com.ibm.VPD.Manager interface
iFace->register_method(
"UpdateKeyword",
[this](const types::Path i_vpdPath,
const types::WriteVpdParams i_paramsToWriteData) -> int {
return this->updateKeyword(i_vpdPath, i_paramsToWriteData);
});

iFace->register_method(
"WriteKeywordOnHardware",
[this](const types::Path i_fruPath,
const types::WriteVpdParams i_paramsToWriteData) -> int {
return this->updateKeywordOnHardware(i_fruPath,
i_paramsToWriteData);
});

iFace->register_method(
"ReadKeyword",
[this](const types::Path i_fruPath,
const types::ReadVpdParams i_paramsToReadData)
-> types::DbusVariantType {
return this->readKeyword(i_fruPath, i_paramsToReadData);
});

iFace->register_method(
"CollectFRUVPD",
[this](const sdbusplus::message::object_path& i_dbusObjPath) {
this->collectSingleFruVpd(i_dbusObjPath);
});

iFace->register_method(
"deleteFRUVPD",
[this](const sdbusplus::message::object_path& i_dbusObjPath) {
this->deleteSingleFruVpd(i_dbusObjPath);
});

iFace->register_method(
"GetExpandedLocationCode",
[this](const std::string& i_unexpandedLocationCode,
uint16_t& i_nodeNumber) -> std::string {
return this->getExpandedLocationCode(i_unexpandedLocationCode,
i_nodeNumber);
});

iFace->register_method("GetFRUsByExpandedLocationCode",
[this](const std::string& i_expandedLocationCode)
-> types::ListOfPaths {
return this->getFrusByExpandedLocationCode(i_expandedLocationCode);
});

iFace->register_method(
"GetFRUsByUnexpandedLocationCode",
[this](const std::string& i_unexpandedLocationCode,
uint16_t& i_nodeNumber) -> types::ListOfPaths {
return this->getFrusByUnexpandedLocationCode(
i_unexpandedLocationCode, i_nodeNumber);
});

iFace->register_method(
"GetHardwarePath",
[this](const sdbusplus::message::object_path& i_dbusObjPath)
-> std::string { return this->getHwPath(i_dbusObjPath); });

iFace->register_method("PerformVPDRecollection",
[this]() { this->performVpdRecollection(); });

// Indicates FRU VPD collection for the system has not started.
iFace->register_property_rw<std::string>(
"CollectionStatus", sdbusplus::vtable::property_::emits_change,
[this](const std::string l_currStatus, const auto&) {
m_vpdCollectionStatus = l_currStatus;
return 0;
}, [this](const auto&) { return m_vpdCollectionStatus; });
}
catch (const std::exception& e)
{
logging::logMessage("VPD-Manager service failed. " +
std::string(e.what()));
throw;
}
// set callback to detect host state change.
registerHostStateChangeCallback();

// For backward compatibility. Should be depricated.
iFace->register_method("WriteKeyword",
[this](const sdbusplus::message::object_path i_path,
const std::string i_recordName,
const std::string i_keyword,
const types::BinaryVector i_value) -> int {
return this->updateKeyword(
i_path, std::make_tuple(i_recordName, i_keyword, i_value));
});

// Register methods under com.ibm.VPD.Manager interface
iFace->register_method(
"UpdateKeyword",
[this](const types::Path i_vpdPath,
const types::WriteVpdParams i_paramsToWriteData) -> int {
return this->updateKeyword(i_vpdPath, i_paramsToWriteData);
});

iFace->register_method(
"WriteKeywordOnHardware",
[this](const types::Path i_fruPath,
const types::WriteVpdParams i_paramsToWriteData) -> int {
return this->updateKeywordOnHardware(i_fruPath, i_paramsToWriteData);
});

iFace->register_method("ReadKeyword",
[this](const types::Path i_fruPath,
const types::ReadVpdParams i_paramsToReadData)
-> types::DbusVariantType {
return this->readKeyword(i_fruPath, i_paramsToReadData);
});

iFace->register_method(
"CollectFRUVPD",
[this](const sdbusplus::message::object_path& i_dbusObjPath) {
this->collectSingleFruVpd(i_dbusObjPath);
});

iFace->register_method(
"deleteFRUVPD",
[this](const sdbusplus::message::object_path& i_dbusObjPath) {
this->deleteSingleFruVpd(i_dbusObjPath);
});

iFace->register_method("GetExpandedLocationCode",
[this](const std::string& i_unexpandedLocationCode,
uint16_t& i_nodeNumber) -> std::string {
return this->getExpandedLocationCode(i_unexpandedLocationCode,
i_nodeNumber);
});

iFace->register_method("GetFRUsByExpandedLocationCode",
[this](const std::string& i_expandedLocationCode)
-> types::ListOfPaths {
return this->getFrusByExpandedLocationCode(i_expandedLocationCode);
});

iFace->register_method(
"GetFRUsByUnexpandedLocationCode",
[this](const std::string& i_unexpandedLocationCode,
uint16_t& i_nodeNumber) -> types::ListOfPaths {
return this->getFrusByUnexpandedLocationCode(i_unexpandedLocationCode,
i_nodeNumber);
});

iFace->register_method(
"GetHardwarePath",
[this](const sdbusplus::message::object_path& i_dbusObjPath)
-> std::string { return this->getHwPath(i_dbusObjPath); });

iFace->register_method("PerformVPDRecollection",
[this]() { this->performVpdRecollection(); });

// Indicates FRU VPD collection for the system has not started.
iFace->register_property_rw<std::string>(
"CollectionStatus", sdbusplus::vtable::property_::emits_change,
[this](const std::string l_currStatus, const auto&) {
m_vpdCollectionStatus = l_currStatus;
return 0;
}, [this](const auto&) { return m_vpdCollectionStatus; });
}

#ifdef IBM_SYSTEM
Expand Down Expand Up @@ -197,9 +186,12 @@ void Manager::processAssetTagChangeCallback(sdbusplus::message_t& i_msg)
}
catch (const std::exception& l_ex)
{
// TODO: Log PEL with below description.
logging::logMessage("Asset tag callback update failed with error: " +
std::string(l_ex.what()));
EventLogger::createSyncPel(
types::ErrorType::InvalidVpdMessage,
types::SeverityType::Informational, __FILE__, __FUNCTION__, 0,
"Asset tag callback update failed with error: " +
std::string(l_ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
}
}

Expand Down Expand Up @@ -353,9 +345,12 @@ int Manager::updateKeyword(const types::Path i_vpdPath,
}
catch (const std::exception& l_exception)
{
// TODO:: error log needed
logging::logMessage("Update keyword failed for file[" + i_vpdPath +
"], reason: " + std::string(l_exception.what()));
EventLogger::createSyncPel(
types::ErrorType::InvalidVpdMessage,
types::SeverityType::Informational, __FILE__, __FUNCTION__, 0,
"Update keyword failed for file[" + i_vpdPath +
"], reason: " + std::string(l_exception.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
return -1;
}
}
Expand Down Expand Up @@ -531,8 +526,11 @@ void Manager::collectSingleFruVpd(
}
catch (const std::exception& l_error)
{
// TODO: Log PEL
logging::logMessage(std::string(l_error.what()));
EventLogger::createSyncPel(types::ErrorType::InvalidVpdMessage,
types::SeverityType::Informational, __FILE__,
__FUNCTION__, 0, std::string(l_error.what()),
std::nullopt, std::nullopt, std::nullopt,
std::nullopt);
}
}

Expand All @@ -558,8 +556,10 @@ void Manager::deleteSingleFruVpd(
}
catch (const std::exception& l_ex)
{
// TODO: Log PEL
logging::logMessage(l_ex.what());
EventLogger::createSyncPel(types::ErrorType::InvalidVpdMessage,
types::SeverityType::Informational, __FILE__,
__FUNCTION__, 0, l_ex.what(), std::nullopt,
std::nullopt, std::nullopt, std::nullopt);
}
}

Expand Down Expand Up @@ -867,8 +867,12 @@ void Manager::hostStateChangeCallBack(sdbusplus::message_t& i_msg)
}
catch (const std::exception& l_ex)
{
// TODO: Log PEL.
logging::logMessage(l_ex.what());
EventLogger::createSyncPel(
types::ErrorType::InvalidVpdMessage,
types::SeverityType::Informational, __FILE__, __FUNCTION__, 0,
"Failed to get Host state change call back. Error: " +
std::string(l_ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
}
}

Expand Down Expand Up @@ -905,9 +909,11 @@ void Manager::performVpdRecollection()
}
catch (const std::exception& l_ex)
{
// TODO Log PEL
logging::logMessage("VPD recollection failed with error: " +
std::string(l_ex.what()));
EventLogger::createSyncPel(
types::ErrorType::InvalidVpdMessage,
types::SeverityType::Informational, __FILE__, __FUNCTION__, 0,
"VPD recollection failed with error: " + std::string(l_ex.what()),
std::nullopt, std::nullopt, std::nullopt, std::nullopt);
}
}
} // namespace vpd

0 comments on commit 9ec42b1

Please sign in to comment.