Send port notifications when host_route is getting updated
Change-Id: I9f52a1ee4733f93befa9ea95603d8a57f8c8850a
This commit is contained in:
parent
35ddfeb0de
commit
6af7d7958b
|
@ -1115,9 +1115,15 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
|||
network_id = current['network_id']
|
||||
network_db = self.plugin._get_network(context._plugin_context,
|
||||
network_id)
|
||||
is_ext = network_db.external is not None
|
||||
session = context._plugin_context.session
|
||||
|
||||
# This should apply to both external and internal networks
|
||||
if current['host_routes'] != original['host_routes']:
|
||||
affected_port_ids = self._get_compute_dhcp_ports_in_subnets(
|
||||
session, [current['id']])
|
||||
self._notify_port_update_bulk(context._plugin_context,
|
||||
affected_port_ids)
|
||||
|
||||
is_ext = network_db.external is not None
|
||||
if is_ext:
|
||||
# We have to allow this upon a customer request.
|
||||
if (original[cisco_apic.SNAT_HOST_POOL] !=
|
||||
|
@ -1141,13 +1147,13 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
|||
if current['gateway_ip']:
|
||||
ns.create_subnet(aim_ctx, l3out,
|
||||
self._subnet_to_gw_ip_mask(current))
|
||||
elif current['name'] != original['name']:
|
||||
return
|
||||
|
||||
if current['name'] != original['name']:
|
||||
# Nothing to be done for SVI network.
|
||||
if self._is_svi(context.network.current):
|
||||
return
|
||||
|
||||
bd = self._get_network_bd(network_db.aim_mapping)
|
||||
|
||||
for gw_ip, router_id in self._subnet_router_ips(session,
|
||||
current['id']):
|
||||
router_db = self.l3_plugin._get_router(context._plugin_context,
|
||||
|
@ -1155,7 +1161,6 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
|
|||
dname = aim_utils.sanitize_display_name(
|
||||
router_db.name + "-" +
|
||||
(current['name'] or current['cidr']))
|
||||
|
||||
sn = self._map_subnet(current, gw_ip, bd)
|
||||
self.aim.update(aim_ctx, sn, display_name=dname)
|
||||
|
||||
|
|
|
@ -1573,6 +1573,20 @@ class TestAimMapping(ApicAimTestCase):
|
|||
port['dns_name'] = ''
|
||||
port_calls = [mock.call(mock.ANY, port)]
|
||||
|
||||
fixed_ips = [{'subnet_id': subnet1_id, 'ip_address': '10.0.1.101'}]
|
||||
port = self._make_port(self.fmt, net_id, fixed_ips=fixed_ips)['port']
|
||||
port = self._bind_port_to_host(port['id'], 'host2')['port']
|
||||
port['dns_name'] = ''
|
||||
port_calls.append(mock.call(mock.ANY, port))
|
||||
|
||||
# The update to host_routes should trigger the port updates
|
||||
data = {'subnet': {'host_routes':
|
||||
[{'nexthop': '1.1.1.1',
|
||||
'destination': '1.1.1.0/24'}]}}
|
||||
subnet = self._update('subnets', subnet1_id, data)['subnet']
|
||||
self._check_subnet(subnet, net, [], [gw1_ip])
|
||||
mock_notif.assert_has_calls(port_calls, any_order=True)
|
||||
|
||||
# Create subnet2.
|
||||
if not is_svi:
|
||||
gw2_ip = '10.0.2.1'
|
||||
|
@ -1613,9 +1627,11 @@ class TestAimMapping(ApicAimTestCase):
|
|||
self._check_subnet(subnet, net, [], [gw2_ip])
|
||||
|
||||
# Test subnet update.
|
||||
mock_notif.reset_mock()
|
||||
data = {'subnet': {'name': 'newnameforsubnet'}}
|
||||
subnet = self._update('subnets', subnet1_id, data)['subnet']
|
||||
self._check_subnet(subnet, net, [(gw1_ip, router)], [])
|
||||
mock_notif.assert_not_called()
|
||||
|
||||
# Test router update.
|
||||
data = {'router': {'name': 'newnameforrouter'}}
|
||||
|
@ -6797,8 +6813,10 @@ class TestPortVlanNetwork(ApicAimTestCase):
|
|||
self.assertEqual(0, len(dyn_segments))
|
||||
|
||||
def _do_test_port_lifecycle(self, external_net=False):
|
||||
aim_ctx = aim_context.AimContext(self.db_session)
|
||||
mock_notif = mock.Mock(side_effect=self.port_notif_verifier())
|
||||
self.driver.notifier.port_update = mock_notif
|
||||
|
||||
aim_ctx = aim_context.AimContext(self.db_session)
|
||||
if external_net:
|
||||
net1 = self._make_ext_network('net1',
|
||||
dn=self.dn_t1_l1_n1)
|
||||
|
@ -6830,6 +6848,15 @@ class TestPortVlanNetwork(ApicAimTestCase):
|
|||
epg.static_paths)
|
||||
self._validate()
|
||||
|
||||
# The update to host_routes should trigger the port updates
|
||||
port_calls = [mock.call(mock.ANY, p1['port'])]
|
||||
data = {'subnet': {'host_routes':
|
||||
[{'nexthop': '1.1.1.1',
|
||||
'destination': '1.1.1.0/24'}]}}
|
||||
self._update('subnets', sub1['subnet']['id'],
|
||||
data)['subnet']
|
||||
mock_notif.assert_has_calls(port_calls, any_order=True)
|
||||
|
||||
# move port to host h2
|
||||
p1 = self._bind_port_to_host(p1['port']['id'], 'h2')
|
||||
vlan_h2 = self._check_binding(p1['port']['id'])
|
||||
|
|
Loading…
Reference in New Issue