utils: Retrieval of managed objects of DBUS
This commit implements functionality to retrieve the managed object of a
specific DBUS service on a particular path. Additionally implements a
function template for inventory objects which efficiently enables
retrieval of managed object for Inventory Manager.
Tested: Added unit test cases for checking the return value.
Change-Id: Ide652f843db1623bdacebf3e269e03895bbb7f1a
Signed-off-by: Riya Dixit <riyadixitagra@gmail.com>
diff --git a/libpldmresponder/fru.cpp b/libpldmresponder/fru.cpp
index 632489c..a9ef613 100644
--- a/libpldmresponder/fru.cpp
+++ b/libpldmresponder/fru.cpp
@@ -145,18 +145,12 @@
}
fru_parser::DBusLookupInfo dbusInfo;
- // Read the all the inventory D-Bus objects
- auto& bus = pldm::utils::DBusHandler::getBus();
- dbus::ObjectValueTree objects;
try
{
dbusInfo = parser.inventoryLookup();
- auto method = bus.new_method_call(
- std::get<0>(dbusInfo).c_str(), std::get<1>(dbusInfo).c_str(),
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
- auto reply = bus.call(method, dbusTimeout);
- reply.read(objects);
+ objects = pldm::utils::DBusHandler::getInventoryObjects<
+ pldm::utils::DBusHandler>();
}
catch (const std::exception& e)
{
diff --git a/libpldmresponder/fru.hpp b/libpldmresponder/fru.hpp
index 20bc509..40a1517 100644
--- a/libpldmresponder/fru.hpp
+++ b/libpldmresponder/fru.hpp
@@ -24,9 +24,9 @@
namespace dbus
{
-using Value =
- std::variant<bool, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t,
- uint64_t, double, std::string, std::vector<uint8_t>>;
+using Value = std::variant<bool, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
+ int64_t, uint64_t, double, std::string,
+ std::vector<uint8_t>, std::vector<std::string>>;
using PropertyMap = std::map<Property, Value>;
using InterfaceMap = std::map<Interface, PropertyMap>;
using ObjectValueTree = std::map<sdbusplus::message::object_path, InterfaceMap>;
@@ -225,6 +225,7 @@
pldm_entity_association_tree* entityTree;
pldm_entity_association_tree* bmcEntityTree;
pldm::responder::oem_fru::Handler* oemFruHandler;
+ dbus::ObjectValueTree objects;
std::map<dbus::ObjectPath, pldm_entity_node*> objToEntityNode{};