Send push-style event only if EventService enabled
As per DMTF Redfish, if the event service is disabled, events are not
expected to be posted to the existing subscribers
This commit adds validation to check "ServiceEnabled" property while
sending events. An additional check is made not to attempt sending
events if there are no event subscribers at BMC
Tested by:
Using DMTF Redfish-Event-Listener script with some local modification
to support the latest event subscription specifications
1. With a Push-style event subscriber setup, set "ServiceEnabled" to
false
PATCH /redfish/v1/EventService -d '{"ServiceEnabled":false}'
2. Generate events and check no events are posted to subscriber
2. Set "ServiceEnabled" to true. BMC should resume sending further
events
3. Check if BMC attempts to send events by forming the eventRecords
when there are no subscriptions made - Verified with traces that
events are not sent out
4. With "ServiceEnabled" set to false, verified the SubmitTestEvent
fails
Signed-off-by: Sunitha Harish <sunharis@in.ibm.com>
Change-Id: Icbe7c25ba12bbfb73e59639c484fccdf384ebecf
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index 115bfee..9b4f6bd 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -161,7 +161,12 @@
.methods(boost::beast::http::verb::post)(
[](const crow::Request&,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- EventServiceManager::getInstance().sendTestEventLog();
+ if (!EventServiceManager::getInstance().sendTestEventLog())
+ {
+ messages::serviceDisabled(asyncResp->res,
+ "/redfish/v1/EventService/");
+ return;
+ }
asyncResp->res.result(boost::beast::http::status::no_content);
});
}