]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix DHCP agent to work with latest dnsmasq
authorKyle Mestery <kmestery@cisco.com>
Tue, 23 Jul 2013 15:17:20 +0000 (15:17 +0000)
committerKyle Mestery <kmestery@cisco.com>
Wed, 24 Jul 2013 05:26:57 +0000 (05:26 +0000)
The latest dnsmasq no longer accepts hostnames which begin with a number. This
affects Fedora 19 right now, and will mean Fedora 19 will not work with Neutron
DHCP. dnsmasq should work with hostnames beginning with a number (RFC 1123 says
this is valid), but until this is fixed, many users will be left unable to use
Fedora 19 with Neutron.

This patch adds a "host-" prefix to each hostname entry generated by the DHCP
agent. This fixes the issue in Neutron.

Fixes bug 1204125

Change-Id: I0e29ec033969c3fb958ed3a12b8962b73b0e3d94

neutron/agent/linux/dhcp.py
neutron/tests/unit/test_linux_dhcp.py

index 2c603d4bddfc3a2924377de5d5cf6dd5544d2076..d0316ed489dc775fec422dff9fba64b3e2bb8f03 100644 (file)
@@ -343,8 +343,8 @@ class Dnsmasq(DhcpLocalProcess):
 
         for port in self.network.ports:
             for alloc in port.fixed_ips:
-                name = '%s.%s' % (r.sub('-', alloc.ip_address),
-                                  self.conf.dhcp_domain)
+                name = 'host-%s.%s' % (r.sub('-', alloc.ip_address),
+                                       self.conf.dhcp_domain)
                 buf.write('%s,%s,%s\n' %
                           (port.mac_address, name, alloc.ip_address))
 
index ab2815e4253924dc1e8e3c9a48c4f2e813663621..3c1784c4a456eee1b5d8d04496a8f5b83ba0abd6 100644 (file)
@@ -581,12 +581,14 @@ tag:tag0,option:router""".lstrip()
 
     def test_reload_allocations(self):
         exp_host_name = '/dhcp/cccccccc-cccc-cccc-cccc-cccccccccccc/host'
-        exp_host_data = """
-00:00:80:aa:bb:cc,192-168-0-2.openstacklocal,192.168.0.2
-00:00:f3:aa:bb:cc,fdca-3ba5-a17a-4ba3--2.openstacklocal,fdca:3ba5:a17a:4ba3::2
-00:00:0f:aa:bb:cc,192-168-0-3.openstacklocal,192.168.0.3
-00:00:0f:aa:bb:cc,fdca-3ba5-a17a-4ba3--3.openstacklocal,fdca:3ba5:a17a:4ba3::3
-""".lstrip()
+        exp_host_data = ('00:00:80:aa:bb:cc,host-192-168-0-2.openstacklocal,'
+                         '192.168.0.2\n'
+                         '00:00:f3:aa:bb:cc,host-fdca-3ba5-a17a-4ba3--2.'
+                         'openstacklocal,fdca:3ba5:a17a:4ba3::2\n'
+                         '00:00:0f:aa:bb:cc,host-192-168-0-3.openstacklocal,'
+                         '192.168.0.3\n'
+                         '00:00:0f:aa:bb:cc,host-fdca-3ba5-a17a-4ba3--3.'
+                         'openstacklocal,fdca:3ba5:a17a:4ba3::3\n').lstrip()
         exp_opt_name = '/dhcp/cccccccc-cccc-cccc-cccc-cccccccccccc/opts'
         exp_opt_data = "tag:tag0,option:router,192.168.0.1"
         fake_v6 = 'gdca:3ba5:a17a:4ba3::1'
@@ -625,12 +627,15 @@ tag:tag1,option:classless-static-route,%s,%s""".lstrip() % (fake_v6,
 
     def test_reload_allocations_stale_pid(self):
         exp_host_name = '/dhcp/cccccccc-cccc-cccc-cccc-cccccccccccc/host'
-        exp_host_data = """
-00:00:80:aa:bb:cc,192-168-0-2.openstacklocal,192.168.0.2
-00:00:f3:aa:bb:cc,fdca-3ba5-a17a-4ba3--2.openstacklocal,fdca:3ba5:a17a:4ba3::2
-00:00:0f:aa:bb:cc,192-168-0-3.openstacklocal,192.168.0.3
-00:00:0f:aa:bb:cc,fdca-3ba5-a17a-4ba3--3.openstacklocal,fdca:3ba5:a17a:4ba3::3
-""".lstrip()
+        exp_host_data = ('00:00:80:aa:bb:cc,host-192-168-0-2.openstacklocal,'
+                         '192.168.0.2\n'
+                         '00:00:f3:aa:bb:cc,host-fdca-3ba5-a17a-4ba3--2.'
+                         'openstacklocal,fdca:3ba5:a17a:4ba3::2\n'
+                         '00:00:0f:aa:bb:cc,host-192-168-0-3.openstacklocal,'
+                         '192.168.0.3\n'
+                         '00:00:0f:aa:bb:cc,host-fdca-3ba5-a17a-4ba3--3.'
+                         'openstacklocal,fdca:3ba5:a17a:4ba3::3\n').lstrip()
+        exp_host_data.replace('\n', '')
         exp_opt_name = '/dhcp/cccccccc-cccc-cccc-cccc-cccccccccccc/opts'
         exp_opt_data = "tag:tag0,option:router,192.168.0.1"
         fake_v6 = 'gdca:3ba5:a17a:4ba3::1'