summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0017-Add-MutualExclusiveProperties-registry.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0017-Add-MutualExclusiveProperties-registry.patch')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0017-Add-MutualExclusiveProperties-registry.patch151
1 files changed, 151 insertions, 0 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0017-Add-MutualExclusiveProperties-registry.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0017-Add-MutualExclusiveProperties-registry.patch
new file mode 100644
index 000000000..2b510e0b5
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0017-Add-MutualExclusiveProperties-registry.patch
@@ -0,0 +1,151 @@
+From 891a0a2deb616b7e3f135b5df8501947ce5d6ad4 Mon Sep 17 00:00:00 2001
+From: AppaRao Puli <apparao.puli@linux.intel.com>
+Date: Tue, 8 Sep 2020 01:53:21 +0530
+Subject: [PATCH] Add MutualExclusiveProperties registry
+
+Add MutualExclusiveProperties message registry entry
+and error message.
+As per redfish specification, "RegistryPrefixes" and
+"MessageIds" are mutually exclusive. So add check for
+same in EventService and return MutualExclusiveProperties
+error message.
+
+Tested:
+ - Create subscription failed with error(bad request)
+ when the request body contain both "RegistryPrefixes"
+ and "MessageIds".
+
+Change-Id: I4c14f946977bce2ced8a7f96eb85855117fde9a8
+Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
+---
+ redfish-core/include/error_messages.hpp | 14 +++++++++++
+ .../include/registries/base_message_registry.hpp | 18 +++++++++++++-
+ redfish-core/lib/event_service.hpp | 10 ++++++++
+ redfish-core/src/error_messages.cpp | 29 ++++++++++++++++++++++
+ 4 files changed, 70 insertions(+), 1 deletion(-)
+
+diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
+index 0243be9..9a2d1ca 100644
+--- a/redfish-core/include/error_messages.hpp
++++ b/redfish-core/include/error_messages.hpp
+@@ -787,6 +787,20 @@ nlohmann::json invalidUpload(const std::string& arg1, const std::string& arg2);
+ void invalidUpload(crow::Response& res, const std::string& arg1,
+ const std::string& arg2);
+
++/**
++ * @brief Formats MutualExclusiveProperties message into JSON
++ * Message body: "The properties <arg1> and <arg2> are mutually exclusive."
++ *
++ * @param[in] arg1 Parameter of message that will replace %1 in its body.
++ * @param[in] arg2 Parameter of message that will replace %2 in its body.
++ *
++ * @returns Message MutualExclusiveProperties formatted to JSON */
++nlohmann::json mutualExclusiveProperties(const std::string& arg1,
++ const std::string& arg2);
++
++void mutualExclusiveProperties(crow::Response& res, const std::string& arg1,
++ const std::string& arg2);
++
+ } // namespace messages
+
+ } // namespace redfish
+diff --git a/redfish-core/include/registries/base_message_registry.hpp b/redfish-core/include/registries/base_message_registry.hpp
+index 90aef56..7c385a0 100644
+--- a/redfish-core/include/registries/base_message_registry.hpp
++++ b/redfish-core/include/registries/base_message_registry.hpp
+@@ -36,7 +36,7 @@ const Header header = {
+ constexpr const char* url =
+ "https://redfish.dmtf.org/registries/Base.1.8.1.json";
+
+-constexpr std::array<MessageEntry, 73> registry = {
++constexpr std::array<MessageEntry, 74> registry = {
+ MessageEntry{
+ "AccessDenied",
+ {
+@@ -429,6 +429,22 @@ constexpr std::array<MessageEntry, 73> registry = {
+ "Resolve other reported errors and retry the current operation.",
+ }},
+ MessageEntry{
++ "MutualExclusiveProperties",
++ {
++ "Indicates that the requested operation could not be completed, "
++ "because of a conflict properties.",
++ "The properties '%1' and '%2' are mutually exclusive.",
++ "Warning",
++ "Warning",
++ 2,
++ {
++ "string",
++ "string",
++ },
++ "Ensure that the request body doesn't have mutually exclusive "
++ "properties and resubmit the request.",
++ }},
++ MessageEntry{
+ "NoOperation",
+ {
+ "Indicates that the requested operation will not perform any "
+diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
+index f59d093..4804d26 100644
+--- a/redfish-core/lib/event_service.hpp
++++ b/redfish-core/lib/event_service.hpp
+@@ -242,6 +242,16 @@ class EventDestinationCollection : public Node
+ return;
+ }
+
++ if (regPrefixes && msgIds)
++ {
++ if (regPrefixes->size() && msgIds->size())
++ {
++ messages::mutualExclusiveProperties(
++ asyncResp->res, "RegistryPrefixes", "MessageIds");
++ return;
++ }
++ }
++
+ // Validate the URL using regex expression
+ // Format: <protocol>://<host>:<port>/<uri>
+ // protocol: http/https
+diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
+index 160b73f..c6938ba 100644
+--- a/redfish-core/src/error_messages.cpp
++++ b/redfish-core/src/error_messages.cpp
+@@ -1750,6 +1750,35 @@ nlohmann::json invalidUpload(const std::string& arg1, const std::string& arg2)
+ {"Resolution", "None."}};
+ }
+
++/**
++ * @internal
++ * @brief Formats MutualExclusiveProperties into JSON
++ *
++ * See header file for more information
++ * @endinternal
++ */
++nlohmann::json mutualExclusiveProperties(const std::string& arg1,
++ const std::string& arg2)
++{
++ return nlohmann::json{
++ {"@odata.type", "#Message.v1_0_0.Message"},
++ {"MessageId", "Base.1.5.0.MutualExclusiveProperties"},
++ {"Message", "The properties " + arg1 + " and " + arg2 +
++ " are mutually exclusive."},
++ {"MessageArgs", {arg1, arg2}},
++ {"Severity", "Warning"},
++ {"Resolution",
++ "Ensure that the request body doesn't contain mutually exclusive "
++ "properties and resubmit the request."}};
++}
++
++void mutualExclusiveProperties(crow::Response& res, const std::string& arg1,
++ const std::string& arg2)
++{
++ res.result(boost::beast::http::status::bad_request);
++ addMessageToErrorJson(res.jsonValue, mutualExclusiveProperties(arg1, arg2));
++}
++
+ } // namespace messages
+
+ } // namespace redfish
+--
+2.7.4
+