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>
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index c61132f..392d739 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 @@
}
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;
}