From 1842e19487b4afb92cc5d2e87f5cf4281ed34603 Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Thu, 13 Oct 2016 14:29:28 +0200 Subject: [PATCH] register ceilometer options at runtime This remove pollsters option from configfile sample due to a duplicate option registration. This will be fixed later. The exchange_control group in the config sample doesn't exit in reality exchange are in DEFAULT group. This removes usage of cfg.CONF everywhere left. This adds all missing OPTS in sample file. Change-Id: I48c11ee7e1aae65847958b98532b3bdb48a3ceb5 --- ceilometer/agent/discovery/endpoint.py | 3 - ceilometer/agent/discovery/tenant.py | 4 -- ceilometer/agent/manager.py | 11 ---- ceilometer/api/app.py | 11 ---- ceilometer/api/controllers/v2/root.py | 3 - ceilometer/api/controllers/v2/utils.py | 3 - ceilometer/api/hooks.py | 4 -- ceilometer/cmd/api.py | 23 +++++++ ceilometer/cmd/polling.py | 8 +-- ceilometer/cmd/sample.py | 5 +- ceilometer/cmd/storage.py | 6 +- ceilometer/collector.py | 14 ++-- ceilometer/compute/discovery.py | 1 - ceilometer/compute/util.py | 2 - ceilometer/compute/virt/inspector.py | 2 - ceilometer/compute/virt/libvirt/inspector.py | 3 - ceilometer/compute/virt/vmware/inspector.py | 3 - ceilometer/compute/virt/xenapi/inspector.py | 4 -- ceilometer/coordination.py | 1 - ceilometer/dispatcher/__init__.py | 2 - ceilometer/dispatcher/file.py | 2 - ceilometer/dispatcher/gnocchi.py | 23 +------ ceilometer/dispatcher/gnocchi_opts.py | 32 +++++++++ ceilometer/dispatcher/http.py | 2 - ceilometer/energy/kwapi.py | 2 - ceilometer/event/converter.py | 2 - ceilometer/exchange_control.py | 3 + ceilometer/gnocchi_client.py | 2 - ceilometer/hardware/discovery.py | 2 - ceilometer/hardware/pollsters/generic.py | 2 - ceilometer/image/discovery.py | 3 - ceilometer/ipmi/notifications/ironic.py | 3 - .../ipmi/platform/intel_node_manager.py | 3 - ceilometer/ipmi/pollsters/__init__.py | 2 - ceilometer/ipmi/pollsters/node.py | 5 -- ceilometer/ipmi/pollsters/sensor.py | 5 -- ceilometer/keystone_client.py | 2 - ceilometer/meter/notifications.py | 4 -- ceilometer/middleware.py | 2 - ceilometer/network/floatingip.py | 3 - .../network/statistics/opencontrail/client.py | 5 -- .../network/statistics/opendaylight/client.py | 5 -- ceilometer/neutron_client.py | 3 - ceilometer/notification.py | 13 ++-- ceilometer/nova_client.py | 6 -- ceilometer/objectstore/rgw.py | 4 -- ceilometer/objectstore/swift.py | 4 -- ceilometer/opts.py | 66 +++++++++++++------ ceilometer/pipeline.py | 2 - ceilometer/publisher/messaging.py | 4 -- ceilometer/publisher/udp.py | 4 -- ceilometer/publisher/utils.py | 1 - ceilometer/sample.py | 2 - ceilometer/service.py | 40 ++--------- ceilometer/storage/__init__.py | 2 - ceilometer/telemetry/notifications.py | 10 --- ceilometer/tests/db.py | 4 +- ceilometer/tests/functional/api/__init__.py | 9 +-- ceilometer/tests/functional/gabbi/fixtures.py | 15 ++--- .../storage/test_storage_scenarios.py | 2 - ceilometer/tests/functional/test_collector.py | 4 +- .../tests/functional/test_notification.py | 12 ++-- .../tests/unit/dispatcher/test_gnocchi.py | 12 ++-- ceilometer/tests/unit/dispatcher/test_http.py | 7 +- ceilometer/tests/unit/event/test_converter.py | 4 +- .../unit/hardware/pollsters/test_generic.py | 5 +- .../tests/unit/meter/test_notifications.py | 4 +- ceilometer/tests/unit/test_novaclient.py | 4 +- ceilometer/utils.py | 2 - ceilometer/volume/discovery.py | 3 - etc/ceilometer/api_paste.ini | 2 + .../ceilometer-config-generator.conf | 1 + setup.cfg | 3 +- 73 files changed, 176 insertions(+), 305 deletions(-) create mode 100644 ceilometer/cmd/api.py create mode 100644 ceilometer/dispatcher/gnocchi_opts.py diff --git a/ceilometer/agent/discovery/endpoint.py b/ceilometer/agent/discovery/endpoint.py index a8fdedf586..f319fc8c91 100644 --- a/ceilometer/agent/discovery/endpoint.py +++ b/ceilometer/agent/discovery/endpoint.py @@ -12,7 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg from oslo_log import log from ceilometer.agent import plugin_base as plugin @@ -21,8 +20,6 @@ from ceilometer import keystone_client LOG = log.getLogger(__name__) -cfg.CONF.import_group('service_credentials', 'ceilometer.keystone_client') - class EndpointDiscovery(plugin.DiscoveryBase): """Discovery that supplies service endpoints. diff --git a/ceilometer/agent/discovery/tenant.py b/ceilometer/agent/discovery/tenant.py index 8ae8468801..6754b85726 100644 --- a/ceilometer/agent/discovery/tenant.py +++ b/ceilometer/agent/discovery/tenant.py @@ -12,12 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg - from ceilometer.agent import plugin_base as plugin -cfg.CONF.import_group('service_credentials', 'ceilometer.keystone_client') - class TenantDiscovery(plugin.DiscoveryBase): """Discovery that supplies keystone tenants. diff --git a/ceilometer/agent/manager.py b/ceilometer/agent/manager.py index 7d1a33fe84..94dd0aaa1f 100644 --- a/ceilometer/agent/manager.py +++ b/ceilometer/agent/manager.py @@ -65,17 +65,6 @@ POLLING_OPTS = [ 'subset of pollsters should be loaded.'), ] -cfg.CONF.register_opts(OPTS) -cfg.CONF.register_opts(POLLING_OPTS, group='polling') -cfg.CONF.import_opt('telemetry_driver', 'ceilometer.publisher.messaging', - group='publisher_notifier') -cfg.CONF.import_group('service_types', 'ceilometer.energy.kwapi') -cfg.CONF.import_group('service_types', 'ceilometer.image.glance') -cfg.CONF.import_group('service_types', 'ceilometer.neutron_client') -cfg.CONF.import_group('service_types', 'ceilometer.nova_client') -cfg.CONF.import_group('service_types', 'ceilometer.objectstore.rgw') -cfg.CONF.import_group('service_types', 'ceilometer.objectstore.swift') - class PollsterListForbidden(Exception): def __init__(self): diff --git a/ceilometer/api/app.py b/ceilometer/api/app.py index d16a358dcd..d506ca6c4d 100644 --- a/ceilometer/api/app.py +++ b/ceilometer/api/app.py @@ -25,12 +25,8 @@ import pecan from ceilometer.api import hooks from ceilometer.api import middleware -from ceilometer import service - LOG = log.getLogger(__name__) -CONF = cfg.CONF - OPTS = [ cfg.StrOpt('api_paste_config', default="api_paste.ini", @@ -46,9 +42,6 @@ API_OPTS = [ ), ] -CONF.register_opts(OPTS) -CONF.register_opts(API_OPTS, group='api') - def setup_app(pecan_config=None, conf=None): if conf is None: @@ -117,7 +110,3 @@ def app_factory(global_config, **local_conf): global APPCONFIGS conf = APPCONFIGS.get(global_config.get('configkey')) return setup_app(conf=conf) - - -def build_wsgi_app(argv=None): - return load_app(service.prepare_service(argv=argv)) diff --git a/ceilometer/api/controllers/v2/root.py b/ceilometer/api/controllers/v2/root.py index daf3785c89..f106ad90e1 100644 --- a/ceilometer/api/controllers/v2/root.py +++ b/ceilometer/api/controllers/v2/root.py @@ -54,9 +54,6 @@ API_OPTS = [ 'keystone.')), ] -cfg.CONF.register_opts(API_OPTS, group='api') -cfg.CONF.import_opt('meter_dispatchers', 'ceilometer.dispatcher') - LOG = log.getLogger(__name__) diff --git a/ceilometer/api/controllers/v2/utils.py b/ceilometer/api/controllers/v2/utils.py index f7b64e5479..ba85cb81aa 100644 --- a/ceilometer/api/controllers/v2/utils.py +++ b/ceilometer/api/controllers/v2/utils.py @@ -23,7 +23,6 @@ import datetime import functools import inspect -from oslo_config import cfg from oslo_log import log from oslo_utils import timeutils import pecan @@ -36,8 +35,6 @@ from ceilometer.i18n import _, _LI from ceilometer import utils LOG = log.getLogger(__name__) -cfg.CONF.import_opt('default_api_return_limit', 'ceilometer.api.app', - group='api') def enforce_limit(limit): diff --git a/ceilometer/api/hooks.py b/ceilometer/api/hooks.py index 1ec5b015a4..7dd52203ce 100644 --- a/ceilometer/api/hooks.py +++ b/ceilometer/api/hooks.py @@ -13,7 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg from oslo_log import log import oslo_messaging from oslo_policy import policy @@ -26,9 +25,6 @@ from ceilometer import storage LOG = log.getLogger(__name__) -cfg.CONF.import_opt('telemetry_driver', 'ceilometer.publisher.messaging', - group='publisher_notifier') - class ConfigHook(hooks.PecanHook): """Attach the configuration object to the request. diff --git a/ceilometer/cmd/api.py b/ceilometer/cmd/api.py new file mode 100644 index 0000000000..22a9e41d2b --- /dev/null +++ b/ceilometer/cmd/api.py @@ -0,0 +1,23 @@ +# +# Copyright 2012 New Dream Network, LLC (DreamHost) +# Copyright 2015-2016 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +from ceilometer.api import app +from ceilometer import service + + +def build_wsgi_app(argv=None): + return app.load_app(service.prepare_service(argv=argv)) diff --git a/ceilometer/cmd/polling.py b/ceilometer/cmd/polling.py index 285a91d585..d6b949e8ed 100644 --- a/ceilometer/cmd/polling.py +++ b/ceilometer/cmd/polling.py @@ -24,8 +24,6 @@ from ceilometer import service LOG = log.getLogger(__name__) -CONF = cfg.CONF - class MultiChoicesOpt(cfg.Opt): def __init__(self, name, choices=None, **kwargs): @@ -75,8 +73,6 @@ CLI_OPTS = [ 'used while polling'), ] -CONF.register_cli_opts(CLI_OPTS) - def create_polling_service(worker_id, conf): return manager.AgentManager(worker_id, @@ -86,7 +82,9 @@ def create_polling_service(worker_id, conf): def main(): - conf = service.prepare_service() + conf = cfg.ConfigOpts() + conf.register_cli_opts(CLI_OPTS) + service.prepare_service(conf=conf) sm = cotyledon.ServiceManager() sm.add(create_polling_service, args=(conf,)) sm.run() diff --git a/ceilometer/cmd/sample.py b/ceilometer/cmd/sample.py index e96c385bd4..639f0e6f27 100644 --- a/ceilometer/cmd/sample.py +++ b/ceilometer/cmd/sample.py @@ -29,7 +29,8 @@ from ceilometer import service def send_sample(): - cfg.CONF.register_cli_opts([ + conf = cfg.ConfigOpts() + conf.register_cli_opts([ cfg.StrOpt('sample-name', short='n', help='Meter name.', @@ -65,7 +66,7 @@ def send_sample(): help='Meter metadata.'), ]) - conf = service.prepare_service() + service.prepare_service(conf=conf) # Set up logging to use the console console = logging.StreamHandler(sys.stderr) diff --git a/ceilometer/cmd/storage.py b/ceilometer/cmd/storage.py index 80777282ae..01c83095a3 100644 --- a/ceilometer/cmd/storage.py +++ b/ceilometer/cmd/storage.py @@ -28,8 +28,7 @@ LOG = log.getLogger(__name__) def upgrade(): - # FIXME(sileht): Use cfg.ConfigOpts() - conf = cfg.CONF + conf = cfg.ConfigOpts() conf.register_cli_opts([ cfg.BoolOpt('skip-metering-database', help='Skip metering database upgrade.', @@ -86,8 +85,7 @@ def expirer(): def db_clean_legacy(): - # FIXME(sileht): Use cfg.ConfigOpts() - conf = cfg.CONF + conf = cfg.ConfigOpts() conf.register_cli_opts([ cfg.strOpt('confirm-drop-alarm-table', short='n', diff --git a/ceilometer/collector.py b/ceilometer/collector.py index 0f6731fc2c..4537a5b6b5 100644 --- a/ceilometer/collector.py +++ b/ceilometer/collector.py @@ -46,15 +46,15 @@ OPTS = [ cfg.IntOpt('batch_timeout', help='Number of seconds to wait before dispatching samples' 'when batch_size is not reached (None means indefinitely)'), + cfg.IntOpt('workers', + default=1, + min=1, + deprecated_group='DEFAULT', + deprecated_name='collector_workers', + help='Number of workers for collector service. ' + 'default value is 1.') ] -cfg.CONF.register_opts(OPTS, group="collector") -cfg.CONF.import_opt('metering_topic', 'ceilometer.publisher.messaging', - group='publisher_notifier') -cfg.CONF.import_opt('event_topic', 'ceilometer.publisher.messaging', - group='publisher_notifier') - - LOG = log.getLogger(__name__) diff --git a/ceilometer/compute/discovery.py b/ceilometer/compute/discovery.py index eb25531382..50980a1b31 100644 --- a/ceilometer/compute/discovery.py +++ b/ceilometer/compute/discovery.py @@ -36,7 +36,6 @@ OPTS = [ "to the instances will match intervals " "defined in pipeline.") ] -cfg.CONF.register_opts(OPTS, group='compute') class InstanceDiscovery(plugin_base.DiscoveryBase): diff --git a/ceilometer/compute/util.py b/ceilometer/compute/util.py index 9e85b16c15..94b18a1b8c 100644 --- a/ceilometer/compute/util.py +++ b/ceilometer/compute/util.py @@ -34,8 +34,6 @@ OPTS = [ 'namespace.'), ] -cfg.CONF.register_opts(OPTS) - def add_reserved_user_metadata(conf, src_metadata, dest_metadata): limit = conf.reserved_metadata_length diff --git a/ceilometer/compute/virt/inspector.py b/ceilometer/compute/virt/inspector.py index 3401008bd2..dfbe09e1e8 100644 --- a/ceilometer/compute/virt/inspector.py +++ b/ceilometer/compute/virt/inspector.py @@ -32,8 +32,6 @@ OPTS = [ 'and powervm.'), ] -cfg.CONF.register_opts(OPTS) - LOG = log.getLogger(__name__) diff --git a/ceilometer/compute/virt/libvirt/inspector.py b/ceilometer/compute/virt/libvirt/inspector.py index 3087f0bf15..44310a9531 100644 --- a/ceilometer/compute/virt/libvirt/inspector.py +++ b/ceilometer/compute/virt/libvirt/inspector.py @@ -39,9 +39,6 @@ OPTS = [ '(which is dependent on libvirt_type).'), ] -CONF = cfg.CONF -CONF.register_opts(OPTS) - def retry_on_disconnect(function): def decorator(self, *args, **kwargs): diff --git a/ceilometer/compute/virt/vmware/inspector.py b/ceilometer/compute/virt/vmware/inspector.py index ba08808d4e..5998bcecc6 100644 --- a/ceilometer/compute/virt/vmware/inspector.py +++ b/ceilometer/compute/virt/vmware/inspector.py @@ -65,9 +65,6 @@ OPTS = [ 'work-arounds.'), ] -cfg.CONF.register_group(opt_group) -cfg.CONF.register_opts(OPTS, group=opt_group) - VC_AVERAGE_MEMORY_CONSUMED_CNTR = 'mem:consumed:average' VC_AVERAGE_CPU_CONSUMED_CNTR = 'cpu:usage:average' VC_NETWORK_RX_COUNTER = 'net:received:average' diff --git a/ceilometer/compute/virt/xenapi/inspector.py b/ceilometer/compute/virt/xenapi/inspector.py index 45da31f220..67d442a376 100644 --- a/ceilometer/compute/virt/xenapi/inspector.py +++ b/ceilometer/compute/virt/xenapi/inspector.py @@ -40,10 +40,6 @@ OPTS = [ secret=True), ] -CONF = cfg.CONF -CONF.register_group(opt_group) -CONF.register_opts(OPTS, group=opt_group) - class XenapiException(virt_inspector.InspectorException): pass diff --git a/ceilometer/coordination.py b/ceilometer/coordination.py index 8118b2e613..324afe1a8c 100644 --- a/ceilometer/coordination.py +++ b/ceilometer/coordination.py @@ -50,7 +50,6 @@ OPTS = [ help='Maximum number of seconds between retry to join ' 'partitioning group') ] -cfg.CONF.register_opts(OPTS, group='coordination') class ErrorJoiningPartitioningGroup(Exception): diff --git a/ceilometer/dispatcher/__init__.py b/ceilometer/dispatcher/__init__.py index cfda7f89e6..98d1e79956 100644 --- a/ceilometer/dispatcher/__init__.py +++ b/ceilometer/dispatcher/__init__.py @@ -35,7 +35,6 @@ OPTS = [ deprecated_name='dispatcher', help='Dispatchers to process event data.'), ] -cfg.CONF.register_opts(OPTS) STORAGE_OPTS = [ cfg.IntOpt('max_retries', @@ -48,7 +47,6 @@ STORAGE_OPTS = [ deprecated_group='database', help='Interval (in seconds) between retries of connection.'), ] -cfg.CONF.register_opts(STORAGE_OPTS, group='storage') def _load_dispatcher_manager(conf, dispatcher_type): diff --git a/ceilometer/dispatcher/file.py b/ceilometer/dispatcher/file.py index b5675c1506..cb7683cc73 100644 --- a/ceilometer/dispatcher/file.py +++ b/ceilometer/dispatcher/file.py @@ -33,8 +33,6 @@ OPTS = [ help='The max number of the files to keep.'), ] -cfg.CONF.register_opts(OPTS, group="dispatcher_file") - @removals.removed_class("FileDispatcher", message="Use file publisher instead", removal_version="9.0.0") diff --git a/ceilometer/dispatcher/gnocchi.py b/ceilometer/dispatcher/gnocchi.py index e5bacbbdd3..76caf7453a 100644 --- a/ceilometer/dispatcher/gnocchi.py +++ b/ceilometer/dispatcher/gnocchi.py @@ -24,7 +24,6 @@ import uuid from gnocchiclient import exceptions as gnocchi_exc from gnocchiclient import utils as gnocchi_utils from keystoneauth1 import exceptions as ka_exceptions -from oslo_config import cfg from oslo_log import log from oslo_serialization import jsonutils from oslo_utils import fnmatch @@ -35,7 +34,7 @@ import tenacity from ceilometer import declarative from ceilometer import dispatcher -from ceilometer.i18n import _, _LE, _LW +from ceilometer.i18n import _LE, _LW from ceilometer import gnocchi_client from ceilometer import keystone_client @@ -43,26 +42,6 @@ NAME_ENCODED = __name__.encode('utf-8') CACHE_NAMESPACE = uuid.UUID(bytes=hashlib.md5(NAME_ENCODED).digest()) LOG = log.getLogger(__name__) -dispatcher_opts = [ - cfg.BoolOpt('filter_service_activity', - default=True, - help='Filter out samples generated by Gnocchi ' - 'service activity'), - cfg.StrOpt('filter_project', - default='gnocchi', - help='Gnocchi project used to filter out samples ' - 'generated by Gnocchi service activity'), - cfg.StrOpt('archive_policy', - help='The archive policy to use when the dispatcher ' - 'create a new metric.'), - cfg.StrOpt('resources_definition_file', - default='gnocchi_resources.yaml', - help=_('The Yaml file that defines mapping between samples ' - 'and gnocchi resources/metrics')), -] - -cfg.CONF.register_opts(dispatcher_opts, group="dispatcher_gnocchi") - def cache_key_mangler(key): """Construct an opaque cache key.""" diff --git a/ceilometer/dispatcher/gnocchi_opts.py b/ceilometer/dispatcher/gnocchi_opts.py new file mode 100644 index 0000000000..66ba98061d --- /dev/null +++ b/ceilometer/dispatcher/gnocchi_opts.py @@ -0,0 +1,32 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo_config import cfg + + +dispatcher_opts = [ + cfg.BoolOpt('filter_service_activity', + default=True, + help='Filter out samples generated by Gnocchi ' + 'service activity'), + cfg.StrOpt('filter_project', + default='gnocchi', + help='Gnocchi project used to filter out samples ' + 'generated by Gnocchi service activity'), + cfg.StrOpt('archive_policy', + help='The archive policy to use when the dispatcher ' + 'create a new metric.'), + cfg.StrOpt('resources_definition_file', + default='gnocchi_resources.yaml', + help=('The Yaml file that defines mapping between samples ' + 'and gnocchi resources/metrics')), +] diff --git a/ceilometer/dispatcher/http.py b/ceilometer/dispatcher/http.py index 8e1ed192ec..86f3309916 100644 --- a/ceilometer/dispatcher/http.py +++ b/ceilometer/dispatcher/http.py @@ -47,8 +47,6 @@ http_dispatcher_opts = [ help='Indicates whether samples are published in a batch.'), ] -cfg.CONF.register_opts(http_dispatcher_opts, group="dispatcher_http") - class HttpDispatcher(dispatcher.MeterDispatcherBase, dispatcher.EventDispatcherBase): diff --git a/ceilometer/energy/kwapi.py b/ceilometer/energy/kwapi.py index f62fb81dbe..abe73ae162 100644 --- a/ceilometer/energy/kwapi.py +++ b/ceilometer/energy/kwapi.py @@ -31,8 +31,6 @@ SERVICE_OPTS = [ help='Kwapi service type.'), ] -cfg.CONF.register_opts(SERVICE_OPTS, group='service_types') - class KwapiClient(object): """Kwapi API client.""" diff --git a/ceilometer/event/converter.py b/ceilometer/event/converter.py index 5b9a762484..4bf514b9b8 100644 --- a/ceilometer/event/converter.py +++ b/ceilometer/event/converter.py @@ -39,8 +39,6 @@ OPTS = [ 'not captured.') ] -cfg.CONF.register_opts(OPTS, group='event') - LOG = log.getLogger(__name__) diff --git a/ceilometer/exchange_control.py b/ceilometer/exchange_control.py index c8acc8faef..5a7a8cc9d4 100644 --- a/ceilometer/exchange_control.py +++ b/ceilometer/exchange_control.py @@ -50,4 +50,7 @@ EXCHANGE_OPTS = [ cfg.StrOpt('dns_control_exchange', default='central', help="Exchange name for DNS service notifications."), + cfg.StrOpt('ceilometer_control_exchange', + default='ceilometer', + help="Exchange name for ceilometer notifications."), ] diff --git a/ceilometer/gnocchi_client.py b/ceilometer/gnocchi_client.py index 1e3deabe9d..956445a4b6 100644 --- a/ceilometer/gnocchi_client.py +++ b/ceilometer/gnocchi_client.py @@ -26,8 +26,6 @@ OPTS = [ help='URL to Gnocchi. default: autodetection'), ] -cfg.CONF.register_opts(OPTS, group="dispatcher_gnocchi") - def get_gnocchiclient(conf, endpoint_override=None): session = keystone_client.get_session(conf) diff --git a/ceilometer/hardware/discovery.py b/ceilometer/hardware/discovery.py index 5903c6d9da..0bfc72784b 100644 --- a/ceilometer/hardware/discovery.py +++ b/ceilometer/hardware/discovery.py @@ -50,8 +50,6 @@ OPTS = [ ] -CONF = cfg.CONF -CONF.register_opts(OPTS, group='hardware') class NodesDiscoveryTripleO(plugin_base.DiscoveryBase): diff --git a/ceilometer/hardware/pollsters/generic.py b/ceilometer/hardware/pollsters/generic.py index 33393e76a8..22e65a8f7a 100644 --- a/ceilometer/hardware/pollsters/generic.py +++ b/ceilometer/hardware/pollsters/generic.py @@ -35,8 +35,6 @@ OPTS = [ ), ] -cfg.CONF.register_opts(OPTS, group='hardware') - LOG = log.getLogger(__name__) diff --git a/ceilometer/image/discovery.py b/ceilometer/image/discovery.py index e3bf102c4b..5dcf4757cb 100644 --- a/ceilometer/image/discovery.py +++ b/ceilometer/image/discovery.py @@ -23,9 +23,6 @@ SERVICE_OPTS = [ help='Glance service type.'), ] -cfg.CONF.register_opts(SERVICE_OPTS, group='service_types') -cfg.CONF.import_group('service_credentials', 'ceilometer.keystone_client') - class ImagesDiscovery(plugin_base.DiscoveryBase): def __init__(self, conf): diff --git a/ceilometer/ipmi/notifications/ironic.py b/ceilometer/ipmi/notifications/ironic.py index 51a00fef1a..58e8dc1b96 100644 --- a/ceilometer/ipmi/notifications/ironic.py +++ b/ceilometer/ipmi/notifications/ironic.py @@ -32,9 +32,6 @@ OPTS = [ ] -cfg.CONF.register_opts(OPTS) - - # Map unit name to SI UNIT_MAP = { 'Watts': 'W', diff --git a/ceilometer/ipmi/platform/intel_node_manager.py b/ceilometer/ipmi/platform/intel_node_manager.py index 7278345abb..9f06ec568b 100644 --- a/ceilometer/ipmi/platform/intel_node_manager.py +++ b/ceilometer/ipmi/platform/intel_node_manager.py @@ -43,9 +43,6 @@ OPTS = [ ] -CONF = cfg.CONF -CONF.register_opts(OPTS, group='ipmi') - IPMICMD = {"sdr_dump": "sdr dump", "sdr_info": "sdr info", "sensor_dump": "sdr -v"} diff --git a/ceilometer/ipmi/pollsters/__init__.py b/ceilometer/ipmi/pollsters/__init__.py index 9ebbf230ef..a51f708a78 100644 --- a/ceilometer/ipmi/pollsters/__init__.py +++ b/ceilometer/ipmi/pollsters/__init__.py @@ -25,5 +25,3 @@ OPTS = [ 'before disable this pollster. ' 'Negative indicates retrying forever.') ] - -cfg.CONF.register_opts(OPTS, group='ipmi') diff --git a/ceilometer/ipmi/pollsters/node.py b/ceilometer/ipmi/pollsters/node.py index 8e16be7dfb..639858268c 100644 --- a/ceilometer/ipmi/pollsters/node.py +++ b/ceilometer/ipmi/pollsters/node.py @@ -14,7 +14,6 @@ import abc -from oslo_config import cfg from oslo_log import log import six @@ -24,10 +23,6 @@ from ceilometer.ipmi.platform import exception as nmexcept from ceilometer.ipmi.platform import intel_node_manager as node_manager from ceilometer import sample -cfg.CONF.import_opt('host', 'ceilometer.service') -cfg.CONF.import_opt('polling_retry', 'ceilometer.ipmi.pollsters', - group='ipmi') - LOG = log.getLogger(__name__) diff --git a/ceilometer/ipmi/pollsters/sensor.py b/ceilometer/ipmi/pollsters/sensor.py index ab970c7041..107d160fbb 100644 --- a/ceilometer/ipmi/pollsters/sensor.py +++ b/ceilometer/ipmi/pollsters/sensor.py @@ -12,7 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg from oslo_log import log from ceilometer.agent import plugin_base @@ -22,10 +21,6 @@ from ceilometer.ipmi.platform import exception as ipmiexcept from ceilometer.ipmi.platform import ipmi_sensor from ceilometer import sample -cfg.CONF.import_opt('host', 'ceilometer.service') -cfg.CONF.import_opt('polling_retry', 'ceilometer.ipmi.pollsters', - group='ipmi') - LOG = log.getLogger(__name__) diff --git a/ceilometer/keystone_client.py b/ceilometer/keystone_client.py index 8a24986ae1..fabba2bb75 100644 --- a/ceilometer/keystone_client.py +++ b/ceilometer/keystone_client.py @@ -62,8 +62,6 @@ CLI_OPTS = [ 'communication with OpenStack services.'), ] -cfg.CONF.register_cli_opts(CLI_OPTS, group=CFG_GROUP) - def register_keystoneauth_opts(conf): ka_loading.register_auth_conf_options(conf, CFG_GROUP) diff --git a/ceilometer/meter/notifications.py b/ceilometer/meter/notifications.py index 4ce687de7c..438c2caca8 100644 --- a/ceilometer/meter/notifications.py +++ b/ceilometer/meter/notifications.py @@ -33,10 +33,6 @@ OPTS = [ ), ] -cfg.CONF.register_opts(OPTS, group='meter') -cfg.CONF.import_opt('disable_non_metric_meters', 'ceilometer.notification', - group='notification') - LOG = log.getLogger(__name__) diff --git a/ceilometer/middleware.py b/ceilometer/middleware.py index 0cf6ca76c0..03ab4e4e9e 100644 --- a/ceilometer/middleware.py +++ b/ceilometer/middleware.py @@ -32,8 +32,6 @@ OPTS = [ help="Exchanges name to listen for notifications."), ] -cfg.CONF.register_opts(OPTS) - class HTTPRequest(plugin_base.NotificationBase, plugin_base.NonMetricNotificationBase): diff --git a/ceilometer/network/floatingip.py b/ceilometer/network/floatingip.py index ce178704a1..b64c642964 100644 --- a/ceilometer/network/floatingip.py +++ b/ceilometer/network/floatingip.py @@ -16,7 +16,6 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg from oslo_log import log from ceilometer.i18n import _LW @@ -25,8 +24,6 @@ from ceilometer import sample LOG = log.getLogger(__name__) -cfg.CONF.import_group('service_types', 'ceilometer.neutron_client') - class FloatingIPPollster(base.BaseServicesPollster): diff --git a/ceilometer/network/statistics/opencontrail/client.py b/ceilometer/network/statistics/opencontrail/client.py index 5a3f623cfb..f2f79651db 100644 --- a/ceilometer/network/statistics/opencontrail/client.py +++ b/ceilometer/network/statistics/opencontrail/client.py @@ -14,7 +14,6 @@ import copy -from oslo_config import cfg from oslo_log import log import requests import six @@ -23,10 +22,6 @@ from six.moves.urllib import parse as urlparse from ceilometer.i18n import _ -CONF = cfg.CONF -CONF.import_opt('http_timeout', 'ceilometer.service') - - LOG = log.getLogger(__name__) diff --git a/ceilometer/network/statistics/opendaylight/client.py b/ceilometer/network/statistics/opendaylight/client.py index 26d9a36b72..30379d1491 100644 --- a/ceilometer/network/statistics/opendaylight/client.py +++ b/ceilometer/network/statistics/opendaylight/client.py @@ -15,7 +15,6 @@ import abc -from oslo_config import cfg from oslo_log import log import requests from requests import auth @@ -24,10 +23,6 @@ import six from ceilometer.i18n import _ -CONF = cfg.CONF -CONF.import_opt('http_timeout', 'ceilometer.service') - - LOG = log.getLogger(__name__) diff --git a/ceilometer/neutron_client.py b/ceilometer/neutron_client.py index 9e0df33952..3e66671ca9 100644 --- a/ceilometer/neutron_client.py +++ b/ceilometer/neutron_client.py @@ -31,9 +31,6 @@ SERVICE_OPTS = [ help='Neutron load balancer version.') ] -cfg.CONF.register_opts(SERVICE_OPTS, group='service_types') -cfg.CONF.import_group('service_credentials', 'ceilometer.keystone_client') - LOG = log.getLogger(__name__) diff --git a/ceilometer/notification.py b/ceilometer/notification.py index b2dc3c8213..644cee5464 100644 --- a/ceilometer/notification.py +++ b/ceilometer/notification.py @@ -25,7 +25,6 @@ from stevedore import extension from ceilometer.agent import plugin_base as base from ceilometer import coordination from ceilometer.event import endpoint as event_endpoint -from ceilometer import exchange_control from ceilometer.i18n import _, _LI, _LW from ceilometer import messaging from ceilometer import pipeline @@ -78,13 +77,15 @@ OPTS = [ default=5, help='Number of seconds to wait before publishing samples' 'when batch_size is not reached (None means indefinitely)'), + cfg.IntOpt('workers', + default=1, + min=1, + deprecated_group='DEFAULT', + deprecated_name='notification_workers', + help='Number of workers for notification service, ' + 'default value is 1.') ] -cfg.CONF.register_opts(exchange_control.EXCHANGE_OPTS) -cfg.CONF.register_opts(OPTS, group="notification") -cfg.CONF.import_opt('telemetry_driver', 'ceilometer.publisher.messaging', - group='publisher_notifier') - class NotificationService(service_base.PipelineBasedService): """Notification service. diff --git a/ceilometer/nova_client.py b/ceilometer/nova_client.py index b318884f3d..3a74052922 100644 --- a/ceilometer/nova_client.py +++ b/ceilometer/nova_client.py @@ -37,12 +37,6 @@ SERVICE_OPTS = [ help='Nova service type.'), ] -cfg.CONF.register_opts(OPTS) -cfg.CONF.register_opts(SERVICE_OPTS, group='service_types') -cfg.CONF.import_opt('http_timeout', 'ceilometer.service') -cfg.CONF.import_opt('glance', 'ceilometer.image.discovery', 'service_types') -cfg.CONF.import_group('service_credentials', 'ceilometer.keystone_client') - LOG = log.getLogger(__name__) diff --git a/ceilometer/objectstore/rgw.py b/ceilometer/objectstore/rgw.py index c175a7045b..d372b67418 100644 --- a/ceilometer/objectstore/rgw.py +++ b/ceilometer/objectstore/rgw.py @@ -41,10 +41,6 @@ CREDENTIAL_OPTS = [ help='Secret key for Radosgw Admin.') ] -cfg.CONF.register_opts(SERVICE_OPTS, group='service_types') -cfg.CONF.register_opts(CREDENTIAL_OPTS, group='rgw_admin_credentials') -cfg.CONF.import_group('rgw_admin_credentials', 'ceilometer.service') - class _Base(plugin_base.PollsterBase): METHOD = 'bucket' diff --git a/ceilometer/objectstore/swift.py b/ceilometer/objectstore/swift.py index 6e888855b4..c04e87a4ef 100644 --- a/ceilometer/objectstore/swift.py +++ b/ceilometer/objectstore/swift.py @@ -44,10 +44,6 @@ SERVICE_OPTS = [ help='Swift service type.'), ] -cfg.CONF.register_opts(OPTS) -cfg.CONF.register_opts(SERVICE_OPTS, group='service_types') -cfg.CONF.import_group('service_credentials', 'ceilometer.keystone_client') - class _Base(plugin_base.PollsterBase): diff --git a/ceilometer/opts.py b/ceilometer/opts.py index e28b13ddf5..c0ad2211f7 100644 --- a/ceilometer/opts.py +++ b/ceilometer/opts.py @@ -12,12 +12,14 @@ # License for the specific language governing permissions and limitations # under the License. import itertools +import socket from keystoneauth1 import loading +from oslo_config import cfg import ceilometer.agent.manager import ceilometer.api.app -import ceilometer.cmd.polling +import ceilometer.api.controllers.v2.root import ceilometer.collector import ceilometer.compute.discovery import ceilometer.compute.util @@ -28,10 +30,13 @@ import ceilometer.compute.virt.xenapi.inspector import ceilometer.coordination import ceilometer.dispatcher import ceilometer.dispatcher.file -import ceilometer.dispatcher.gnocchi +import ceilometer.dispatcher.gnocchi_opts +import ceilometer.dispatcher.http import ceilometer.energy.kwapi import ceilometer.event.converter +import ceilometer.exchange_control import ceilometer.hardware.discovery +import ceilometer.hardware.pollsters.generic import ceilometer.image.discovery import ceilometer.ipmi.notifications.ironic import ceilometer.ipmi.platform.intel_node_manager @@ -48,18 +53,32 @@ import ceilometer.pipeline import ceilometer.publisher.messaging import ceilometer.publisher.utils import ceilometer.sample -import ceilometer.service import ceilometer.storage import ceilometer.utils import ceilometer.volume.discovery +OPTS = [ + cfg.StrOpt('host', + default=socket.gethostname(), + sample_default='', + help='Name of this node, which must be valid in an AMQP ' + 'key. Can be an opaque identifier. For ZeroMQ only, must ' + 'be a valid host name, FQDN, or IP address.'), + cfg.IntOpt('http_timeout', + default=600, + help='Timeout seconds for HTTP requests. Set it to None to ' + 'disable timeout.'), +] + + def list_opts(): + # FIXME(sileht): readd pollster namespaces in the generated configfile + # This have been removed due to a recursive import issue return [ ('DEFAULT', itertools.chain(ceilometer.agent.manager.OPTS, ceilometer.api.app.OPTS, - ceilometer.cmd.polling.CLI_OPTS, ceilometer.compute.util.OPTS, ceilometer.compute.virt.inspector.OPTS, ceilometer.compute.virt.libvirt.inspector.OPTS, @@ -70,27 +89,28 @@ def list_opts(): ceilometer.objectstore.swift.OPTS, ceilometer.pipeline.OPTS, ceilometer.sample.OPTS, - ceilometer.service.OPTS, - ceilometer.utils.OPTS,)), - ('api', ceilometer.api.app.API_OPTS), - ('collector', - itertools.chain(ceilometer.collector.OPTS, - [ceilometer.service.COLL_OPT])), + ceilometer.utils.OPTS, + ceilometer.exchange_control.EXCHANGE_OPTS, + OPTS)), + ('api', itertools.chain(ceilometer.api.app.API_OPTS, + ceilometer.api.controllers.v2.root.API_OPTS)), + ('collector', ceilometer.collector.OPTS), ('compute', ceilometer.compute.discovery.OPTS), ('coordination', ceilometer.coordination.OPTS), ('database', ceilometer.storage.OPTS), ('dispatcher_file', ceilometer.dispatcher.file.OPTS), - ('dispatcher_gnocchi', ceilometer.dispatcher.gnocchi.dispatcher_opts), + ('dispatcher_http', ceilometer.dispatcher.http.http_dispatcher_opts), + ('dispatcher_gnocchi', + ceilometer.dispatcher.gnocchi_opts.dispatcher_opts), ('event', ceilometer.event.converter.OPTS), - ('exchange_control', ceilometer.exchange_control.EXCHANGE_OPTS), - ('hardware', ceilometer.hardware.discovery.OPTS), + ('hardware', itertools.chain( + ceilometer.hardware.discovery.OPTS, + ceilometer.hardware.pollsters.generic.OPTS)), ('ipmi', itertools.chain(ceilometer.ipmi.platform.intel_node_manager.OPTS, ceilometer.ipmi.pollsters.OPTS)), ('meter', ceilometer.meter.notifications.OPTS), - ('notification', - itertools.chain(ceilometer.notification.OPTS, - [ceilometer.service.NOTI_OPT])), + ('notification', ceilometer.notification.OPTS), ('polling', ceilometer.agent.manager.POLLING_OPTS), ('publisher', ceilometer.publisher.utils.OPTS), ('publisher_notifier', ceilometer.publisher.messaging.NOTIFIER_OPTS), @@ -98,10 +118,7 @@ def list_opts(): # NOTE(sileht): the configuration file contains only the options # for the password plugin that handles keystone v2 and v3 API # with discovery. But other options are possible. - ('service_credentials', ( - ceilometer.keystone_client.CLI_OPTS + - loading.get_auth_common_conf_options() + - loading.get_auth_plugin_conf_options('password'))), + ('service_credentials', ceilometer.keystone_client.CLI_OPTS), ('service_types', itertools.chain(ceilometer.energy.kwapi.SERVICE_OPTS, ceilometer.image.discovery.SERVICE_OPTS, @@ -114,3 +131,12 @@ def list_opts(): ('vmware', ceilometer.compute.virt.vmware.inspector.OPTS), ('xenapi', ceilometer.compute.virt.xenapi.inspector.OPTS), ] + + +def list_keystoneauth_opts(): + # NOTE(sileht): the configuration file contains only the options + # for the password plugin that handles keystone v2 and v3 API + # with discovery. But other options are possible. + return [('service_credentials', ( + loading.get_auth_common_conf_options() + + loading.get_auth_plugin_conf_options('password')))] diff --git a/ceilometer/pipeline.py b/ceilometer/pipeline.py index 9be464bc72..e35299c661 100644 --- a/ceilometer/pipeline.py +++ b/ceilometer/pipeline.py @@ -61,8 +61,6 @@ OPTS = [ ), ] -cfg.CONF.register_opts(OPTS) - LOG = log.getLogger(__name__) diff --git a/ceilometer/publisher/messaging.py b/ceilometer/publisher/messaging.py index e691ebd780..516e32a194 100644 --- a/ceilometer/publisher/messaging.py +++ b/ceilometer/publisher/messaging.py @@ -54,10 +54,6 @@ NOTIFIER_OPTS = [ ) ] -cfg.CONF.register_opts(NOTIFIER_OPTS, - group="publisher_notifier") -cfg.CONF.import_opt('host', 'ceilometer.service') - class DeliveryFailure(Exception): def __init__(self, message=None, cause=None): diff --git a/ceilometer/publisher/udp.py b/ceilometer/publisher/udp.py index 4f905b99bc..605b77e395 100644 --- a/ceilometer/publisher/udp.py +++ b/ceilometer/publisher/udp.py @@ -18,7 +18,6 @@ import socket import msgpack -from oslo_config import cfg from oslo_log import log from oslo_utils import netutils @@ -27,9 +26,6 @@ from ceilometer.i18n import _, _LW from ceilometer import publisher from ceilometer.publisher import utils -cfg.CONF.import_opt('udp_port', 'ceilometer.collector', - group='collector') - LOG = log.getLogger(__name__) diff --git a/ceilometer/publisher/utils.py b/ceilometer/publisher/utils.py index 50f4ae89af..6db55a4f23 100644 --- a/ceilometer/publisher/utils.py +++ b/ceilometer/publisher/utils.py @@ -38,7 +38,6 @@ OPTS = [ "publisher")] ), ] -cfg.CONF.register_opts(OPTS, group="publisher") def compute_signature(message, secret): diff --git a/ceilometer/sample.py b/ceilometer/sample.py index c19c9cf0bb..bcd25bf5cb 100644 --- a/ceilometer/sample.py +++ b/ceilometer/sample.py @@ -32,8 +32,6 @@ OPTS = [ help='Source for samples emitted on this instance.'), ] -cfg.CONF.register_opts(OPTS) - # Fields explanation: # diff --git a/ceilometer/service.py b/ceilometer/service.py index 61eaaf4fd5..c9062e6b5e 100644 --- a/ceilometer/service.py +++ b/ceilometer/service.py @@ -12,7 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -import socket import sys from keystoneauth1 import loading as ka_loading @@ -26,52 +25,23 @@ from oslo_reports import guru_meditation_report as gmr from ceilometer.conf import defaults from ceilometer import keystone_client from ceilometer import messaging +from ceilometer import opts from ceilometer import sample from ceilometer import utils from ceilometer import version -OPTS = [ - cfg.StrOpt('host', - default=socket.gethostname(), - sample_default='', - help='Name of this node, which must be valid in an AMQP ' - 'key. Can be an opaque identifier. For ZeroMQ only, must ' - 'be a valid host name, FQDN, or IP address.'), - cfg.IntOpt('http_timeout', - default=600, - help='Timeout seconds for HTTP requests. Set it to None to ' - 'disable timeout.'), -] -cfg.CONF.register_opts(OPTS) - -NOTI_OPT = cfg.IntOpt('workers', - default=1, - min=1, - deprecated_group='DEFAULT', - deprecated_name='notification_workers', - help='Number of workers for notification service, ' - 'default value is 1.') -cfg.CONF.register_opt(NOTI_OPT, 'notification') - -COLL_OPT = cfg.IntOpt('workers', - default=1, - min=1, - deprecated_group='DEFAULT', - deprecated_name='collector_workers', - help='Number of workers for collector service. ' - 'default value is 1.') -cfg.CONF.register_opt(COLL_OPT, 'collector') - def prepare_service(argv=None, config_files=None, conf=None): if argv is None: argv = sys.argv - # FIXME(sileht): Use ConfigOpts() instead if conf is None: - conf = cfg.CONF + conf = cfg.ConfigOpts() oslo_i18n.enable_lazy() + for group, options in opts.list_opts(): + conf.register_opts(list(options), + group=None if group == "DEFAULT" else group) keystone_client.register_keystoneauth_opts(conf) log.register_options(conf) log_levels = (conf.default_log_levels + diff --git a/ceilometer/storage/__init__.py b/ceilometer/storage/__init__.py index d3d6ac1217..165bc13c39 100644 --- a/ceilometer/storage/__init__.py +++ b/ceilometer/storage/__init__.py @@ -53,8 +53,6 @@ OPTS = [ " resource and meter definition data will remain."), ] -cfg.CONF.register_opts(OPTS, group='database') - class StorageUnknownWriteError(Exception): """Error raised when an unknown error occurs while recording.""" diff --git a/ceilometer/telemetry/notifications.py b/ceilometer/telemetry/notifications.py index db825ac02b..9cd9072091 100644 --- a/ceilometer/telemetry/notifications.py +++ b/ceilometer/telemetry/notifications.py @@ -11,21 +11,11 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg import oslo_messaging from ceilometer.agent import plugin_base from ceilometer import sample -OPTS = [ - cfg.StrOpt('ceilometer_control_exchange', - default='ceilometer', - help="Exchange name for ceilometer notifications."), -] - - -cfg.CONF.register_opts(OPTS) - class TelemetryBase(plugin_base.NotificationBase): """Convert telemetry notification into Samples.""" diff --git a/ceilometer/tests/db.py b/ceilometer/tests/db.py index cef5c148c2..65348b8bb8 100644 --- a/ceilometer/tests/db.py +++ b/ceilometer/tests/db.py @@ -191,8 +191,8 @@ class TestBase(test_base.BaseTestCase): raise testcase.TestSkipped( 'Test is not applicable for %s' % engine) - self.CONF = self.useFixture(fixture_config.Config()).conf - service.prepare_service([], [], self.CONF) + conf = service.prepare_service([], []) + self.CONF = self.useFixture(fixture_config.Config(conf)).conf manager = self.DRIVER_MANAGERS.get(engine) if not manager: diff --git a/ceilometer/tests/functional/api/__init__.py b/ceilometer/tests/functional/api/__init__.py index 5de6d80445..c774d6d097 100644 --- a/ceilometer/tests/functional/api/__init__.py +++ b/ceilometer/tests/functional/api/__init__.py @@ -15,16 +15,13 @@ """Base classes for API tests. """ -from oslo_config import cfg from oslo_config import fixture as fixture_config -from oslo_policy import opts import pecan import pecan.testing +from ceilometer import service from ceilometer.tests import db as db_test_base -cfg.CONF.import_group('api', 'ceilometer.api.controllers.v2.root') - class FunctionalTest(db_test_base.TestBase): """Used for functional tests of Pecan controllers. @@ -37,9 +34,9 @@ class FunctionalTest(db_test_base.TestBase): def setUp(self): super(FunctionalTest, self).setUp() - self.CONF = self.useFixture(fixture_config.Config()).conf + conf = service.prepare_service([], []) + self.CONF = self.useFixture(fixture_config.Config(conf)).conf self.setup_messaging(self.CONF) - opts.set_defaults(self.CONF) self.CONF.set_override("policy_file", self.path_get('etc/ceilometer/policy.json'), diff --git a/ceilometer/tests/functional/gabbi/fixtures.py b/ceilometer/tests/functional/gabbi/fixtures.py index f30976c406..5a0823b620 100644 --- a/ceilometer/tests/functional/gabbi/fixtures.py +++ b/ceilometer/tests/functional/gabbi/fixtures.py @@ -24,7 +24,6 @@ import uuid from gabbi import fixture from oslo_config import cfg from oslo_config import fixture as fixture_config -from oslo_policy import opts from oslo_utils import fileutils import six from six.moves.urllib import parse as urlparse @@ -33,6 +32,7 @@ from ceilometer.api import app from ceilometer.event.storage import models from ceilometer.publisher import utils from ceilometer import sample +from ceilometer import service from ceilometer import storage # TODO(chdent): For now only MongoDB is supported, because of easy @@ -72,11 +72,9 @@ class ConfigFixture(fixture.GabbiFixture): if engine not in ENGINES: raise case.SkipTest('Database engine not supported') - conf = fixture_config.Config().conf + conf = service.prepare_service([], []) + conf = fixture_config.Config(conf).conf self.conf = conf - self.conf([], project='ceilometer', validate_default_values=True) - opts.set_defaults(self.conf) - conf.import_group('api', 'ceilometer.api.controllers.v2.root') content = ('{"default": ""}') if six.PY3: @@ -94,7 +92,6 @@ class ConfigFixture(fixture.GabbiFixture): ) # A special pipeline is required to use the direct publisher. - conf.import_opt('pipeline_cfg_file', 'ceilometer.pipeline') conf.set_override('pipeline_cfg_file', 'ceilometer/tests/functional/gabbi_pipeline.yaml') @@ -123,7 +120,8 @@ class SampleDataFixture(fixture.GabbiFixture): def start_fixture(self): """Create some samples.""" - conf = fixture_config.Config().conf + global LOAD_APP_KWARGS + conf = LOAD_APP_KWARGS['conf'] self.conn = storage.get_connection_from_config(conf) timestamp = datetime.datetime.utcnow() project_id = str(uuid.uuid4()) @@ -160,7 +158,8 @@ class EventDataFixture(fixture.GabbiFixture): def start_fixture(self): """Create some events.""" - conf = fixture_config.Config().conf + global LOAD_APP_KWARGS + conf = LOAD_APP_KWARGS['conf'] self.conn = storage.get_connection_from_config(conf, 'event') events = [] name_list = ['chocolate.chip', 'peanut.butter', 'sugar'] diff --git a/ceilometer/tests/functional/storage/test_storage_scenarios.py b/ceilometer/tests/functional/storage/test_storage_scenarios.py index 7ff1ba2627..7307bcf8a2 100644 --- a/ceilometer/tests/functional/storage/test_storage_scenarios.py +++ b/ceilometer/tests/functional/storage/test_storage_scenarios.py @@ -18,7 +18,6 @@ import datetime import operator import mock -from oslo_config import fixture as fixture_config from oslo_db import api from oslo_db import exception as dbexc from oslo_utils import timeutils @@ -66,7 +65,6 @@ class DBTestBase(tests_db.TestBase): def setUp(self): super(DBTestBase, self).setUp() - self.CONF = self.useFixture(fixture_config.Config()).conf patcher = mock.patch.object(timeutils, 'utcnow') self.addCleanup(patcher.stop) self.mock_utcnow = patcher.start() diff --git a/ceilometer/tests/functional/test_collector.py b/ceilometer/tests/functional/test_collector.py index baca060b65..030264fa0c 100644 --- a/ceilometer/tests/functional/test_collector.py +++ b/ceilometer/tests/functional/test_collector.py @@ -42,8 +42,8 @@ class FakeConnection(object): class TestCollector(tests_base.BaseTestCase): def setUp(self): super(TestCollector, self).setUp() - self.CONF = self.useFixture(fixture_config.Config()).conf - service.prepare_service([], [], self.CONF) + conf = service.prepare_service([], []) + self.CONF = self.useFixture(fixture_config.Config(conf)).conf self.CONF.import_opt("connection", "oslo_db.options", group="database") self.CONF.set_override("connection", "log://", group='database') self.CONF.set_override('telemetry_secret', 'not-so-secret', diff --git a/ceilometer/tests/functional/test_notification.py b/ceilometer/tests/functional/test_notification.py index 5c50c280c8..70229ad12e 100644 --- a/ceilometer/tests/functional/test_notification.py +++ b/ceilometer/tests/functional/test_notification.py @@ -100,8 +100,8 @@ class TestNotification(tests_base.BaseTestCase): def setUp(self): super(TestNotification, self).setUp() - self.CONF = self.useFixture(fixture_config.Config()).conf - service.prepare_service([], [], self.CONF) + conf = service.prepare_service([], []) + self.CONF = self.useFixture(fixture_config.Config(conf)).conf self.CONF.set_override("connection", "log://", group='database') self.CONF.set_override("backend_url", None, group="coordination") self.CONF.set_override("disable_non_metric_meters", False, @@ -226,8 +226,8 @@ class BaseRealNotification(tests_base.BaseTestCase): def setUp(self): super(BaseRealNotification, self).setUp() - self.CONF = self.useFixture(fixture_config.Config()).conf - service.prepare_service([], [], self.CONF) + conf = service.prepare_service([], []) + self.CONF = self.useFixture(fixture_config.Config(conf)).conf self.setup_messaging(self.CONF, 'nova') pipeline_cfg_file = self.setup_pipeline(['vcpus', 'memory']) @@ -524,8 +524,8 @@ class TestRealNotificationMultipleAgents(tests_base.BaseTestCase): def setUp(self): super(TestRealNotificationMultipleAgents, self).setUp() - self.CONF = self.useFixture(fixture_config.Config()).conf - service.prepare_service([], [], self.CONF) + conf = service.prepare_service([], []) + self.CONF = self.useFixture(fixture_config.Config(conf)).conf self.setup_messaging(self.CONF, 'nova') pipeline_cfg_file = self.setup_pipeline(['instance', 'memory']) diff --git a/ceilometer/tests/unit/dispatcher/test_gnocchi.py b/ceilometer/tests/unit/dispatcher/test_gnocchi.py index 6ce8b08a60..2caef137fd 100644 --- a/ceilometer/tests/unit/dispatcher/test_gnocchi.py +++ b/ceilometer/tests/unit/dispatcher/test_gnocchi.py @@ -87,8 +87,8 @@ class DispatcherTest(base.BaseTestCase): def setUp(self): super(DispatcherTest, self).setUp() - self.conf = self.useFixture(config_fixture.Config()) - ceilometer_service.prepare_service(argv=[], config_files=[]) + conf = ceilometer_service.prepare_service(argv=[], config_files=[]) + self.conf = self.useFixture(config_fixture.Config(conf)) self.conf.config( resources_definition_file=self.path_get( 'etc/ceilometer/gnocchi_resources.yaml'), @@ -381,11 +381,8 @@ class DispatcherWorkflowTest(base.BaseTestCase, def setUp(self): super(DispatcherWorkflowTest, self).setUp() - self.conf = self.useFixture(config_fixture.Config()) - # Set this explicitly to avoid conflicts with any existing - # configuration. - self.conf.config(url='http://localhost:8041', - group='dispatcher_gnocchi') + conf = ceilometer_service.prepare_service(argv=[], config_files=[]) + self.conf = self.useFixture(config_fixture.Config(conf)) ks_client = mock.Mock() ks_client.projects.find.return_value = mock.Mock( name='gnocchi', id='a2d42c23-d518-46b6-96ab-3fba2e146859') @@ -394,7 +391,6 @@ class DispatcherWorkflowTest(base.BaseTestCase, return_value=ks_client)) self.ks_client = ks_client - ceilometer_service.prepare_service(argv=[], config_files=[]) self.conf.config( resources_definition_file=self.path_get( 'etc/ceilometer/gnocchi_resources.yaml'), diff --git a/ceilometer/tests/unit/dispatcher/test_http.py b/ceilometer/tests/unit/dispatcher/test_http.py index ff81adc838..53d188c176 100644 --- a/ceilometer/tests/unit/dispatcher/test_http.py +++ b/ceilometer/tests/unit/dispatcher/test_http.py @@ -24,6 +24,7 @@ import requests from ceilometer.dispatcher import http from ceilometer.event.storage import models as event_models from ceilometer.publisher import utils +from ceilometer import service class TestDispatcherHttp(base.BaseTestCase): @@ -31,7 +32,8 @@ class TestDispatcherHttp(base.BaseTestCase): def setUp(self): super(TestDispatcherHttp, self).setUp() - self.CONF = self.useFixture(fixture_config.Config()).conf + conf = service.prepare_service([], []) + self.CONF = self.useFixture(fixture_config.Config(conf)).conf self.msg = {'counter_name': 'test', 'resource_id': self.id(), 'counter_volume': 1, @@ -142,7 +144,8 @@ class TestEventDispatcherHttp(base.BaseTestCase): """Test sending events with the http dispatcher""" def setUp(self): super(TestEventDispatcherHttp, self).setUp() - self.CONF = self.useFixture(fixture_config.Config()).conf + conf = service.prepare_service([], []) + self.CONF = self.useFixture(fixture_config.Config(conf)).conf # repr(uuid.uuid4()) is used in test event creation to avoid an # exception being thrown when the uuid is serialized to JSON diff --git a/ceilometer/tests/unit/event/test_converter.py b/ceilometer/tests/unit/event/test_converter.py index 288ae37436..a56c0dc71a 100644 --- a/ceilometer/tests/unit/event/test_converter.py +++ b/ceilometer/tests/unit/event/test_converter.py @@ -599,8 +599,8 @@ class TestNotificationConverter(ConverterBase): def setUp(self): super(TestNotificationConverter, self).setUp() - self.CONF = self.useFixture(fixture_config.Config()).conf - ceilometer_service.prepare_service(argv=[], config_files=[]) + conf = ceilometer_service.prepare_service(argv=[], config_files=[]) + self.CONF = self.useFixture(fixture_config.Config(conf)).conf self.valid_event_def1 = [{ 'event_type': 'compute.instance.create.*', 'traits': { diff --git a/ceilometer/tests/unit/hardware/pollsters/test_generic.py b/ceilometer/tests/unit/hardware/pollsters/test_generic.py index af50404aaa..734ae106f6 100644 --- a/ceilometer/tests/unit/hardware/pollsters/test_generic.py +++ b/ceilometer/tests/unit/hardware/pollsters/test_generic.py @@ -25,6 +25,7 @@ from ceilometer import declarative from ceilometer.hardware.inspector import base as inspector_base from ceilometer.hardware.pollsters import generic from ceilometer import sample +from ceilometer import service from ceilometer.tests import base as test_base @@ -109,12 +110,12 @@ class TestGenericPollsters(test_base.BaseTestCase): def setUp(self): super(TestGenericPollsters, self).setUp() - self.conf = self.useFixture(fixture_config.Config()).conf + conf = service.prepare_service([], []) + self.conf = self.useFixture(fixture_config.Config(conf)).conf self.resources = ["snmp://test", "snmp://test2"] self.useFixture(mockpatch.Patch( 'ceilometer.hardware.inspector.get_inspector', self.faux_get_inspector)) - self.conf(args=[]) self.pollster = generic.GenericHardwareDeclarativePollster(self.conf) def _setup_meter_def_file(self, cfg): diff --git a/ceilometer/tests/unit/meter/test_notifications.py b/ceilometer/tests/unit/meter/test_notifications.py index 0ce3c1faa7..310c2d789f 100644 --- a/ceilometer/tests/unit/meter/test_notifications.py +++ b/ceilometer/tests/unit/meter/test_notifications.py @@ -262,8 +262,8 @@ class TestMeterProcessing(test.BaseTestCase): def setUp(self): super(TestMeterProcessing, self).setUp() - self.CONF = self.useFixture(fixture_config.Config()).conf - ceilometer_service.prepare_service(argv=[], config_files=[]) + conf = ceilometer_service.prepare_service(argv=[], config_files=[]) + self.CONF = self.useFixture(fixture_config.Config(conf)).conf self.handler = notifications.ProcessMeterNotifications( mock.Mock(conf=self.CONF)) diff --git a/ceilometer/tests/unit/test_novaclient.py b/ceilometer/tests/unit/test_novaclient.py index 66981fe94d..033abeca6b 100644 --- a/ceilometer/tests/unit/test_novaclient.py +++ b/ceilometer/tests/unit/test_novaclient.py @@ -20,13 +20,15 @@ from oslotest import base from oslotest import mockpatch from ceilometer import nova_client +from ceilometer import service class TestNovaClient(base.BaseTestCase): def setUp(self): super(TestNovaClient, self).setUp() - self.CONF = self.useFixture(fixture_config.Config()).conf + conf = service.prepare_service([], []) + self.CONF = self.useFixture(fixture_config.Config(conf)).conf self._flavors_count = 0 self._images_count = 0 self.nv = nova_client.Client(self.CONF) diff --git a/ceilometer/utils.py b/ceilometer/utils.py index 3e9831411b..df64ad41fa 100644 --- a/ceilometer/utils.py +++ b/ceilometer/utils.py @@ -44,8 +44,6 @@ OPTS = [ help='Path to the rootwrap configuration file to' 'use for running commands as root'), ] -CONF = cfg.CONF -CONF.register_opts(OPTS) EPOCH_TIME = datetime.datetime(1970, 1, 1) diff --git a/ceilometer/volume/discovery.py b/ceilometer/volume/discovery.py index 9aba119f43..f572681578 100644 --- a/ceilometer/volume/discovery.py +++ b/ceilometer/volume/discovery.py @@ -23,9 +23,6 @@ SERVICE_OPTS = [ help='Cinder V2 service type.'), ] -cfg.CONF.register_opts(SERVICE_OPTS, group='service_types') -cfg.CONF.import_group('service_credentials', 'ceilometer.keystone_client') - class _BaseDiscovery(plugin_base.DiscoveryBase): def __init__(self, conf): diff --git a/etc/ceilometer/api_paste.ini b/etc/ceilometer/api_paste.ini index f06634f338..4247f1bbb4 100644 --- a/etc/ceilometer/api_paste.ini +++ b/etc/ceilometer/api_paste.ini @@ -12,9 +12,11 @@ paste.app_factory = ceilometer.api.app:app_factory [filter:authtoken] paste.filter_factory = keystonemiddleware.auth_token:filter_factory +oslo_config_project = ceilometer [filter:request_id] paste.filter_factory = oslo_middleware:RequestId.factory +oslo_config_project = ceilometer [filter:cors] paste.filter_factory = oslo_middleware.cors:filter_factory diff --git a/etc/ceilometer/ceilometer-config-generator.conf b/etc/ceilometer/ceilometer-config-generator.conf index 59d6b45a2d..976385b736 100644 --- a/etc/ceilometer/ceilometer-config-generator.conf +++ b/etc/ceilometer/ceilometer-config-generator.conf @@ -2,6 +2,7 @@ output_file = etc/ceilometer/ceilometer.conf wrap_width = 79 namespace = ceilometer +namespace = ceilometer-auth namespace = oslo.concurrency namespace = oslo.db namespace = oslo.log diff --git a/setup.cfg b/setup.cfg index 7688d2d1d4..1185980e2f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -258,7 +258,7 @@ ceilometer.event.trait_plugin = timedelta = ceilometer.event.trait_plugins:TimedeltaPlugin wsgi_scripts = - ceilometer-api = ceilometer.api.app:build_wsgi_app + ceilometer-api = ceilometer.cmd.api:build_wsgi_app console_scripts = ceilometer-polling = ceilometer.cmd.polling:main @@ -288,6 +288,7 @@ network.statistics.drivers = oslo.config.opts = ceilometer = ceilometer.opts:list_opts + ceilometer-auth = ceilometer.opts:list_keystoneauth_opts oslo.config.opts.defaults = ceilometer = ceilometer.conf.defaults:set_cors_middleware_defaults