Refactor getManagedObjects method
Since the getManagedObjects method has been implemented in
dbus_utility and this commit is to integrate all the places where the
GetManagedObjects method is obtained, and use the method in
dbus_utility uniformly.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ic13f2bef7b30f805cd3444a75d7df17b031f2eb0
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 6f5f122..91f7804 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -53,7 +53,6 @@
constexpr const char* ldapEnableInterface = "xyz.openbmc_project.Object.Enable";
constexpr const char* ldapPrivMapperInterface =
"xyz.openbmc_project.User.PrivilegeMapper";
-constexpr const char* dbusObjManagerIntf = "org.freedesktop.DBus.ObjectManager";
constexpr const char* propertyInterface = "org.freedesktop.DBus.Properties";
struct LDAPRoleMapData
@@ -580,7 +579,9 @@
return;
}
std::string service = resp.begin()->first;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::message::object_path path(ldapRootObject);
+ dbus::utility::getManagedObjects(
+ service, path,
[callback,
ldapType](const boost::system::error_code& errorCode,
const dbus::utility::ManagedObjectType& ldapObjects) {
@@ -717,8 +718,7 @@
}
}
callback(true, confData, ldapType);
- },
- service, ldapRootObject, dbusObjManagerIntf, "GetManagedObjects");
+ });
});
}
@@ -1732,7 +1732,9 @@
{
thisUser = req.session->username;
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::message::object_path path("/xyz/openbmc_project/user");
+ dbus::utility::getManagedObjects(
+ "xyz.openbmc_project.User.Manager", path,
[asyncResp, thisUser, effectiveUserPrivileges](
const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& users) {
@@ -1776,9 +1778,7 @@
}
}
asyncResp->res.jsonValue["Members@odata.count"] = memberArray.size();
- },
- "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+ });
}
inline void processAfterCreateUser(
@@ -2016,7 +2016,9 @@
}
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::message::object_path path("/xyz/openbmc_project/user");
+ dbus::utility::getManagedObjects(
+ "xyz.openbmc_project.User.Manager", path,
[asyncResp,
accountName](const boost::system::error_code& ec,
const dbus::utility::ManagedObjectType& users) {
@@ -2148,9 +2150,7 @@
"/redfish/v1/AccountService/Accounts/" + accountName;
asyncResp->res.jsonValue["Id"] = accountName;
asyncResp->res.jsonValue["UserName"] = accountName;
- },
- "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+ });
}
inline void