Fix Present property update in prime inventory
This commit adds changes in vpd-manager prime inventory flow to skip
updating Present property for FRUs for which vpd-manager doesn't
handle Present property.
This commit also adds changes to skip updating Present property for a
FRU if vpd-manager is not supposed to handle Present property for the
FRU, in the scenario where VPD parsing fails for the FRU.
Test:
```
Tested on an Everest system.
- Reboot BMC with Chassis Off and fan3 plugged in.
After reboot, fan3 name and Present property appears properly on GUI.
- Reboot BMC with Chassis Off and fan3 plugged out.
After reboot, fan3 name and Present property appears properly on GUI.
Fan Health shows critical on GUI.
- Reboot BMC with Chassis On and fan3 plugged out.
After reboot, fan3 name and Present property appears properly on GUI.
fan3 Health shows critical on GUI.
- Reboot BMC with Chassis On and fan3 plugged in.
After reboot, fan3 name and Present property appears properly on GUI.
- Recreate genesis boot scenario and reboot BMC with fan3 plugged in.
After reboot, fan3 name and Present property appears properly on GUI.
- Recreate genesis boot scenario and reboot BMC with fan3 plugged out.
After reboot, fan3 name and Present property appears properly on GUI.
fan3 Health shows critical on GUI.
```
Change-Id: Ifa6a8909df059a7d3bddd34338d89f0fd8dd5098
Signed-off-by: Souvik Roy <souvikroyofficial10@gmail.com>
diff --git a/vpd-manager/include/worker.hpp b/vpd-manager/include/worker.hpp
index f364964..68ebb3a 100644
--- a/vpd-manager/include/worker.hpp
+++ b/vpd-manager/include/worker.hpp
@@ -519,6 +519,10 @@
/**
* @brief API to set present property.
*
+ * This API updates the present property of the given FRU with the given
+ * value. Note: It is the responsibility of the caller to determine whether
+ * the present property for the FRU should be updated or not.
+ *
* @param[in] i_vpdPath - EEPROM or inventory path.
* @param[in] i_value - value to be set.
*/
@@ -536,6 +540,25 @@
*/
bool skipPathForCollection(const std::string& i_vpdFilePath);
+ /**
+ * @brief API to check if present property should be handled for given FRU.
+ *
+ * vpd-manager should update present property for a FRU if and only if it's
+ * not synthesized and vpd-manager handles present property for the FRU.
+ * This API assumes "handlePresence" tag is a subset of "synthesized" tag.
+ *
+ * @param[in] i_fru - JSON block for a single FRU.
+ *
+ * @return true if present property should be handled, false otherwise.
+ */
+ inline bool isPresentPropertyHandlingRequired(
+ const nlohmann::json& i_fru) const noexcept
+ {
+ // TODO: revisit this to see if this logic can be optimized.
+ return !i_fru.value("synthesized", false) &&
+ i_fru.value("handlePresence", true);
+ }
+
// Parsed JSON file.
nlohmann::json m_parsedJson{};