Fix VMM/Physdoms allocation to only incluyde non-monitored
When associating VMMs to EPGs, make sure we only select managed domains. Loading monitored ones might include some from other Openstack installations. Change-Id: I159830a0af3ecffd02f75f50737790e930ed8132
This commit is contained in:
@@ -2258,10 +2258,12 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
||||
self.ap_name = new_conf['value']
|
||||
|
||||
def get_aim_domains(self, aim_ctx):
|
||||
vmms = [x.name for x in self.aim.find(aim_ctx, aim_resource.VMMDomain)
|
||||
if x.type == utils.OPENSTACK_VMM_TYPE]
|
||||
phys = [x.name for x in
|
||||
self.aim.find(aim_ctx, aim_resource.PhysicalDomain)]
|
||||
vmms = [{'name': x.name, 'type': x.type} for x in
|
||||
self.aim.find(aim_ctx, aim_resource.VMMDomain, monitored=False)
|
||||
if x.type.lower() in utils.KNOWN_VMM_TYPES]
|
||||
phys = [{'name': x.name} for x in
|
||||
self.aim.find(aim_ctx, aim_resource.PhysicalDomain,
|
||||
monitored=False)]
|
||||
return vmms, phys
|
||||
|
||||
def _is_external(self, network):
|
||||
@@ -2733,8 +2735,7 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
||||
domain = aim_hd_mapping.vmm_domain_name
|
||||
if not domain:
|
||||
vmms, phys = self.get_aim_domains(aim_ctx)
|
||||
self.aim.update(aim_ctx, epg,
|
||||
openstack_vmm_domain_names=vmms)
|
||||
self.aim.update(aim_ctx, epg, vmm_domains=vmms)
|
||||
elif domain not in aim_epg.openstack_vmm_domain_names:
|
||||
aim_epg.openstack_vmm_domain_names.append(domain)
|
||||
vmms = aim_epg.openstack_vmm_domain_names
|
||||
@@ -2745,13 +2746,11 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
||||
domain = aim_hd_mapping.physical_domain_name
|
||||
if not domain:
|
||||
vmms, phys = self.get_aim_domains(aim_ctx)
|
||||
self.aim.update(aim_ctx, epg,
|
||||
physical_domain_names=phys)
|
||||
self.aim.update(aim_ctx, epg, physical_domains=phys)
|
||||
elif domain not in aim_epg.physical_domain_names:
|
||||
aim_epg.physical_domain_names.append(domain)
|
||||
phys = aim_epg.physical_domain_names
|
||||
self.aim.update(aim_ctx, epg,
|
||||
physical_domain_names=phys)
|
||||
self.aim.update(aim_ctx, epg, physical_domain_names=phys)
|
||||
# this could be caused by concurrent transactions
|
||||
except db_exc.DBDuplicateEntry as e:
|
||||
LOG.debug(e)
|
||||
|
||||
@@ -3513,22 +3513,38 @@ class TestMl2NetworksV2(test_plugin.TestNetworksV2,
|
||||
aim_resource.VMMDomain(type='OpenStack',
|
||||
name='vm1'),
|
||||
overwrite=True)
|
||||
self.aim_mgr.create(aim_ctx,
|
||||
aim_resource.VMMDomain(type='OpenStack',
|
||||
name='vm_m',
|
||||
monitored=True),
|
||||
overwrite=True)
|
||||
self.aim_mgr.create(aim_ctx,
|
||||
aim_resource.VMMDomain(type='OpenStack',
|
||||
name='vm2'),
|
||||
overwrite=True)
|
||||
self.aim_mgr.create(aim_ctx,
|
||||
aim_resource.VMMDomain(type='VMware',
|
||||
name='vm3'),
|
||||
overwrite=True)
|
||||
self.aim_mgr.create(aim_ctx,
|
||||
aim_resource.PhysicalDomain(name='ph1'),
|
||||
overwrite=True)
|
||||
self.aim_mgr.create(aim_ctx,
|
||||
aim_resource.PhysicalDomain(name='ph2'),
|
||||
aim_resource.PhysicalDomain(name='ph2',
|
||||
monitored=True),
|
||||
overwrite=True)
|
||||
with self.network(name='net'):
|
||||
net1 = self._make_network(self.fmt, 'pvt-net1', True)['network']
|
||||
sub1 = self._make_subnet(
|
||||
self.fmt, {'network': net1}, '10.10.1.1', '10.10.1.0/24')
|
||||
self._register_agent('host1', AGENT_CONF_OPFLEX)
|
||||
with self.port(subnet=sub1) as port:
|
||||
self._bind_port_to_host(port['port']['id'], 'host1')
|
||||
epg = self.aim_mgr.find(aim_ctx, aim_resource.EndpointGroup)[0]
|
||||
self.assertEqual(set([]),
|
||||
set(epg.openstack_vmm_domain_names))
|
||||
self.assertEqual(set([]),
|
||||
set(epg.physical_domain_names))
|
||||
self.assertEqual(sorted([{'type': 'OpenStack', 'name': 'vm1'},
|
||||
{'type': 'OpenStack', 'name': 'vm2'},
|
||||
{'type': 'VMware', 'name': 'vm3'}]),
|
||||
sorted(epg.vmm_domains))
|
||||
self.assertEqual(sorted([]), sorted(epg.physical_domains))
|
||||
|
||||
|
||||
class TestMl2SubnetsV2(test_plugin.TestSubnetsV2,
|
||||
|
||||
@@ -2661,6 +2661,11 @@ class TestPolicyTarget(AIMBaseTestCase):
|
||||
aim_resource.VMMDomain(type='OpenStack',
|
||||
name='vm2'),
|
||||
overwrite=True)
|
||||
self.aim_mgr.create(aim_ctx,
|
||||
aim_resource.VMMDomain(type='OpenStack',
|
||||
name='vm_m',
|
||||
monitored=True),
|
||||
overwrite=True)
|
||||
ptg = self.create_policy_target_group(
|
||||
name="ptg1")['policy_target_group']
|
||||
pt = self.create_policy_target(
|
||||
@@ -2698,6 +2703,11 @@ class TestPolicyTarget(AIMBaseTestCase):
|
||||
aim_resource.VMMDomain(type='OpenStack',
|
||||
name='vm2'),
|
||||
overwrite=True)
|
||||
self.aim_mgr.create(aim_ctx,
|
||||
aim_resource.VMMDomain(type='OpenStack',
|
||||
name='vm_m',
|
||||
monitored=True),
|
||||
overwrite=True)
|
||||
with self.port() as port:
|
||||
port_id = port['port']['id']
|
||||
self._bind_port_to_host(port_id, 'h1')
|
||||
|
||||
Reference in New Issue
Block a user