summaryrefslogtreecommitdiff
path: root/redfish-core/lib/event_service.hpp
diff options
context:
space:
mode:
authorAppaRao Puli <apparao.puli@linux.intel.com>2020-08-03 19:53:12 +0300
committerAppaRao Puli <apparao.puli@linux.intel.com>2020-08-06 06:14:35 +0300
commit144b631845d4ab67a5b21bf91fea4ac2c1d3f006 (patch)
tree03eb7e773dd9ed9ec69f3926d8d7ee24ef869112 /redfish-core/lib/event_service.hpp
parent5738de59eb185c0d9c01ef4518e86bf99503f4f4 (diff)
downloadbmcweb-144b631845d4ab67a5b21bf91fea4ac2c1d3f006.tar.xz
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
Diffstat (limited to 'redfish-core/lib/event_service.hpp')
-rw-r--r--redfish-core/lib/event_service.hpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index 4d9d4d9887..b532815e4d 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -239,7 +239,7 @@ class EventDestinationCollection : public Node
std::optional<std::vector<std::string>> regPrefixes;
std::optional<std::vector<std::string>> resTypes;
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,
@@ -247,7 +247,7 @@ class EventDestinationCollection : public Node
"EventFormatType", eventFormatType, "HttpHeaders", headers,
"RegistryPrefixes", regPrefixes, "MessageIds", msgIds,
"DeliveryRetryPolicy", retryPolicy, "MetricReportDefinitions",
- metricReportDefinitions, "ResourceTypes", resTypes))
+ mrdJsonArray, "ResourceTypes", resTypes))
{
return;
}
@@ -413,9 +413,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 =
@@ -593,8 +608,13 @@ class EventDestination : public Node
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,