diff options
author | Jonathan Doman <jonathan.doman@intel.com> | 2021-06-11 19:36:17 +0300 |
---|---|---|
committer | Krzysztof Grobelny <krzysztof.grobelny@intel.com> | 2021-12-28 15:23:02 +0300 |
commit | 1e1e598df6d1d9530dde6e92d8f74f8143f60e50 (patch) | |
tree | b71aee4a4c50c79332e14d6e74094693888855a6 /redfish-core/lib/update_service.hpp | |
parent | 168e20c1306e3e689907ba43e14ea679e2328611 (diff) | |
download | bmcweb-1e1e598df6d1d9530dde6e92d8f74f8143f60e50.tar.xz |
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>
Diffstat (limited to 'redfish-core/lib/update_service.hpp')
-rw-r--r-- | redfish-core/lib/update_service.hpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp index f5528e1a70..fde878e4aa 100644 --- a/redfish-core/lib/update_service.hpp +++ b/redfish-core/lib/update_service.hpp @@ -21,6 +21,7 @@ #include <boost/container/flat_map.hpp> #include <dbus_utility.hpp> #include <registries/privilege_registry.hpp> +#include <sdbusplus/asio/property.hpp> #include <utils/fw_utils.hpp> namespace redfish @@ -542,9 +543,12 @@ inline void requestRoutesUpdateService(App& app) {"TFTP"}; #endif // Get the current ApplyTime value - crow::connections::systemBus->async_method_call( + sdbusplus::asio::getProperty<std::string>( + *crow::connections::systemBus, "xyz.openbmc_project.Settings", + "/xyz/openbmc_project/software/apply_time", + "xyz.openbmc_project.Software.ApplyTime", "RequestedApplyTime", [asyncResp](const boost::system::error_code ec, - const dbus::utility::DbusVariantType& applyTime) { + const std::string& applyTime) { if (ec) { BMCWEB_LOG_DEBUG << "DBUS response error " << ec; @@ -552,34 +556,25 @@ inline void requestRoutesUpdateService(App& app) return; } - const std::string* s = std::get_if<std::string>(&applyTime); - if (s == nullptr) - { - return; - } // Store the ApplyTime Value - if (*s == - "xyz.openbmc_project.Software.ApplyTime.RequestedApplyTimes.Immediate") + if (applyTime == "xyz.openbmc_project.Software.ApplyTime." + "RequestedApplyTimes.Immediate") { asyncResp->res .jsonValue["HttpPushUriOptions"] ["HttpPushUriApplyTime"]["ApplyTime"] = "Immediate"; } - else if ( - *s == - "xyz.openbmc_project.Software.ApplyTime.RequestedApplyTimes.OnReset") + else if (applyTime == + "xyz.openbmc_project.Software.ApplyTime." + "RequestedApplyTimes.OnReset") { asyncResp->res .jsonValue["HttpPushUriOptions"] ["HttpPushUriApplyTime"]["ApplyTime"] = "OnReset"; } - }, - "xyz.openbmc_project.Settings", - "/xyz/openbmc_project/software/apply_time", - "org.freedesktop.DBus.Properties", "Get", - "xyz.openbmc_project.Software.ApplyTime", "RequestedApplyTime"); + }); }); BMCWEB_ROUTE(app, "/redfish/v1/UpdateService/") .privileges(redfish::privileges::patchUpdateService) |