Kill 'Skipping unknown group key: firewall_driver' log trace

This is done by trying to import the option first. If this
does not work, emit a warning instead as in most cases this is
harmless for a number of reasons: a) the service might not
even need the opt; b) if things do break down the line, we'll
see bigger traces; c) it's not gonna be long for this legacy
quantum/neutron stuff to be removed altogether.

Closes-bug: 1210121

Change-Id: I34917da9cb6117ee1d42140621c742f503279b6b
changes/79/80379/1
armando-migliaccio 9 years ago
parent 00281819f3
commit b5ee496239

@ -17,6 +17,8 @@
# @author Mark McClain (DreamHost)
from oslo.config import cfg
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__)
@ -45,11 +47,19 @@ def override_config(config, config_keys=None):
group = None
if not isinstance(key, basestring):
try:
group, key = key
group, key, module_str = key
old_value = getattr(getattr(config, group), key, None)
except AttributeError:
LOG.error(_('Skipping unknown group key: %s'), key)
continue
try:
config.import_opt(key, module_str, group)
old_value = getattr(getattr(config, group), key, None)
except (cfg.NoSuchOptError,
cfg.NoSuchGroupError,
AttributeError):
LOG.warn(_('Key %(key)s in group %(group)s is unknown. '
'It may not be defined or needed by this '
'service.') % {'key': key, 'group': group})
continue
else:
old_value = getattr(config, key, None)
if not old_value:
@ -77,7 +87,9 @@ def modernize_quantum_config(config):
'router_scheduler_driver',
'rpc_backend',
'service_plugins',
('SECURITYGROUP', 'firewall_driver'),
('SECURITYGROUP',
'firewall_driver',
'neutron.agent.securitygroups_rpc'),
]
override_config(config, config_keys)

@ -58,7 +58,7 @@ quota_opts = [
]
# Register the configuration options
cfg.CONF.register_opts(quota_opts, 'QUOTAS')
legacy.override_config(cfg.CONF, [('QUOTAS', 'quota_driver')])
legacy.override_config(cfg.CONF, [('QUOTAS', 'quota_driver', 'neutron.quota')])
class ConfDriver(object):

@ -71,7 +71,7 @@ class TestLegacyConfigOverride(base.BaseTestCase):
def test_override_config_group_key(self):
self.cfg(args=['--bar-baz=quantum'])
legacy.override_config(self.cfg, [('bar', 'baz')])
legacy.override_config(self.cfg, [('bar', 'baz', 'mod')])
self.assertEqual(self.cfg.bar.baz, 'neutron')
def test_override_config_list_value(self):

Loading…
Cancel
Save