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/oem/ibm/libpldmresponder/file_io_type_dump.cpp b/oem/ibm/libpldmresponder/file_io_type_dump.cpp
index f1c6bec..f3394a3 100644
--- a/oem/ibm/libpldmresponder/file_io_type_dump.cpp
+++ b/oem/ibm/libpldmresponder/file_io_type_dump.cpp
@@ -46,14 +46,11 @@
static constexpr auto DUMP_MANAGER_BUSNAME =
"xyz.openbmc_project.Dump.Manager";
static constexpr auto DUMP_MANAGER_PATH = "/xyz/openbmc_project/dump";
- static constexpr auto OBJECT_MANAGER_INTERFACE =
- "org.freedesktop.DBus.ObjectManager";
- auto& bus = pldm::utils::DBusHandler::getBus();
// Stores the current resource dump entry path
std::string curResDumpEntryPath{};
- dbus::ObjectValueTree objects;
+ ObjectValueTree objects;
// Select the dump entry interface for system dump or resource dump
DumpEntryInterface dumpEntryIntf = systemDumpEntry;
if ((dumpType == PLDM_FILE_TYPE_RESOURCE_DUMP) ||
@@ -64,12 +61,8 @@
try
{
- auto method =
- bus.new_method_call(DUMP_MANAGER_BUSNAME, DUMP_MANAGER_PATH,
- OBJECT_MANAGER_INTERFACE, "GetManagedObjects");
-
- auto reply = bus.call(method, dbusTimeout);
- reply.read(objects);
+ objects = pldm::utils::DBusHandler::getManagedObj(DUMP_MANAGER_BUSNAME,
+ DUMP_MANAGER_PATH);
}
catch (const sdbusplus::exception_t& e)
{