Merge "Default dnsmasq --conf-file to /dev/null" into stable/victoria
This commit is contained in:
commit
af4e518a5e
@ -462,7 +462,8 @@ class Dnsmasq(DhcpLocalProcess):
|
|||||||
cmd.append('--dhcp-option-force=option:T2,%ds' %
|
cmd.append('--dhcp-option-force=option:T2,%ds' %
|
||||||
self.conf.dhcp_rebinding_time)
|
self.conf.dhcp_rebinding_time)
|
||||||
|
|
||||||
cmd.append('--conf-file=%s' % self.conf.dnsmasq_config_file)
|
cmd.append('--conf-file=%s' %
|
||||||
|
(self.conf.dnsmasq_config_file.strip() or '/dev/null'))
|
||||||
for server in self.conf.dnsmasq_dns_servers:
|
for server in self.conf.dnsmasq_dns_servers:
|
||||||
cmd.append('--server=%s' % server)
|
cmd.append('--server=%s' % server)
|
||||||
|
|
||||||
|
@ -1287,6 +1287,21 @@ class TestDnsmasq(TestBase):
|
|||||||
def mock_get_conf_file_name(kind):
|
def mock_get_conf_file_name(kind):
|
||||||
return '/dhcp/%s/%s' % (network.id, kind)
|
return '/dhcp/%s/%s' % (network.id, kind)
|
||||||
|
|
||||||
|
# Empty string passed to --conf-file in dnsmasq is invalid
|
||||||
|
# we must force '' to '/dev/null' because the dhcp agent
|
||||||
|
# does the same. Therefore we allow empty string to
|
||||||
|
# be passed to neutron but not to dnsmasq.
|
||||||
|
def check_conf_file_empty(cmd_list):
|
||||||
|
for i in cmd_list:
|
||||||
|
conf_file = ''
|
||||||
|
value = ''
|
||||||
|
if i.startswith('--conf-file='):
|
||||||
|
conf_file = i
|
||||||
|
value = i[12:].strip()
|
||||||
|
if not value:
|
||||||
|
idx = cmd_list.index(conf_file)
|
||||||
|
cmd_list[idx] = '--conf-file=/dev/null'
|
||||||
|
|
||||||
# if you need to change this path here, think twice,
|
# if you need to change this path here, think twice,
|
||||||
# that means pid files will move around, breaking upgrades
|
# that means pid files will move around, breaking upgrades
|
||||||
# or backwards-compatibility
|
# or backwards-compatibility
|
||||||
@ -1348,7 +1363,9 @@ class TestDnsmasq(TestBase):
|
|||||||
expected.append('--dhcp-option-force=option:T1,%ds' % dhcp_t1)
|
expected.append('--dhcp-option-force=option:T1,%ds' % dhcp_t1)
|
||||||
if dhcp_t2:
|
if dhcp_t2:
|
||||||
expected.append('--dhcp-option-force=option:T2,%ds' % dhcp_t2)
|
expected.append('--dhcp-option-force=option:T2,%ds' % dhcp_t2)
|
||||||
|
|
||||||
expected.extend(extra_options)
|
expected.extend(extra_options)
|
||||||
|
check_conf_file_empty(expected)
|
||||||
|
|
||||||
self.execute.return_value = ('', '')
|
self.execute.return_value = ('', '')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user