Refactor getManagedObjects method
Since the getManagedObjects method has been implemented in
dbus_utility and this commit is to integrate all the places where the
GetManagedObjects method is obtained, and use the method in
dbus_utility uniformly.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ic13f2bef7b30f805cd3444a75d7df17b031f2eb0
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 9ff3cdf..323c22a 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -467,10 +467,12 @@
return;
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::message::object_path path("/xyz/openbmc_project/dump");
+ dbus::utility::getManagedObjects(
+ "xyz.openbmc_project.Dump.Manager", path,
[asyncResp, entriesPath,
dumpType](const boost::system::error_code& ec,
- dbus::utility::ManagedObjectType& resp) {
+ const dbus::utility::ManagedObjectType& objects) {
if (ec)
{
BMCWEB_LOG_ERROR << "DumpEntry resp_handler got error " << ec;
@@ -498,6 +500,7 @@
"/xyz/openbmc_project/dump/" +
std::string(boost::algorithm::to_lower_copy(dumpType)) + "/entry/";
+ dbus::utility::ManagedObjectType resp(objects);
std::sort(resp.begin(), resp.end(), [](const auto& l, const auto& r) {
return AlphanumLess<std::string>()(l.first.filename(),
r.first.filename());
@@ -567,9 +570,7 @@
entriesArray.emplace_back(std::move(thisEntry));
}
asyncResp->res.jsonValue["Members@odata.count"] = entriesArray.size();
- },
- "xyz.openbmc_project.Dump.Manager", "/xyz/openbmc_project/dump",
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+ });
}
inline void
@@ -583,7 +584,9 @@
return;
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::message::object_path path("/xyz/openbmc_project/dump");
+ dbus::utility::getManagedObjects(
+ "xyz.openbmc_project.Dump.Manager", path,
[asyncResp, entryID, dumpType,
entriesPath](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) {
@@ -667,9 +670,7 @@
entryID);
return;
}
- },
- "xyz.openbmc_project.Dump.Manager", "/xyz/openbmc_project/dump",
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+ });
}
inline void deleteDumpEntry(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
@@ -1564,7 +1565,9 @@
// DBus implementation of EventLog/Entries
// Make call to Logging Service to find all log entry objects
- crow::connections::systemBus->async_method_call(
+ sdbusplus::message::object_path path("/xyz/openbmc_project/logging");
+ dbus::utility::getManagedObjects(
+ "xyz.openbmc_project.Logging", path,
[asyncResp](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& resp) {
if (ec)
@@ -1718,9 +1721,7 @@
});
asyncResp->res.jsonValue["Members@odata.count"] =
entriesArray.size();
- },
- "xyz.openbmc_project.Logging", "/xyz/openbmc_project/logging",
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+ });
});
}