From dad35d6e6736f1c4ab6d739c62b22923ad749ad7 Mon Sep 17 00:00:00 2001 From: Krzysztof Grobelny Date: Tue, 13 Jul 2021 12:30:08 +0000 Subject: [PATCH] EventService: Log events for subscription actions Log redfish event for below 3 actions - Add new subscription - Update existing subscription properties - Delete existing subscription in order to notify the subscribed clients on the subscription related information. Modified method name accordingly to indicate the clear purpose and added updateSubscription method with subscription id param to log event for subscription update. Tested: - Performed all the above actions and verified the redfish event messages are logged. Change-Id: I528293e55b1f3401bc2bb09c11c63ae985fbfedb Signed-off-by: AppaRao Puli Signed-off-by: Ayushi Smriti --- .../include/event_service_manager.hpp | 35 ++++++++++++++++--- redfish-core/lib/event_service.hpp | 2 +- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp index a5b37e5..75f5615 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -20,6 +20,7 @@ #include "registries/task_event_message_registry.hpp" #include +#include #include #include @@ -813,7 +814,7 @@ class EventServiceManager return; } - void updateSubscriptionData() + void persistSubscriptionData() { // Persist the config and subscription data. nlohmann::json jsonData; @@ -910,7 +911,7 @@ class EventServiceManager if (updateConfig) { - updateSubscriptionData(); + persistSubscriptionData(); } if (updateRetryCfg) @@ -1005,7 +1006,7 @@ class EventServiceManager if (updateFile) { - updateSubscriptionData(); + persistSubscriptionData(); } #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES @@ -1020,6 +1021,13 @@ class EventServiceManager // Set Subscription ID for back trace subValue->setSubscriptionId(id); + + /* Log event for subscription addition */ + sd_journal_send("MESSAGE=Event subscription added(Id: %s)", id.c_str(), + "PRIORITY=%i", LOG_INFO, "REDFISH_MESSAGE_ID=%s", + "OpenBMC.0.1.EventSubscriptionAdded", + "REDFISH_MESSAGE_ARGS=%s", id.c_str(), NULL); + return id; } @@ -1040,7 +1048,14 @@ class EventServiceManager { subscriptionsMap.erase(obj); updateNoOfSubscribersCount(); - updateSubscriptionData(); + + persistSubscriptionData(); + /* Log event for subscription delete. */ + sd_journal_send("MESSAGE=Event subscription removed.(Id = %s)", + id.c_str(), "PRIORITY=%i", LOG_INFO, + "REDFISH_MESSAGE_ID=%s", + "OpenBMC.0.1.EventSubscriptionRemoved", + "REDFISH_MESSAGE_ARGS=%s", id.c_str(), NULL); } } @@ -1062,6 +1077,18 @@ class EventServiceManager } } + void updateSubscription(const std::string& id) + { + persistSubscriptionData(); + + /* Log event for subscription update. */ + sd_journal_send("MESSAGE=Event subscription updated.(Id = %s)", + id.c_str(), "PRIORITY=%i", LOG_INFO, + "REDFISH_MESSAGE_ID=%s", + "OpenBMC.0.1.EventSubscriptionUpdated", + "REDFISH_MESSAGE_ARGS=%s", id.c_str(), NULL); + } + size_t getNumberOfSubscriptions() { return subscriptionsMap.size(); diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp index 53a60d3..435c93d 100644 --- a/redfish-core/lib/event_service.hpp +++ b/redfish-core/lib/event_service.hpp @@ -579,7 +579,7 @@ inline void requestRoutesEventDestination(App& app) subValue->updateRetryPolicy(); } - EventServiceManager::getInstance().updateSubscriptionData(); + EventServiceManager::getInstance().updateSubscription(param); }); BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions//") .privileges({{"ConfigureManager"}}) -- 2.25.1