summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0009-Fix-MetricReportDefinitions-filter-not-working.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0009-Fix-MetricReportDefinitions-filter-not-working.patch')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0009-Fix-MetricReportDefinitions-filter-not-working.patch112
1 files changed, 112 insertions, 0 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0009-Fix-MetricReportDefinitions-filter-not-working.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0009-Fix-MetricReportDefinitions-filter-not-working.patch
new file mode 100644
index 000000000..64b3c1112
--- /dev/null
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0009-Fix-MetricReportDefinitions-filter-not-working.patch
@@ -0,0 +1,112 @@
+From 455b1d4c687a5c14197af1c1aba80b579c75900e Mon Sep 17 00:00:00 2001
+From: AppaRao Puli <apparao.puli@linux.intel.com>
+Date: Mon, 3 Aug 2020 22:23:12 +0530
+Subject: [PATCH 1/2] Fix: MetricReportDefinitions filter not working
+
+The metric reports are not sending when user configures
+the MetricReportDefinitions filter. This is of odata json
+object type. Corrected code to properly handle odata type
+object and store it as string array to make filters faster.
+
+Tested:
+ - Created metric report EventService subscription type
+ with MetricReportDefinitions and events properly sent to
+ Event listener.
+
+Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
+Change-Id: If96564219da7d38a2ee5e415b89824ba25cd686d
+---
+ redfish-core/include/event_service_manager.hpp | 4 ++--
+ redfish-core/lib/event_service.hpp | 32 +++++++++++++++++++++-----
+ 2 files changed, 28 insertions(+), 8 deletions(-)
+
+diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
+index 214f1e4..7c47842 100644
+--- a/redfish-core/include/event_service_manager.hpp
++++ b/redfish-core/include/event_service_manager.hpp
+@@ -283,7 +283,7 @@ bool isFilterQuerySpecialChar(char c)
+ bool readSSEQueryParams(std::string sseFilter, std::string& formatType,
+ std::vector<std::string>& messageIds,
+ std::vector<std::string>& registryPrefixes,
+- std::vector<nlohmann::json>& metricReportDefinitions)
++ std::vector<std::string>& metricReportDefinitions)
+ {
+ sseFilter.erase(std::remove_if(sseFilter.begin(), sseFilter.end(),
+ isFilterQuerySpecialChar),
+@@ -369,7 +369,7 @@ class Subscription
+ std::vector<std::string> registryMsgIds;
+ std::vector<std::string> registryPrefixes;
+ std::vector<nlohmann::json> httpHeaders; // key-value pair
+- std::vector<nlohmann::json> metricReportDefinitions;
++ std::vector<std::string> metricReportDefinitions;
+
+ Subscription(const Subscription&) = delete;
+ Subscription& operator=(const Subscription&) = delete;
+diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
+index 8bd30f5..f59d093 100644
+--- a/redfish-core/lib/event_service.hpp
++++ b/redfish-core/lib/event_service.hpp
+@@ -229,7 +229,7 @@ class EventDestinationCollection : public Node
+ std::optional<std::vector<std::string>> msgIds;
+ std::optional<std::vector<std::string>> regPrefixes;
+ std::optional<std::vector<nlohmann::json>> headers;
+- std::optional<std::vector<nlohmann::json>> metricReportDefinitions;
++ std::optional<std::vector<nlohmann::json>> mrdJsonArray;
+
+ if (!json_util::readJson(
+ req, res, "Destination", destUrl, "Context", context,
+@@ -237,7 +237,7 @@ class EventDestinationCollection : public Node
+ "EventFormatType", eventFormatType, "HttpHeaders", headers,
+ "RegistryPrefixes", regPrefixes, "MessageIds", msgIds,
+ "DeliveryRetryPolicy", retryPolicy, "MetricReportDefinitions",
+- metricReportDefinitions))
++ mrdJsonArray))
+ {
+ return;
+ }
+@@ -387,9 +387,24 @@ class EventDestinationCollection : public Node
+ subValue->retryPolicy = "TerminateAfterRetries";
+ }
+
+- if (metricReportDefinitions)
++ if (mrdJsonArray)
+ {
+- subValue->metricReportDefinitions = *metricReportDefinitions;
++ for (nlohmann::json& mrdObj : *mrdJsonArray)
++ {
++ std::string mrdUri;
++ if (json_util::getValueFromJsonObject(mrdObj, "@odata.id",
++ mrdUri))
++ {
++ subValue->metricReportDefinitions.emplace_back(mrdUri);
++ }
++ else
++ {
++ messages::propertyValueFormatError(
++ asyncResp->res, mrdObj.dump(),
++ "MetricReportDefinitions");
++ return;
++ }
++ }
+ }
+
+ std::string id =
+@@ -565,8 +580,13 @@ class EventDestination : public Node
+ subValue->registryPrefixes;
+ asyncResp->res.jsonValue["MessageIds"] = subValue->registryMsgIds;
+ asyncResp->res.jsonValue["DeliveryRetryPolicy"] = subValue->retryPolicy;
+- asyncResp->res.jsonValue["MetricReportDefinitions"] =
+- subValue->metricReportDefinitions;
++
++ std::vector<nlohmann::json> mrdJsonArray;
++ for (const auto& mdrUri : subValue->metricReportDefinitions)
++ {
++ mrdJsonArray.push_back({{"@odata.id", mdrUri}});
++ }
++ asyncResp->res.jsonValue["MetricReportDefinitions"] = mrdJsonArray;
+ }
+
+ void doPatch(crow::Response& res, const crow::Request& req,
+--
+2.7.4
+