From d288a28589d3791bc71eee626d1ed0b7ac7bcd23 Mon Sep 17 00:00:00 2001 From: ZhiQiang Fan Date: Fri, 21 Nov 2014 01:58:45 +0800 Subject: [PATCH] Remove unnecessary import_opt|group Usually, we should import an option before we use it, otherwise, NoSuchOpt exception will be raised. When we import a module, the options in that module are registered, (or imported), so we don't need to explicitly import them again. However, it is a bit hard for developers, reviewers and maintainers to track between files just to check if a specific option is imported or not. So it is good (not required) whenever we use an option, we import it explicitly, such kind of redundant is acceptable. But not the case that we already import a module A, then import_opt|group registered or imported in that module again, this is obviously unnecessary and should be avoid. Change-Id: I8672d9f12d862f9a622e5557d9c8dc2fe6717f5e Closes-Bug: #1389229 --- ceilometer/agent/base.py | 3 --- ceilometer/alarm/service.py | 6 ------ ceilometer/alarm/storage/impl_mongodb.py | 4 ---- ceilometer/api/app.py | 1 - ceilometer/cmd/storage.py | 3 --- ceilometer/network/floatingip.py | 2 -- ceilometer/network/services/discovery.py | 3 --- ceilometer/service.py | 3 --- ceilometer/storage/__init__.py | 1 - ceilometer/storage/impl_mongodb.py | 3 --- 10 files changed, 29 deletions(-) diff --git a/ceilometer/agent/base.py b/ceilometer/agent/base.py index c6d9b34a9..3a234c6be 100644 --- a/ceilometer/agent/base.py +++ b/ceilometer/agent/base.py @@ -37,9 +37,6 @@ from ceilometer import utils LOG = log.getLogger(__name__) -cfg.CONF.import_opt('heartbeat', 'ceilometer.coordination', - group='coordination') - class PollsterListForbidden(Exception): def __init__(self): diff --git a/ceilometer/alarm/service.py b/ceilometer/alarm/service.py index 9b2d3496c..8156aa185 100644 --- a/ceilometer/alarm/service.py +++ b/ceilometer/alarm/service.py @@ -45,12 +45,6 @@ OPTS = [ ] cfg.CONF.register_opts(OPTS, group='alarm') -cfg.CONF.import_opt('notifier_rpc_topic', 'ceilometer.alarm.rpc', - group='alarm') -cfg.CONF.import_opt('partition_rpc_topic', 'ceilometer.alarm.rpc', - group='alarm') -cfg.CONF.import_opt('heartbeat', 'ceilometer.coordination', - group='coordination') cfg.CONF.import_opt('http_timeout', 'ceilometer.service') cfg.CONF.import_group('service_credentials', 'ceilometer.service') diff --git a/ceilometer/alarm/storage/impl_mongodb.py b/ceilometer/alarm/storage/impl_mongodb.py index 831c29c05..07a78edc2 100644 --- a/ceilometer/alarm/storage/impl_mongodb.py +++ b/ceilometer/alarm/storage/impl_mongodb.py @@ -20,7 +20,6 @@ # under the License. """MongoDB storage backend""" -from oslo.config import cfg import pymongo from ceilometer.alarm.storage import pymongo_base @@ -28,9 +27,6 @@ from ceilometer.openstack.common import log from ceilometer import storage from ceilometer.storage.mongo import utils as pymongo_utils -cfg.CONF.import_opt('time_to_live', 'ceilometer.storage', - group="database") - LOG = log.getLogger(__name__) diff --git a/ceilometer/api/app.py b/ceilometer/api/app.py index cd03c8460..476ce25c6 100644 --- a/ceilometer/api/app.py +++ b/ceilometer/api/app.py @@ -35,7 +35,6 @@ from ceilometer import storage LOG = log.getLogger(__name__) CONF = cfg.CONF -CONF.import_opt('debug', 'ceilometer.openstack.common.log') OPTS = [ cfg.StrOpt('api_paste_config', diff --git a/ceilometer/cmd/storage.py b/ceilometer/cmd/storage.py index a4d85069d..ac684d68f 100644 --- a/ceilometer/cmd/storage.py +++ b/ceilometer/cmd/storage.py @@ -22,9 +22,6 @@ from ceilometer.i18n import _ from ceilometer import service from ceilometer import storage -cfg.CONF.import_opt('time_to_live', 'ceilometer.storage', - group='database') - LOG = logging.getLogger(__name__) diff --git a/ceilometer/network/floatingip.py b/ceilometer/network/floatingip.py index f16defa39..ee75e72d6 100644 --- a/ceilometer/network/floatingip.py +++ b/ceilometer/network/floatingip.py @@ -30,8 +30,6 @@ from ceilometer import sample LOG = log.getLogger(__name__) -cfg.CONF.import_group('service_types', 'ceilometer.nova_client') - class FloatingIPPollster(plugin_base.PollsterBase): diff --git a/ceilometer/network/services/discovery.py b/ceilometer/network/services/discovery.py index 6a67c794b..68dc0e0c5 100644 --- a/ceilometer/network/services/discovery.py +++ b/ceilometer/network/services/discovery.py @@ -21,9 +21,6 @@ from ceilometer.agent import plugin_base from ceilometer import neutron_client -cfg.CONF.import_group('service_types', 'ceilometer.neutron_client') - - class _BaseServicesDiscovery(plugin_base.DiscoveryBase): def __init__(self): diff --git a/ceilometer/service.py b/ceilometer/service.py index 734fa550f..21e25e32c 100644 --- a/ceilometer/service.py +++ b/ceilometer/service.py @@ -91,9 +91,6 @@ CLI_OPTS = [ ] cfg.CONF.register_cli_opts(CLI_OPTS, group="service_credentials") -cfg.CONF.import_opt('default_log_levels', - 'ceilometer.openstack.common.log') - LOG = log.getLogger(__name__) diff --git a/ceilometer/storage/__init__.py b/ceilometer/storage/__init__.py index 1915cf8ff..41a4002a7 100644 --- a/ceilometer/storage/__init__.py +++ b/ceilometer/storage/__init__.py @@ -73,7 +73,6 @@ OPTS = [ cfg.CONF.register_opts(OPTS, group='database') db_options.set_defaults(cfg.CONF) -cfg.CONF.import_opt('connection', 'oslo.db.options', group='database') class StorageBadVersion(Exception): diff --git a/ceilometer/storage/impl_mongodb.py b/ceilometer/storage/impl_mongodb.py index c0d8b4803..816a9776d 100644 --- a/ceilometer/storage/impl_mongodb.py +++ b/ceilometer/storage/impl_mongodb.py @@ -44,9 +44,6 @@ from ceilometer.storage.mongo import utils as pymongo_utils from ceilometer.storage import pymongo_base from ceilometer import utils -cfg.CONF.import_opt('time_to_live', 'ceilometer.storage', - group="database") - LOG = log.getLogger(__name__)