diff options
author | Konstantin Aladyshev <aladyshev22@gmail.com> | 2024-02-20 09:51:29 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2024-03-13 00:26:48 +0300 |
commit | 9970e93f794d0110de436828775e333e81330ad5 (patch) | |
tree | 4cc741ced80cf190d2a6b0fd35b8fe10a5fbe054 /redfish-core | |
parent | 6f4bd2904fd231c90ee86040f067018088097715 (diff) | |
download | bmcweb-9970e93f794d0110de436828775e333e81330ad5.tar.xz |
Correct Actions/Manager.ResetToDefaults parameter name
According to the Redfish Data Model specification the correct parameter
name for the '/Actions/Manager.ResetToDefaults' action is not
'ResetToDefaults' but 'ResetType'.
The mistake was originally introduced in the commit "Redfish: Manager:
ResetToDefault" (3e40fc742265c3ec1384e7e5994e62aed356331f).
Change parameter name to match with the specification.
Leave some support for the old parameter name to keep the compatibility
with the old clients.
Tested:
The POST request
/redfish/v1/Managers/bmc/Actions/Manager.ResetToDefaults
with {"ResetType": "ResetAll"} body accepted successfully.
Redfish validator passed.
Change-Id: I6aab20314f85dbda16ad3758091de8822943b761
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Diffstat (limited to 'redfish-core')
-rw-r--r-- | redfish-core/lib/managers.hpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp index c61132f215..392d73984f 100644 --- a/redfish-core/lib/managers.hpp +++ b/redfish-core/lib/managers.hpp @@ -38,8 +38,10 @@ #include <array> #include <cstdint> #include <memory> +#include <optional> #include <ranges> #include <sstream> +#include <string> #include <string_view> #include <variant> @@ -186,25 +188,34 @@ inline void requestRoutesManagerResetToDefaultsAction(App& app) } BMCWEB_LOG_DEBUG("Post ResetToDefaults."); - std::string resetType; + std::optional<std::string> resetType; + std::optional<std::string> resetToDefaultsType; - if (!json_util::readJsonAction(req, asyncResp->res, - "ResetToDefaultsType", resetType)) + if (!json_util::readJsonAction(req, asyncResp->res, "ResetType", + resetType, "ResetToDefaultsType", + resetToDefaultsType)) { - BMCWEB_LOG_DEBUG("Missing property ResetToDefaultsType."); + BMCWEB_LOG_DEBUG("Missing property ResetType."); messages::actionParameterMissing(asyncResp->res, "ResetToDefaults", - "ResetToDefaultsType"); + "ResetType"); return; } + if (resetToDefaultsType && !resetType) + { + BMCWEB_LOG_WARNING( + "Using deprecated ResetToDefaultsType, should be ResetType." + "Support for the ResetToDefaultsType will be dropped in 2Q24"); + resetType = resetToDefaultsType; + } + if (resetType != "ResetAll") { - BMCWEB_LOG_DEBUG( - "Invalid property value for ResetToDefaultsType: {}", - resetType); - messages::actionParameterNotSupported(asyncResp->res, resetType, - "ResetToDefaultsType"); + BMCWEB_LOG_DEBUG("Invalid property value for ResetType: {}", + *resetType); + messages::actionParameterNotSupported(asyncResp->res, *resetType, + "ResetType"); return; } |