From edcb83f2961b7e837d26e2ca9efe01d88b2111e8 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 8 Jun 2022 21:56:43 +0900 Subject: [PATCH] Remove unused get_log_args This method has been unused since [1] was merged. [1] 3b22541a2aa9a5b06e2bff256701dbe24554c17c Change-Id: I6765c1277341d7ec19fd6eae398fdd4ef9ef66e0 --- neutron/conf/agent/common.py | 26 -------- neutron/tests/unit/agent/dhcp/test_agent.py | 68 --------------------- 2 files changed, 94 deletions(-) diff --git a/neutron/conf/agent/common.py b/neutron/conf/agent/common.py index 139c2d54eef..5a069c2b26d 100644 --- a/neutron/conf/agent/common.py +++ b/neutron/conf/agent/common.py @@ -13,7 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import os import shlex from oslo_config import cfg @@ -173,31 +172,6 @@ DHCP_PROTOCOL_OPTS = [ ] -def get_log_args(conf, log_file_name, **kwargs): - cmd_args = [] - if conf.debug: - cmd_args.append('--debug') - if (conf.log_dir or conf.log_file): - cmd_args.append('--log-file=%s' % log_file_name) - log_dir = None - if conf.log_dir and conf.log_file: - log_dir = os.path.dirname( - os.path.join(conf.log_dir, conf.log_file)) - elif conf.log_dir: - log_dir = conf.log_dir - elif conf.log_file: - log_dir = os.path.dirname(conf.log_file) - if log_dir: - cmd_args.append('--log-dir=%s' % log_dir) - else: - 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 - - def register_external_process_opts(cfg=cfg.CONF): cfg.register_opts(EXTERNAL_PROCESS_OPTS) diff --git a/neutron/tests/unit/agent/dhcp/test_agent.py b/neutron/tests/unit/agent/dhcp/test_agent.py index 6fa8b174955..e81f963dcbc 100644 --- a/neutron/tests/unit/agent/dhcp/test_agent.py +++ b/neutron/tests/unit/agent/dhcp/test_agent.py @@ -730,74 +730,6 @@ class TestDhcpAgent(base.BaseTestCase): cfg.CONF, mock.Mock()) -class TestLogArgs(base.BaseTestCase): - - def test_log_args_without_log_dir_and_file(self): - conf_dict = {'debug': True, - 'log_dir': None, - 'log_file': None, - 'use_syslog': True, - 'syslog_log_facility': 'LOG_USER'} - conf = dhcp.DictModel(conf_dict) - expected_args = ['--debug', - '--use-syslog', - '--syslog-log-facility=LOG_USER'] - args = config.get_log_args(conf, 'log_file_name') - self.assertEqual(expected_args, args) - - def test_log_args_without_log_file(self): - conf_dict = {'debug': True, - 'log_dir': '/etc/tests', - 'log_file': None, - 'use_syslog': False, - 'syslog_log_facility': 'LOG_USER'} - conf = dhcp.DictModel(conf_dict) - expected_args = ['--debug', - '--log-file=log_file_name', - '--log-dir=/etc/tests'] - args = config.get_log_args(conf, 'log_file_name') - self.assertEqual(expected_args, args) - - def test_log_args_with_log_dir_and_file(self): - conf_dict = {'debug': True, - 'log_dir': '/etc/tests', - 'log_file': 'tests/filelog', - 'use_syslog': False, - 'syslog_log_facility': 'LOG_USER'} - conf = dhcp.DictModel(conf_dict) - expected_args = ['--debug', - '--log-file=log_file_name', - '--log-dir=/etc/tests/tests'] - args = config.get_log_args(conf, 'log_file_name') - self.assertEqual(expected_args, args) - - def test_log_args_without_log_dir(self): - conf_dict = {'debug': True, - 'log_file': 'tests/filelog', - 'log_dir': None, - 'use_syslog': False, - 'syslog_log_facility': 'LOG_USER'} - conf = dhcp.DictModel(conf_dict) - expected_args = ['--debug', - '--log-file=log_file_name', - '--log-dir=tests'] - 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, - 'log_file': 'tests/filelog', - 'log_dir': '/etc/tests', - 'use_syslog': True, - 'syslog_log_facility': 'LOG_USER'} - conf = dhcp.DictModel(conf_dict) - expected_args = ['--debug', - '--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): super(TestDhcpAgentEventHandler, self).setUp()