Process FRU only when present with specific CCIN
Some FRUs are only supported with specific CCINs in case of PowerVS
configuration.
The commit implements changes to check for presence of the FRU based on
its Present property, if found checks for specific CCIN, if found
updates the PN else skips.
Change-Id: I1f3ff08f82788aed4d8153474cd38352e5cc2394
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/vpd-manager/src/manager.cpp b/vpd-manager/src/manager.cpp
index fd63ffc..437fdd9 100644
--- a/vpd-manager/src/manager.cpp
+++ b/vpd-manager/src/manager.cpp
@@ -329,9 +329,65 @@
{
for (const auto& [l_fruPath, l_recJson] : i_powerVsJsonObj.items())
{
- // TODO add special handling for PROC CCIN check.
+ nlohmann::json l_sysCfgJsonObj{};
+ if (m_worker.get() != nullptr)
+ {
+ l_sysCfgJsonObj = m_worker->getSysCfgJsonObj();
+ }
+
+ // The utility method will handle emty JSON case. No explicit
+ // handling required here.
+ auto l_inventoryPath = jsonUtility::getInventoryObjPathFromJson(
+ l_sysCfgJsonObj, l_fruPath);
+
+ // Mark it as failed if inventory path not found in JSON.
+ if (l_inventoryPath.empty())
+ {
+ o_failedPathList.push_back(l_fruPath);
+ continue;
+ }
+
+ // check if the FRU is present
+ if (!dbusUtility::isInventoryPresent(l_inventoryPath))
+ {
+ logging::logMessage(
+ "Inventory not present, skip updating part number. Path: " +
+ l_inventoryPath);
+ continue;
+ }
+
+ // check if the FRU needs CCIN check before updating PN.
+ if (l_recJson.contains("CCIN"))
+ {
+ const auto& l_ccinFromDbus =
+ vpdSpecificUtility::getCcinFromDbus(l_inventoryPath);
+
+ // Not an ideal situation as CCIN can't be empty.
+ if (l_ccinFromDbus.empty())
+ {
+ o_failedPathList.push_back(l_fruPath);
+ continue;
+ }
+
+ std::vector<std::string> l_ccinListFromJson = l_recJson["CCIN"];
+
+ if (find(l_ccinListFromJson.begin(), l_ccinListFromJson.end(),
+ l_ccinFromDbus) == l_ccinListFromJson.end())
+ {
+ // Don't update PN in this case.
+ continue;
+ }
+ }
+
for (const auto& [l_recordName, l_kwdJson] : l_recJson.items())
{
+ // Record name can't be CCIN, skip processing as it is there for PN
+ // update based on CCIN check.
+ if (l_recordName == constants::kwdCCIN)
+ {
+ continue;
+ }
+
for (const auto& [l_kwdName, l_kwdValue] : l_kwdJson.items())
{
// Is value of type array.
@@ -341,24 +397,6 @@
continue;
}
- nlohmann::json l_sysCfgJsonObj{};
- if (m_worker.get() != nullptr)
- {
- l_sysCfgJsonObj = m_worker->getSysCfgJsonObj();
- }
-
- // The utility method will handle empty JSON case. No explicit
- // handling required here.
- auto l_inventoryPath = jsonUtility::getInventoryObjPathFromJson(
- l_sysCfgJsonObj, l_fruPath);
-
- // Mark it as failed if inventory path not found in JSON.
- if (l_inventoryPath.empty())
- {
- o_failedPathList.push_back(l_fruPath);
- continue;
- }
-
// Get current Part number.
auto l_retVal = dbusUtility::readDbusProperty(
constants::pimServiceName, l_inventoryPath,