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/health.hpp b/redfish-core/lib/health.hpp
index 7955fc0..6805a2d 100644
--- a/redfish-core/lib/health.hpp
+++ b/redfish-core/lib/health.hpp
@@ -16,12 +16,14 @@
#pragma once
#include "async_resp.hpp"
+#include "dbus_utility.hpp"
#include <app.hpp>
#include <dbus_singleton.hpp>
-#include <dbus_utility.hpp>
#include <nlohmann/json.hpp>
+#include <array>
+#include <string_view>
#include <variant>
namespace redfish
@@ -192,9 +194,12 @@
void getGlobalPath()
{
+ constexpr std::array<std::string_view, 1> interfaces = {
+ "xyz.openbmc_project.Inventory.Item.Global"};
std::shared_ptr<HealthPopulate> self = shared_from_this();
- crow::connections::systemBus->async_method_call(
- [self](const boost::system::error_code ec,
+ dbus::utility::getSubTreePaths(
+ "/", 0, interfaces,
+ [self](const boost::system::error_code& ec,
const dbus::utility::MapperGetSubTreePathsResponse& resp) {
if (ec || resp.size() != 1)
{
@@ -202,12 +207,7 @@
return;
}
self->globalInventoryPath = resp[0];
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "/", 0,
- std::array<const char*, 1>{
- "xyz.openbmc_project.Inventory.Item.Global"});
+ });
}
void getAllStatusAssociations()