]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Ensure metadata network works with DVR
authorSalvatore Orlando <salv.orlando@gmail.com>
Wed, 22 Apr 2015 20:27:53 +0000 (13:27 -0700)
committerSalvatore Orlando <salv.orlando@gmail.com>
Wed, 22 Apr 2015 20:47:18 +0000 (13:47 -0700)
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
neutron/tests/unit/agent/dhcp/test_agent.py

index 214bfdff14de3c55c2335d15866ed52301e02344..aa0f9bc82c339c492ffbd7196444158d80664a9f 100644 (file)
@@ -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:
index c618658f7c5659d6c98bf5aaef8ef0a77f51c5b8..c9ecbed2cb420ec986ad77c864a5742a6a4c132b 100644 (file)
@@ -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)