Refactor setProperty method
SetProperty is a method we should use more, and use consistently in the
codebase, this commit makes it consistently used from the utility
namespace.
Tested: Refactor. Code compiles.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I5939317d23483e16bd98a8298f53e75604ef374d
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 795010d..45d5664 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -63,18 +63,17 @@
const std::string& service)
{
BMCWEB_LOG_DEBUG << "Activate image for " << objPath << " " << service;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, service, objPath,
+ "xyz.openbmc_project.Software.Activation", "RequestedActivation",
+ "xyz.openbmc_project.Software.Activation.RequestedActivations.Active",
[](const boost::system::error_code& errorCode) {
if (errorCode)
{
BMCWEB_LOG_DEBUG << "error_code = " << errorCode;
BMCWEB_LOG_DEBUG << "error msg = " << errorCode.message();
}
- },
- service, objPath, "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Software.Activation", "RequestedActivation",
- dbus::utility::DbusVariantType(
- "xyz.openbmc_project.Software.Activation.RequestedActivations.Active"));
+ });
}
// Note that asyncResp can be either a valid pointer or nullptr. If nullptr
@@ -575,21 +574,19 @@
}
// Set the requested image apply time value
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec;
- messages::internalError(asyncResp->res);
- return;
- }
- messages::success(asyncResp->res);
- },
- "xyz.openbmc_project.Settings",
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
"/xyz/openbmc_project/software/apply_time",
- "org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Software.ApplyTime", "RequestedApplyTime",
- dbus::utility::DbusVariantType{applyTimeNewVal});
+ applyTimeNewVal, [asyncResp](const boost::system::error_code& ec) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ messages::success(asyncResp->res);
+ });
}
inline void