From: Nachi Ueno Date: Tue, 15 Jan 2013 17:54:59 +0000 (-0800) Subject: Disable dhcp_domain distribution when dhcp_domain is empty X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c63e0465d047413b71dd616249bbbe2efddbf0f9;p=openstack-build%2Fneutron-build.git Disable dhcp_domain distribution when dhcp_domain is empty fixes bug 1099625 Change-Id: Ib86770345c46a0dd8bb38a4c3e435420170828af --- diff --git a/quantum/agent/linux/dhcp.py b/quantum/agent/linux/dhcp.py index 1df41439d..296688f88 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 27020ea52..7ad4444a7 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'