@@ -22,6 +22,9 @@ import sys
22
22
from sonic_py_common import multi_asic , device_info
23
23
from swsscommon import swsscommon
24
24
25
+ EVENTS_PUBLISHER_SOURCE = "sonic-events-host"
26
+ EVENTS_PUBLISHER_TAG = "event-container"
27
+
25
28
def get_expected_running_containers ():
26
29
"""
27
30
@summary: This function will get the expected running & always-enabled containers by following the rule:
@@ -150,6 +153,17 @@ def get_current_running_containers(always_running_containers):
150
153
return current_running_containers
151
154
152
155
156
+ def publish_events (lst ):
157
+ events_handle = swsscommon .events_init_publisher (EVENTS_PUBLISHER_SOURCE )
158
+ params = swsscommon .FieldValueMap ()
159
+
160
+ for ctr in lst :
161
+ params ["name" ] = ctr ;
162
+ swsscommon .event_publish (events_handle , EVENTS_PUBLISHER_TAG , params )
163
+
164
+ swsscommon .events_deinit_publisher (events_handle )
165
+
166
+
153
167
def main ():
154
168
"""
155
169
@summary: This function will compare the difference between the current running containers
@@ -162,6 +176,7 @@ def main():
162
176
expected_running_containers |= always_running_containers
163
177
not_running_containers = expected_running_containers .difference (current_running_containers )
164
178
if not_running_containers :
179
+ publish_events (not_running_containers )
165
180
print ("Expected containers not running: " + ", " .join (not_running_containers ))
166
181
sys .exit (3 )
167
182
0 commit comments