PEL: Check Presence Before Error Logging
In case of VPD parsing exceptions, check if the FRU presence is false.
If it is, then ignore any parser errors.
This helps with cases where a card with a VPD we don't recognize
shows up at the same address, but witout the presence detect.
Signed-off-by: Santosh Puranik <santosh.puranik@in.ibm.com>
Change-Id: Ia57dec455f37db52c480b9dbbb23b3cea2ec0f14
diff --git a/ibm_vpd_utils.cpp b/ibm_vpd_utils.cpp
index 2690c26..c75c0de 100644
--- a/ibm_vpd_utils.cpp
+++ b/ibm_vpd_utils.cpp
@@ -662,7 +662,8 @@
}
}
-bool executePreAction(const nlohmann::json& json, const string& file)
+std::optional<bool> isPresent(const nlohmann::json& json, const string& file)
+
{
if ((json["frus"][file].at(0)).find("presence") !=
json["frus"][file].at(0).end())
@@ -683,7 +684,6 @@
{
cerr << "couldn't find presence line:" << presPinName
<< "\n";
- executePostFailAction(json, file);
return false;
}
@@ -692,21 +692,27 @@
Byte gpioData = presenceLine.get_value();
- if (gpioData != presPinValue)
- {
- executePostFailAction(json, file);
- return false;
- }
+ return (gpioData == presPinValue);
}
catch (system_error&)
{
cerr << "Failed to get the presence GPIO for - " << presPinName
<< endl;
- executePostFailAction(json, file);
return false;
}
}
}
+ return std::optional<bool>{};
+}
+
+bool executePreAction(const nlohmann::json& json, const string& file)
+{
+ auto present = isPresent(json, file);
+ if (present && !present.value())
+ {
+ executePostFailAction(json, file);
+ return false;
+ }
if ((json["frus"][file].at(0)).find("preAction") !=
json["frus"][file].at(0).end())