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/managers.hpp b/redfish-core/lib/managers.hpp
index 5bb4908..b630609 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -290,7 +290,9 @@
const std::vector<std::string>& supportedProfiles,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::message::object_path objPath(path);
+ dbus::utility::getManagedObjects(
+ connection, objPath,
[asyncResp, currentProfile, supportedProfiles](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& managedObj) {
@@ -688,8 +690,7 @@
}
}
}
- },
- connection, path, objectManagerIface, "GetManagedObjects");
+ });
}
enum class CreatePIDRet
@@ -1358,7 +1359,10 @@
// todo(james): might make sense to do a mapper call here if this
// interface gets more traction
- crow::connections::systemBus->async_method_call(
+ sdbusplus::message::object_path objPath(
+ "/xyz/openbmc_project/inventory");
+ dbus::utility::getManagedObjects(
+ "xyz.openbmc_project.EntityManager", objPath,
[self](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& mObj) {
if (ec)
@@ -1384,10 +1388,7 @@
}
}
self->managedObj = mObj;
- },
- "xyz.openbmc_project.EntityManager",
- "/xyz/openbmc_project/inventory", objectManagerIface,
- "GetManagedObjects");
+ });
// at the same time get the profile information
constexpr std::array<std::string_view, 1> thermalModeIfaces = {
@@ -1779,10 +1780,12 @@
std::string firmwareId = runningFirmwareTarget.substr(idPos);
// Make sure the image is valid before setting priority
- crow::connections::systemBus->async_method_call(
- [asyncResp, firmwareId,
- runningFirmwareTarget](const boost::system::error_code& ec,
- dbus::utility::ManagedObjectType& subtree) {
+ sdbusplus::message::object_path objPath("/xyz/openbmc_project/software");
+ dbus::utility::getManagedObjects(
+ "xyz.openbmc_project.Software.BMC.Updater", objPath,
+ [asyncResp, firmwareId, runningFirmwareTarget](
+ const boost::system::error_code& ec,
+ const dbus::utility::ManagedObjectType& subtree) {
if (ec)
{
BMCWEB_LOG_DEBUG << "D-Bus response error getting objects.";
@@ -1852,10 +1855,7 @@
"org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Software.RedundancyPriority", "Priority",
dbus::utility::DbusVariantType(static_cast<uint8_t>(0)));
- },
- "xyz.openbmc_project.Software.BMC.Updater",
- "/xyz/openbmc_project/software", "org.freedesktop.DBus.ObjectManager",
- "GetManagedObjects");
+ });
}
inline void setDateTime(std::shared_ptr<bmcweb::AsyncResp> asyncResp,