Add the l3out to the BD's l3out list for NoNat case
We need to do this when we connect the tenant network to the router which already has the external GW set. Change-Id: I0ca2caa8704fefb347844e6008a590685aa1efed
This commit is contained in:
parent
ee4052c505
commit
583584cdf7
|
@ -1562,6 +1562,10 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
|||
self._manage_external_connectivity(context, router, None, net,
|
||||
vrf)
|
||||
|
||||
aim_l3out, _, ns = self._get_aim_nat_strategy(net)
|
||||
if aim_l3out and ns:
|
||||
ns.set_bd_l3out(aim_ctx, bd, aim_l3out)
|
||||
|
||||
# SNAT information of ports on the subnet will change because
|
||||
# of router interface addition. Send a port update so that it may
|
||||
# be recalculated.
|
||||
|
@ -1709,6 +1713,12 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
|||
self._manage_external_connectivity(context, router_db, None,
|
||||
net, router_vrf)
|
||||
|
||||
# If network is no longer connected to this router
|
||||
if router_id not in router_ids:
|
||||
aim_l3out, _, ns = self._get_aim_nat_strategy(net)
|
||||
if aim_l3out and ns:
|
||||
ns.unset_bd_l3out(aim_ctx, bd, aim_l3out)
|
||||
|
||||
# SNAT information of ports on the subnet will change because
|
||||
# of router interface removal. Send a port update so that it may
|
||||
# be recalculated.
|
||||
|
|
|
@ -4872,8 +4872,15 @@ class TestExternalConnectivityBase(object):
|
|||
self._delete('subnets', subnet['id'])
|
||||
self.mock_ns.delete_subnet.assert_not_called()
|
||||
|
||||
# This will be invoked for non-NoNat strategies
|
||||
def _check_bd_l3out(self, aim_ctx, bridge_domain, l3out_name):
|
||||
bridge_domain = self.aim_mgr.get(aim_ctx, bridge_domain)
|
||||
self.assertEqual([], bridge_domain.l3out_names)
|
||||
|
||||
def _do_test_router_interface(self, use_addr_scope=False,
|
||||
single_tenant=False):
|
||||
session = db_api.get_reader_session()
|
||||
aim_ctx = aim_context.AimContext(session)
|
||||
cv = self.mock_ns.connect_vrf
|
||||
dv = self.mock_ns.disconnect_vrf
|
||||
|
||||
|
@ -4960,6 +4967,13 @@ class TestExternalConnectivityBase(object):
|
|||
cv.assert_called_once_with(mock.ANY, a_ext_net, a_vrf)
|
||||
else:
|
||||
cv.assert_not_called()
|
||||
|
||||
aname = self.name_mapper.network(
|
||||
None, subnets[idx]['network_id'])
|
||||
aim_bd = aim_resource.BridgeDomain(
|
||||
tenant_name=tenant_aname, name=aname)
|
||||
self._check_bd_l3out(aim_ctx, aim_bd, 'l1')
|
||||
|
||||
self._validate()
|
||||
vrf_objs[tenant] = a_ext_net
|
||||
|
||||
|
@ -4987,6 +5001,11 @@ class TestExternalConnectivityBase(object):
|
|||
self.mock_ns.reset_mock()
|
||||
self._router_interface_action('remove', router['id'],
|
||||
subnets[idx]['id'], None)
|
||||
aname = self.name_mapper.network(
|
||||
None, subnets[idx]['network_id'])
|
||||
aim_bd = aim_resource.BridgeDomain(
|
||||
tenant_name=tenant_aname, name=aname)
|
||||
# Last subnet being dis-connected from the router
|
||||
if idx == len(subnets) - 1:
|
||||
num_router -= 1
|
||||
if num_router:
|
||||
|
@ -4995,9 +5014,13 @@ class TestExternalConnectivityBase(object):
|
|||
else:
|
||||
dv.assert_called_once_with(mock.ANY, a_ext_net,
|
||||
a_vrf)
|
||||
aim_bd = self.aim_mgr.get(aim_ctx, aim_bd)
|
||||
self.assertEqual([], aim_bd.l3out_names)
|
||||
else:
|
||||
cv.assert_not_called()
|
||||
dv.assert_not_called()
|
||||
self._check_bd_l3out(aim_ctx, aim_bd, 'l1')
|
||||
|
||||
self._validate()
|
||||
|
||||
self.mock_ns.reset_mock()
|
||||
|
@ -5122,6 +5145,15 @@ class TestExternalConnectivityBase(object):
|
|||
self._router_interface_action('add', router['id'], sub1['id'], None)
|
||||
self.mock_ns.connect_vrf.assert_not_called()
|
||||
|
||||
session = db_api.get_reader_session()
|
||||
aim_ctx = aim_context.AimContext(session)
|
||||
tenant_aname = self.name_mapper.project(None, net['tenant_id'])
|
||||
aname = self.name_mapper.network(None, net['id'])
|
||||
aim_bd = aim_resource.BridgeDomain(tenant_name=tenant_aname,
|
||||
name=aname)
|
||||
aim_bd = self.aim_mgr.get(aim_ctx, aim_bd)
|
||||
self.assertEqual([], aim_bd.l3out_names)
|
||||
|
||||
self._router_interface_action('remove', router['id'], sub1['id'], None)
|
||||
self.mock_ns.disconnect_vrf.assert_not_called()
|
||||
|
||||
|
@ -5752,6 +5784,10 @@ class TestExternalNoNat(TestExternalConnectivityBase,
|
|||
self._do_test_router_interface(use_addr_scope=False,
|
||||
single_tenant=True)
|
||||
|
||||
def _check_bd_l3out(self, aim_ctx, bridge_domain, l3out_name):
|
||||
bridge_domain = self.aim_mgr.get(aim_ctx, bridge_domain)
|
||||
self.assertEqual([l3out_name], bridge_domain.l3out_names)
|
||||
|
||||
|
||||
class TestSnatIpAllocation(ApicAimTestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue