Merge "Add DNS and DHCP log into dhcp agent"
This commit is contained in:
commit
6ee7b12d94
@ -68,6 +68,11 @@
|
||||
# as forwarders.
|
||||
# dnsmasq_dns_servers =
|
||||
|
||||
# Base log dir for dnsmasq logging. The log contains DHCP and DNS log
|
||||
# information and is useful for debugging issues with either DHCP or DNS.
|
||||
# If this section is null, disable dnsmasq log.
|
||||
# dnsmasq_base_log_dir =
|
||||
|
||||
# Limit number of leases to prevent a denial-of-service.
|
||||
# dnsmasq_lease_max = 16777216
|
||||
|
||||
|
@ -54,6 +54,11 @@ DNSMASQ_OPTS = [
|
||||
"This option is deprecated and "
|
||||
"will be removed in a future release."),
|
||||
deprecated_for_removal=True),
|
||||
cfg.StrOpt('dnsmasq_base_log_dir',
|
||||
help=_("Base log dir for dnsmasq logging. "
|
||||
"The log contains DHCP and DNS log information and "
|
||||
"is useful for debugging issues with either DHCP or "
|
||||
"DNS. If this section is null, disable dnsmasq log.")),
|
||||
cfg.IntOpt(
|
||||
'dnsmasq_lease_max',
|
||||
default=(2 ** 24),
|
||||
|
@ -36,7 +36,7 @@ from neutron.common import exceptions
|
||||
from neutron.common import ipv6_utils
|
||||
from neutron.common import utils as commonutils
|
||||
from neutron.extensions import extra_dhcp_opt as edo_ext
|
||||
from neutron.i18n import _LI, _LW
|
||||
from neutron.i18n import _LI, _LW, _LE
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -379,6 +379,20 @@ class Dnsmasq(DhcpLocalProcess):
|
||||
if self.conf.dhcp_broadcast_reply:
|
||||
cmd.append('--dhcp-broadcast')
|
||||
|
||||
if self.conf.dnsmasq_base_log_dir:
|
||||
try:
|
||||
if not os.path.exists(self.conf.dnsmasq_base_log_dir):
|
||||
os.makedirs(self.conf.dnsmasq_base_log_dir)
|
||||
log_filename = os.path.join(
|
||||
self.conf.dnsmasq_base_log_dir,
|
||||
self.network.id, 'dhcp_dns_log')
|
||||
cmd.append('--log-queries')
|
||||
cmd.append('--log-dhcp')
|
||||
cmd.append('--log-facility=%s' % log_filename)
|
||||
except OSError:
|
||||
LOG.error(_LE('Error while create dnsmasq base log dir: %s'),
|
||||
self.conf.dnsmasq_base_log_dir)
|
||||
|
||||
return cmd
|
||||
|
||||
def spawn_process(self):
|
||||
|
@ -1054,6 +1054,19 @@ class TestDnsmasq(TestBase):
|
||||
'--server=9.9.9.9',
|
||||
'--domain=openstacklocal'])
|
||||
|
||||
def test_spawn_cfg_enable_dnsmasq_log(self):
|
||||
self.conf.set_override('dnsmasq_base_log_dir', '/tmp')
|
||||
network = FakeV4Network()
|
||||
dhcp_dns_log = \
|
||||
'/tmp/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/dhcp_dns_log'
|
||||
|
||||
self._test_spawn(['--conf-file=',
|
||||
'--domain=openstacklocal',
|
||||
'--log-queries',
|
||||
'--log-dhcp',
|
||||
('--log-facility=%s' % dhcp_dns_log)],
|
||||
network)
|
||||
|
||||
def test_spawn_max_leases_is_smaller_than_cap(self):
|
||||
self._test_spawn(
|
||||
['--conf-file=', '--domain=openstacklocal'],
|
||||
|
Loading…
Reference in New Issue
Block a user