From 74b0d31de42ab1750d44fedb043f21189c55fdc1 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 22 Apr 2015 13:27:53 -0700 Subject: [PATCH] Ensure metadata network works with DVR As DVR routers use a different type of interface, this patch amends the DHCP agent code ensuring that a metadata proxy is spawned when the metadata network feature is enabled on the DHCP agent. (Cherry-picked from ec408ac379108eee26d87a8d9834180db11877e0) Change-Id: Id7f2e891c0753620a604cf6160c6b592db1aa284 Closes-Bug: #1447344 --- neutron/agent/dhcp/agent.py | 4 ++-- neutron/tests/unit/agent/dhcp/test_agent.py | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/neutron/agent/dhcp/agent.py b/neutron/agent/dhcp/agent.py index 214bfdff1..aa0f9bc82 100644 --- a/neutron/agent/dhcp/agent.py +++ b/neutron/agent/dhcp/agent.py @@ -354,8 +354,8 @@ class DhcpAgent(manager.Manager): # be started for the router attached to the network if self.conf.enable_metadata_network: router_ports = [port for port in network.ports - if (port.device_owner == - constants.DEVICE_OWNER_ROUTER_INTF)] + if (port.device_owner in + constants.ROUTER_INTERFACE_OWNERS)] if router_ports: # Multiple router ports should not be allowed if len(router_ports) > 1: diff --git a/neutron/tests/unit/agent/dhcp/test_agent.py b/neutron/tests/unit/agent/dhcp/test_agent.py index c618658f7..c9ecbed2c 100644 --- a/neutron/tests/unit/agent/dhcp/test_agent.py +++ b/neutron/tests/unit/agent/dhcp/test_agent.py @@ -122,6 +122,9 @@ fake_meta_port = dhcp.DictModel(dict(id='12345678-1234-aaaa-1234567890ab', device_id='forzanapoli', fixed_ips=[fake_meta_fixed_ip])) +fake_meta_dvr_port = dhcp.DictModel(fake_meta_port.copy()) +fake_meta_dvr_port.device_owner = const.DEVICE_OWNER_DVR_INTERFACE + fake_dist_port = dhcp.DictModel(dict(id='12345678-1234-aaaa-1234567890ab', mac_address='aa:bb:cc:dd:ee:ff', network_id='12345678-1234-5678-1234567890ab', @@ -183,6 +186,9 @@ fake_meta_network = dhcp.NetModel( subnets=[fake_meta_subnet], ports=[fake_meta_port])) +fake_meta_dvr_network = dhcp.NetModel(True, fake_meta_network.copy()) +fake_meta_dvr_network.ports = [fake_meta_dvr_port] + fake_dist_network = dhcp.NetModel( True, dict(id='12345678-1234-5678-1234567890ab', tenant_id='aaaaaaaa-aaaa-aaaa-aaaaaaaaaaaa', @@ -780,6 +786,9 @@ class TestDhcpAgentEventHandler(base.BaseTestCase): def test_enable_isolated_metadata_proxy_with_metadata_network(self): self._test_metadata_network(fake_meta_network) + def test_enable_isolated_metadata_proxy_with_metadata_network_dvr(self): + self._test_metadata_network(fake_meta_dvr_network) + def test_enable_isolated_metadata_proxy_with_dist_network(self): self._test_metadata_network(fake_dist_network) -- 2.45.2