Merge "Fix lack of routes for neighbour IPv4 subnets"

This commit is contained in:
Zuul 2018-05-21 22:29:15 +00:00 committed by Gerrit Code Review
commit 5cf8f699e2
3 changed files with 25 additions and 4 deletions

View File

@ -186,7 +186,8 @@ class DhcpAgent(manager.Manager):
known_network_ids = set(self.cache.get_network_ids())
try:
active_networks = self.plugin_rpc.get_active_networks_info()
active_networks = self.plugin_rpc.get_active_networks_info(
enable_dhcp_filter=False)
LOG.info('All active networks have been fetched through RPC.')
active_network_ids = set(network.id for network in active_networks)
for deleted_id in known_network_ids - active_network_ids:
@ -586,11 +587,11 @@ class DhcpPluginApi(object):
# can be independently tracked server side.
return context.get_admin_context_without_session()
def get_active_networks_info(self):
def get_active_networks_info(self, **kwargs):
"""Make a remote process call to retrieve all network info."""
cctxt = self.client.prepare(version='1.1')
networks = cctxt.call(self.context, 'get_active_networks_info',
host=self.host)
host=self.host, **kwargs)
return [dhcp.NetModel(n) for n in networks]
def get_network_info(self, network_id):

View File

@ -144,7 +144,9 @@ class DhcpRpcCallback(object):
plugin = directory.get_plugin()
filters = {'network_id': [network['id'] for network in networks]}
ports = plugin.get_ports(context, filters=filters)
filters['enable_dhcp'] = [True]
# default is to filter subnets based on 'enable_dhcp' flag
if kwargs.get('enable_dhcp_filter', True):
filters['enable_dhcp'] = [True]
# NOTE(kevinbenton): we sort these because the agent builds tags
# based on position in the list and has to restart the process if
# the order changes.

View File

@ -97,6 +97,24 @@ class TestDhcpRpcCallback(base.BaseTestCase):
'ports': []}]
self.assertEqual(expected, networks)
def _test_get_active_networks_info_enable_dhcp_filter(self,
enable_dhcp_filter):
plugin_retval = [{'id': 'a'}, {'id': 'b'}]
self.plugin.get_networks.return_value = plugin_retval
self.callbacks.get_active_networks_info(mock.Mock(), host='host',
enable_dhcp_filter=enable_dhcp_filter)
filters = {'network_id': ['a', 'b']}
if enable_dhcp_filter:
filters['enable_dhcp'] = [True]
self.plugin.get_subnets.assert_called_once_with(mock.ANY,
filters=filters)
def test_get_active_networks_info_enable_dhcp_filter_false(self):
self._test_get_active_networks_info_enable_dhcp_filter(False)
def test_get_active_networks_info_enable_dhcp_filter_true(self):
self._test_get_active_networks_info_enable_dhcp_filter(True)
def _test__port_action_with_failures(self, exc=None, action=None):
port = {
'network_id': 'foo_network_id',