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/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index 8af9580..1e19663 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -16,6 +16,7 @@
#pragma once
+#include "dbus_utility.hpp"
#include "generated/enums/pcie_device.hpp"
#include <app.hpp>
@@ -39,8 +40,9 @@
getPCIeDeviceList(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& name)
{
- auto getPCIeMapCallback =
- [asyncResp, name](const boost::system::error_code ec,
+ dbus::utility::getSubTreePaths(
+ pciePath, 1, {},
+ [asyncResp, name](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse&
pcieDevicePaths) {
if (ec)
@@ -71,12 +73,7 @@
pcieDeviceList.push_back(std::move(pcieDevice));
}
asyncResp->res.jsonValue[name + "@odata.count"] = pcieDeviceList.size();
- };
- crow::connections::systemBus->async_method_call(
- std::move(getPCIeMapCallback), "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
- std::string(pciePath) + "/", 1, std::array<std::string, 0>());
+ });
}
inline void requestRoutesSystemPCIeDeviceCollection(App& app)