summaryrefslogtreecommitdiff
path: root/redfish-core/lib/systems.hpp
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2021-01-06 04:50:11 +0300
committerEd Tanous <ed@tanous.net>2021-03-19 01:00:29 +0300
commit4e69c9040b996b48b6e361ac8caed47e91b71a83 (patch)
tree949c8d0d493cbcbb8f2775c3af0549d665234fa5 /redfish-core/lib/systems.hpp
parent636be396e4f3ecc09e446ca76db380fc0c5b57f9 (diff)
downloadbmcweb-4e69c9040b996b48b6e361ac8caed47e91b71a83.tar.xz
Fix Power Restore Policy not valid enum error
When the client passes a value that is not in list of accepted values use propertyValueNotInList. Tested: curl -k -X PATCH -d '{"PowerRestorePolicy":"badvalue"}'\ https://${bmc}/redfish/v1/Systems/system { "PowerRestorePolicy@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The value badvalue for the property PowerRestorePolicy is not in the list of acceptable values.", "MessageArgs": [ "badvalue", "PowerRestorePolicy" ], "MessageId": "Base.1.8.1.PropertyValueNotInList", Change-Id: Icfa910c9f79aa6ff0a87f748b55ad52d8ad411d8 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'redfish-core/lib/systems.hpp')
-rw-r--r--redfish-core/lib/systems.hpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 57f6b96448..91da523fdb 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -1543,7 +1543,7 @@ inline void setAutomaticRetry(const std::shared_ptr<AsyncResp>& aResp,
* @return None.
*/
inline void setPowerRestorePolicy(const std::shared_ptr<AsyncResp>& aResp,
- std::optional<std::string> policy)
+ const std::string& policy)
{
BMCWEB_LOG_DEBUG << "Set power restore policy.";
@@ -1557,10 +1557,11 @@ inline void setPowerRestorePolicy(const std::shared_ptr<AsyncResp>& aResp,
std::string powerRestorPolicy;
- auto policyMapsIt = policyMaps.find(*policy);
+ auto policyMapsIt = policyMaps.find(policy);
if (policyMapsIt == policyMaps.end())
{
- messages::internalError(aResp->res);
+ messages::propertyValueNotInList(aResp->res, policy,
+ "PowerRestorePolicy");
return;
}
@@ -2252,7 +2253,7 @@ class Systems : public Node
if (powerRestorePolicy)
{
- setPowerRestorePolicy(asyncResp, std::move(*powerRestorePolicy));
+ setPowerRestorePolicy(asyncResp, *powerRestorePolicy);
}
}
};