Fix VMM domain EPG assignment

Commit 6bbbb6cb22 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
This commit is contained in:
Thomas Bachman 2018-02-01 20:40:14 +00:00
parent 6c2ac9b022
commit e36c91d50b
3 changed files with 52 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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')