Merge "Add sg_id in the AFTER_DELETE event of sg_rule delete"
This commit is contained in:
@@ -624,12 +624,15 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
|
||||
**kwargs)
|
||||
|
||||
try:
|
||||
sg_rule = query.one()
|
||||
# As there is a filter on a primary key it is not possible for
|
||||
# MultipleResultsFound to be raised
|
||||
context.session.delete(query.one())
|
||||
context.session.delete(sg_rule)
|
||||
except exc.NoResultFound:
|
||||
raise ext_sg.SecurityGroupRuleNotFound(id=id)
|
||||
|
||||
kwargs['security_group_id'] = sg_rule['security_group_id']
|
||||
|
||||
registry.notify(
|
||||
resources.SECURITY_GROUP_RULE, events.AFTER_DELETE, self,
|
||||
**kwargs)
|
||||
|
||||
@@ -270,7 +270,7 @@ class SecurityGroupDbMixinTestCase(testlib_api.SqlTestCase):
|
||||
'precommit_create', mock.ANY, context=mock.ANY,
|
||||
security_group_rule=mock.ANY)])
|
||||
|
||||
def test_security_group_rule_precommit_delete_event(self):
|
||||
def test_sg_rule_before_precommit_and_after_delete_event(self):
|
||||
sg_dict = self.mixin.create_security_group(self.ctx, FAKE_SECGROUP)
|
||||
fake_rule = FAKE_SECGROUP_RULE
|
||||
fake_rule['security_group_rule']['security_group_id'] = sg_dict['id']
|
||||
@@ -280,9 +280,16 @@ class SecurityGroupDbMixinTestCase(testlib_api.SqlTestCase):
|
||||
fake_rule)
|
||||
self.mixin.delete_security_group_rule(self.ctx,
|
||||
sg_rule_dict['id'])
|
||||
mock_notify.assert_has_calls([mock.call('security_group_rule',
|
||||
'before_delete', mock.ANY, context=mock.ANY,
|
||||
security_group_rule_id=sg_rule_dict['id'])])
|
||||
mock_notify.assert_has_calls([mock.call('security_group_rule',
|
||||
'precommit_delete', mock.ANY, context=mock.ANY,
|
||||
security_group_rule_id=mock.ANY)])
|
||||
security_group_rule_id=sg_rule_dict['id'])])
|
||||
mock_notify.assert_has_calls([mock.call('security_group_rule',
|
||||
'after_delete', mock.ANY, context=mock.ANY,
|
||||
security_group_rule_id=sg_rule_dict['id'],
|
||||
security_group_id=sg_dict['id'])])
|
||||
|
||||
def test_get_ip_proto_name_and_num(self):
|
||||
protocols = [constants.PROTO_NAME_UDP, str(constants.PROTO_NUM_TCP),
|
||||
|
||||
Reference in New Issue
Block a user