Collect all FRUs VPD Dbus method in vpd-manager
This commit adds code to expose new dbus method CollectAllFRUVPD under
vpd-manager service for VPD collection for all the FRUs present in the
system config JSON.
Change-Id: I393ffc15d684d6a0934d12a7f4bc1e23fdda054d
Signed-off-by: Anupama B R <anupama.b.r1@ibm.com>
diff --git a/vpd-manager/src/manager.cpp b/vpd-manager/src/manager.cpp
index f57596c..89283df 100644
--- a/vpd-manager/src/manager.cpp
+++ b/vpd-manager/src/manager.cpp
@@ -121,6 +121,10 @@
this->performVpdRecollection();
});
+ iFace->register_method("CollectAllFRUVPD", [this]() -> bool {
+ return this->collectAllFruVpd();
+ });
+
// Indicates FRU VPD collection for the system has not started.
iFace->register_property_rw<std::string>(
"CollectionStatus", sdbusplus::vtable::property_::emits_change,
@@ -603,4 +607,51 @@
m_worker->performVpdRecollection();
}
}
+
+bool Manager::collectAllFruVpd() const noexcept
+{
+ try
+ {
+ types::SeverityType l_severityType;
+ if (m_vpdCollectionStatus == "NotStarted")
+ {
+ l_severityType = types::SeverityType::Informational;
+ }
+ else if (m_vpdCollectionStatus == "Completed" ||
+ m_vpdCollectionStatus == "Failure")
+ {
+ l_severityType = types::SeverityType::Warning;
+ }
+ else
+ {
+ throw std::runtime_error(
+ "Invalid collection status " + m_vpdCollectionStatus +
+ ". Aborting all FRUs VPD collection.");
+ }
+
+ EventLogger::createSyncPel(
+ types::ErrorType::FirmwareError, l_severityType, __FILE__,
+ __FUNCTION__, 0, "Collect all FRUs VPD is requested.", std::nullopt,
+ std::nullopt, std::nullopt, std::nullopt);
+
+ if (m_ibmHandler.get() != nullptr)
+ {
+ m_ibmHandler->collectAllFruVpd();
+ return true;
+ }
+ else
+ {
+ throw std::runtime_error(
+ "Not found any OEM handler to collect all FRUs VPD.");
+ }
+ }
+ catch (const std::exception& l_ex)
+ {
+ EventLogger::createSyncPel(
+ EventLogger::getErrorType(l_ex), types::SeverityType::Warning,
+ __FILE__, __FUNCTION__, 0, std::string(l_ex.what()), std::nullopt,
+ std::nullopt, std::nullopt, std::nullopt);
+ }
+ return false;
+}
} // namespace vpd