diff --git a/quantum/agent/linux/dhcp.py b/quantum/agent/linux/dhcp.py index 7765e33588..cc2139b0f1 100644 --- a/quantum/agent/linux/dhcp.py +++ b/quantum/agent/linux/dhcp.py @@ -222,9 +222,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(), @@ -253,6 +252,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'