]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Create DHCP port for IPv6 subnet
authorXu Han Peng <xuhanp@cn.ibm.com>
Wed, 24 Sep 2014 09:37:23 +0000 (17:37 +0800)
committerIhar Hrachyshka <ihrachys@redhat.com>
Wed, 29 Oct 2014 13:27:28 +0000 (13:27 +0000)
There is a bug in dhcp agent code that when first port is created
in an IPv6 subnet, DHCP port is not automatically created.

This fix resolves this problem by removing the IP version check
in configure_dhcp_for_network method.

Change-Id: If3f405d367a7099d9f33d72d11ffcb7a393abe23
Closes-Bug: #1367500
(cherry picked from commit 1b66e11b5d8c0b3de0610ca02c3e10b6f64ae375)

neutron/agent/dhcp_agent.py
neutron/tests/unit/test_dhcp_agent.py

index 5a501faa91cba10606ea1d86941b94a23abbf33c..c8ea89b0219e6f99680d924f3760a655cf154f76 100644 (file)
@@ -227,9 +227,10 @@ class DhcpAgent(manager.Manager):
                 self.conf, network)
 
         for subnet in network.subnets:
-            if subnet.enable_dhcp and subnet.ip_version == 4:
+            if subnet.enable_dhcp:
                 if self.call_driver('enable', network):
-                    if self.conf.use_namespaces and enable_metadata:
+                    if (subnet.ip_version == 4 and self.conf.use_namespaces
+                        and enable_metadata):
                         self.enable_isolated_metadata_proxy(network)
                         enable_metadata = False  # Don't trigger twice
                     self.cache.put(network)
index c6f98643fe8e309f1fbb20bc2aa4e0e90d1c4ea0..5e02428b0d6152bfdcdd0752187313592a4cc8d7 100644 (file)
@@ -64,6 +64,12 @@ fake_subnet3 = dhcp.DictModel(dict(id='bbbbbbbb-1111-2222-bbbbbbbbbbbb',
                               network_id='12345678-1234-5678-1234567890ab',
                               cidr='192.168.1.1/24', enable_dhcp=True))
 
+fake_ipv6_subnet = dhcp.DictModel(dict(id='bbbbbbbb-1111-2222-bbbbbbbbbbbb',
+                              network_id='12345678-1234-5678-1234567890ab',
+                              cidr='2001:0db8::1:0:0:1/128', enable_dhcp=True,
+                              tenant_id=fake_tenant_id,
+                              gateway_ip='2001:0db8::1:0:0:1', ip_version=6))
+
 fake_meta_subnet = dhcp.DictModel(dict(id='bbbbbbbb-1111-2222-bbbbbbbbbbbb',
                                   network_id='12345678-1234-5678-1234567890ab',
                                   cidr='169.254.169.252/30',
@@ -104,6 +110,12 @@ fake_network = dhcp.NetModel(True, dict(id='12345678-1234-5678-1234567890ab',
                              subnets=[fake_subnet1, fake_subnet2],
                              ports=[fake_port1]))
 
+fake_network_ipv6 = dhcp.NetModel(True, dict(
+                             id='12345678-1234-5678-1234567890ab',
+                             tenant_id='aaaaaaaa-aaaa-aaaa-aaaaaaaaaaaa',
+                             admin_state_up=True,
+                             subnets=[fake_ipv6_subnet]))
+
 isolated_network = dhcp.NetModel(
     True, dict(
         id='12345678-1234-5678-1234567890ab',
@@ -555,6 +567,9 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
     def test_enable_dhcp_helper(self):
         self._enable_dhcp_helper(fake_network)
 
+    def test_enable_dhcp_helper_ipv6_network(self):
+        self._enable_dhcp_helper(fake_network_ipv6)
+
     def test_enable_dhcp_helper_down_network(self):
         self.plugin.get_network_info.return_value = fake_down_network
         self.dhcp.enable_dhcp_helper(fake_down_network.id)