[aim] Set APIC domains on EPG creation
Change-Id: I45fa45c37e83502df21a877d2ceab8fb3f6c5836
This commit is contained in:
parent
682504575a
commit
702a83e8dc
|
@ -15,6 +15,7 @@
|
|||
|
||||
from aim import aim_manager
|
||||
from aim.api import resource as aim_resource
|
||||
from aim.common import utils
|
||||
from aim import config as aim_cfg
|
||||
from aim import context as aim_context
|
||||
from aim import utils as aim_utils
|
||||
|
@ -155,10 +156,13 @@ class ApicMechanismDriver(api_plus.MechanismDriver):
|
|||
limit_ip_learn_to_subnets=True,
|
||||
ep_move_detect_mode='garp')
|
||||
self.aim.create(aim_ctx, bd)
|
||||
vmms, phys = self.get_aim_domains(aim_ctx)
|
||||
epg = aim_resource.EndpointGroup(tenant_name=tenant_aname,
|
||||
app_profile_name=self.ap_name,
|
||||
name=aname, display_name=dname,
|
||||
bd_name=aname)
|
||||
bd_name=aname,
|
||||
openstack_vmm_domain_names=vmms,
|
||||
physical_domain_names=phys)
|
||||
self.aim.create(aim_ctx, epg)
|
||||
|
||||
def update_network_precommit(self, context):
|
||||
|
@ -1027,3 +1031,10 @@ class ApicMechanismDriver(api_plus.MechanismDriver):
|
|||
|
||||
def _set_ap_name(self, new_conf):
|
||||
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)]
|
||||
return vmms, phys
|
||||
|
|
|
@ -250,6 +250,11 @@ class AIMMappingDriver(nrd.CommonNeutronBase, aim_rpc.AIMMappingRPCMixin):
|
|||
session, context.current, bd_name, bd_tenant_name,
|
||||
provided_contracts=provided_contracts,
|
||||
consumed_contracts=consumed_contracts)
|
||||
session = context._plugin_context.session
|
||||
aim_ctx = aim_context.AimContext(session)
|
||||
vmms, phys = self.aim_mech_driver.get_aim_domains(aim_ctx)
|
||||
aim_epg.openstack_vmm_domain_names = vmms
|
||||
aim_epg.physical_domain_names = phys
|
||||
# AIM EPG will be persisted in the following call
|
||||
self._add_implicit_svc_contracts_to_epg(context, l2p_db, aim_epg)
|
||||
|
||||
|
|
|
@ -920,7 +920,29 @@ class TestMl2PortsV2(test_plugin.TestPortsV2,
|
|||
|
||||
class TestMl2NetworksV2(test_plugin.TestNetworksV2,
|
||||
ApicAimTestCase):
|
||||
pass
|
||||
|
||||
def test_aim_epg_domains(self):
|
||||
aim_ctx = aim_context.AimContext(self.db_session)
|
||||
self.aim_mgr.create(aim_ctx,
|
||||
aim_resource.VMMDomain(type='OpenStack',
|
||||
name='vm1'),
|
||||
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.PhysicalDomain(name='ph1'),
|
||||
overwrite=True)
|
||||
self.aim_mgr.create(aim_ctx,
|
||||
aim_resource.PhysicalDomain(name='ph2'),
|
||||
overwrite=True)
|
||||
with self.network(name='net'):
|
||||
epg = self.aim_mgr.find(aim_ctx, aim_resource.EndpointGroup)[0]
|
||||
self.assertEqual(set(['vm1', 'vm2']),
|
||||
set(epg.openstack_vmm_domain_names))
|
||||
self.assertEqual(set(['ph1', 'ph2']),
|
||||
set(epg.physical_domain_names))
|
||||
|
||||
|
||||
class TestMl2SubnetsV2(test_plugin.TestSubnetsV2,
|
||||
|
|
|
@ -604,6 +604,42 @@ class TestPolicyTargetGroup(AIMBaseTestCase):
|
|||
self.assertEqual(subnets[0]['id'],
|
||||
router_port['fixed_ips'][0]['subnet_id'])
|
||||
|
||||
def test_policy_target_group_aim_domains(self):
|
||||
self.aim_mgr.create(self._aim_context,
|
||||
aim_resource.VMMDomain(type='OpenStack',
|
||||
name='vm1'),
|
||||
overwrite=True)
|
||||
self.aim_mgr.create(self._aim_context,
|
||||
aim_resource.VMMDomain(type='OpenStack',
|
||||
name='vm2'),
|
||||
overwrite=True)
|
||||
self.aim_mgr.create(self._aim_context,
|
||||
aim_resource.PhysicalDomain(name='ph1'),
|
||||
overwrite=True)
|
||||
self.aim_mgr.create(self._aim_context,
|
||||
aim_resource.PhysicalDomain(name='ph2'),
|
||||
overwrite=True)
|
||||
ptg = self.create_policy_target_group(name="ptg1")[
|
||||
'policy_target_group']
|
||||
|
||||
aim_epg_name = str(self.name_mapper.policy_target_group(
|
||||
self._neutron_context.session, ptg['id'], ptg['name']))
|
||||
aim_tenant_name = str(self.name_mapper.tenant(
|
||||
self._neutron_context.session, self._tenant_id))
|
||||
aim_app_profile_name = self.driver.aim_mech_driver.ap_name
|
||||
aim_app_profiles = self.aim_mgr.find(
|
||||
self._aim_context, aim_resource.ApplicationProfile,
|
||||
tenant_name=aim_tenant_name, name=aim_app_profile_name)
|
||||
self.assertEqual(1, len(aim_app_profiles))
|
||||
aim_epg = self.aim_mgr.get(
|
||||
self._aim_context, aim_resource.EndpointGroup(
|
||||
tenant_name=aim_tenant_name,
|
||||
app_profile_name=aim_app_profile_name, name=aim_epg_name))
|
||||
self.assertEqual(set(['vm1', 'vm2']),
|
||||
set(aim_epg.openstack_vmm_domain_names))
|
||||
self.assertEqual(set(['ph1', 'ph2']),
|
||||
set(aim_epg.physical_domain_names))
|
||||
|
||||
def test_policy_target_group_lifecycle_implicit_l2p(self):
|
||||
prs_lists = self._get_provided_consumed_prs_lists()
|
||||
ptg = self.create_policy_target_group(
|
||||
|
|
Loading…
Reference in New Issue