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