summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0007-EventService-Log-events-for-subscription-actions.patch
blob: 3be65ee2a7ae65bb57fafd5695d1484d3bf248e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
From b8eb53886106e44e3668857b13f8642d2ad3cfbf Mon Sep 17 00:00:00 2001
From: AppaRao Puli <apparao.puli@linux.intel.com>
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 <apparao.puli@intel.com>
Signed-off-by: Ayushi Smriti <smriti.ayushi@intel.com>
---
 .../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 <sys/inotify.h>
+#include <systemd/sd-journal.h>
 
 #include <boost/asio/io_context.hpp>
 #include <boost/beast/core/span.hpp>
@@ -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/<str>/")
         // The below privilege is wrong, it should be ConfigureManager OR
-- 
2.17.1