[AIM] Validation fixes

Copy pre-existing external network resources (L3Outside, VRF,
ExternalNetwork and ExternalSubnets) from the actual AIM store to the
validation AIM store so that AIM's NAT strategy code functions
correctly during validation. Also fix a couple nits from the original
validation patch review.

Change-Id: I7f51781cc29b6bf9651c1a50dd5491d511d71a7d
This commit is contained in:
Robert Kukura 2018-06-05 15:59:17 -04:00
parent a9f93eb6ca
commit a571e0c553
3 changed files with 59 additions and 9 deletions

View File

@ -75,7 +75,6 @@ class ProjectNameCache(object):
self.load_projects()
def load_projects(self):
# REVISIT: Does this need locking to prevent concurrent calls?
if self.keystone is None:
self._get_keystone_client()
LOG.debug("Calling project API")

View File

@ -4372,15 +4372,40 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
if not ext_net:
return None, None, None
# REVISIT: Avoid peicemeal queries against the actual DB
# REVISIT: Avoid piecemeal queries against the actual DB
# throughout this code.
# REVISIT: We probably need to copy the external network's
# pre-existing resources, if they are monitored, from the
# actual AIM store to the validation AIM store, so that the
# NatStrategy behaves as expected during validation. But the
# current external connectivity UTs don't actually create
# pre-existing ExternalNetwork resources.
# Copy the external network's pre-existing resources, if they
# are monitored, from the actual AIM store to the validation
# AIM store, so that the NatStrategy behaves as expected
# during validation. Make sure not to overwrite any
# pre-existing resources that have already been copied.
actual_l3out = mgr.aim_mgr.get(mgr.actual_aim_ctx, l3out)
if actual_l3out and actual_l3out.monitored:
if not mgr.aim_mgr.get(mgr.expected_aim_ctx, actual_l3out):
mgr.aim_mgr.create(mgr.expected_aim_ctx, actual_l3out)
ext_vrf = aim_resource.VRF(
tenant_name=actual_l3out.tenant_name,
name=actual_l3out.vrf_name)
actual_ext_vrf = mgr.aim_mgr.get(mgr.actual_aim_ctx, ext_vrf)
if not actual_ext_vrf:
ext_vrf.tenant_name = 'common'
actual_ext_vrf = mgr.aim_mgr.get(mgr.actual_aim_ctx, ext_vrf)
if actual_ext_vrf and actual_ext_vrf.monitored:
if not mgr.aim_mgr.get(mgr.expected_aim_ctx, actual_ext_vrf):
mgr.aim_mgr.create(mgr.expected_aim_ctx, actual_ext_vrf)
actual_ext_net = mgr.aim_mgr.get(mgr.actual_aim_ctx, ext_net)
if actual_ext_net and actual_ext_net.monitored:
if not mgr.aim_mgr.get(mgr.expected_aim_ctx, actual_ext_net):
mgr.aim_mgr.create(mgr.expected_aim_ctx, actual_ext_net)
for actual_ext_sn in mgr.aim_mgr.find(
mgr.actual_aim_ctx, aim_resource.ExternalSubnet,
tenant_name=actual_ext_net.tenant_name,
l3out_name=actual_ext_net.l3out_name,
external_network_name=actual_ext_net.name,
monitored=True):
if not mgr.aim_mgr.get(mgr.expected_aim_ctx, actual_ext_sn):
mgr.aim_mgr.create(mgr.expected_aim_ctx, actual_ext_sn)
domains = self._get_vmm_domains(mgr.expected_aim_ctx, ns)
ns.create_l3outside(

View File

@ -350,7 +350,7 @@ class TestNeutronMapping(AimValidationTestCase):
# Test AIM resources.
self._test_network_resources(net_resp)
def test_external_network(self):
def _test_external_network(self):
# Create AIM HostDomainMappingV2.
hd_mapping = aim_infra.HostDomainMappingV2(
host_name='*', domain_name='vm2', domain_type='OpenStack')
@ -413,6 +413,32 @@ class TestNeutronMapping(AimValidationTestCase):
tenant_name='common', filter_name='openstack_EXT-l1', name='Any')
self._test_aim_resource(entry)
def test_external_network(self):
self._test_external_network()
def test_preexisting_external_network(self):
# Create pre-existing AIM VRF.
vrf = aim_resource.VRF(tenant_name='common', name='v1', monitored=True)
self.aim_mgr.create(self.aim_ctx, vrf)
# Create pre-existing AIM L3Outside.
l3out = aim_resource.L3Outside(
tenant_name='common', name='l1', vrf_name='v1', monitored=True)
self.aim_mgr.create(self.aim_ctx, l3out)
# Create pre-existing AIM ExternalNetwork.
ext_net = aim_resource.ExternalNetwork(
tenant_name='common', l3out_name='l1', name='n1', monitored=True)
self.aim_mgr.create(self.aim_ctx, ext_net)
# Create pre-existing AIM ExternalSubnet.
ext_sn = aim_resource.ExternalSubnet(
tenant_name='common', l3out_name='l1', external_network_name='n1',
cidr='0.0.0.0/0', monitored=True)
self.aim_mgr.create(self.aim_ctx, ext_sn)
self._test_external_network()
def test_svi_network(self):
# REVISIT: Test validation of actual mapping once implemented.