Merge "Fix bug when enable configuration named dnsmasq_base_log_dir"

This commit is contained in:
Jenkins 2016-02-07 15:31:56 +00:00 committed by Gerrit Code Review
commit df4966081a
2 changed files with 9 additions and 7 deletions
neutron
agent/linux
tests/unit/agent/linux

@ -397,16 +397,17 @@ class Dnsmasq(DhcpLocalProcess):
cmd.append('--dhcp-broadcast')
if self.conf.dnsmasq_base_log_dir:
log_dir = os.path.join(
self.conf.dnsmasq_base_log_dir,
self.network.id)
try:
if not os.path.exists(self.conf.dnsmasq_base_log_dir):
os.makedirs(self.conf.dnsmasq_base_log_dir)
if not os.path.exists(log_dir):
os.makedirs(log_dir)
except OSError:
LOG.error(_LE('Error while create dnsmasq base log dir: %s'),
self.conf.dnsmasq_base_log_dir)
LOG.error(_LE('Error while create dnsmasq log dir: %s'),
log_dir)
else:
log_filename = os.path.join(
self.conf.dnsmasq_base_log_dir,
self.network.id, 'dhcp_dns_log')
log_filename = os.path.join(log_dir, 'dhcp_dns_log')
cmd.append('--log-queries')
cmd.append('--log-dhcp')
cmd.append('--log-facility=%s' % log_filename)

@ -1138,6 +1138,7 @@ class TestDnsmasq(TestBase):
'--log-dhcp',
('--log-facility=%s' % dhcp_dns_log)],
network)
self.makedirs.assert_called_with(os.path.join('/tmp', network.id))
def test_spawn_cfg_with_local_resolv(self):
self.conf.set_override('dnsmasq_local_resolv', True)