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/systems.hpp b/redfish-core/lib/systems.hpp
index caf6a29..e476592 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -16,6 +16,7 @@
#pragma once
#include "dbus_singleton.hpp"
+#include "dbus_utility.hpp"
#include "health.hpp"
#include "led.hpp"
#include "pcie.hpp"
@@ -25,7 +26,6 @@
#include <app.hpp>
#include <boost/container/flat_map.hpp>
-#include <dbus_utility.hpp>
#include <registries/privilege_registry.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/unpack_properties.hpp>
@@ -33,6 +33,8 @@
#include <utils/json_utils.hpp>
#include <utils/sw_utils.hpp>
+#include <array>
+#include <string_view>
#include <variant>
namespace redfish
@@ -2984,15 +2986,16 @@
nlohmann::json::array_t({"KVMIP"});
#endif // BMCWEB_ENABLE_KVM
- constexpr const std::array<const char*, 4> inventoryForSystems = {
+ constexpr std::array<std::string_view, 4> inventoryForSystems{
"xyz.openbmc_project.Inventory.Item.Dimm",
"xyz.openbmc_project.Inventory.Item.Cpu",
"xyz.openbmc_project.Inventory.Item.Drive",
"xyz.openbmc_project.Inventory.Item.StorageController"};
auto health = std::make_shared<HealthPopulate>(asyncResp);
- crow::connections::systemBus->async_method_call(
- [health](const boost::system::error_code ec,
+ dbus::utility::getSubTreePaths(
+ "/", 0, inventoryForSystems,
+ [health](const boost::system::error_code& ec,
const std::vector<std::string>& resp) {
if (ec)
{
@@ -3001,11 +3004,7 @@
}
health->inventory = resp;
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "/",
- int32_t(0), inventoryForSystems);
+ });
health->populate();