From b8eb53886106e44e3668857b13f8642d2ad3cfbf Mon Sep 17 00:00:00 2001 From: AppaRao Puli Date: Fri, 27 Aug 2021 16:02:01 +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: I3745fa6357bd215379781a9818d9acc02a853d79 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 c3e7f61..e9bdbfa 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -21,6 +21,7 @@ #include "registries/task_event_message_registry.hpp" #include +#include #include #include @@ -788,7 +789,7 @@ class EventServiceManager } } - void updateSubscriptionData() + void persistSubscriptionData() { persistent_data::EventServiceStore::getInstance() .eventServiceConfig.enabled = serviceEnabled; @@ -835,7 +836,7 @@ class EventServiceManager if (updateConfig) { - updateSubscriptionData(); + persistSubscriptionData(); } if (updateRetryCfg) @@ -947,7 +948,7 @@ class EventServiceManager if (updateFile) { - updateSubscriptionData(); + persistSubscriptionData(); } #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES @@ -962,6 +963,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; } @@ -986,7 +994,14 @@ class EventServiceManager persistent_data::EventServiceStore::getInstance() .subscriptionsConfigMap.erase(obj2); 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); } } @@ -1008,6 +1023,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 9def549..6a8421f 100644 --- a/redfish-core/lib/event_service.hpp +++ b/redfish-core/lib/event_service.hpp @@ -617,7 +617,7 @@ inline void requestRoutesEventDestination(App& app) subValue->updateRetryPolicy(); } - EventServiceManager::getInstance().updateSubscriptionData(); + EventServiceManager::getInstance().updateSubscription(param); }); BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions//") // The below privilege is wrong, it should be ConfigureManager OR -- 2.17.1