diff options
Diffstat (limited to 'redfish-core/include/utils/dbus_utils.hpp')
-rw-r--r-- | redfish-core/include/utils/dbus_utils.hpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/redfish-core/include/utils/dbus_utils.hpp b/redfish-core/include/utils/dbus_utils.hpp index cd7e0e2ca2..80571698a8 100644 --- a/redfish-core/include/utils/dbus_utils.hpp +++ b/redfish-core/include/utils/dbus_utils.hpp @@ -39,7 +39,13 @@ void afterSetProperty(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const nlohmann::json& propertyValue, const boost::system::error_code& ec, const sdbusplus::message_t& msg); -} + +void afterSetPropertyAction(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const std::string& redfishActionName, + const std::string& redfishActionParameterName, + const boost::system::error_code& ec, + const sdbusplus::message_t& msg); +} // namespace details template <typename PropertyType> void setDbusProperty(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, @@ -64,4 +70,32 @@ void setDbusProperty(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, }); } +template <typename DbusPropertyType> +void setDbusPropertyAction(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + std::string_view processName, + const sdbusplus::message::object_path& path, + std::string_view interface, + std::string_view dbusProperty, + std::string_view redfishActionParameterName, + std::string_view redfishActionName, + const DbusPropertyType& prop) +{ + std::string processNameStr(processName); + std::string interfaceStr(interface); + std::string dbusPropertyStr(dbusProperty); + + sdbusplus::asio::setProperty( + *crow::connections::systemBus, processNameStr, path.str, interfaceStr, + dbusPropertyStr, prop, + [asyncResp, + redfishActionParameterName = std::string{redfishActionParameterName}, + jsonProp = nlohmann::json(prop), + redfishActionNameStr = std::string{redfishActionName}]( + const boost::system::error_code& ec, + const sdbusplus::message_t& msg) { + details::afterSetPropertyAction(asyncResp, redfishActionNameStr, + redfishActionParameterName, ec, msg); + }); +} + } // namespace redfish |