From a617f62284acdb87c948f0c0ccb9d5fc3e15a413 Mon Sep 17 00:00:00 2001 From: Nachi Ueno Date: Tue, 15 Jan 2013 09:54:59 -0800 Subject: [PATCH] Disable dhcp_domain distribution when dhcp_domain is empty fixes bug 1099625 Change-Id: Ib86770345c46a0dd8bb38a4c3e435420170828af --- quantum/agent/linux/dhcp.py | 8 +++++--- quantum/tests/unit/test_linux_dhcp.py | 16 ++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/quantum/agent/linux/dhcp.py b/quantum/agent/linux/dhcp.py index 1df41439d6..296688f882 100644 --- a/quantum/agent/linux/dhcp.py +++ b/quantum/agent/linux/dhcp.py @@ -221,9 +221,8 @@ class Dnsmasq(DhcpLocalProcess): '--bind-interfaces', '--interface=%s' % self.interface_name, '--except-interface=lo', - '--domain=%s' % self.conf.dhcp_domain, - '--pid-file=%s' % self.get_conf_file_name('pid', - ensure_conf_dir=True), + '--pid-file=%s' % self.get_conf_file_name( + 'pid', ensure_conf_dir=True), #TODO (mark): calculate value from cidr (defaults to 150) #'--dhcp-lease-max=%s' % ?, '--dhcp-hostsfile=%s' % self._output_hosts_file(), @@ -252,6 +251,9 @@ class Dnsmasq(DhcpLocalProcess): if self.conf.dnsmasq_dns_server: cmd.append('--server=%s' % self.conf.dnsmasq_dns_server) + if self.conf.dhcp_domain: + cmd.append('--domain=%s' % self.conf.dhcp_domain) + if self.namespace: ip_wrapper = ip_lib.IPWrapper(self.root_helper, self.namespace) ip_wrapper.netns.execute(cmd, addl_env=env) diff --git a/quantum/tests/unit/test_linux_dhcp.py b/quantum/tests/unit/test_linux_dhcp.py index 27020ea52c..7ad4444a7b 100644 --- a/quantum/tests/unit/test_linux_dhcp.py +++ b/quantum/tests/unit/test_linux_dhcp.py @@ -425,7 +425,6 @@ class TestDnsmasq(TestBase): '--bind-interfaces', '--interface=tap0', '--except-interface=lo', - '--domain=openstacklocal', '--pid-file=/dhcp/cccccccc-cccc-cccc-cccc-cccccccccccc/pid', '--dhcp-hostsfile=/dhcp/cccccccc-cccc-cccc-cccc-cccccccccccc/host', '--dhcp-optsfile=/dhcp/cccccccc-cccc-cccc-cccc-cccccccccccc/opts', @@ -433,8 +432,7 @@ class TestDnsmasq(TestBase): 'dnsmasq-lease-update'), '--leasefile-ro', '--dhcp-range=set:tag0,192.168.0.0,static,120s', - '--dhcp-range=set:tag1,fdca:3ba5:a17a:4ba3::,static,120s', - ] + '--dhcp-range=set:tag1,fdca:3ba5:a17a:4ba3::,static,120s'] expected.extend(extra_options) self.execute.return_value = ('', '') @@ -465,15 +463,21 @@ class TestDnsmasq(TestBase): check_exit_code=True) def test_spawn(self): - self._test_spawn(['--conf-file=']) + self._test_spawn(['--conf-file=', '--domain=openstacklocal']) def test_spawn_cfg_config_file(self): self.conf.set_override('dnsmasq_config_file', '/foo') - self._test_spawn(['--conf-file=/foo']) + self._test_spawn(['--conf-file=/foo', '--domain=openstacklocal']) + + def test_spawn_no_dhcp_domain(self): + self.conf.set_override('dhcp_domain', '') + self._test_spawn(['--conf-file=']) def test_spawn_cfg_dns_server(self): self.conf.set_override('dnsmasq_dns_server', '8.8.8.8') - self._test_spawn(['--conf-file=', '--server=8.8.8.8']) + self._test_spawn(['--conf-file=', + '--server=8.8.8.8', + '--domain=openstacklocal']) def test_output_opts_file(self): fake_v6 = 'gdca:3ba5:a17a:4ba3::1'