@@ -253,6 +253,9 @@ def subscribe(self):
253
253
registry .subscribe (self ._create_security_group ,
254
254
resources .SECURITY_GROUP ,
255
255
events .AFTER_CREATE )
256
+ registry .subscribe (self ._delete_security_group_precommit ,
257
+ resources .SECURITY_GROUP ,
258
+ events .PRECOMMIT_DELETE )
256
259
registry .subscribe (self ._delete_security_group ,
257
260
resources .SECURITY_GROUP ,
258
261
events .AFTER_DELETE )
@@ -265,9 +268,6 @@ def subscribe(self):
265
268
registry .subscribe (self ._process_sg_rule_notification ,
266
269
resources .SECURITY_GROUP_RULE ,
267
270
events .BEFORE_DELETE )
268
- registry .subscribe (self ._process_sg_rule_after_del_notification ,
269
- resources .SECURITY_GROUP_RULE ,
270
- events .AFTER_DELETE )
271
271
272
272
def _clean_hash_ring (self , * args , ** kwargs ):
273
273
admin_context = n_context .get_admin_context ()
@@ -384,6 +384,14 @@ def _create_security_group(self, resource, event, trigger, payload):
384
384
self ._ovn_client .create_security_group (context ,
385
385
security_group )
386
386
387
+ def _delete_security_group_precommit (self , resource , event , trigger ,
388
+ payload ):
389
+ context = n_context .get_admin_context ()
390
+ security_group_id = payload .resource_id
391
+ for sg_rule in self ._plugin .get_security_group_rules (
392
+ context , filters = {'remote_group_id' : [security_group_id ]}):
393
+ self ._ovn_client .delete_security_group_rule (context , sg_rule )
394
+
387
395
def _delete_security_group (self , resource , event , trigger , payload ):
388
396
context = payload .context
389
397
security_group_id = payload .resource_id
@@ -441,12 +449,6 @@ def _process_sg_rule_notification(
441
449
context ,
442
450
sg_rule )
443
451
444
- def _process_sg_rule_after_del_notification (
445
- self , resource , event , trigger , payload ):
446
- context = payload .context
447
- sg_rule = payload .metadata ['rule' ]
448
- self ._ovn_client .delete_security_group_rule (context , sg_rule )
449
-
450
452
def _sg_has_rules_with_same_normalized_cidr (self , sg_rule ):
451
453
compare_keys = [
452
454
'ethertype' , 'direction' , 'protocol' ,
0 commit comments