From ab0515440f54071f0c686f60e99245ff9740e8a8 Mon Sep 17 00:00:00 2001 From: Hang Yang Date: Thu, 14 May 2020 15:59:56 -0500 Subject: [PATCH] Add sg name in after delete event kwargs Allow the subscriber to know the deleted security group name. It can help some downstream callback utilization to use the deleted sg name for additional workflow. Change-Id: Ia321ff96cf445d20f082779d3f6a96fac07b0943 (cherry picked from commit a2561fa480c28a8bbcbe0528c5a72bc98a9e2a22) --- neutron/db/securitygroups_db.py | 1 + neutron/tests/unit/db/test_securitygroups_db.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/neutron/db/securitygroups_db.py b/neutron/db/securitygroups_db.py index cb553857313..7567311f1d2 100644 --- a/neutron/db/securitygroups_db.py +++ b/neutron/db/securitygroups_db.py @@ -271,6 +271,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase, sg.delete() kwargs.pop('security_group') + kwargs['name'] = sg['name'] registry.notify(resources.SECURITY_GROUP, events.AFTER_DELETE, self, **kwargs) diff --git a/neutron/tests/unit/db/test_securitygroups_db.py b/neutron/tests/unit/db/test_securitygroups_db.py index e12fb498b82..b463a9a5114 100644 --- a/neutron/tests/unit/db/test_securitygroups_db.py +++ b/neutron/tests/unit/db/test_securitygroups_db.py @@ -354,7 +354,8 @@ class SecurityGroupDbMixinTestCase(testlib_api.SqlTestCase): mock.call('security_group', 'after_delete', mock.ANY, context=mock.ANY, security_group_id=sg_dict['id'], - security_group_rule_ids=[mock.ANY, mock.ANY])]) + security_group_rule_ids=[mock.ANY, mock.ANY], + name=sg_dict['name'])]) def test_security_group_rule_precommit_create_event_fail(self): registry.subscribe(fake_callback, resources.SECURITY_GROUP_RULE,