]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Kill 'Skipping unknown group key: firewall_driver' log trace
authorarmando-migliaccio <armamig@gmail.com>
Thu, 13 Mar 2014 19:40:01 +0000 (12:40 -0700)
committerarmando-migliaccio <armamig@gmail.com>
Thu, 13 Mar 2014 19:46:06 +0000 (12:46 -0700)
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

neutron/common/legacy.py
neutron/quota.py
neutron/tests/unit/test_legacy.py

index cf37281a5d46f66e58a37aab8ee48f53b04c18b4..d387aa2bbb080c493e84bf3f93c0d63cb15091c7 100644 (file)
@@ -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)
index cee12cf35723d3c98f94e5f0bc9dce9351e0d8b5..9976f71bea6694f1939b209a47ad11a6c6d5d4dd 100644 (file)
@@ -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):
index 539f7de0c9112a592e0b7e35c3fe2f0189cb102a..6723d06c1a1c279dd58a0d5acbc70cb5730a70e8 100644 (file)
@@ -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):