diff options
author | Sunitha Harish <sunharis@in.ibm.com> | 2020-07-22 10:38:59 +0300 |
---|---|---|
committer | Ratan Gupta <ratagupt@linux.vnet.ibm.com> | 2020-07-31 15:57:28 +0300 |
commit | e56f254c351e7e2ead2b895eb6117ff6cdf05bdf (patch) | |
tree | 207a091adf7bde1f264db6346ff98c8307699456 /redfish-core/lib/event_service.hpp | |
parent | afd77a536ce84c934f56eae4f69d831fbd238d9a (diff) | |
download | bmcweb-e56f254c351e7e2ead2b895eb6117ff6cdf05bdf.tar.xz |
EventService: Add the parameter ResourceTypes to subscription
This commit supports sending the ResourceTypes list while subscribing
to the events. The "Task" resource is added as a supported type to receive
the task life cycle events.
For IBM's management console along with the Task resource, the support
is provided to subscribe to the "IBMConfigFile" ResourceType to receive
events while creating/updating the ConfigFiles.
Tested by:
1. GET https://${bmc}/redfish/v1/EventService
2. Create subscription :
POST https://${bmc}/redfish/v1/EventService/Subscriptions
-d '{"Destination" : <>, "Protocol":"Redfish", "ResourceTypes": ["Task"]}'
3. GET https://${bmc}/redfish/v1/EventService/Subscriptions/<id>
3. Redfish validator was run successfully
Signed-off-by: Sunitha Harish <sunharis@in.ibm.com>
Change-Id: Ibaf3f4f5f005a1beedf0a1cd049ae11d93a3af36
Diffstat (limited to 'redfish-core/lib/event_service.hpp')
-rw-r--r-- | redfish-core/lib/event_service.hpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp index b27c6e061d..d3ed416c62 100644 --- a/redfish-core/lib/event_service.hpp +++ b/redfish-core/lib/event_service.hpp @@ -26,6 +26,14 @@ static constexpr const std::array<const char*, 3> supportedRegPrefixes = { static constexpr const std::array<const char*, 3> supportedRetryPolicies = { "TerminateAfterRetries", "SuspendRetries", "RetryForever"}; +#ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE +static constexpr const std::array<const char*, 2> supportedResourceTypes = { + "IBMConfigFile", "Task"}; +#else +static constexpr const std::array<const char*, 1> supportedResourceTypes = { + "Task"}; +#endif + static constexpr const uint8_t maxNoOfSubscriptions = 20; class EventService : public Node @@ -72,6 +80,7 @@ class EventService : public Node retryTimeoutInterval; asyncResp->res.jsonValue["EventFormatTypes"] = supportedEvtFormatTypes; asyncResp->res.jsonValue["RegistryPrefixes"] = supportedRegPrefixes; + asyncResp->res.jsonValue["ResourceTypes"] = supportedResourceTypes; nlohmann::json supportedSSEFilters = { {"EventFormatType", true}, {"MessageId", true}, @@ -228,6 +237,7 @@ class EventDestinationCollection : public Node std::optional<std::string> retryPolicy; std::optional<std::vector<std::string>> msgIds; 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; @@ -237,7 +247,7 @@ class EventDestinationCollection : public Node "EventFormatType", eventFormatType, "HttpHeaders", headers, "RegistryPrefixes", regPrefixes, "MessageIds", msgIds, "DeliveryRetryPolicy", retryPolicy, "MetricReportDefinitions", - metricReportDefinitions)) + metricReportDefinitions, "ResourceTypes", resTypes)) { return; } @@ -362,6 +372,22 @@ class EventDestinationCollection : public Node subValue->registryPrefixes = *regPrefixes; } + if (resTypes) + { + for (const std::string& it : *resTypes) + { + if (std::find(supportedResourceTypes.begin(), + supportedResourceTypes.end(), + it) == supportedResourceTypes.end()) + { + messages::propertyValueNotInList(asyncResp->res, it, + "ResourceTypes"); + return; + } + } + subValue->resourceTypes = *resTypes; + } + if (msgIds) { // Do we need to loop-up MessageRegistry and validate @@ -560,6 +586,8 @@ class EventDestination : public Node asyncResp->res.jsonValue["EventFormatType"] = subValue->eventFormatType; asyncResp->res.jsonValue["RegistryPrefixes"] = subValue->registryPrefixes; + asyncResp->res.jsonValue["ResourceTypes"] = subValue->resourceTypes; + asyncResp->res.jsonValue["MessageIds"] = subValue->registryMsgIds; asyncResp->res.jsonValue["DeliveryRetryPolicy"] = subValue->retryPolicy; asyncResp->res.jsonValue["MetricReportDefinitions"] = |