From 61d131999281abffa6489c72c9fb7e637008e0ee Mon Sep 17 00:00:00 2001 From: Kyle Mestery Date: Tue, 23 Jul 2013 15:17:20 +0000 Subject: [PATCH] Fix DHCP agent to work with latest dnsmasq 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 (cherry picked from commit acebf769a41a9a55cdc6789bf4962ea64cf87773) --- quantum/agent/linux/dhcp.py | 4 ++-- quantum/tests/unit/test_linux_dhcp.py | 29 ++++++++++++++++----------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/quantum/agent/linux/dhcp.py b/quantum/agent/linux/dhcp.py index 2844b1a62..564af34d8 100644 --- a/quantum/agent/linux/dhcp.py +++ b/quantum/agent/linux/dhcp.py @@ -357,8 +357,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)) diff --git a/quantum/tests/unit/test_linux_dhcp.py b/quantum/tests/unit/test_linux_dhcp.py index f29a364bf..c5f1a6931 100644 --- a/quantum/tests/unit/test_linux_dhcp.py +++ b/quantum/tests/unit/test_linux_dhcp.py @@ -540,12 +540,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' @@ -585,12 +587,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'