Syslog support for neutron metadata proxy
When neutron metadata proxy reads the cli args which are propagated from its parent processes (l3-agent and dhcp-agent), if log-dir and log-file are not defined in the context, it will also double-check whether syslog is enabled and its facility in the user-defined configuration files (/etc/neutron). As a result, the log behavior of each neutron component becomes consistent. File log is the default logging function. The syslog is enabled when use_syslog is explicitly defined and file log options are all disabled. Fixes: bug #1184500 Change-Id: I7804fa8794071d21513e068d084607691215522f
This commit is contained in:
parent
334e646170
commit
2ad940f376
@ -56,7 +56,11 @@ def get_log_args(conf, log_file_name):
|
||||
if log_dir:
|
||||
cmd_args.append('--log-dir=%s' % log_dir)
|
||||
else:
|
||||
cmd_args.append('--use-syslog')
|
||||
if conf.use_syslog:
|
||||
cmd_args.append('--use-syslog')
|
||||
if conf.syslog_log_facility:
|
||||
cmd_args.append(
|
||||
'--syslog-log-facility=%s' % conf.syslog_log_facility)
|
||||
return cmd_args
|
||||
|
||||
|
||||
|
@ -378,9 +378,13 @@ class TestLogArgs(base.BaseTestCase):
|
||||
conf_dict = {'debug': True,
|
||||
'verbose': False,
|
||||
'log_dir': None,
|
||||
'log_file': None}
|
||||
'log_file': None,
|
||||
'use_syslog': True,
|
||||
'syslog_log_facility': 'LOG_USER'}
|
||||
conf = dhcp_agent.DictModel(conf_dict)
|
||||
expected_args = ['--debug', '--use-syslog']
|
||||
expected_args = ['--debug',
|
||||
'--use-syslog',
|
||||
'--syslog-log-facility=LOG_USER']
|
||||
args = config.get_log_args(conf, 'log_file_name')
|
||||
self.assertEqual(expected_args, args)
|
||||
|
||||
@ -388,9 +392,12 @@ class TestLogArgs(base.BaseTestCase):
|
||||
conf_dict = {'debug': True,
|
||||
'verbose': True,
|
||||
'log_dir': '/etc/tests',
|
||||
'log_file': None}
|
||||
'log_file': None,
|
||||
'use_syslog': False,
|
||||
'syslog_log_facility': 'LOG_USER'}
|
||||
conf = dhcp_agent.DictModel(conf_dict)
|
||||
expected_args = ['--debug', '--verbose',
|
||||
expected_args = ['--debug',
|
||||
'--verbose',
|
||||
'--log-file=log_file_name',
|
||||
'--log-dir=/etc/tests']
|
||||
args = config.get_log_args(conf, 'log_file_name')
|
||||
@ -400,7 +407,9 @@ class TestLogArgs(base.BaseTestCase):
|
||||
conf_dict = {'debug': True,
|
||||
'verbose': False,
|
||||
'log_dir': '/etc/tests',
|
||||
'log_file': 'tests/filelog'}
|
||||
'log_file': 'tests/filelog',
|
||||
'use_syslog': False,
|
||||
'syslog_log_facility': 'LOG_USER'}
|
||||
conf = dhcp_agent.DictModel(conf_dict)
|
||||
expected_args = ['--debug',
|
||||
'--log-file=log_file_name',
|
||||
@ -412,7 +421,9 @@ class TestLogArgs(base.BaseTestCase):
|
||||
conf_dict = {'debug': True,
|
||||
'verbose': False,
|
||||
'log_file': 'tests/filelog',
|
||||
'log_dir': None}
|
||||
'log_dir': None,
|
||||
'use_syslog': False,
|
||||
'syslog_log_facility': 'LOG_USER'}
|
||||
conf = dhcp_agent.DictModel(conf_dict)
|
||||
expected_args = ['--debug',
|
||||
'--log-file=log_file_name',
|
||||
@ -420,6 +431,21 @@ class TestLogArgs(base.BaseTestCase):
|
||||
args = config.get_log_args(conf, 'log_file_name')
|
||||
self.assertEqual(expected_args, args)
|
||||
|
||||
def test_log_args_with_filelog_and_syslog(self):
|
||||
conf_dict = {'debug': True,
|
||||
'verbose': True,
|
||||
'log_file': 'tests/filelog',
|
||||
'log_dir': '/etc/tests',
|
||||
'use_syslog': True,
|
||||
'syslog_log_facility': 'LOG_USER'}
|
||||
conf = dhcp_agent.DictModel(conf_dict)
|
||||
expected_args = ['--debug',
|
||||
'--verbose',
|
||||
'--log-file=log_file_name',
|
||||
'--log-dir=/etc/tests/tests']
|
||||
args = config.get_log_args(conf, 'log_file_name')
|
||||
self.assertEqual(expected_args, args)
|
||||
|
||||
|
||||
class TestDhcpAgentEventHandler(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
|
Loading…
Reference in New Issue
Block a user