Refactor GetSubTreePaths method
Since the GetSubTreePaths method has been implemented in dbus_utility
and this commit is to integrate all the places where the
GetSubTreePaths method is called, and use the method in dbus_utility
uniformly.
Requires https://gerrit.openbmc.org/c/openbmc/sdbusplus/+/60020 to
build.
Tested: Redfish Validator Passed
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ie4140d4484a7e4f4b943013f4371ffd2d44a22e9
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index 2cb2bc3..c7dbb27 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -13,6 +13,7 @@
// limitations under the License.
#pragma once
+#include "dbus_utility.hpp"
#include "http_request.hpp"
#include "http_response.hpp"
#include "logging.hpp"
@@ -1640,9 +1641,10 @@
inline void handleList(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& objectPath, int32_t depth = 0)
{
- crow::connections::systemBus->async_method_call(
+ dbus::utility::getSubTreePaths(
+ objectPath, depth, {},
[asyncResp](
- const boost::system::error_code ec,
+ const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse& objectPaths) {
if (ec)
{
@@ -1656,11 +1658,7 @@
asyncResp->res.jsonValue["message"] = "200 OK";
asyncResp->res.jsonValue["data"] = objectPaths;
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", objectPath,
- depth, std::array<std::string, 0>());
+ });
}
inline void handleEnumerate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,