worker::CollectionStatus for each inventory FRU
This commit populates CollectionStatus D-bus property under
com.ibm.VPD.Collection D-bus interface for each inventory D-bus object
path which represents a FRU.
The property tells the current status of VPD collection for a given
FRU's D-bus object path.
The property takes the below enum values:
>>>com.ibm.VPD.Collection.Status.Success
-------------------------------------
This value is assigned when VPD collection is successful.
>>>com.ibm.VPD.Collection.Status.Failure
-------------------------------------
VPD collection failure due to VPD exceptions.
>>>com.ibm.VPD.Collection.Status.InProgress
----------------------------------------
This value is assigned when VPD collection starts for the given FRU.
>>>com.ibm.VPD.Collection.Status.NotStarted
----------------------------------------
This default value is assigned when we hit prime inventory path.
Test:
1. VPD parsing failed for /sys/bus/i2c/drivers/at24/0-0051
/eeprom due to error: Unable to determine VPD format
=>CollectionStatus property value for tpm_wilson
s "com.ibm.VPD.Collection.Status.Failure"
2. FRU not found
s "com.ibm.VPD.Collection.Status.Failure"
3. Successful collection of VPD
s "com.ibm.VPD.Collection.Status.Success"
Change-Id: Ia5010a181f720454bb51538d6fcf308daf6b75ca
Signed-off-by: Priyanga Ramasamy <priyanga24@in.ibm.com>
diff --git a/vpd-manager/include/constants.hpp b/vpd-manager/include/constants.hpp
index 7f23070..f7e55d0 100644
--- a/vpd-manager/include/constants.hpp
+++ b/vpd-manager/include/constants.hpp
@@ -197,5 +197,18 @@
static constexpr auto systemdObjectPath = "/org/freedesktop/systemd1";
static constexpr auto systemdManagerInterface =
"org.freedesktop.systemd1.Manager";
+
+static constexpr auto vpdCollectionInterface = "com.ibm.VPD.Collection";
+
+// enumerated values of CollectionStatus D-bus property defined under
+// com.ibm.VPD.Collection interface.
+static constexpr auto vpdCollectionSuccess =
+ "com.ibm.VPD.Collection.Status.Success";
+static constexpr auto vpdCollectionFailure =
+ "com.ibm.VPD.Collection.Status.Failure";
+static constexpr auto vpdCollectionInProgress =
+ "com.ibm.VPD.Collection.Status.InProgress";
+static constexpr auto vpdCollectionNotStarted =
+ "com.ibm.VPD.Collection.Status.NotStarted";
} // namespace constants
} // namespace vpd
diff --git a/vpd-manager/include/utility/dbus_utility.hpp b/vpd-manager/include/utility/dbus_utility.hpp
index 27014df..0cb8151 100644
--- a/vpd-manager/include/utility/dbus_utility.hpp
+++ b/vpd-manager/include/utility/dbus_utility.hpp
@@ -563,5 +563,34 @@
return l_rc;
}
+/**
+ * @brief API to notify FRU VPD Collection status.
+ *
+ * This API uses PIM's Notify method to update the given FRU VPD collection
+ * status on D-bus.
+ *
+ * @param[in] i_inventoryPath - D-bus inventory path
+ * @param[in] i_fruCollectionStatus - FRU VPD collection status.
+ *
+ * @return true if update succeeds, false otherwise.
+ */
+inline bool notifyFRUCollectionStatus(const std::string& i_inventoryPath,
+ const std::string& i_fruCollectionStatus)
+{
+ types::ObjectMap l_objectMap;
+ types::InterfaceMap l_interfaceMap;
+ types::PropertyMap l_propertyMap;
+
+ l_propertyMap.emplace("CollectionStatus", i_fruCollectionStatus);
+ l_interfaceMap.emplace(constants::vpdCollectionInterface, l_propertyMap);
+ l_objectMap.emplace(i_inventoryPath, l_interfaceMap);
+
+ if (!dbusUtility::callPIM(std::move(l_objectMap)))
+ {
+ return false;
+ }
+
+ return true;
+}
} // namespace dbusUtility
} // namespace vpd