Using sdbusplus::asio::getProperty
It simplifies a lot of code and after changing sdbusplus implementation
slightly reduces binary size if used together with:
https://gerrit.openbmc-project.xyz/c/openbmc/sdbusplus/+/49467
* Uncompressed size: 3033148 -> 3012164, -20984 B
* gzip compressed size: 1220586 -> 1214625, -5961 B
Tested:
- Redfish validator output is the same before and after the change
Change-Id: Ibe3227d3f4230de2363ba3d9396e51130c8240a5
Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 46f6a93..b746cef 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -21,6 +21,7 @@
#include <openbmc_dbus_rest.hpp>
#include <persistent_data.hpp>
#include <registries/privilege_registry.hpp>
+#include <sdbusplus/asio/property.hpp>
#include <utils/json_utils.hpp>
namespace redfish
@@ -1600,10 +1601,13 @@
}
// Reading AllGroups property
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::getProperty<std::vector<std::string>>(
+ *crow::connections::systemBus,
+ "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
+ "xyz.openbmc_project.User.Manager", "AllGroups",
[asyncResp, username, password{std::move(password)}, roleId,
enabled](const boost::system::error_code ec,
- const dbus::utility::DbusVariantType& allGroups) {
+ const std::vector<std::string>& allGroupsList) {
if (ec)
{
BMCWEB_LOG_DEBUG << "ERROR with async_method_call";
@@ -1611,10 +1615,7 @@
return;
}
- const std::vector<std::string>* allGroupsList =
- std::get_if<std::vector<std::string>>(&allGroups);
-
- if (allGroupsList == nullptr || allGroupsList->empty())
+ if (allGroupsList.empty())
{
messages::internalError(asyncResp->res);
return;
@@ -1676,11 +1677,8 @@
"xyz.openbmc_project.User.Manager",
"/xyz/openbmc_project/user",
"xyz.openbmc_project.User.Manager", "CreateUser",
- username, *allGroupsList, *roleId, *enabled);
- },
- "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
- "org.freedesktop.DBus.Properties", "Get",
- "xyz.openbmc_project.User.Manager", "AllGroups");
+ username, allGroupsList, *roleId, *enabled);
+ });
});
BMCWEB_ROUTE(app, "/redfish/v1/AccountService/Accounts/<str>/")