From bd5a5f38b0b4156f8c6bedbaace5bcd83514394f Mon Sep 17 00:00:00 2001 From: Kent Wu Date: Thu, 30 Aug 2018 11:17:39 -0700 Subject: [PATCH] Use cascade delete instead for SG deletion This way AIM will automatically delete all the children after deleting the SG. Then in AIM we can optimize it so that when a parent is already marked for deletion, we don't add those children to the deletion queue to reduce the deletion requests sent to APIC. Change-Id: Ib78a5023e388cd5a70d945471ab0b018ca7e2732 --- .../ml2plus/drivers/apic_aim/mechanism_driver.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/gbpservice/neutron/plugins/ml2plus/drivers/apic_aim/mechanism_driver.py b/gbpservice/neutron/plugins/ml2plus/drivers/apic_aim/mechanism_driver.py index 86b344fb2..9d78066ef 100644 --- a/gbpservice/neutron/plugins/ml2plus/drivers/apic_aim/mechanism_driver.py +++ b/gbpservice/neutron/plugins/ml2plus/drivers/apic_aim/mechanism_driver.py @@ -1986,20 +1986,9 @@ class ApicMechanismDriver(api_plus.MechanismDriver, aim_ctx = aim_context.AimContext(session) sg = context.current tenant_aname = self.name_mapper.project(session, sg['tenant_id']) - for sg_rule in sg.get('security_group_rules'): - sg_rule_aim = aim_resource.SecurityGroupRule( - tenant_name=tenant_aname, - security_group_name=sg['id'], - security_group_subject_name='default', - name=sg_rule['id']) - self.aim.delete(aim_ctx, sg_rule_aim) - sg_subject = aim_resource.SecurityGroupSubject( - tenant_name=tenant_aname, - security_group_name=sg['id'], name='default') - self.aim.delete(aim_ctx, sg_subject) sg_aim = aim_resource.SecurityGroup(tenant_name=tenant_aname, name=sg['id']) - self.aim.delete(aim_ctx, sg_aim) + self.aim.delete(aim_ctx, sg_aim, cascade=True) def _get_sg_rule_tenant_id(self, session, sg_rule): # There is a bug in Neutron that sometimes the tenant_id contained