host-bmc: Implement Inventory Item interface
Adding support to host Inventory Item dbus interface. PLDM hosts the
dbus interface based on the entity type. The Inventory Item interface
is defined at [1].
Tested:
Functional test passed
[1]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Inventory/Item.interface.yaml
Change-Id: Ifed3cc01d825a69d64afcffd8447f7c8d9387913
Signed-off-by: Archana Kakani <archana.kakani@ibm.com>
diff --git a/host-bmc/dbus/custom_dbus.cpp b/host-bmc/dbus/custom_dbus.cpp
index 08f9750..7a7e168 100644
--- a/host-bmc/dbus/custom_dbus.cpp
+++ b/host-bmc/dbus/custom_dbus.cpp
@@ -199,5 +199,29 @@
availabilityState.at(path)->available(state);
}
+void CustomDBus::updateItemPresentStatus(const std::string& path,
+ bool isPresent)
+{
+ if (!presentStatus.contains(path))
+ {
+ presentStatus.emplace(
+ path, std::make_unique<InventoryItem>(
+ pldm::utils::DBusHandler::getBus(), path.c_str()));
+ std::filesystem::path ObjectPath(path);
+
+ // Hardcode the present dbus property to true
+ presentStatus.at(path)->present(true);
+
+ // Set the pretty name dbus property to the filename
+ // form the dbus path object
+ presentStatus.at(path)->prettyName(ObjectPath.filename());
+ }
+ else
+ {
+ // object is already created
+ presentStatus.at(path)->present(isPresent);
+ }
+}
+
} // namespace dbus
} // namespace pldm