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/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index 5e177ab..81af41f 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -94,7 +94,9 @@
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
CheckItemHandler&& handler)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::message::object_path path("/xyz/openbmc_project/VirtualMedia");
+ dbus::utility::getManagedObjects(
+ service, path,
[service, resName, asyncResp,
handler](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& subtree) {
@@ -117,9 +119,7 @@
BMCWEB_LOG_DEBUG << "Parent item not found";
asyncResp->res.result(boost::beast::http::status::not_found);
- },
- service, "/xyz/openbmc_project/VirtualMedia",
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+ });
}
/**
@@ -273,7 +273,10 @@
const std::string& name)
{
BMCWEB_LOG_DEBUG << "Get available Virtual Media resources.";
- crow::connections::systemBus->async_method_call(
+ sdbusplus::message::object_path objPath(
+ "/xyz/openbmc_project/VirtualMedia");
+ dbus::utility::getManagedObjects(
+ service, objPath,
[name, asyncResp{std::move(asyncResp)}](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& subtree) {
@@ -299,9 +302,7 @@
members.emplace_back(std::move(item));
}
asyncResp->res.jsonValue["Members@odata.count"] = members.size();
- },
- service, "/xyz/openbmc_project/VirtualMedia",
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+ });
}
inline void
@@ -877,10 +878,13 @@
std::string service = getObjectType.begin()->first;
BMCWEB_LOG_DEBUG << "GetObjectType: " << service;
- crow::connections::systemBus->async_method_call(
- [service, resName, action, actionParams,
- asyncResp](const boost::system::error_code& ec2,
- dbus::utility::ManagedObjectType& subtree) mutable {
+ sdbusplus::message::object_path path(
+ "/xyz/openbmc_project/VirtualMedia");
+ dbus::utility::getManagedObjects(
+ service, path,
+ [service, resName, action, actionParams, asyncResp](
+ const boost::system::error_code& ec2,
+ const dbus::utility::ManagedObjectType& subtree) mutable {
if (ec2)
{
// Not possible in proxy mode
@@ -902,9 +906,7 @@
}
BMCWEB_LOG_DEBUG << "Parent item not found";
messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName);
- },
- service, "/xyz/openbmc_project/VirtualMedia",
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+ });
});
}
@@ -941,7 +943,10 @@
std::string service = getObjectType.begin()->first;
BMCWEB_LOG_DEBUG << "GetObjectType: " << service;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::message::object_path path(
+ "/xyz/openbmc_project/VirtualMedia");
+ dbus::utility::getManagedObjects(
+ service, path,
[resName, service, action,
asyncResp](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& subtree) {
@@ -964,9 +969,7 @@
}
BMCWEB_LOG_DEBUG << "Parent item not found";
messages::resourceNotFound(asyncResp->res, "VirtualMedia", resName);
- },
- service, "/xyz/openbmc_project/VirtualMedia",
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+ });
});
}