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/dbus_utility.hpp b/include/dbus_utility.hpp
index 393ffe3..c7fda6d 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -29,6 +29,7 @@
 #include <span>
 #include <sstream>
 #include <string>
+#include <string_view>
 #include <tuple>
 #include <utility>
 #include <variant>
@@ -157,7 +158,8 @@
 }
 
 inline void getSubTreePaths(
-    const std::string& path, std::span<std::string> interfaces,
+    const std::string& path, int32_t depth,
+    std::span<const std::string_view> interfaces,
     std::function<void(const boost::system::error_code&,
                        const MapperGetSubTreePathsResponse&)>&& callback)
 {
@@ -169,7 +171,7 @@
         },
         "xyz.openbmc_project.ObjectMapper",
         "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", path, 0,
+        "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", path, depth,
         interfaces);
 }
 
diff --git a/include/google/google_service_root.hpp b/include/google/google_service_root.hpp
index d802d00..f14cffe 100644
--- a/include/google/google_service_root.hpp
+++ b/include/google/google_service_root.hpp
@@ -9,6 +9,8 @@
 #include <utils/hex_utils.hpp>
 #include <utils/json_utils.hpp>
 
+#include <array>
+#include <string_view>
 #include <vector>
 
 namespace crow
@@ -37,9 +39,11 @@
     asyncResp->res.jsonValue["@odata.id"] = "/google/v1/RootOfTrustCollection";
     asyncResp->res.jsonValue["@odata.type"] =
         "#RootOfTrustCollection.RootOfTrustCollection";
+    const std::array<std::string_view, 1> interfaces{
+        "xyz.openbmc_project.Control.Hoth"};
     redfish::collection_util::getCollectionMembers(
         asyncResp, boost::urls::url("/google/v1/RootOfTrustCollection"),
-        {"xyz.openbmc_project.Control.Hoth"}, "/xyz/openbmc_project");
+        interfaces, "/xyz/openbmc_project");
 }
 
 // Helper struct to identify a resolved D-Bus object interface
@@ -94,7 +98,7 @@
                        ResolvedEntityHandler&& entityHandler)
 {
 
-    std::array<std::string, 1> hothIfaces = {
+    constexpr std::array<std::string_view, 1> hothIfaces = {
         "xyz.openbmc_project.Control.Hoth"};
     crow::connections::systemBus->async_method_call(
         [command, asyncResp, rotId,
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,
diff --git a/redfish-core/include/utils/chassis_utils.hpp b/redfish-core/include/utils/chassis_utils.hpp
index b7f16d8..33e8bb7 100644
--- a/redfish-core/include/utils/chassis_utils.hpp
+++ b/redfish-core/include/utils/chassis_utils.hpp
@@ -1,6 +1,12 @@
 #pragma once
+
+#include "dbus_utility.hpp"
+
 #include <async_resp.hpp>
 
+#include <array>
+#include <string_view>
+
 namespace redfish
 {
 
@@ -16,13 +22,15 @@
                          const std::string& chassisId, Callback&& callback)
 {
     BMCWEB_LOG_DEBUG << "checkChassisId enter";
-    const std::array<const char*, 2> interfaces = {
+    constexpr std::array<std::string_view, 2> interfaces = {
         "xyz.openbmc_project.Inventory.Item.Board",
         "xyz.openbmc_project.Inventory.Item.Chassis"};
 
-    auto respHandler =
+    // Get the Chassis Collection
+    dbus::utility::getSubTreePaths(
+        "/xyz/openbmc_project/inventory", 0, interfaces,
         [callback{std::forward<Callback>(callback)}, asyncResp,
-         chassisId](const boost::system::error_code ec,
+         chassisId](const boost::system::error_code& ec,
                     const dbus::utility::MapperGetSubTreePathsResponse&
                         chassisPaths) mutable {
         BMCWEB_LOG_DEBUG << "getValidChassisPath respHandler enter";
@@ -51,14 +59,7 @@
             }
         }
         callback(chassisPath);
-    };
-
-    // Get the Chassis Collection
-    crow::connections::systemBus->async_method_call(
-        respHandler, "xyz.openbmc_project.ObjectMapper",
-        "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
-        "/xyz/openbmc_project/inventory", 0, interfaces);
+        });
     BMCWEB_LOG_DEBUG << "checkChassisId exit";
 }
 
diff --git a/redfish-core/include/utils/collection.hpp b/redfish-core/include/utils/collection.hpp
index f117302..b66ab5d 100644
--- a/redfish-core/include/utils/collection.hpp
+++ b/redfish-core/include/utils/collection.hpp
@@ -1,8 +1,12 @@
 #pragma once
 
+#include "dbus_utility.hpp"
+
 #include <human_sort.hpp>
 
+#include <span>
 #include <string>
+#include <string_view>
 #include <vector>
 
 namespace redfish
@@ -25,14 +29,15 @@
 inline void
     getCollectionMembers(std::shared_ptr<bmcweb::AsyncResp> aResp,
                          const boost::urls::url& collectionPath,
-                         const std::vector<const char*>& interfaces,
+                         std::span<const std::string_view> interfaces,
                          const char* subtree = "/xyz/openbmc_project/inventory")
 {
     BMCWEB_LOG_DEBUG << "Get collection members for: "
                      << collectionPath.buffer();
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::getSubTreePaths(
+        subtree, 0, interfaces,
         [collectionPath, aResp{std::move(aResp)}](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const dbus::utility::MapperGetSubTreePathsResponse& objects) {
         if (ec == boost::system::errc::io_error)
         {
@@ -73,11 +78,7 @@
             members.push_back(std::move(member));
         }
         aResp->res.jsonValue["Members@odata.count"] = members.size();
-        },
-        "xyz.openbmc_project.ObjectMapper",
-        "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", subtree, 0,
-        interfaces);
+        });
 }
 
 } // namespace collection_util
diff --git a/redfish-core/lib/cable.hpp b/redfish-core/lib/cable.hpp
index 6bc7fba..3cb8c1d 100644
--- a/redfish-core/lib/cable.hpp
+++ b/redfish-core/lib/cable.hpp
@@ -1,11 +1,16 @@
 #pragma once
-#include <dbus_utility.hpp>
+
+#include "dbus_utility.hpp"
+
 #include <query.hpp>
 #include <sdbusplus/asio/property.hpp>
 #include <sdbusplus/unpack_properties.hpp>
 #include <utils/dbus_utils.hpp>
 #include <utils/json_utils.hpp>
 
+#include <array>
+#include <string_view>
+
 namespace redfish
 {
 /**
@@ -179,10 +184,10 @@
         asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Cables";
         asyncResp->res.jsonValue["Name"] = "Cable Collection";
         asyncResp->res.jsonValue["Description"] = "Collection of Cable Entries";
-
+        constexpr std::array<std::string_view, 1> interfaces{
+            "xyz.openbmc_project.Inventory.Item.Cable"};
         collection_util::getCollectionMembers(
-            asyncResp, boost::urls::url("/redfish/v1/Cables"),
-            {"xyz.openbmc_project.Inventory.Item.Cable"});
+            asyncResp, boost::urls::url("/redfish/v1/Cables"), interfaces);
         });
 }
 
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 8a46964..a65f33c 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -1,17 +1,20 @@
 #pragma once
 
+#include "dbus_utility.hpp"
 #include "utils/dbus_utils.hpp"
 
 #include <app.hpp>
 #include <async_resp.hpp>
 #include <boost/system/linux_error.hpp>
-#include <dbus_utility.hpp>
 #include <http_response.hpp>
 #include <query.hpp>
 #include <registries/privilege_registry.hpp>
 #include <sdbusplus/asio/property.hpp>
 #include <sdbusplus/unpack_properties.hpp>
 
+#include <array>
+#include <string_view>
+
 namespace redfish
 {
 namespace certs
@@ -212,9 +215,12 @@
                        const nlohmann::json::json_pointer& listPtr,
                        const nlohmann::json::json_pointer& countPtr)
 {
-    crow::connections::systemBus->async_method_call(
+    constexpr std::array<std::string_view, 1> interfaces = {
+        certs::certPropIntf};
+    dbus::utility::getSubTreePaths(
+        basePath, 0, interfaces,
         [asyncResp, listPtr, countPtr](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const dbus::utility::MapperGetSubTreePathsResponse& certPaths) {
         if (ec)
         {
@@ -265,11 +271,7 @@
         }
 
         asyncResp->res.jsonValue[countPtr] = links.size();
-        },
-        "xyz.openbmc_project.ObjectMapper",
-        "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", basePath, 0,
-        std::array<const char*, 1>{certs::certPropIntf});
+        });
 }
 
 /**
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index c6016cb..f08a3f3 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -15,12 +15,12 @@
 */
 #pragma once
 
+#include "dbus_utility.hpp"
 #include "health.hpp"
 #include "led.hpp"
 #include "utils/json_utils.hpp"
 
 #include <app.hpp>
-#include <dbus_utility.hpp>
 #include <query.hpp>
 #include <registries/privilege_registry.hpp>
 #include <sdbusplus/asio/property.hpp>
@@ -28,6 +28,9 @@
 #include <utils/collection.hpp>
 #include <utils/dbus_utils.hpp>
 
+#include <array>
+#include <string_view>
+
 namespace redfish
 {
 
@@ -147,10 +150,11 @@
     asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Chassis";
     asyncResp->res.jsonValue["Name"] = "Chassis Collection";
 
+    constexpr std::array<std::string_view, 2> interfaces{
+        "xyz.openbmc_project.Inventory.Item.Board",
+        "xyz.openbmc_project.Inventory.Item.Chassis"};
     collection_util::getCollectionMembers(
-        asyncResp, boost::urls::url("/redfish/v1/Chassis"),
-        {"xyz.openbmc_project.Inventory.Item.Board",
-         "xyz.openbmc_project.Inventory.Item.Chassis"});
+        asyncResp, boost::urls::url("/redfish/v1/Chassis"), interfaces);
 }
 
 /**
@@ -604,18 +608,14 @@
 inline void
     doChassisPowerCycle(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
 {
-    const char* busName = "xyz.openbmc_project.ObjectMapper";
-    const char* path = "/xyz/openbmc_project/object_mapper";
-    const char* interface = "xyz.openbmc_project.ObjectMapper";
-    const char* method = "GetSubTreePaths";
-
-    const std::array<const char*, 1> interfaces = {
+    constexpr std::array<std::string_view, 1> interfaces = {
         "xyz.openbmc_project.State.Chassis"};
 
     // Use mapper to get subtree paths.
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::getSubTreePaths(
+        "/", 0, interfaces,
         [asyncResp](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const dbus::utility::MapperGetSubTreePathsResponse& chassisList) {
         if (ec)
         {
@@ -656,8 +656,7 @@
             processName, objectPath, "org.freedesktop.DBus.Properties", "Set",
             interfaceName, destProperty,
             dbus::utility::DbusVariantType{propertyValue});
-        },
-        busName, path, interface, method, "/", 0, interfaces);
+        });
 }
 
 inline void handleChassisResetActionInfoPost(
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index d957ad8..cccae8b 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -15,6 +15,7 @@
 */
 #pragma once
 
+#include "dbus_utility.hpp"
 #include "utils/ip_utils.hpp"
 
 #include <app.hpp>
@@ -22,14 +23,15 @@
 #include <boost/algorithm/string/split.hpp>
 #include <boost/container/flat_set.hpp>
 #include <dbus_singleton.hpp>
-#include <dbus_utility.hpp>
 #include <error_messages.hpp>
 #include <query.hpp>
 #include <registries/privilege_registry.hpp>
 #include <utils/json_utils.hpp>
 
+#include <array>
 #include <optional>
 #include <regex>
+#include <string_view>
 
 namespace redfish
 {
@@ -1588,7 +1590,7 @@
     const boost::container::flat_set<IPv4AddressData>& ipv4Data,
     const boost::container::flat_set<IPv6AddressData>& ipv6Data)
 {
-    constexpr const std::array<const char*, 1> inventoryForEthernet = {
+    constexpr std::array<std::string_view, 1> inventoryForEthernet = {
         "xyz.openbmc_project.Inventory.Item.Ethernet"};
 
     nlohmann::json& jsonResponse = asyncResp->res.jsonValue;
@@ -1599,8 +1601,9 @@
 
     auto health = std::make_shared<HealthPopulate>(asyncResp);
 
-    crow::connections::systemBus->async_method_call(
-        [health](const boost::system::error_code ec,
+    dbus::utility::getSubTreePaths(
+        "/", 0, inventoryForEthernet,
+        [health](const boost::system::error_code& ec,
                  const dbus::utility::MapperGetSubTreePathsResponse& resp) {
         if (ec)
         {
@@ -1608,11 +1611,7 @@
         }
 
         health->inventory = resp;
-        },
-        "xyz.openbmc_project.ObjectMapper",
-        "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "/", int32_t(0),
-        inventoryForEthernet);
+        });
 
     health->populate();
 
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()
diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp
index 2b27fb4..27d0c35 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -1,18 +1,20 @@
 #pragma once
 
+#include "dbus_utility.hpp"
 #include "utils/ip_utils.hpp"
 
 #include <app.hpp>
 #include <boost/container/flat_set.hpp>
 #include <dbus_singleton.hpp>
-#include <dbus_utility.hpp>
 #include <error_messages.hpp>
 #include <query.hpp>
 #include <registries/privilege_registry.hpp>
 #include <sdbusplus/asio/property.hpp>
 #include <utils/json_utils.hpp>
 
+#include <array>
 #include <optional>
+#include <string_view>
 #include <utility>
 
 // TODO(ed) requestRoutesHypervisorSystems seems to have copy-pasted a
@@ -786,12 +788,13 @@
         {
             return;
         }
-        const std::array<const char*, 1> interfaces = {
+        constexpr std::array<std::string_view, 1> interfaces = {
             "xyz.openbmc_project.Network.EthernetInterface"};
 
-        crow::connections::systemBus->async_method_call(
+        dbus::utility::getSubTreePaths(
+            "/xyz/openbmc_project/network/hypervisor", 0, interfaces,
             [asyncResp](
-                const boost::system::error_code error,
+                const boost::system::error_code& error,
                 const dbus::utility::MapperGetSubTreePathsResponse& ifaceList) {
             if (error)
             {
@@ -826,11 +829,7 @@
                 ifaceArray.push_back(std::move(ethIface));
             }
             asyncResp->res.jsonValue["Members@odata.count"] = ifaceArray.size();
-            },
-            "xyz.openbmc_project.ObjectMapper",
-            "/xyz/openbmc_project/object_mapper",
-            "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
-            "/xyz/openbmc_project/network/hypervisor", 0, interfaces);
+            });
         });
 
     BMCWEB_ROUTE(app,
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 307f2e2..e5beb32 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -15,6 +15,7 @@
 */
 #pragma once
 
+#include "dbus_utility.hpp"
 #include "gzfile.hpp"
 #include "http_utility.hpp"
 #include "human_sort.hpp"
@@ -35,7 +36,6 @@
 #include <boost/beast/http/verb.hpp>
 #include <boost/container/flat_map.hpp>
 #include <boost/system/linux_error.hpp>
-#include <dbus_utility.hpp>
 #include <error_messages.hpp>
 #include <query.hpp>
 #include <registries/privilege_registry.hpp>
@@ -44,6 +44,7 @@
 #include <utils/dbus_utils.hpp>
 #include <utils/time_utils.hpp>
 
+#include <array>
 #include <charconv>
 #include <filesystem>
 #include <optional>
@@ -973,10 +974,13 @@
 {
     std::string dumpTypeLowerCopy =
         std::string(boost::algorithm::to_lower_copy(dumpType));
+    std::string interface = "xyz.openbmc_project.Dump.Entry." + dumpType;
+    const std::array<const std::string_view, 1> interfaces{interface};
 
-    crow::connections::systemBus->async_method_call(
+    dbus::utility::getSubTreePaths(
+        "/xyz/openbmc_project/dump/" + dumpTypeLowerCopy, 0, interfaces,
         [asyncResp, dumpType](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const dbus::utility::MapperGetSubTreePathsResponse& subTreePaths) {
         if (ec)
         {
@@ -995,13 +999,7 @@
             }
             deleteDumpEntry(asyncResp, logID, dumpType);
         }
-        },
-        "xyz.openbmc_project.ObjectMapper",
-        "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
-        "/xyz/openbmc_project/dump/" + dumpTypeLowerCopy, 0,
-        std::array<std::string, 1>{"xyz.openbmc_project.Dump.Entry." +
-                                   dumpType});
+        });
 }
 
 inline static void
@@ -1038,7 +1036,6 @@
     }
 }
 
-constexpr char const* postCodeIface = "xyz.openbmc_project.State.Boot.PostCode";
 inline void requestRoutesSystemLogServiceCollection(App& app)
 {
     /**
@@ -1098,8 +1095,11 @@
         asyncResp->res.jsonValue["Members@odata.count"] =
             logServiceArray.size();
 
-        crow::connections::systemBus->async_method_call(
-            [asyncResp](const boost::system::error_code ec,
+        constexpr std::array<std::string_view, 1> interfaces = {
+            "xyz.openbmc_project.State.Boot.PostCode"};
+        dbus::utility::getSubTreePaths(
+            "/", 0, interfaces,
+            [asyncResp](const boost::system::error_code& ec,
                         const dbus::utility::MapperGetSubTreePathsResponse&
                             subtreePath) {
             if (ec)
@@ -1125,11 +1125,7 @@
                     return;
                 }
             }
-            },
-            "xyz.openbmc_project.ObjectMapper",
-            "/xyz/openbmc_project/object_mapper",
-            "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "/", 0,
-            std::array<const char*, 1>{postCodeIface});
+            });
         });
 }
 
@@ -2257,8 +2253,6 @@
         });
 }
 
-constexpr char const* dumpManagerIface =
-    "xyz.openbmc_project.Collection.DeleteAll";
 inline void handleBMCLogServicesCollectionGet(
     crow::App& app, const crow::Request& req,
     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
@@ -2288,9 +2282,12 @@
     asyncResp->res.jsonValue["Members@odata.count"] = logServiceArray.size();
 
 #ifdef BMCWEB_ENABLE_REDFISH_DUMP_LOG
-    auto respHandler =
+    const std::array<const char*, 1> interfaces = {
+        "xyz.openbmc_project.Collection.DeleteAll"};
+    dbus::utility::getSubTreePaths(
+        "/xyz/openbmc_project/dump", 0, interfaces,
         [asyncResp](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const dbus::utility::MapperGetSubTreePathsResponse& subTreePaths) {
         if (ec)
         {
@@ -2325,14 +2322,7 @@
 
         asyncResp->res.jsonValue["Members@odata.count"] =
             logServiceArrayLocal.size();
-    };
-
-    crow::connections::systemBus->async_method_call(
-        respHandler, "xyz.openbmc_project.ObjectMapper",
-        "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
-        "/xyz/openbmc_project/dump", 0,
-        std::array<const char*, 1>{dumpManagerIface});
+        });
 #endif
 }
 
@@ -3155,8 +3145,11 @@
             return;
         }
 
-        crow::connections::systemBus->async_method_call(
-            [asyncResp](const boost::system::error_code ec,
+        constexpr std::array<std::string_view, 1> interfaces = {
+            crashdumpInterface};
+        dbus::utility::getSubTreePaths(
+            "/", 0, interfaces,
+            [asyncResp](const boost::system::error_code& ec,
                         const std::vector<std::string>& resp) {
             if (ec)
             {
@@ -3192,11 +3185,7 @@
                 logCrashdumpEntry(asyncResp, logID,
                                   asyncResp->res.jsonValue["Members"]);
             }
-            },
-            "xyz.openbmc_project.ObjectMapper",
-            "/xyz/openbmc_project/object_mapper",
-            "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "", 0,
-            std::array<const char*, 1>{crashdumpInterface});
+            });
         });
 }
 
diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp
index f8af707..395d6a0 100644
--- a/redfish-core/lib/memory.hpp
+++ b/redfish-core/lib/memory.hpp
@@ -28,6 +28,9 @@
 #include <utils/hex_utils.hpp>
 #include <utils/json_utils.hpp>
 
+#include <array>
+#include <string_view>
+
 namespace redfish
 {
 
@@ -792,9 +795,11 @@
         asyncResp->res.jsonValue["@odata.id"] =
             "/redfish/v1/Systems/system/Memory";
 
+        constexpr std::array<std::string_view, 1> interfaces{
+            "xyz.openbmc_project.Inventory.Item.Dimm"};
         collection_util::getCollectionMembers(
             asyncResp, boost::urls::url("/redfish/v1/Systems/system/Memory"),
-            {"xyz.openbmc_project.Inventory.Item.Dimm"});
+            interfaces);
         });
 }
 
diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp
index 0fb3a68..48fc934 100644
--- a/redfish-core/lib/metric_report.hpp
+++ b/redfish-core/lib/metric_report.hpp
@@ -10,6 +10,9 @@
 #include <registries/privilege_registry.hpp>
 #include <sdbusplus/asio/property.hpp>
 
+#include <array>
+#include <string_view>
+
 namespace redfish
 {
 
@@ -73,7 +76,8 @@
         asyncResp->res.jsonValue["@odata.id"] =
             "/redfish/v1/TelemetryService/MetricReports";
         asyncResp->res.jsonValue["Name"] = "Metric Report Collection";
-        const std::vector<const char*> interfaces{telemetry::reportInterface};
+        constexpr std::array<std::string_view, 1> interfaces{
+            telemetry::reportInterface};
         collection_util::getCollectionMembers(
             asyncResp,
             boost::urls::url("/redfish/v1/TelemetryService/MetricReports"),
diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
index e6308eb..7a7b5aa 100644
--- a/redfish-core/lib/metric_report_definition.hpp
+++ b/redfish-core/lib/metric_report_definition.hpp
@@ -13,7 +13,9 @@
 #include <sdbusplus/unpack_properties.hpp>
 #include <utils/dbus_utils.hpp>
 
+#include <array>
 #include <map>
+#include <string_view>
 #include <tuple>
 #include <variant>
 
@@ -359,7 +361,8 @@
         asyncResp->res.jsonValue["@odata.id"] =
             "/redfish/v1/TelemetryService/MetricReportDefinitions";
         asyncResp->res.jsonValue["Name"] = "Metric Definition Collection";
-        const std::vector<const char*> interfaces{telemetry::reportInterface};
+        constexpr std::array<std::string_view, 1> interfaces{
+            telemetry::reportInterface};
         collection_util::getCollectionMembers(
             asyncResp,
             boost::urls::url(
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)
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index 33aefa3..88f6a0c 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -16,15 +16,18 @@
 */
 #pragma once
 
+#include "dbus_utility.hpp"
 #include "sensors.hpp"
 #include "utils/chassis_utils.hpp"
 
 #include <app.hpp>
-#include <dbus_utility.hpp>
 #include <query.hpp>
 #include <registries/privilege_registry.hpp>
 #include <sdbusplus/asio/property.hpp>
 
+#include <array>
+#include <string_view>
+
 namespace redfish
 {
 inline void setPowerCapOverride(
@@ -144,7 +147,7 @@
 
         using Mapper = dbus::utility::MapperGetSubTreePathsResponse;
         auto chassisHandler =
-            [sensorAsyncResp](const boost::system::error_code e,
+            [sensorAsyncResp](const boost::system::error_code& e,
                               const Mapper& chassisPaths) {
             if (e)
             {
@@ -273,6 +276,9 @@
                     }
                 }
 
+                nlohmann::json& value =
+                    sensorJson["PowerLimit"]["LimitInWatts"];
+
                 // LimitException is Mandatory attribute as per OCP
                 // Baseline Profile – v1.0.0, so currently making it
                 // "NoAction" as default value to make it OCP Compliant.
@@ -282,12 +288,7 @@
                 {
                     // Redfish specification indicates PowerLimit should
                     // be null if the limit is not enabled.
-                    sensorJson["PowerLimit"]["LimitInWatts"] =
-                        powerCap * std::pow(10, scale);
-                }
-                else
-                {
-                    sensorJson["PowerLimit"]["LimitInWatts"] = nullptr;
+                    value = powerCap * std::pow(10, scale);
                 }
             };
 
@@ -298,14 +299,12 @@
                 std::move(valueHandler));
         };
 
-        crow::connections::systemBus->async_method_call(
-            std::move(chassisHandler), "xyz.openbmc_project.ObjectMapper",
-            "/xyz/openbmc_project/object_mapper",
-            "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
-            "/xyz/openbmc_project/inventory", 0,
-            std::array<const char*, 2>{
-                "xyz.openbmc_project.Inventory.Item.Board",
-                "xyz.openbmc_project.Inventory.Item.Chassis"});
+        constexpr std::array<std::string_view, 2> interfaces = {
+            "xyz.openbmc_project.Inventory.Item.Board",
+            "xyz.openbmc_project.Inventory.Item.Chassis"};
+
+        dbus::utility::getSubTreePaths("/xyz/openbmc_project/inventory", 0,
+                                       interfaces, std::move(chassisHandler));
         });
 
     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Power/")
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index d9c26f3..f5203a9 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -16,12 +16,12 @@
 #pragma once
 
 #include "dbus_singleton.hpp"
+#include "dbus_utility.hpp"
 #include "error_messages.hpp"
 #include "health.hpp"
 
 #include <app.hpp>
 #include <boost/container/flat_map.hpp>
-#include <dbus_utility.hpp>
 #include <query.hpp>
 #include <registries/privilege_registry.hpp>
 #include <sdbusplus/asio/property.hpp>
@@ -32,11 +32,14 @@
 #include <utils/dbus_utils.hpp>
 #include <utils/json_utils.hpp>
 
+#include <array>
+#include <string_view>
+
 namespace redfish
 {
 
 // Interfaces which imply a D-Bus object represents a Processor
-constexpr std::array<const char*, 2> processorInterfaces = {
+constexpr std::array<std::string_view, 2> processorInterfaces = {
     "xyz.openbmc_project.Inventory.Item.Cpu",
     "xyz.openbmc_project.Inventory.Item.Accelerator"};
 
@@ -1075,9 +1078,12 @@
 
         // First find the matching CPU object so we know how to
         // constrain our search for related Config objects.
-        crow::connections::systemBus->async_method_call(
+        const std::array<std::string_view, 1> interfaces = {
+            "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig"};
+        dbus::utility::getSubTreePaths(
+            "/xyz/openbmc_project/inventory", 0, interfaces,
             [asyncResp, cpuName](
-                const boost::system::error_code ec,
+                const boost::system::error_code& ec,
                 const dbus::utility::MapperGetSubTreePathsResponse& objects) {
             if (ec)
             {
@@ -1100,22 +1106,18 @@
 
                 // Use the common search routine to construct the
                 // Collection of all Config objects under this CPU.
+                constexpr std::array<std::string_view, 1> interface {
+                    "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig"
+                };
                 collection_util::getCollectionMembers(
                     asyncResp,
                     crow::utility::urlFromPieces("redfish", "v1", "Systems",
                                                  "system", "Processors",
                                                  cpuName, "OperatingConfigs"),
-                    {"xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig"},
-                    object.c_str());
+                    interface, object.c_str());
                 return;
             }
-            },
-            "xyz.openbmc_project.ObjectMapper",
-            "/xyz/openbmc_project/object_mapper",
-            "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
-            "/xyz/openbmc_project/inventory", 0,
-            std::array<const char*, 1>{
-                "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig"});
+            });
         });
 }
 
@@ -1221,8 +1223,7 @@
         collection_util::getCollectionMembers(
             asyncResp,
             boost::urls::url("/redfish/v1/Systems/system/Processors"),
-            std::vector<const char*>(processorInterfaces.begin(),
-                                     processorInterfaces.end()));
+            processorInterfaces);
         });
 }
 
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index e53a7d2..00b2ba6 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -15,6 +15,7 @@
 */
 #pragma once
 
+#include "dbus_utility.hpp"
 #include "generated/enums/sensor.hpp"
 
 #include <app.hpp>
@@ -34,10 +35,12 @@
 #include <utils/json_utils.hpp>
 #include <utils/query_param.hpp>
 
+#include <array>
 #include <cmath>
 #include <iterator>
 #include <map>
 #include <set>
+#include <string_view>
 #include <utility>
 #include <variant>
 
@@ -515,14 +518,17 @@
                 std::span<std::string_view> sensorTypes, Callback&& callback)
 {
     BMCWEB_LOG_DEBUG << "getChassis enter";
-    const std::array<const char*, 2> interfaces = {
+    constexpr std::array<std::string_view, 2> interfaces = {
         "xyz.openbmc_project.Inventory.Item.Board",
         "xyz.openbmc_project.Inventory.Item.Chassis"};
-    auto respHandler =
+
+    // Get the Chassis Collection
+    dbus::utility::getSubTreePaths(
+        "/xyz/openbmc_project/inventory", 0, interfaces,
         [callback{std::forward<Callback>(callback)}, asyncResp,
          chassisIdStr{std::string(chassisId)},
          chassisSubNode{std::string(chassisSubNode)}, sensorTypes](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const dbus::utility::MapperGetSubTreePathsResponse& chassisPaths) {
         BMCWEB_LOG_DEBUG << "getChassis respHandler enter";
         if (ec)
@@ -581,14 +587,7 @@
             BMCWEB_LOG_DEBUG << "Finishing with " << culledSensorList->size();
             callback(culledSensorList);
             });
-    };
-
-    // Get the Chassis Collection
-    crow::connections::systemBus->async_method_call(
-        respHandler, "xyz.openbmc_project.ObjectMapper",
-        "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
-        "/xyz/openbmc_project/inventory", 0, interfaces);
+        });
     BMCWEB_LOG_DEBUG << "getChassis exit";
 }
 
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp
index f4a6604..44ed7ff 100644
--- a/redfish-core/lib/storage.hpp
+++ b/redfish-core/lib/storage.hpp
@@ -15,17 +15,20 @@
 */
 #pragma once
 
+#include "dbus_utility.hpp"
 #include "health.hpp"
 #include "openbmc_dbus_rest.hpp"
 
 #include <app.hpp>
-#include <dbus_utility.hpp>
 #include <query.hpp>
 #include <registries/privilege_registry.hpp>
 #include <sdbusplus/asio/property.hpp>
 #include <sdbusplus/unpack_properties.hpp>
 #include <utils/dbus_utils.hpp>
 
+#include <array>
+#include <string_view>
+
 namespace redfish
 {
 inline void requestRoutesStorageCollection(App& app)
@@ -64,9 +67,12 @@
 inline void getDrives(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
                       const std::shared_ptr<HealthPopulate>& health)
 {
-    crow::connections::systemBus->async_method_call(
+    const std::array<std::string_view, 1> interfaces = {
+        "xyz.openbmc_project.Inventory.Item.Drive"};
+    dbus::utility::getSubTreePaths(
+        "/xyz/openbmc_project/inventory", 0, interfaces,
         [asyncResp, health](
-            const boost::system::error_code ec,
+            const boost::system::error_code& ec,
             const dbus::utility::MapperGetSubTreePathsResponse& driveList) {
         if (ec)
         {
@@ -100,12 +106,7 @@
         }
 
         count = driveArray.size();
-        },
-        "xyz.openbmc_project.ObjectMapper",
-        "/xyz/openbmc_project/object_mapper",
-        "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
-        "/xyz/openbmc_project/inventory", int32_t(0),
-        std::array<const char*, 1>{"xyz.openbmc_project.Inventory.Item.Drive"});
+        });
 }
 
 inline void
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();
 
diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp
index ad38556..4da1ed5 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -10,6 +10,8 @@
 #include <sdbusplus/unpack_properties.hpp>
 #include <utils/dbus_utils.hpp>
 
+#include <array>
+#include <string_view>
 #include <tuple>
 #include <variant>
 #include <vector>
@@ -304,7 +306,8 @@
         asyncResp->res.jsonValue["@odata.id"] =
             "/redfish/v1/TelemetryService/Triggers";
         asyncResp->res.jsonValue["Name"] = "Triggers Collection";
-        const std::vector<const char*> interfaces{telemetry::triggerInterface};
+        constexpr std::array<std::string_view, 1> interfaces{
+            telemetry::triggerInterface};
         collection_util::getCollectionMembers(
             asyncResp,
             boost::urls::url("/redfish/v1/TelemetryService/Triggers"),