Add the GetManagedObjects method to dbus_utility

There are currently many files that use the GetManagedObjects method.
Since they are a general method, they are defined in the
dbus_utility.hpp file and refactors them.

Tested:
1. Built bmcweb successfully and Validator passes.
2. We got the same result as previously in the ethernet schema.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I0c25b7b6b9421bea46ff0afadbaa4783b704e664
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index ea06101..854c2c1 100644
--- a/include/dbus_utility.hpp
+++ b/include/dbus_utility.hpp
@@ -206,5 +206,20 @@
         "xyz.openbmc_project.Association", "endpoints", std::move(callback));
 }
 
+inline void
+    getManagedObjects(const std::string& service,
+                      const sdbusplus::message::object_path& path,
+                      std::function<void(const boost::system::error_code&,
+                                         const ManagedObjectType&)>&& callback)
+{
+    crow::connections::systemBus->async_method_call(
+        [callback{std::move(callback)}](const boost::system::error_code& ec,
+                                        const ManagedObjectType& objects) {
+        callback(ec, objects);
+        },
+        service, path, "org.freedesktop.DBus.ObjectManager",
+        "GetManagedObjects");
+}
+
 } // namespace utility
 } // namespace dbus