blob: e706077499289e5ea447936750ab6bc9a3aa5846 [file] [log] [blame]
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -05001#include "config.h"
2
3#include "manager.hpp"
4
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -05005#include "constants.hpp"
6#include "exceptions.hpp"
7#include "logger.hpp"
8#include "parser.hpp"
9#include "parser_factory.hpp"
10#include "parser_interface.hpp"
Rekha Aparnaffdff312025-03-25 01:10:56 -050011#include "single_fab.hpp"
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -050012#include "types.hpp"
13#include "utility/dbus_utility.hpp"
14#include "utility/json_utility.hpp"
15#include "utility/vpd_specific_utility.hpp"
16
17#include <boost/asio/steady_timer.hpp>
18#include <sdbusplus/bus/match.hpp>
19#include <sdbusplus/message.hpp>
20
21namespace vpd
22{
23Manager::Manager(
24 const std::shared_ptr<boost::asio::io_context>& ioCon,
25 const std::shared_ptr<sdbusplus::asio::dbus_interface>& iFace,
26 const std::shared_ptr<sdbusplus::asio::connection>& asioConnection) :
27 m_ioContext(ioCon), m_interface(iFace), m_asioConnection(asioConnection)
28{
Jinu Joy Thomas3419f5d2025-04-09 04:04:18 -050029#ifdef IBM_SYSTEM
Rekha Aparnaffdff312025-03-25 01:10:56 -050030 if (!dbusUtility::isChassisPowerOn())
31 {
32 SingleFab l_singleFab;
33 const int& l_rc = l_singleFab.singleFabImOverride();
34
35 if (l_rc == constants::FAILURE)
36 {
37 throw std::runtime_error(
38 std::string(__FUNCTION__) +
39 " : Found an invalid system configuration. Needs manual intervention. BMC is being quiesced.");
40 }
41 }
42#endif
43
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -050044 try
45 {
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -050046 // For backward compatibility. Should be depricated.
47 iFace->register_method(
48 "WriteKeyword",
49 [this](const sdbusplus::message::object_path i_path,
50 const std::string i_recordName, const std::string i_keyword,
51 const types::BinaryVector i_value) -> int {
52 return this->updateKeyword(
53 i_path, std::make_tuple(i_recordName, i_keyword, i_value));
54 });
55
56 // Register methods under com.ibm.VPD.Manager interface
57 iFace->register_method(
58 "UpdateKeyword",
59 [this](const types::Path i_vpdPath,
60 const types::WriteVpdParams i_paramsToWriteData) -> int {
61 return this->updateKeyword(i_vpdPath, i_paramsToWriteData);
62 });
63
64 iFace->register_method(
65 "WriteKeywordOnHardware",
66 [this](const types::Path i_fruPath,
67 const types::WriteVpdParams i_paramsToWriteData) -> int {
68 return this->updateKeywordOnHardware(i_fruPath,
69 i_paramsToWriteData);
70 });
71
72 iFace->register_method(
73 "ReadKeyword",
74 [this](const types::Path i_fruPath,
75 const types::ReadVpdParams i_paramsToReadData)
76 -> types::DbusVariantType {
77 return this->readKeyword(i_fruPath, i_paramsToReadData);
78 });
79
80 iFace->register_method(
81 "CollectFRUVPD",
82 [this](const sdbusplus::message::object_path& i_dbusObjPath) {
83 this->collectSingleFruVpd(i_dbusObjPath);
84 });
85
86 iFace->register_method(
87 "deleteFRUVPD",
88 [this](const sdbusplus::message::object_path& i_dbusObjPath) {
89 this->deleteSingleFruVpd(i_dbusObjPath);
90 });
91
92 iFace->register_method(
93 "GetExpandedLocationCode",
94 [this](const std::string& i_unexpandedLocationCode,
95 uint16_t& i_nodeNumber) -> std::string {
96 return this->getExpandedLocationCode(i_unexpandedLocationCode,
97 i_nodeNumber);
98 });
99
100 iFace->register_method("GetFRUsByExpandedLocationCode",
101 [this](const std::string& i_expandedLocationCode)
102 -> types::ListOfPaths {
103 return this->getFrusByExpandedLocationCode(
104 i_expandedLocationCode);
105 });
106
107 iFace->register_method(
108 "GetFRUsByUnexpandedLocationCode",
109 [this](const std::string& i_unexpandedLocationCode,
110 uint16_t& i_nodeNumber) -> types::ListOfPaths {
111 return this->getFrusByUnexpandedLocationCode(
112 i_unexpandedLocationCode, i_nodeNumber);
113 });
114
115 iFace->register_method(
116 "GetHardwarePath",
117 [this](const sdbusplus::message::object_path& i_dbusObjPath)
118 -> std::string { return this->getHwPath(i_dbusObjPath); });
119
120 iFace->register_method("PerformVPDRecollection", [this]() {
121 this->performVpdRecollection();
122 });
123
Anupama B R7127ab42025-06-26 01:39:08 -0500124 iFace->register_method("CollectAllFRUVPD", [this]() -> bool {
125 return this->collectAllFruVpd();
126 });
127
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500128 // Indicates FRU VPD collection for the system has not started.
129 iFace->register_property_rw<std::string>(
130 "CollectionStatus", sdbusplus::vtable::property_::emits_change,
Souvik Roya6832472025-05-22 13:18:12 -0500131 [this](const std::string& l_currStatus, const auto&) {
Souvik Roy251d85e2025-05-26 04:30:30 -0500132 if (m_vpdCollectionStatus != l_currStatus)
133 {
134 m_vpdCollectionStatus = l_currStatus;
135 m_interface->signal_property("CollectionStatus");
136 }
Souvik Roya6832472025-05-22 13:18:12 -0500137 return true;
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500138 },
139 [this](const auto&) { return m_vpdCollectionStatus; });
Sunny Srivastavac74c8ef2025-04-16 12:45:27 +0530140
141 // If required, instantiate OEM specific handler here.
142#ifdef IBM_SYSTEM
143 m_ibmHandler = std::make_shared<IbmHandler>(
144 m_worker, m_backupAndRestoreObj, m_interface, m_ioContext,
145 m_asioConnection);
Sunny Srivastavac74c8ef2025-04-16 12:45:27 +0530146#else
147 m_worker = std::make_shared<Worker>(INVENTORY_JSON_DEFAULT);
148 m_interface->set_property("CollectionStatus", std::string("Completed"));
149#endif
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500150 }
151 catch (const std::exception& e)
152 {
153 logging::logMessage(
Sunny Srivastava4c509c22025-03-25 12:43:40 +0530154 "Manager class instantiation failed. " + std::string(e.what()));
155
156 vpd::EventLogger::createSyncPel(
157 vpd::EventLogger::getErrorType(e), vpd::types::SeverityType::Error,
158 __FILE__, __FUNCTION__, 0, vpd::EventLogger::getErrorMsg(e),
159 std::nullopt, std::nullopt, std::nullopt, std::nullopt);
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500160 }
161}
162
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500163int Manager::updateKeyword(const types::Path i_vpdPath,
164 const types::WriteVpdParams i_paramsToWriteData)
165{
166 if (i_vpdPath.empty())
167 {
168 logging::logMessage("Given VPD path is empty.");
169 return -1;
170 }
171
172 types::Path l_fruPath;
173 nlohmann::json l_sysCfgJsonObj{};
174
175 if (m_worker.get() != nullptr)
176 {
177 l_sysCfgJsonObj = m_worker->getSysCfgJsonObj();
178
179 // Get the EEPROM path
180 if (!l_sysCfgJsonObj.empty())
181 {
RekhaAparna017fea9f52025-02-17 04:14:02 -0600182 l_fruPath =
183 jsonUtility::getFruPathFromJson(l_sysCfgJsonObj, i_vpdPath);
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500184 }
185 }
186
187 if (l_fruPath.empty())
188 {
189 l_fruPath = i_vpdPath;
190 }
191
192 try
193 {
194 std::shared_ptr<Parser> l_parserObj =
195 std::make_shared<Parser>(l_fruPath, l_sysCfgJsonObj);
Anupama B R8dedd1e2025-03-24 07:43:47 -0500196 auto l_rc = l_parserObj->updateVpdKeyword(i_paramsToWriteData);
197
198 if (l_rc != constants::FAILURE && m_backupAndRestoreObj)
199 {
200 if (m_backupAndRestoreObj->updateKeywordOnPrimaryOrBackupPath(
201 l_fruPath, i_paramsToWriteData) < constants::VALUE_0)
202 {
203 logging::logMessage(
204 "Write success, but backup and restore failed for file[" +
205 l_fruPath + "]");
206 }
207 }
Souvik Roy2ee8a212025-04-24 02:37:59 -0500208
209 // update keyword in inherited FRUs
210 if (l_rc != constants::FAILURE)
211 {
212 vpdSpecificUtility::updateKwdOnInheritedFrus(
213 l_fruPath, i_paramsToWriteData, l_sysCfgJsonObj);
214 }
215
Souvik Roy96ebe962025-04-29 04:01:07 -0500216 // update common interface(s) properties
217 if (l_rc != constants::FAILURE)
218 {
219 vpdSpecificUtility::updateCiPropertyOfInheritedFrus(
220 l_fruPath, i_paramsToWriteData, l_sysCfgJsonObj);
221 }
222
Anupama B R8dedd1e2025-03-24 07:43:47 -0500223 return l_rc;
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500224 }
225 catch (const std::exception& l_exception)
226 {
227 // TODO:: error log needed
228 logging::logMessage("Update keyword failed for file[" + i_vpdPath +
229 "], reason: " + std::string(l_exception.what()));
230 return -1;
231 }
232}
233
234int Manager::updateKeywordOnHardware(
235 const types::Path i_fruPath,
236 const types::WriteVpdParams i_paramsToWriteData) noexcept
237{
238 try
239 {
240 if (i_fruPath.empty())
241 {
242 throw std::runtime_error("Given FRU path is empty");
243 }
244
245 nlohmann::json l_sysCfgJsonObj{};
246
247 if (m_worker.get() != nullptr)
248 {
249 l_sysCfgJsonObj = m_worker->getSysCfgJsonObj();
250 }
251
252 std::shared_ptr<Parser> l_parserObj =
253 std::make_shared<Parser>(i_fruPath, l_sysCfgJsonObj);
254 return l_parserObj->updateVpdKeywordOnHardware(i_paramsToWriteData);
255 }
256 catch (const std::exception& l_exception)
257 {
258 EventLogger::createAsyncPel(
259 types::ErrorType::InvalidEeprom, types::SeverityType::Informational,
260 __FILE__, __FUNCTION__, 0,
261 "Update keyword on hardware failed for file[" + i_fruPath +
262 "], reason: " + std::string(l_exception.what()),
263 std::nullopt, std::nullopt, std::nullopt, std::nullopt);
264
265 return constants::FAILURE;
266 }
267}
268
269types::DbusVariantType Manager::readKeyword(
270 const types::Path i_fruPath, const types::ReadVpdParams i_paramsToReadData)
271{
272 try
273 {
274 nlohmann::json l_jsonObj{};
275
276 if (m_worker.get() != nullptr)
277 {
278 l_jsonObj = m_worker->getSysCfgJsonObj();
279 }
280
281 std::error_code ec;
282
283 // Check if given path is filesystem path
284 if (!std::filesystem::exists(i_fruPath, ec) && (ec))
285 {
286 throw std::runtime_error(
287 "Given file path " + i_fruPath + " not found.");
288 }
289
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500290 std::shared_ptr<vpd::Parser> l_parserObj =
291 std::make_shared<vpd::Parser>(i_fruPath, l_jsonObj);
292
293 std::shared_ptr<vpd::ParserInterface> l_vpdParserInstance =
294 l_parserObj->getVpdParserInstance();
295
296 return (
297 l_vpdParserInstance->readKeywordFromHardware(i_paramsToReadData));
298 }
299 catch (const std::exception& e)
300 {
301 logging::logMessage(
302 e.what() + std::string(". VPD manager read operation failed for ") +
303 i_fruPath);
304 throw types::DeviceError::ReadFailure();
305 }
306}
307
308void Manager::collectSingleFruVpd(
309 const sdbusplus::message::object_path& i_dbusObjPath)
310{
Sunny Srivastava380efbb2025-04-25 10:28:30 +0530311 if (m_vpdCollectionStatus != "Completed")
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500312 {
Sunny Srivastava380efbb2025-04-25 10:28:30 +0530313 logging::logMessage(
314 "Currently VPD CollectionStatus is not completed. Cannot perform single FRU VPD collection for " +
315 std::string(i_dbusObjPath));
316 return;
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500317 }
Priyanga Ramasamy46b73d92025-01-09 10:52:07 -0600318
Sunny Srivastava380efbb2025-04-25 10:28:30 +0530319 if (m_worker.get() != nullptr)
320 {
321 m_worker->collectSingleFruVpd(i_dbusObjPath);
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500322 }
323}
324
325void Manager::deleteSingleFruVpd(
326 const sdbusplus::message::object_path& i_dbusObjPath)
327{
328 try
329 {
330 if (std::string(i_dbusObjPath).empty())
331 {
332 throw std::runtime_error(
333 "Given DBus object path is empty. Aborting FRU VPD deletion.");
334 }
335
336 if (m_worker.get() == nullptr)
337 {
338 throw std::runtime_error(
339 "Worker object not found, can't perform FRU VPD deletion for: " +
340 std::string(i_dbusObjPath));
341 }
342
343 m_worker->deleteFruVpd(std::string(i_dbusObjPath));
344 }
345 catch (const std::exception& l_ex)
346 {
347 // TODO: Log PEL
348 logging::logMessage(l_ex.what());
349 }
350}
351
352bool Manager::isValidUnexpandedLocationCode(
353 const std::string& i_unexpandedLocationCode)
354{
355 if ((i_unexpandedLocationCode.length() <
356 constants::UNEXP_LOCATION_CODE_MIN_LENGTH) ||
357 ((i_unexpandedLocationCode.compare(0, 4, "Ufcs") !=
358 constants::STR_CMP_SUCCESS) &&
359 (i_unexpandedLocationCode.compare(0, 4, "Umts") !=
360 constants::STR_CMP_SUCCESS)) ||
361 ((i_unexpandedLocationCode.length() >
362 constants::UNEXP_LOCATION_CODE_MIN_LENGTH) &&
363 (i_unexpandedLocationCode.find("-") != 4)))
364 {
365 return false;
366 }
367
368 return true;
369}
370
371std::string Manager::getExpandedLocationCode(
372 const std::string& i_unexpandedLocationCode,
373 [[maybe_unused]] const uint16_t i_nodeNumber)
374{
375 if (!isValidUnexpandedLocationCode(i_unexpandedLocationCode))
376 {
377 phosphor::logging::elog<types::DbusInvalidArgument>(
378 types::InvalidArgument::ARGUMENT_NAME("LOCATIONCODE"),
379 types::InvalidArgument::ARGUMENT_VALUE(
380 i_unexpandedLocationCode.c_str()));
381 }
382
383 const nlohmann::json& l_sysCfgJsonObj = m_worker->getSysCfgJsonObj();
384 if (!l_sysCfgJsonObj.contains("frus"))
385 {
386 logging::logMessage("Missing frus tag in system config JSON");
387 }
388
389 const nlohmann::json& l_listOfFrus =
390 l_sysCfgJsonObj["frus"].get_ref<const nlohmann::json::object_t&>();
391
392 for (const auto& l_frus : l_listOfFrus.items())
393 {
394 for (const auto& l_aFru : l_frus.value())
395 {
396 if (l_aFru["extraInterfaces"].contains(
397 constants::locationCodeInf) &&
398 l_aFru["extraInterfaces"][constants::locationCodeInf].value(
399 "LocationCode", "") == i_unexpandedLocationCode)
400 {
401 return std::get<std::string>(dbusUtility::readDbusProperty(
402 l_aFru["serviceName"], l_aFru["inventoryPath"],
403 constants::locationCodeInf, "LocationCode"));
404 }
405 }
406 }
407 phosphor::logging::elog<types::DbusInvalidArgument>(
408 types::InvalidArgument::ARGUMENT_NAME("LOCATIONCODE"),
409 types::InvalidArgument::ARGUMENT_VALUE(
410 i_unexpandedLocationCode.c_str()));
411}
412
413types::ListOfPaths Manager::getFrusByUnexpandedLocationCode(
414 const std::string& i_unexpandedLocationCode,
415 [[maybe_unused]] const uint16_t i_nodeNumber)
416{
417 types::ListOfPaths l_inventoryPaths;
418
419 if (!isValidUnexpandedLocationCode(i_unexpandedLocationCode))
420 {
421 phosphor::logging::elog<types::DbusInvalidArgument>(
422 types::InvalidArgument::ARGUMENT_NAME("LOCATIONCODE"),
423 types::InvalidArgument::ARGUMENT_VALUE(
424 i_unexpandedLocationCode.c_str()));
425 }
426
427 const nlohmann::json& l_sysCfgJsonObj = m_worker->getSysCfgJsonObj();
428 if (!l_sysCfgJsonObj.contains("frus"))
429 {
430 logging::logMessage("Missing frus tag in system config JSON");
431 }
432
433 const nlohmann::json& l_listOfFrus =
434 l_sysCfgJsonObj["frus"].get_ref<const nlohmann::json::object_t&>();
435
436 for (const auto& l_frus : l_listOfFrus.items())
437 {
438 for (const auto& l_aFru : l_frus.value())
439 {
440 if (l_aFru["extraInterfaces"].contains(
441 constants::locationCodeInf) &&
442 l_aFru["extraInterfaces"][constants::locationCodeInf].value(
443 "LocationCode", "") == i_unexpandedLocationCode)
444 {
445 l_inventoryPaths.push_back(
446 l_aFru.at("inventoryPath")
447 .get_ref<const nlohmann::json::string_t&>());
448 }
449 }
450 }
451
452 if (l_inventoryPaths.empty())
453 {
454 phosphor::logging::elog<types::DbusInvalidArgument>(
455 types::InvalidArgument::ARGUMENT_NAME("LOCATIONCODE"),
456 types::InvalidArgument::ARGUMENT_VALUE(
457 i_unexpandedLocationCode.c_str()));
458 }
459
460 return l_inventoryPaths;
461}
462
Patrick Williams43fedab2025-02-03 14:28:05 -0500463std::string Manager::getHwPath(
464 const sdbusplus::message::object_path& i_dbusObjPath)
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500465{
466 // Dummy code to supress unused variable warning. To be removed.
467 logging::logMessage(std::string(i_dbusObjPath));
468
469 return std::string{};
470}
471
472std::tuple<std::string, uint16_t> Manager::getUnexpandedLocationCode(
473 const std::string& i_expandedLocationCode)
474{
475 /**
476 * Location code should always start with U and fulfil minimum length
477 * criteria.
478 */
479 if (i_expandedLocationCode[0] != 'U' ||
480 i_expandedLocationCode.length() <
481 constants::EXP_LOCATION_CODE_MIN_LENGTH)
482 {
483 phosphor::logging::elog<types::DbusInvalidArgument>(
484 types::InvalidArgument::ARGUMENT_NAME("LOCATIONCODE"),
485 types::InvalidArgument::ARGUMENT_VALUE(
486 i_expandedLocationCode.c_str()));
487 }
488
489 std::string l_fcKwd;
490
491 auto l_fcKwdValue = dbusUtility::readDbusProperty(
492 "xyz.openbmc_project.Inventory.Manager",
493 "/xyz/openbmc_project/inventory/system/chassis/motherboard",
494 "com.ibm.ipzvpd.VCEN", "FC");
495
496 if (auto l_kwdValue = std::get_if<types::BinaryVector>(&l_fcKwdValue))
497 {
498 l_fcKwd.assign(l_kwdValue->begin(), l_kwdValue->end());
499 }
500
501 // Get the first part of expanded location code to check for FC or TM.
502 std::string l_firstKwd = i_expandedLocationCode.substr(1, 4);
503
504 std::string l_unexpandedLocationCode{};
505 uint16_t l_nodeNummber = constants::INVALID_NODE_NUMBER;
506
507 // Check if this value matches the value of FC keyword.
508 if (l_fcKwd.substr(0, 4) == l_firstKwd)
509 {
510 /**
511 * Period(.) should be there in expanded location code to seggregate
512 * FC, node number and SE values.
513 */
514 size_t l_nodeStartPos = i_expandedLocationCode.find('.');
515 if (l_nodeStartPos == std::string::npos)
516 {
517 phosphor::logging::elog<types::DbusInvalidArgument>(
518 types::InvalidArgument::ARGUMENT_NAME("LOCATIONCODE"),
519 types::InvalidArgument::ARGUMENT_VALUE(
520 i_expandedLocationCode.c_str()));
521 }
522
523 size_t l_nodeEndPos =
524 i_expandedLocationCode.find('.', l_nodeStartPos + 1);
525 if (l_nodeEndPos == std::string::npos)
526 {
527 phosphor::logging::elog<types::DbusInvalidArgument>(
528 types::InvalidArgument::ARGUMENT_NAME("LOCATIONCODE"),
529 types::InvalidArgument::ARGUMENT_VALUE(
530 i_expandedLocationCode.c_str()));
531 }
532
533 // Skip 3 bytes for '.ND'
534 l_nodeNummber = std::stoi(i_expandedLocationCode.substr(
535 l_nodeStartPos + 3, (l_nodeEndPos - l_nodeStartPos - 3)));
536
537 /**
538 * Confirm if there are other details apart FC, node number and SE
539 * in location code
540 */
541 if (i_expandedLocationCode.length() >
542 constants::EXP_LOCATION_CODE_MIN_LENGTH)
543 {
544 l_unexpandedLocationCode =
545 i_expandedLocationCode[0] + std::string("fcs") +
546 i_expandedLocationCode.substr(
547 l_nodeEndPos + 1 + constants::SE_KWD_LENGTH,
548 std::string::npos);
549 }
550 else
551 {
552 l_unexpandedLocationCode = "Ufcs";
553 }
554 }
555 else
556 {
557 std::string l_tmKwd;
558 // Read TM keyword value.
559 auto l_tmKwdValue = dbusUtility::readDbusProperty(
560 "xyz.openbmc_project.Inventory.Manager",
561 "/xyz/openbmc_project/inventory/system/chassis/motherboard",
562 "com.ibm.ipzvpd.VSYS", "TM");
563
564 if (auto l_kwdValue = std::get_if<types::BinaryVector>(&l_tmKwdValue))
565 {
566 l_tmKwd.assign(l_kwdValue->begin(), l_kwdValue->end());
567 }
568
569 // Check if the substr matches to TM keyword value.
570 if (l_tmKwd.substr(0, 4) == l_firstKwd)
571 {
572 /**
573 * System location code will not have node number and any other
574 * details.
575 */
576 l_unexpandedLocationCode = "Umts";
577 }
578 // The given location code is neither "fcs" or "mts".
579 else
580 {
581 phosphor::logging::elog<types::DbusInvalidArgument>(
582 types::InvalidArgument::ARGUMENT_NAME("LOCATIONCODE"),
583 types::InvalidArgument::ARGUMENT_VALUE(
584 i_expandedLocationCode.c_str()));
585 }
586 }
587
588 return std::make_tuple(l_unexpandedLocationCode, l_nodeNummber);
589}
590
591types::ListOfPaths Manager::getFrusByExpandedLocationCode(
592 const std::string& i_expandedLocationCode)
593{
594 std::tuple<std::string, uint16_t> l_locationAndNodePair =
595 getUnexpandedLocationCode(i_expandedLocationCode);
596
597 return getFrusByUnexpandedLocationCode(std::get<0>(l_locationAndNodePair),
598 std::get<1>(l_locationAndNodePair));
599}
600
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500601void Manager::performVpdRecollection()
602{
Sunny Srivastava380efbb2025-04-25 10:28:30 +0530603 if (m_worker.get() != nullptr)
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500604 {
Sunny Srivastava380efbb2025-04-25 10:28:30 +0530605 m_worker->performVpdRecollection();
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500606 }
607}
Anupama B R7127ab42025-06-26 01:39:08 -0500608
609bool Manager::collectAllFruVpd() const noexcept
610{
611 try
612 {
613 types::SeverityType l_severityType;
614 if (m_vpdCollectionStatus == "NotStarted")
615 {
616 l_severityType = types::SeverityType::Informational;
617 }
618 else if (m_vpdCollectionStatus == "Completed" ||
619 m_vpdCollectionStatus == "Failure")
620 {
621 l_severityType = types::SeverityType::Warning;
622 }
623 else
624 {
625 throw std::runtime_error(
626 "Invalid collection status " + m_vpdCollectionStatus +
627 ". Aborting all FRUs VPD collection.");
628 }
629
630 EventLogger::createSyncPel(
631 types::ErrorType::FirmwareError, l_severityType, __FILE__,
632 __FUNCTION__, 0, "Collect all FRUs VPD is requested.", std::nullopt,
633 std::nullopt, std::nullopt, std::nullopt);
634
Anupama B Rb6787bf2025-07-16 01:36:53 -0500635// ToDo: Handle with OEM interface
636#ifdef IBM_SYSTEM
Anupama B R7127ab42025-06-26 01:39:08 -0500637 if (m_ibmHandler.get() != nullptr)
638 {
639 m_ibmHandler->collectAllFruVpd();
640 return true;
641 }
642 else
643 {
644 throw std::runtime_error(
645 "Not found any OEM handler to collect all FRUs VPD.");
646 }
Anupama B Rb6787bf2025-07-16 01:36:53 -0500647#endif
Anupama B R7127ab42025-06-26 01:39:08 -0500648 }
649 catch (const std::exception& l_ex)
650 {
651 EventLogger::createSyncPel(
652 EventLogger::getErrorType(l_ex), types::SeverityType::Warning,
653 __FILE__, __FUNCTION__, 0, std::string(l_ex.what()), std::nullopt,
654 std::nullopt, std::nullopt, std::nullopt);
655 }
656 return false;
657}
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -0500658} // namespace vpd