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/account_service.hpp b/redfish-core/lib/account_service.hpp
index 8a893e3..9f3c96e 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* propertyInterface = "org.freedesktop.DBus.Properties";
struct LDAPRoleMapData
{
@@ -259,20 +258,18 @@
return;
}
- 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.User.Manager", dbusObjectPath,
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.User.Attributes", "UserGroups",
- dbus::utility::DbusVariantType{updatedUserGroups});
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.User.Manager",
+ dbusObjectPath, "xyz.openbmc_project.User.Attributes", "UserGroups",
+ updatedUserGroups, [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 userErrorMessageHandler(
@@ -426,7 +423,11 @@
// If "RemoteGroup" info is provided
if (remoteGroup)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, ldapDbusService,
+ roleMapObjData[index].first,
+ "xyz.openbmc_project.User.PrivilegeMapperEntry",
+ "GroupName", *remoteGroup,
[asyncResp, roleMapObjData, serverType, index,
remoteGroup](const boost::system::error_code& ec,
const sdbusplus::message_t& msg) {
@@ -451,19 +452,17 @@
asyncResp->res
.jsonValue[serverType]["RemoteRoleMapping"][index]
["RemoteGroup"] = *remoteGroup;
- },
- ldapDbusService, roleMapObjData[index].first,
- propertyInterface, "Set",
- "xyz.openbmc_project.User.PrivilegeMapperEntry",
- "GroupName",
- dbus::utility::DbusVariantType(
- std::move(*remoteGroup)));
+ });
}
// If "LocalRole" info is provided
if (localRole)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, ldapDbusService,
+ roleMapObjData[index].first,
+ "xyz.openbmc_project.User.PrivilegeMapperEntry",
+ "Privilege", *localRole,
[asyncResp, roleMapObjData, serverType, index,
localRole](const boost::system::error_code& ec,
const sdbusplus::message_t& msg) {
@@ -487,13 +486,7 @@
asyncResp->res
.jsonValue[serverType]["RemoteRoleMapping"][index]
["LocalRole"] = *localRole;
- },
- ldapDbusService, roleMapObjData[index].first,
- propertyInterface, "Set",
- "xyz.openbmc_project.User.PrivilegeMapperEntry",
- "Privilege",
- dbus::utility::DbusVariantType(
- getPrivilegeFromRoleId(std::move(*localRole))));
+ });
}
}
// Create a new RoleMapping Object.
@@ -802,7 +795,9 @@
const std::string& ldapServerElementName,
const std::string& ldapConfigObject)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, ldapDbusService, ldapConfigObject,
+ ldapConfigInterface, "LDAPServerURI", serviceAddressList.front(),
[asyncResp, ldapServerElementName, serviceAddressList](
const boost::system::error_code& ec, sdbusplus::message_t& msg) {
if (ec)
@@ -833,10 +828,7 @@
serviceAddressList.front());
}
BMCWEB_LOG_DEBUG << "Updated the service address";
- },
- ldapDbusService, ldapConfigObject, propertyInterface, "Set",
- ldapConfigInterface, "LDAPServerURI",
- dbus::utility::DbusVariantType(serviceAddressList.front()));
+ });
}
/**
* @brief updates the LDAP Bind DN and updates the
@@ -853,9 +845,11 @@
const std::string& ldapServerElementName,
const std::string& ldapConfigObject)
{
- crow::connections::systemBus->async_method_call(
- [asyncResp, username,
- ldapServerElementName](const boost::system::error_code& ec) {
+ sdbusplus::asio::setProperty(*crow::connections::systemBus, ldapDbusService,
+ ldapConfigObject, ldapConfigInterface,
+ "LDAPBindDN", username,
+ [asyncResp, username, ldapServerElementName](
+ const boost::system::error_code& ec) {
if (ec)
{
BMCWEB_LOG_DEBUG << "Error occurred in updating the username";
@@ -865,10 +859,7 @@
asyncResp->res.jsonValue[ldapServerElementName]["Authentication"]
["Username"] = username;
BMCWEB_LOG_DEBUG << "Updated the username";
- },
- ldapDbusService, ldapConfigObject, propertyInterface, "Set",
- ldapConfigInterface, "LDAPBindDN",
- dbus::utility::DbusVariantType(username));
+ });
}
/**
@@ -885,9 +876,11 @@
const std::string& ldapServerElementName,
const std::string& ldapConfigObject)
{
- crow::connections::systemBus->async_method_call(
- [asyncResp, password,
- ldapServerElementName](const boost::system::error_code& ec) {
+ sdbusplus::asio::setProperty(*crow::connections::systemBus, ldapDbusService,
+ ldapConfigObject, ldapConfigInterface,
+ "LDAPBindDNPassword", password,
+ [asyncResp, password, ldapServerElementName](
+ const boost::system::error_code& ec) {
if (ec)
{
BMCWEB_LOG_DEBUG << "Error occurred in updating the password";
@@ -897,10 +890,7 @@
asyncResp->res.jsonValue[ldapServerElementName]["Authentication"]
["Password"] = "";
BMCWEB_LOG_DEBUG << "Updated the password";
- },
- ldapDbusService, ldapConfigObject, propertyInterface, "Set",
- ldapConfigInterface, "LDAPBindDNPassword",
- dbus::utility::DbusVariantType(password));
+ });
}
/**
@@ -918,10 +908,12 @@
const std::string& ldapServerElementName,
const std::string& ldapConfigObject)
{
- crow::connections::systemBus->async_method_call(
- [asyncResp, baseDNList,
- ldapServerElementName](const boost::system::error_code& ec,
- const sdbusplus::message_t& msg) {
+ sdbusplus::asio::setProperty(*crow::connections::systemBus, ldapDbusService,
+ ldapConfigObject, ldapConfigInterface,
+ "LDAPBaseDN", baseDNList.front(),
+ [asyncResp, baseDNList, ldapServerElementName](
+ const boost::system::error_code& ec,
+ const sdbusplus::message_t& msg) {
if (ec)
{
BMCWEB_LOG_DEBUG << "Error Occurred in Updating the base DN";
@@ -950,10 +942,7 @@
asyncResp->res, "BaseDistinguishedNames", baseDNList.front());
}
BMCWEB_LOG_DEBUG << "Updated the base DN";
- },
- ldapDbusService, ldapConfigObject, propertyInterface, "Set",
- ldapConfigInterface, "LDAPBaseDN",
- dbus::utility::DbusVariantType(baseDNList.front()));
+ });
}
/**
* @brief updates the LDAP user name attribute and updates the
@@ -970,7 +959,9 @@
const std::string& ldapServerElementName,
const std::string& ldapConfigObject)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, ldapDbusService, ldapConfigObject,
+ ldapConfigInterface, "UserNameAttribute", userNameAttribute,
[asyncResp, userNameAttribute,
ldapServerElementName](const boost::system::error_code& ec) {
if (ec)
@@ -985,10 +976,7 @@
serverTypeJson["LDAPService"]["SearchSettings"];
searchSettingsJson["UsernameAttribute"] = userNameAttribute;
BMCWEB_LOG_DEBUG << "Updated the user name attr.";
- },
- ldapDbusService, ldapConfigObject, propertyInterface, "Set",
- ldapConfigInterface, "UserNameAttribute",
- dbus::utility::DbusVariantType(userNameAttribute));
+ });
}
/**
* @brief updates the LDAP group attribute and updates the
@@ -1005,7 +993,9 @@
const std::string& ldapServerElementName,
const std::string& ldapConfigObject)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, ldapDbusService, ldapConfigObject,
+ ldapConfigInterface, "GroupNameAttribute", groupsAttribute,
[asyncResp, groupsAttribute,
ldapServerElementName](const boost::system::error_code& ec) {
if (ec)
@@ -1020,10 +1010,7 @@
serverTypeJson["LDAPService"]["SearchSettings"];
searchSettingsJson["GroupsAttribute"] = groupsAttribute;
BMCWEB_LOG_DEBUG << "Updated the groupname attr";
- },
- ldapDbusService, ldapConfigObject, propertyInterface, "Set",
- ldapConfigInterface, "GroupNameAttribute",
- dbus::utility::DbusVariantType(groupsAttribute));
+ });
}
/**
* @brief updates the LDAP service enable and updates the
@@ -1039,7 +1026,9 @@
const std::string& ldapServerElementName,
const std::string& ldapConfigObject)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, ldapDbusService, ldapConfigObject,
+ ldapEnableInterface, "Enabled", serviceEnabled,
[asyncResp, serviceEnabled,
ldapServerElementName](const boost::system::error_code& ec) {
if (ec)
@@ -1051,10 +1040,7 @@
asyncResp->res.jsonValue[ldapServerElementName]["ServiceEnabled"] =
serviceEnabled;
BMCWEB_LOG_DEBUG << "Updated Service enable = " << serviceEnabled;
- },
- ldapDbusService, ldapConfigObject, propertyInterface, "Set",
- ldapEnableInterface, "Enabled",
- dbus::utility::DbusVariantType(serviceEnabled));
+ });
}
inline void
@@ -1363,21 +1349,19 @@
if (enabled)
{
- 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);
- return;
- },
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus,
"xyz.openbmc_project.User.Manager", dbusObjectPath,
- "org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.User.Attributes", "UserEnabled",
- dbus::utility::DbusVariantType{*enabled});
+ *enabled, [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);
+ });
}
if (roleId)
@@ -1390,20 +1374,19 @@
return;
}
- 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);
- },
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus,
"xyz.openbmc_project.User.Manager", dbusObjectPath,
- "org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.User.Attributes", "UserPrivilege",
- dbus::utility::DbusVariantType{priv});
+ priv, [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);
+ });
}
if (locked)
@@ -1418,7 +1401,11 @@
return;
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus,
+ "xyz.openbmc_project.User.Manager", dbusObjectPath,
+ "xyz.openbmc_project.User.Attributes",
+ "UserLockedForFailedAttempt", *locked,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -1427,13 +1414,7 @@
return;
}
messages::success(asyncResp->res);
- return;
- },
- "xyz.openbmc_project.User.Manager", dbusObjectPath,
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.User.Attributes",
- "UserLockedForFailedAttempt",
- dbus::utility::DbusVariantType{*locked});
+ });
}
if (accountTypes)
@@ -1603,7 +1584,11 @@
if (minPasswordLength)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.User.Manager",
+ "/xyz/openbmc_project/user",
+ "xyz.openbmc_project.User.AccountPolicy", "MinPasswordLength",
+ *minPasswordLength,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -1611,11 +1596,7 @@
return;
}
messages::success(asyncResp->res);
- },
- "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.User.AccountPolicy", "MinPasswordLength",
- dbus::utility::DbusVariantType(*minPasswordLength));
+ });
}
if (maxPasswordLength)
@@ -1651,23 +1632,26 @@
if (unlockTimeout)
{
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- messages::success(asyncResp->res);
- },
- "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
- "org.freedesktop.DBus.Properties", "Set",
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.User.Manager",
+ "/xyz/openbmc_project/user",
"xyz.openbmc_project.User.AccountPolicy", "AccountUnlockTimeout",
- dbus::utility::DbusVariantType(*unlockTimeout));
+ *unlockTimeout, [asyncResp](const boost::system::error_code& ec) {
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ messages::success(asyncResp->res);
+ });
}
if (lockoutThreshold)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.User.Manager",
+ "/xyz/openbmc_project/user",
+ "xyz.openbmc_project.User.AccountPolicy",
+ "MaxLoginAttemptBeforeLockout", *lockoutThreshold,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -1675,12 +1659,7 @@
return;
}
messages::success(asyncResp->res);
- },
- "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.User.AccountPolicy",
- "MaxLoginAttemptBeforeLockout",
- dbus::utility::DbusVariantType(*lockoutThreshold));
+ });
}
}
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index b27a790..30ba4bc 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -750,7 +750,9 @@
objectPath = "/xyz/openbmc_project/state/chassis0";
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, processName, objectPath,
+ interfaceName, destProperty, propertyValue,
[asyncResp](const boost::system::error_code& ec2,
sdbusplus::message_t& sdbusErrMsg) {
// Use "Set" method to set the property value.
@@ -762,10 +764,7 @@
}
messages::success(asyncResp->res);
- },
- processName, objectPath, "org.freedesktop.DBus.Properties", "Set",
- interfaceName, destProperty,
- dbus::utility::DbusVariantType{propertyValue});
+ });
});
}
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 9aadaea..5fb5aef 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -638,20 +638,18 @@
const std::string& ifaceId, const std::string& gateway,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.result(boost::beast::http::status::no_content);
- },
- "xyz.openbmc_project.Network",
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Network",
"/xyz/openbmc_project/network/" + ifaceId,
- "org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.EthernetInterface", "DefaultGateway",
- dbus::utility::DbusVariantType(gateway));
+ gateway, [asyncResp](const boost::system::error_code& ec) {
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.result(boost::beast::http::status::no_content);
+ });
}
/**
* @brief Creates a static IPv4 entry
@@ -888,17 +886,16 @@
"HostName");
return;
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Network",
+ "/xyz/openbmc_project/network/config",
+ "xyz.openbmc_project.Network.SystemConfiguration", "HostName", hostname,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
messages::internalError(asyncResp->res);
}
- },
- "xyz.openbmc_project.Network", "/xyz/openbmc_project/network/config",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Network.SystemConfiguration", "HostName",
- dbus::utility::DbusVariantType(hostname));
+ });
}
inline void
@@ -907,17 +904,15 @@
{
sdbusplus::message::object_path objPath = "/xyz/openbmc_project/network/" +
ifaceId;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Network", objPath,
+ "xyz.openbmc_project.Network.EthernetInterface", "MTU", mtuSize,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
messages::internalError(asyncResp->res);
}
- },
- "xyz.openbmc_project.Network", objPath,
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Network.EthernetInterface", "MTU",
- std::variant<size_t>(mtuSize));
+ });
}
inline void
@@ -926,18 +921,16 @@
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
std::vector<std::string> vectorDomainname = {domainname};
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- }
- },
- "xyz.openbmc_project.Network",
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Network",
"/xyz/openbmc_project/network/" + ifaceId,
- "org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.EthernetInterface", "DomainName",
- dbus::utility::DbusVariantType(vectorDomainname));
+ vectorDomainname, [asyncResp](const boost::system::error_code& ec) {
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ }
+ });
}
inline bool isHostnameValid(const std::string& hostname)
@@ -1007,9 +1000,12 @@
static constexpr std::string_view dbusNotAllowedError =
"xyz.openbmc_project.Common.Error.NotAllowed";
- crow::connections::systemBus->async_method_call(
- [asyncResp, macAddress](const boost::system::error_code& ec,
- const sdbusplus::message_t& msg) {
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Network",
+ "/xyz/openbmc_project/network/" + ifaceId,
+ "xyz.openbmc_project.Network.MACAddress", "MACAddress", macAddress,
+ [asyncResp](const boost::system::error_code& ec,
+ const sdbusplus::message_t& msg) {
if (ec)
{
const sd_bus_error* err = msg.get_error();
@@ -1026,12 +1022,7 @@
messages::internalError(asyncResp->res);
return;
}
- },
- "xyz.openbmc_project.Network",
- "/xyz/openbmc_project/network/" + ifaceId,
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Network.MACAddress", "MACAddress",
- dbus::utility::DbusVariantType(macAddress));
+ });
}
inline void setDHCPEnabled(const std::string& ifaceId,
@@ -1040,7 +1031,10 @@
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
const std::string dhcp = getDhcpEnabledEnumeration(v4Value, v6Value);
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Network",
+ "/xyz/openbmc_project/network/" + ifaceId,
+ "xyz.openbmc_project.Network.EthernetInterface", propertyName, dhcp,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -1049,19 +1043,17 @@
return;
}
messages::success(asyncResp->res);
- },
- "xyz.openbmc_project.Network",
- "/xyz/openbmc_project/network/" + ifaceId,
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Network.EthernetInterface", propertyName,
- dbus::utility::DbusVariantType{dhcp});
+ });
}
inline void setEthernetInterfaceBoolProperty(
const std::string& ifaceId, const std::string& propertyName,
const bool& value, const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Network",
+ "/xyz/openbmc_project/network/" + ifaceId,
+ "xyz.openbmc_project.Network.EthernetInterface", propertyName, value,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -1069,19 +1061,17 @@
messages::internalError(asyncResp->res);
return;
}
- },
- "xyz.openbmc_project.Network",
- "/xyz/openbmc_project/network/" + ifaceId,
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Network.EthernetInterface", propertyName,
- dbus::utility::DbusVariantType{value});
+ });
}
inline void setDHCPv4Config(const std::string& propertyName, const bool& value,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
BMCWEB_LOG_DEBUG << propertyName << " = " << value;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Network",
+ "/xyz/openbmc_project/network/dhcp",
+ "xyz.openbmc_project.Network.DHCPConfiguration", propertyName, value,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -1089,11 +1079,7 @@
messages::internalError(asyncResp->res);
return;
}
- },
- "xyz.openbmc_project.Network", "/xyz/openbmc_project/network/dhcp",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Network.DHCPConfiguration", propertyName,
- dbus::utility::DbusVariantType{value});
+ });
}
inline void handleDHCPPatch(const std::string& ifaceId,
@@ -1407,19 +1393,18 @@
const std::vector<std::string>& updatedStaticNameServers,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Network",
+ "/xyz/openbmc_project/network/" + ifaceId,
+ "xyz.openbmc_project.Network.EthernetInterface", "StaticNameServers",
+ updatedStaticNameServers,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
messages::internalError(asyncResp->res);
return;
}
- },
- "xyz.openbmc_project.Network",
- "/xyz/openbmc_project/network/" + ifaceId,
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Network.EthernetInterface", "StaticNameServers",
- dbus::utility::DbusVariantType{updatedStaticNameServers});
+ });
}
inline void handleIPv6StaticAddressesPatch(
diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp
index c16c171..c2580fe 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -351,7 +351,10 @@
{
BMCWEB_LOG_DEBUG << "Setting the Hypervisor IPaddress : " << ipv4Address
<< " on Iface: " << ethIfaceId;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/network/hypervisor/" + ethIfaceId + "/ipv4/addr0",
+ "xyz.openbmc_project.Network.IP", "Address", ipv4Address,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -359,12 +362,7 @@
return;
}
BMCWEB_LOG_DEBUG << "Hypervisor IPaddress is Set";
- },
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/network/hypervisor/" + ethIfaceId + "/ipv4/addr0",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Network.IP", "Address",
- dbus::utility::DbusVariantType(ipv4Address));
+ });
}
/**
@@ -383,7 +381,10 @@
BMCWEB_LOG_DEBUG << "Setting the Hypervisor subnet : " << subnet
<< " on Iface: " << ethIfaceId;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/network/hypervisor/" + ethIfaceId + "/ipv4/addr0",
+ "xyz.openbmc_project.Network.IP", "PrefixLength", subnet,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -391,12 +392,7 @@
return;
}
BMCWEB_LOG_DEBUG << "SubnetMask is Set";
- },
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/network/hypervisor/" + ethIfaceId + "/ipv4/addr0",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Network.IP", "PrefixLength",
- dbus::utility::DbusVariantType(subnet));
+ });
}
/**
@@ -415,20 +411,18 @@
BMCWEB_LOG_DEBUG
<< "Setting the DefaultGateway to the last configured gateway";
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "DBUS response error " << ec;
- return;
- }
- BMCWEB_LOG_DEBUG << "Default Gateway is Set";
- },
- "xyz.openbmc_project.Settings",
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
"/xyz/openbmc_project/network/hypervisor",
- "org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Network.SystemConfiguration", "DefaultGateway",
- dbus::utility::DbusVariantType(gateway));
+ gateway, [asyncResp](const boost::system::error_code& ec) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "DBUS response error " << ec;
+ return;
+ }
+ BMCWEB_LOG_DEBUG << "Default Gateway is Set";
+ });
}
/**
@@ -514,7 +508,10 @@
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
const std::string dhcp = getDhcpEnabledEnumeration(ipv4DHCPEnabled, false);
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/network/hypervisor/" + ifaceId,
+ "xyz.openbmc_project.Network.EthernetInterface", "DHCPEnabled", dhcp,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -522,12 +519,7 @@
messages::internalError(asyncResp->res);
return;
}
- },
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/network/hypervisor/" + ifaceId,
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Network.EthernetInterface", "DHCPEnabled",
- dbus::utility::DbusVariantType{dhcp});
+ });
// Set the IPv4 address origin to the DHCP / Static as per the new value
// of the DHCPEnabled property
@@ -543,7 +535,10 @@
deleteHypervisorIPv4(ifaceId, asyncResp);
origin = "xyz.openbmc_project.Network.IP.AddressOrigin.DHCP";
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/network/hypervisor/" + ifaceId + "/ipv4/addr0",
+ "xyz.openbmc_project.Network.IP", "Origin", origin,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -552,12 +547,7 @@
return;
}
BMCWEB_LOG_DEBUG << "Hypervisor IPaddress Origin is Set";
- },
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/network/hypervisor/" + ifaceId + "/ipv4/addr0",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Network.IP", "Origin",
- dbus::utility::DbusVariantType(origin));
+ });
}
inline void handleHypervisorIPv4StaticPatch(
@@ -675,38 +665,32 @@
}
asyncResp->res.jsonValue["HostName"] = hostName;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/network/hypervisor/",
+ "xyz.openbmc_project.Network.SystemConfiguration", "HostName", hostName,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
messages::internalError(asyncResp->res);
}
- },
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/network/hypervisor",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Network.SystemConfiguration", "HostName",
- dbus::utility::DbusVariantType(hostName));
+ });
}
inline void
setIPv4InterfaceEnabled(const std::string& ifaceId, bool isActive,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/network/hypervisor/" + ifaceId + "/ipv4/addr0",
+ "xyz.openbmc_project.Object.Enable", "Enabled", isActive,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
- BMCWEB_LOG_ERROR << "D-Bus responses error: " << ec;
messages::internalError(asyncResp->res);
- return;
}
- },
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/network/hypervisor/" + ifaceId + "/ipv4/addr0",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Object.Enable", "Enabled",
- dbus::utility::DbusVariantType(isActive));
+ });
}
inline void handleHypervisorEthernetInterfaceCollectionGet(
@@ -1021,7 +1005,10 @@
std::string command = "xyz.openbmc_project.State.Host.Transition.On";
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.State.Hypervisor",
+ "/xyz/openbmc_project/state/hypervisor0",
+ "xyz.openbmc_project.State.Host", "RequestedHostTransition", command,
[asyncResp, resetType](const boost::system::error_code& ec) {
if (ec)
{
@@ -1043,12 +1030,7 @@
return;
}
messages::success(asyncResp->res);
- },
- "xyz.openbmc_project.State.Hypervisor",
- "/xyz/openbmc_project/state/hypervisor0",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.State.Host", "RequestedHostTransition",
- dbus::utility::DbusVariantType{std::move(command)});
+ });
}
inline void requestRoutesHypervisorSystems(App& app)
diff --git a/redfish-core/lib/led.hpp b/redfish-core/lib/led.hpp
index 64b097a..53df1db 100644
--- a/redfish-core/lib/led.hpp
+++ b/redfish-core/lib/led.hpp
@@ -122,7 +122,10 @@
return;
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.LED.GroupManager",
+ "/xyz/openbmc_project/led/groups/enclosure_identify_blink",
+ "xyz.openbmc_project.Led.Group", "Asserted", ledBlinkng,
[asyncResp, ledOn,
ledBlinkng](const boost::system::error_code& ec) mutable {
if (ec)
@@ -135,7 +138,11 @@
ledOn = true;
}
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus,
+ "xyz.openbmc_project.LED.GroupManager",
+ "/xyz/openbmc_project/led/groups/enclosure_identify",
+ "xyz.openbmc_project.Led.Group", "Asserted", ledBlinkng,
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
@@ -144,18 +151,8 @@
return;
}
messages::success(asyncResp->res);
- },
- "xyz.openbmc_project.LED.GroupManager",
- "/xyz/openbmc_project/led/groups/enclosure_identify",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Led.Group", "Asserted",
- dbus::utility::DbusVariantType(ledOn));
- },
- "xyz.openbmc_project.LED.GroupManager",
- "/xyz/openbmc_project/led/groups/enclosure_identify_blink",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Led.Group", "Asserted",
- dbus::utility::DbusVariantType(ledBlinkng));
+ });
+ });
}
/**
@@ -229,14 +226,21 @@
{
BMCWEB_LOG_DEBUG << "Set LocationIndicatorActive";
- crow::connections::systemBus->async_method_call(
- [asyncResp, ledState](const boost::system::error_code& ec) mutable {
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.LED.GroupManager",
+ "/xyz/openbmc_project/led/groups/enclosure_identify_blink",
+ "xyz.openbmc_project.Led.Group", "Asserted", ledState,
+ [asyncResp, ledState](const boost::system::error_code& ec) {
if (ec)
{
// Some systems may not have enclosure_identify_blink object so
// lets set enclosure_identify state also if
// enclosure_identify_blink failed
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus,
+ "xyz.openbmc_project.LED.GroupManager",
+ "/xyz/openbmc_project/led/groups/enclosure_identify",
+ "xyz.openbmc_project.Led.Group", "Asserted", ledState,
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
@@ -244,18 +248,8 @@
messages::internalError(asyncResp->res);
return;
}
- },
- "xyz.openbmc_project.LED.GroupManager",
- "/xyz/openbmc_project/led/groups/enclosure_identify",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Led.Group", "Asserted",
- dbus::utility::DbusVariantType(ledState));
+ });
}
- },
- "xyz.openbmc_project.LED.GroupManager",
- "/xyz/openbmc_project/led/groups/enclosure_identify_blink",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Led.Group", "Asserted",
- dbus::utility::DbusVariantType(ledState));
+ });
}
} // namespace redfish
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 7ad489b..ce4203b 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1883,7 +1883,10 @@
}
BMCWEB_LOG_DEBUG << "Set Resolved";
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Logging",
+ "/xyz/openbmc_project/logging/entry/" + entryId,
+ "xyz.openbmc_project.Logging.Entry", "Resolved", *resolved,
[asyncResp, entryId](const boost::system::error_code& ec) {
if (ec)
{
@@ -1891,12 +1894,7 @@
messages::internalError(asyncResp->res);
return;
}
- },
- "xyz.openbmc_project.Logging",
- "/xyz/openbmc_project/logging/entry/" + entryId,
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Logging.Entry", "Resolved",
- dbus::utility::DbusVariantType(*resolved));
+ });
});
BMCWEB_ROUTE(
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index a3f060b..c97ba02 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -61,9 +61,9 @@
const char* destProperty = "RequestedBMCTransition";
// Create the D-Bus variant for D-Bus call.
- dbus::utility::DbusVariantType dbusPropertyValue(propertyValue);
-
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, processName, objectPath, interfaceName,
+ destProperty, propertyValue,
[asyncResp](const boost::system::error_code& ec) {
// Use "Set" method to set the property value.
if (ec)
@@ -74,9 +74,7 @@
}
messages::success(asyncResp->res);
- },
- processName, objectPath, "org.freedesktop.DBus.Properties", "Set",
- interfaceName, destProperty, dbusPropertyValue);
+ });
}
inline void
@@ -90,9 +88,9 @@
const char* destProperty = "RequestedBMCTransition";
// Create the D-Bus variant for D-Bus call.
- dbus::utility::DbusVariantType dbusPropertyValue(propertyValue);
-
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, processName, objectPath, interfaceName,
+ destProperty, propertyValue,
[asyncResp](const boost::system::error_code& ec) {
// Use "Set" method to set the property value.
if (ec)
@@ -103,9 +101,7 @@
}
messages::success(asyncResp->res);
- },
- processName, objectPath, "org.freedesktop.DBus.Properties", "Set",
- interfaceName, destProperty, dbusPropertyValue);
+ });
}
/**
@@ -1466,17 +1462,16 @@
return;
}
currentProfile = *profile;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, profileConnection, profilePath,
+ thermalModeIface, "Current", *profile,
[response](const boost::system::error_code& ec) {
if (ec)
{
BMCWEB_LOG_ERROR << "Error patching profile" << ec;
messages::internalError(response->res);
}
- },
- profileConnection, profilePath,
- "org.freedesktop.DBus.Properties", "Set", thermalModeIface,
- "Current", dbus::utility::DbusVariantType(*profile));
+ });
}
for (auto& containerPair : configuration)
@@ -1600,7 +1595,10 @@
{
for (const auto& property : output)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus,
+ "xyz.openbmc_project.EntityManager", path, iface,
+ property.first, property.second,
[response,
propertyName{std::string(property.first)}](
const boost::system::error_code& ec) {
@@ -1612,10 +1610,7 @@
return;
}
messages::success(response->res);
- },
- "xyz.openbmc_project.EntityManager", path,
- "org.freedesktop.DBus.Properties", "Set", iface,
- property.first, property.second);
+ });
}
}
else
@@ -1839,7 +1834,12 @@
// Only support Immediate
// An addition could be a Redfish Setting like
// ActiveSoftwareImageApplyTime and support OnReset
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus,
+ "xyz.openbmc_project.Software.BMC.Updater",
+ "/xyz/openbmc_project/software/" + firmwareId,
+ "xyz.openbmc_project.Software.RedundancyPriority", "Priority",
+ static_cast<uint8_t>(0),
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
@@ -1848,13 +1848,7 @@
return;
}
doBMCGracefulRestart(asyncResp);
- },
-
- "xyz.openbmc_project.Software.BMC.Updater",
- "/xyz/openbmc_project/software/" + firmwareId,
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Software.RedundancyPriority", "Priority",
- dbus::utility::DbusVariantType(static_cast<uint8_t>(0)));
+ });
});
}
@@ -1871,7 +1865,10 @@
"DateTime");
return;
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Time.Manager",
+ "/xyz/openbmc_project/time/bmc", "xyz.openbmc_project.Time.EpochTime",
+ "Elapsed", us->count(),
[asyncResp{std::move(asyncResp)},
datetime{std::move(datetime)}](const boost::system::error_code& ec) {
if (ec)
@@ -1883,11 +1880,7 @@
return;
}
asyncResp->res.jsonValue["DateTime"] = datetime;
- },
- "xyz.openbmc_project.Time.Manager", "/xyz/openbmc_project/time/bmc",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Time.EpochTime", "Elapsed",
- dbus::utility::DbusVariantType(us->count()));
+ });
}
inline void
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 35c3dae..2792dcf 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -252,17 +252,17 @@
"xyz.openbmc_project.Time.Synchronization.Method.Manual";
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/time/sync_method",
+ "xyz.openbmc_project.Time.Synchronization", "TimeSyncMethod",
+ timeSyncMethod,
[asyncResp](const boost::system::error_code& errorCode) {
if (errorCode)
{
messages::internalError(asyncResp->res);
}
- },
- "xyz.openbmc_project.Settings", "/xyz/openbmc_project/time/sync_method",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Time.Synchronization", "TimeSyncMethod",
- dbus::utility::DbusVariantType{timeSyncMethod});
+ });
}
inline void
@@ -369,17 +369,16 @@
continue;
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, service, objectPath,
+ interface, "StaticNTPServers", currentNtpServers,
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
messages::internalError(asyncResp->res);
return;
}
- },
- service, objectPath, "org.freedesktop.DBus.Properties",
- "Set", interface, "StaticNTPServers",
- dbus::utility::DbusVariantType{currentNtpServers});
+ });
}
}
}
@@ -408,31 +407,30 @@
{
if (boost::algorithm::starts_with(entry.first, netBasePath))
{
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec2) {
- if (ec2)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- },
- entry.second.begin()->first, entry.first,
- "org.freedesktop.DBus.Properties", "Set",
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, entry.second.begin()->first,
+ entry.first,
"xyz.openbmc_project.Control.Service.Attributes", "Running",
- dbus::utility::DbusVariantType{protocolEnabled});
-
- crow::connections::systemBus->async_method_call(
+ protocolEnabled,
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
messages::internalError(asyncResp->res);
return;
}
- },
- entry.second.begin()->first, entry.first,
- "org.freedesktop.DBus.Properties", "Set",
+ });
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, entry.second.begin()->first,
+ entry.first,
"xyz.openbmc_project.Control.Service.Attributes", "Enabled",
- dbus::utility::DbusVariantType{protocolEnabled});
+ protocolEnabled,
+ [asyncResp](const boost::system::error_code& ec2) {
+ if (ec2)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ });
}
}
});
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index 3072b89..4aaac67 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -97,7 +97,10 @@
return;
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/control/host0/power_cap",
+ "xyz.openbmc_project.Control.Power.Cap", "PowerCap", *value,
[sensorsAsyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
@@ -107,12 +110,7 @@
}
sensorsAsyncResp->asyncResp->res.result(
boost::beast::http::status::no_content);
- },
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/control/host0/power_cap",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Control.Power.Cap", "PowerCap",
- std::variant<uint32_t>(*value));
+ });
});
};
redfish::chassis_utils::getValidChassisPath(sensorsAsyncResp->asyncResp,
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index 1806ffc..8efa78e 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -1122,14 +1122,14 @@
BMCWEB_LOG_INFO << "Setting config to " << configPath.str;
// Set the property, with handler to check error responses
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, *controlService, cpuObjectPath,
+ "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig",
+ "AppliedConfig", configPath,
[resp, appliedConfigUri](const boost::system::error_code& ec,
const sdbusplus::message_t& msg) {
handleAppliedConfigResponse(resp, appliedConfigUri, ec, msg);
- },
- *controlService, cpuObjectPath, "org.freedesktop.DBus.Properties",
- "Set", "xyz.openbmc_project.Control.Processor.CurrentOperatingConfig",
- "AppliedConfig", dbus::utility::DbusVariantType(std::move(configPath)));
+ });
}
inline void
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 3fbbd2d..011e670 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -2694,7 +2694,10 @@
messages::internalError(sensorAsyncResp->asyncResp->res);
return;
}
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, item.second, item.first,
+ "xyz.openbmc_project.Sensor.Value", "Value",
+ iterator->second.first,
[sensorAsyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -2714,10 +2717,7 @@
messages::internalError(
sensorAsyncResp->asyncResp->res);
}
- },
- item.second, item.first, "org.freedesktop.DBus.Properties",
- "Set", "xyz.openbmc_project.Sensor.Value", "Value",
- dbus::utility::DbusVariantType(iterator->second.first));
+ });
}
};
// Get object with connection for the given sensor name
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 70f8870..e2e3ed4 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -1332,20 +1332,20 @@
const uint32_t retryAttempts)
{
BMCWEB_LOG_DEBUG << "Set Automatic Retry Attempts.";
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR
- << "DBUS response error: Set setAutomaticRetryAttempts" << ec;
- messages::internalError(asyncResp->res);
- return;
- }
- },
- "xyz.openbmc_project.State.Host", "/xyz/openbmc_project/state/host0",
- "org.freedesktop.DBus.Properties", "Set",
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.State.Host",
+ "/xyz/openbmc_project/state/host0",
"xyz.openbmc_project.Control.Boot.RebootAttempts", "RetryAttempts",
- std::variant<uint32_t>(retryAttempts));
+ retryAttempts, [asyncResp](const boost::system::error_code& ec) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR
+ << "DBUS response error: Set setAutomaticRetryAttempts"
+ << ec;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ });
}
inline computer_system::PowerRestorePolicyTypes
@@ -1558,7 +1558,9 @@
}
// Valid TPM Enable object found, now setting the value
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, serv, path,
+ "xyz.openbmc_project.Control.TPM.Policy", "TPMEnable", tpmRequired,
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
@@ -1569,10 +1571,7 @@
return;
}
BMCWEB_LOG_DEBUG << "Set TrustedModuleRequiredToBoot done.";
- },
- serv, path, "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Control.TPM.Policy", "TPMEnable",
- dbus::utility::DbusVariantType(tpmRequired));
+ });
});
}
@@ -1617,7 +1616,10 @@
// Act on validated parameters
BMCWEB_LOG_DEBUG << "DBUS boot type: " << bootTypeStr;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/control/host0/boot",
+ "xyz.openbmc_project.Control.Boot.Type", "BootType", bootTypeStr,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -1631,12 +1633,7 @@
return;
}
BMCWEB_LOG_DEBUG << "Boot type update done.";
- },
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/control/host0/boot",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Control.Boot.Type", "BootType",
- dbus::utility::DbusVariantType(bootTypeStr));
+ });
}
/**
@@ -1687,7 +1684,10 @@
// Act on validated parameters
BMCWEB_LOG_DEBUG << "DBUS boot override enable: " << bootOverrideEnable;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/control/host0/boot",
+ "xyz.openbmc_project.Object.Enable", "Enabled", bootOverrideEnable,
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
@@ -1696,12 +1696,7 @@
return;
}
BMCWEB_LOG_DEBUG << "Boot override enable update done.";
- },
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/control/host0/boot",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Object.Enable", "Enabled",
- dbus::utility::DbusVariantType(bootOverrideEnable));
+ });
if (!bootOverrideEnable)
{
@@ -1713,7 +1708,10 @@
BMCWEB_LOG_DEBUG << "DBUS boot override persistent: "
<< bootOverridePersistent;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/control/host0/boot/one_time",
+ "xyz.openbmc_project.Object.Enable", "Enabled", !bootOverridePersistent,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -1722,12 +1720,7 @@
return;
}
BMCWEB_LOG_DEBUG << "Boot one_time update done.";
- },
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/control/host0/boot/one_time",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Object.Enable", "Enabled",
- dbus::utility::DbusVariantType(!bootOverridePersistent));
+ });
}
/**
@@ -1768,7 +1761,10 @@
BMCWEB_LOG_DEBUG << "DBUS boot source: " << bootSourceStr;
BMCWEB_LOG_DEBUG << "DBUS boot mode: " << bootModeStr;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/control/host0/boot",
+ "xyz.openbmc_project.Control.Boot.Source", "BootSource", bootSourceStr,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -1777,14 +1773,12 @@
return;
}
BMCWEB_LOG_DEBUG << "Boot source update done.";
- },
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/control/host0/boot",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Control.Boot.Source", "BootSource",
- dbus::utility::DbusVariantType(bootSourceStr));
+ });
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/control/host0/boot",
+ "xyz.openbmc_project.Control.Boot.Mode", "BootMode", bootModeStr,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -1793,12 +1787,7 @@
return;
}
BMCWEB_LOG_DEBUG << "Boot mode update done.";
- },
- "xyz.openbmc_project.Settings",
- "/xyz/openbmc_project/control/host0/boot",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Control.Boot.Mode", "BootMode",
- dbus::utility::DbusVariantType(bootModeStr));
+ });
}
/**
@@ -1880,19 +1869,18 @@
return;
}
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec2) {
- if (ec2)
- {
- BMCWEB_LOG_DEBUG << "D-Bus response error on AssetTag Set "
- << ec2;
- messages::internalError(asyncResp->res);
- return;
- }
- },
- service, path, "org.freedesktop.DBus.Properties", "Set",
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, service, path,
"xyz.openbmc_project.Inventory.Decorator.AssetTag", "AssetTag",
- dbus::utility::DbusVariantType(assetTag));
+ assetTag, [asyncResp](const boost::system::error_code& ec2) {
+ if (ec2)
+ {
+ BMCWEB_LOG_DEBUG << "D-Bus response error on AssetTag Set "
+ << ec2;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ });
});
}
@@ -1930,19 +1918,17 @@
return;
}
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- },
- "xyz.openbmc_project.Settings",
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
"/xyz/openbmc_project/control/host0/auto_reboot",
- "org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Control.Boot.RebootPolicy", "AutoReboot",
- dbus::utility::DbusVariantType(autoRebootEnabled));
+ autoRebootEnabled, [asyncResp](const boost::system::error_code& ec) {
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ });
}
inline std::string dbusPowerRestorePolicyFromRedfish(std::string_view policy)
@@ -1985,19 +1971,17 @@
return;
}
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- },
- "xyz.openbmc_project.Settings",
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Settings",
"/xyz/openbmc_project/control/host0/power_restore_policy",
- "org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.Control.Power.RestorePolicy", "PowerRestorePolicy",
- dbus::utility::DbusVariantType(powerRestorePolicy));
+ powerRestorePolicy, [asyncResp](const boost::system::error_code& ec) {
+ if (ec)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ });
}
#ifdef BMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE
@@ -2295,17 +2279,16 @@
<< path;
// Set the Power Mode property
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, service, path,
+ "xyz.openbmc_project.Control.Power.Mode", "PowerMode", powerMode,
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
messages::internalError(asyncResp->res);
return;
}
- },
- service, path, "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Control.Power.Mode", "PowerMode",
- dbus::utility::DbusVariantType(powerMode));
+ });
});
}
@@ -2463,25 +2446,26 @@
return;
}
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
- messages::internalError(asyncResp->res);
- return;
- }
- },
- "xyz.openbmc_project.Watchdog",
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Watchdog",
"/xyz/openbmc_project/watchdog/host0",
- "org.freedesktop.DBus.Properties", "Set",
"xyz.openbmc_project.State.Watchdog", "ExpireAction",
- dbus::utility::DbusVariantType(wdtTimeOutActStr));
+ wdtTimeOutActStr, [asyncResp](const boost::system::error_code& ec) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ });
}
if (wdtEnable)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.Watchdog",
+ "/xyz/openbmc_project/watchdog/host0",
+ "xyz.openbmc_project.State.Watchdog", "Enabled", *wdtEnable,
[asyncResp](const boost::system::error_code& ec) {
if (ec)
{
@@ -2489,12 +2473,7 @@
messages::internalError(asyncResp->res);
return;
}
- },
- "xyz.openbmc_project.Watchdog",
- "/xyz/openbmc_project/watchdog/host0",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.State.Watchdog", "Enabled",
- dbus::utility::DbusVariantType(*wdtEnable));
+ });
}
}
@@ -2725,22 +2704,24 @@
if (ipsEnable)
{
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code& ec2) {
- if (ec2)
- {
- BMCWEB_LOG_DEBUG << "DBUS response error " << ec2;
- messages::internalError(asyncResp->res);
- return;
- }
- },
- service, path, "org.freedesktop.DBus.Properties", "Set",
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, service, path,
"xyz.openbmc_project.Control.Power.IdlePowerSaver", "Enabled",
- dbus::utility::DbusVariantType(*ipsEnable));
+ *ipsEnable, [asyncResp](const boost::system::error_code& ec2) {
+ if (ec2)
+ {
+ BMCWEB_LOG_DEBUG << "DBUS response error " << ec2;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ });
}
if (ipsEnterUtil)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, service, path,
+ "xyz.openbmc_project.Control.Power.IdlePowerSaver",
+ "EnterUtilizationPercent", *ipsEnterUtil,
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
@@ -2748,17 +2729,16 @@
messages::internalError(asyncResp->res);
return;
}
- },
- service, path, "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Control.Power.IdlePowerSaver",
- "EnterUtilizationPercent",
- dbus::utility::DbusVariantType(*ipsEnterUtil));
+ });
}
if (ipsEnterTime)
{
// Convert from seconds into milliseconds for DBus
const uint64_t timeMilliseconds = *ipsEnterTime * 1000;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, service, path,
+ "xyz.openbmc_project.Control.Power.IdlePowerSaver",
+ "EnterDwellTime", timeMilliseconds,
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
@@ -2766,15 +2746,14 @@
messages::internalError(asyncResp->res);
return;
}
- },
- service, path, "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Control.Power.IdlePowerSaver",
- "EnterDwellTime",
- dbus::utility::DbusVariantType(timeMilliseconds));
+ });
}
if (ipsExitUtil)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, service, path,
+ "xyz.openbmc_project.Control.Power.IdlePowerSaver",
+ "ExitUtilizationPercent", *ipsExitUtil,
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
@@ -2782,17 +2761,16 @@
messages::internalError(asyncResp->res);
return;
}
- },
- service, path, "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Control.Power.IdlePowerSaver",
- "ExitUtilizationPercent",
- dbus::utility::DbusVariantType(*ipsExitUtil));
+ });
}
if (ipsExitTime)
{
// Convert from seconds into milliseconds for DBus
const uint64_t timeMilliseconds = *ipsExitTime * 1000;
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, service, path,
+ "xyz.openbmc_project.Control.Power.IdlePowerSaver",
+ "ExitDwellTime", timeMilliseconds,
[asyncResp](const boost::system::error_code& ec2) {
if (ec2)
{
@@ -2800,11 +2778,7 @@
messages::internalError(asyncResp->res);
return;
}
- },
- service, path, "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Control.Power.IdlePowerSaver",
- "ExitDwellTime",
- dbus::utility::DbusVariantType(timeMilliseconds));
+ });
}
});
@@ -3023,7 +2997,11 @@
if (hostCommand)
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.State.Host",
+ "/xyz/openbmc_project/state/host0",
+ "xyz.openbmc_project.State.Host", "RequestedHostTransition",
+ command,
[asyncResp, resetType](const boost::system::error_code& ec,
sdbusplus::message_t& sdbusErrMsg) {
if (ec)
@@ -3034,16 +3012,15 @@
return;
}
messages::success(asyncResp->res);
- },
- "xyz.openbmc_project.State.Host",
- "/xyz/openbmc_project/state/host0",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.State.Host", "RequestedHostTransition",
- dbus::utility::DbusVariantType{command});
+ });
}
else
{
- crow::connections::systemBus->async_method_call(
+ sdbusplus::asio::setProperty(
+ *crow::connections::systemBus, "xyz.openbmc_project.State.Chassis",
+ "/xyz/openbmc_project/state/chassis0",
+ "xyz.openbmc_project.State.Chassis", "RequestedPowerTransition",
+ command,
[asyncResp, resetType](const boost::system::error_code& ec,
sdbusplus::message_t& sdbusErrMsg) {
if (ec)
@@ -3053,12 +3030,7 @@
return;
}
messages::success(asyncResp->res);
- },
- "xyz.openbmc_project.State.Chassis",
- "/xyz/openbmc_project/state/chassis0",
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.State.Chassis", "RequestedPowerTransition",
- dbus::utility::DbusVariantType{command});
+ });
}
}
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