From 8fd88fd2239bd19794f2a1cf9480e5aa7d4f5a9b Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Mon, 31 Jan 2022 14:50:50 +0100 Subject: [PATCH] Pass host parameter to the get_network_info method Host parameter is needed there to filter subnets per segment when segments plugin is enabled. When dhcp agent requests informations about networks, and segments plugin is enabled, subnets which belongs to the network are filtered out based on the host passed as argument to the get_network_info() method. But we never passed host to that method, even when we should e.g. during the full sync of the DHCP agent, when it requests details about each network. This patch fixes that issue by passing host parameter to that method. Closes-Bug: #1958955 Change-Id: Ib5eef501493f6735a47ea085196242a5807c4565 --- neutron/api/rpc/handlers/dhcp_rpc.py | 2 +- neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/neutron/api/rpc/handlers/dhcp_rpc.py b/neutron/api/rpc/handlers/dhcp_rpc.py index e6901183e3a..4703ffb6f83 100644 --- a/neutron/api/rpc/handlers/dhcp_rpc.py +++ b/neutron/api/rpc/handlers/dhcp_rpc.py @@ -167,7 +167,7 @@ class DhcpRpcCallback(object): ret = [] for network in networks: ret.append(self.get_network_info( - context, network=network, enable_dhcp=enable_dhcp, + context, network=network, enable_dhcp=enable_dhcp, host=host, ports=grouped_ports.get(network.id, []))) return ret diff --git a/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py b/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py index c5e912468cf..f3ac04f5786 100644 --- a/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py +++ b/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py @@ -70,9 +70,9 @@ class TestDhcpRpcCallback(base.BaseTestCase): {'id': 'port2', 'network_id': 'net2'}, {'id': 'port3', 'network_id': 'net3'}] self.plugin.get_ports.return_value = ports - iter_kwargs = iter([{'enable_dhcp_filter': True}, - {'enable_dhcp_filter': False}, - {}]) + iter_kwargs = iter([{'enable_dhcp_filter': True, 'host': 'test-host'}, + {'enable_dhcp_filter': False, 'host': 'test-host'}, + {'host': 'test-host'}]) with mock.patch.object(self.callbacks, '_get_active_networks') as \ mock_get_networks, \ mock.patch.object(self.callbacks, 'get_network_info') as \ @@ -86,11 +86,11 @@ class TestDhcpRpcCallback(base.BaseTestCase): None) mock_get_network_info.assert_has_calls([ mock.call('ctx', network=networks[0], enable_dhcp=enable_dhcp, - ports=[ports[0]]), + host='test-host', ports=[ports[0]]), mock.call('ctx', network=networks[1], enable_dhcp=enable_dhcp, - ports=[ports[1]]), + host='test-host', ports=[ports[1]]), mock.call('ctx', network=networks[2], enable_dhcp=enable_dhcp, - ports=[ports[2]]) + host='test-host', ports=[ports[2]]) ]) def _test__port_action_with_failures(self, exc=None, action=None):