From e36c91d50b051b9e587ec4bb39965343dd4f84fe Mon Sep 17 00:00:00 2001 From: Thomas Bachman Date: Thu, 1 Feb 2018 20:40:14 +0000 Subject: [PATCH] Fix VMM domain EPG assignment Commit 6bbbb6cb2266d059df4ee109c588fee5e0d5d0be introduced a backwards-incompatible change to the assignment of VMM domains to EPGs in APIC. If the Host Domain Mapping table had no entries, then the default behavior was to only assign OpenStack VMM Domains to the EPGs. The above commit changed it such that both OpenStack and VMware VMM Domains got assigned to EPGs. This commit reverts that behavior, ensuring that only OpenStack VMM Domains are assigned when the table is empty. Change-Id: I5e610daa025c3992f841ae5fcae6f0cca3776880 --- .../drivers/apic_aim/mechanism_driver.py | 2 +- .../unit/plugins/ml2plus/test_apic_aim.py | 39 +++++++++++++++++++ .../grouppolicy/test_aim_mapping_driver.py | 12 ++++++ 3 files changed, 52 insertions(+), 1 deletion(-) 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 0a7fbe1fb..ad003f3a8 100644 --- a/gbpservice/neutron/plugins/ml2plus/drivers/apic_aim/mechanism_driver.py +++ b/gbpservice/neutron/plugins/ml2plus/drivers/apic_aim/mechanism_driver.py @@ -2349,7 +2349,7 @@ class ApicMechanismDriver(api_plus.MechanismDriver, def get_aim_domains(self, aim_ctx): vmms = [{'name': x.name, 'type': x.type} for x in self.aim.find(aim_ctx, aim_resource.VMMDomain) - if x.type in utils.KNOWN_VMM_TYPES.values()] + if x.type == utils.OPENSTACK_VMM_TYPE] phys = [{'name': x.name} for x in self.aim.find(aim_ctx, aim_resource.PhysicalDomain)] return vmms, phys diff --git a/gbpservice/neutron/tests/unit/plugins/ml2plus/test_apic_aim.py b/gbpservice/neutron/tests/unit/plugins/ml2plus/test_apic_aim.py index 6e20327d4..0f50b35d2 100644 --- a/gbpservice/neutron/tests/unit/plugins/ml2plus/test_apic_aim.py +++ b/gbpservice/neutron/tests/unit/plugins/ml2plus/test_apic_aim.py @@ -6094,6 +6094,45 @@ class TestPortOnPhysicalNode(TestPortVlanNetwork): set(self._doms(epg1.physical_domains, with_type=False))) + def test_no_host_domain_mappings(self): + aim_ctx = aim_context.AimContext(self.db_session) + self.aim_mgr.create(aim_ctx, + aim_resource.VMMDomain(type='OpenStack', + name='ostack1'), + overwrite=True) + self.aim_mgr.create(aim_ctx, + aim_resource.VMMDomain(type='VMware', + name='vmware1'), + overwrite=True) + self._register_agent('opflex-1', AGENT_CONF_OPFLEX) + self._register_agent('opflex-2', AGENT_CONF_OPFLEX) + net1 = self._make_network( + self.fmt, 'net1', True, + arg_list=('provider:physical_network', 'provider:network_type'), + **{'provider:physical_network': 'physnet3', + 'provider:network_type': 'opflex'})['network'] + epg1 = self._net_2_epg(net1) + + with self.subnet(network={'network': net1}) as sub1: + + # "normal" port on opflex host + with self.port(subnet=sub1) as p1: + p1 = self._bind_port_to_host(p1['port']['id'], 'opflex-1') + epg1 = self.aim_mgr.get(aim_ctx, epg1) + self.assertEqual(set([('ostack1', 'OpenStack')]), + set(self._doms(epg1.vmm_domains))) + self.assertEqual(set([]), + set(self._doms(epg1.physical_domains, + with_type=False))) + # move port to another host + p1 = self._bind_port_to_host(p1['port']['id'], 'opflex-2') + epg1 = self.aim_mgr.get(aim_ctx, epg1) + self.assertEqual(set([('ostack1', 'OpenStack')]), + set(self._doms(epg1.vmm_domains))) + self.assertEqual(set([]), + set(self._doms(epg1.physical_domains, + with_type=False))) + class TestPortOnPhysicalNodeSingleDriver(TestPortOnPhysicalNode): # Tests for binding port on physical node where no other ML2 mechanism diff --git a/gbpservice/neutron/tests/unit/services/grouppolicy/test_aim_mapping_driver.py b/gbpservice/neutron/tests/unit/services/grouppolicy/test_aim_mapping_driver.py index 3094d0c91..7820e0e8a 100644 --- a/gbpservice/neutron/tests/unit/services/grouppolicy/test_aim_mapping_driver.py +++ b/gbpservice/neutron/tests/unit/services/grouppolicy/test_aim_mapping_driver.py @@ -2159,6 +2159,10 @@ class TestPolicyTargetGroupVmmDomains(AIMBaseTestCase): aim_resource.VMMDomain(type='OpenStack', name='vm2'), overwrite=True) + self.aim_mgr.create(self._aim_context, + aim_resource.VMMDomain(type='VMware', + name='vm3'), + overwrite=True) self.aim_mgr.create(self._aim_context, aim_resource.PhysicalDomain(name='ph1'), overwrite=True) @@ -2671,6 +2675,10 @@ class TestPolicyTarget(AIMBaseTestCase): aim_resource.VMMDomain(type='OpenStack', name='vm2'), overwrite=True) + self.aim_mgr.create(aim_ctx, + aim_resource.VMMDomain(type='VMware', + name='vm3'), + overwrite=True) ptg = self.create_policy_target_group( name="ptg1")['policy_target_group'] pt = self.create_policy_target( @@ -2721,6 +2729,10 @@ class TestPolicyTarget(AIMBaseTestCase): aim_resource.VMMDomain(type='OpenStack', name='vm2'), overwrite=True) + self.aim_mgr.create(aim_ctx, + aim_resource.VMMDomain(type='VMware', + name='vm3'), + overwrite=True) with self.port() as port: port_id = port['port']['id'] self._bind_port_to_host(port_id, 'h1')