Add DNS and DHCP log into dhcp agent
Enable set DNS and DHCP log of dnsmasq for dhcp agent Add a new configuration named 'dnsmasq_base_log_dir' in dhcp_agent.ini. This entry should be a path of log file. It should like this: dnsmasq_base_log_dir=/tmp And the DNS and DHCP log will be written into the file "/tmp/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/dhcp_dns_log". The dir path will be created if the given path doesn't exists. DocImpact Closes-Bug: #1475636 Change-Id: I87be346ec5059eaa8a29f48fe53933af82d1b155
This commit is contained in:
parent
5e925b23d2
commit
e79d602e38
@ -68,6 +68,11 @@
|
|||||||
# as forwarders.
|
# as forwarders.
|
||||||
# dnsmasq_dns_servers =
|
# 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.
|
# Limit number of leases to prevent a denial-of-service.
|
||||||
# dnsmasq_lease_max = 16777216
|
# dnsmasq_lease_max = 16777216
|
||||||
|
|
||||||
|
@ -54,6 +54,11 @@ DNSMASQ_OPTS = [
|
|||||||
"This option is deprecated and "
|
"This option is deprecated and "
|
||||||
"will be removed in a future release."),
|
"will be removed in a future release."),
|
||||||
deprecated_for_removal=True),
|
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(
|
cfg.IntOpt(
|
||||||
'dnsmasq_lease_max',
|
'dnsmasq_lease_max',
|
||||||
default=(2 ** 24),
|
default=(2 ** 24),
|
||||||
|
@ -36,7 +36,7 @@ from neutron.common import exceptions
|
|||||||
from neutron.common import ipv6_utils
|
from neutron.common import ipv6_utils
|
||||||
from neutron.common import utils as commonutils
|
from neutron.common import utils as commonutils
|
||||||
from neutron.extensions import extra_dhcp_opt as edo_ext
|
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__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -379,6 +379,20 @@ class Dnsmasq(DhcpLocalProcess):
|
|||||||
if self.conf.dhcp_broadcast_reply:
|
if self.conf.dhcp_broadcast_reply:
|
||||||
cmd.append('--dhcp-broadcast')
|
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
|
return cmd
|
||||||
|
|
||||||
def spawn_process(self):
|
def spawn_process(self):
|
||||||
|
@ -1001,6 +1001,19 @@ class TestDnsmasq(TestBase):
|
|||||||
'--server=9.9.9.9',
|
'--server=9.9.9.9',
|
||||||
'--domain=openstacklocal'])
|
'--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):
|
def test_spawn_max_leases_is_smaller_than_cap(self):
|
||||||
self._test_spawn(
|
self._test_spawn(
|
||||||
['--conf-file=', '--domain=openstacklocal'],
|
['--conf-file=', '--domain=openstacklocal'],
|
||||||
|
Loading…
Reference in New Issue
Block a user