diff --git a/nova/conf/glance.py b/nova/conf/glance.py index c701cebc55a9..e6586fd2d6bc 100644 --- a/nova/conf/glance.py +++ b/nova/conf/glance.py @@ -76,6 +76,9 @@ Glance v2 will be a hard requirement in Ocata. default=False, help='Require Nova to perform signature verification on ' 'each image downloaded from Glance.'), + cfg.BoolOpt('debug', + default=False, + help='Enable or disable debug logging with glanceclient.'), ] diff --git a/nova/config.py b/nova/config.py index 22233624db72..db64ddf8f74a 100644 --- a/nova/config.py +++ b/nova/config.py @@ -26,16 +26,18 @@ from nova import version CONF = nova.conf.CONF -_EXTRA_DEFAULT_LOG_LEVELS = ['glanceclient=WARN'] - def parse_args(argv, default_config_files=None, configure_db=True, init_rpc=True): log.register_options(CONF) # We use the oslo.log default log levels which includes suds=INFO # and add only the extra levels that Nova needs + if CONF.glance.debug: + extra_default_log_levels = ['glanceclient=DEBUG'] + else: + extra_default_log_levels = ['glanceclient=WARN'] log.set_defaults(default_log_levels=log.get_default_log_levels() + - _EXTRA_DEFAULT_LOG_LEVELS) + extra_default_log_levels) rpc.set_defaults(control_exchange='nova') config.set_middleware_defaults() diff --git a/nova/tests/unit/test_conf.py b/nova/tests/unit/test_conf.py index 17f3630cea25..d6e62cf375d7 100644 --- a/nova/tests/unit/test_conf.py +++ b/nova/tests/unit/test_conf.py @@ -16,9 +16,11 @@ import os import tempfile import fixtures +import mock from oslo_config import cfg import nova.conf.virt +from nova import config from nova import test @@ -80,3 +82,18 @@ class ConfTest(test.NoDBTestCase): # a dict. actual = [{'node': '0', 'size': '2048', 'count': '64'}] self.assertEqual(actual, self.conf.reserved_huge_pages) + + +class TestParseArgs(test.NoDBTestCase): + + @mock.patch.object(config.log, 'register_options') + def test_parse_args_glance_debug_false(self, register_options): + self.flags(debug=False, group='glance') + config.parse_args([], configure_db=False, init_rpc=False) + self.assertIn('glanceclient=WARN', config.CONF.default_log_levels) + + @mock.patch.object(config.log, 'register_options') + def test_parse_args_glance_debug_true(self, register_options): + self.flags(debug=True, group='glance') + config.parse_args([], configure_db=False, init_rpc=False) + self.assertIn('glanceclient=DEBUG', config.CONF.default_log_levels)