From b5020756ae3fbff6283c293c74b779d656429f3a 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 Signed-off-by: P Dheeraj Srujan Kumar --- .../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 aae9f02..69db652 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 @@ -780,7 +781,7 @@ class EventServiceManager } } - void updateSubscriptionData() + void persistSubscriptionData() { persistent_data::EventServiceStore::getInstance() .eventServiceConfig.enabled = serviceEnabled; @@ -827,7 +828,7 @@ class EventServiceManager if (updateConfig) { - updateSubscriptionData(); + persistSubscriptionData(); } if (updateRetryCfg) @@ -939,7 +940,7 @@ class EventServiceManager if (updateFile) { - updateSubscriptionData(); + persistSubscriptionData(); } #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES @@ -955,6 +956,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; } @@ -979,7 +987,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); } } @@ -1001,6 +1016,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 99c3bfd..15e45dc 100644 --- a/redfish-core/lib/event_service.hpp +++ b/redfish-core/lib/event_service.hpp @@ -624,7 +624,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