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
This commit is contained in:
Mehdi Abaakouk 2016-10-13 14:29:28 +02:00
parent e16e2329e6
commit 1842e19487
73 changed files with 176 additions and 305 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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):

View File

@ -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))

View File

@ -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__)

View File

@ -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):

View File

@ -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.

23
ceilometer/cmd/api.py Normal file
View File

@ -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))

View File

@ -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()

View File

@ -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)

View File

@ -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',

View File

@ -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__)

View File

@ -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):

View File

@ -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

View File

@ -32,8 +32,6 @@ OPTS = [
'and powervm.'),
]
cfg.CONF.register_opts(OPTS)
LOG = log.getLogger(__name__)

View File

@ -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):

View File

@ -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'

View File

@ -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

View File

@ -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):

View File

@ -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):

View File

@ -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")

View File

@ -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."""

View File

@ -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')),
]

View File

@ -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):

View File

@ -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."""

View File

@ -39,8 +39,6 @@ OPTS = [
'not captured.')
]
cfg.CONF.register_opts(OPTS, group='event')
LOG = log.getLogger(__name__)

View File

@ -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."),
]

View File

@ -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)

View File

@ -50,8 +50,6 @@ OPTS = [
]
CONF = cfg.CONF
CONF.register_opts(OPTS, group='hardware')
class NodesDiscoveryTripleO(plugin_base.DiscoveryBase):

View File

@ -35,8 +35,6 @@ OPTS = [
),
]
cfg.CONF.register_opts(OPTS, group='hardware')
LOG = log.getLogger(__name__)

View File

@ -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):

View File

@ -32,9 +32,6 @@ OPTS = [
]
cfg.CONF.register_opts(OPTS)
# Map unit name to SI
UNIT_MAP = {
'Watts': 'W',

View File

@ -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"}

View File

@ -25,5 +25,3 @@ OPTS = [
'before disable this pollster. '
'Negative indicates retrying forever.')
]
cfg.CONF.register_opts(OPTS, group='ipmi')

View File

@ -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__)

View File

@ -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__)

View File

@ -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)

View File

@ -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__)

View File

@ -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):

View File

@ -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):

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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.

View File

@ -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__)

View File

@ -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'

View File

@ -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):

View File

@ -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='<your_hostname>',
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')))]

View File

@ -61,8 +61,6 @@ OPTS = [
),
]
cfg.CONF.register_opts(OPTS)
LOG = log.getLogger(__name__)

View File

@ -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):

View File

@ -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__)

View File

@ -38,7 +38,6 @@ OPTS = [
"publisher")]
),
]
cfg.CONF.register_opts(OPTS, group="publisher")
def compute_signature(message, secret):

View File

@ -32,8 +32,6 @@ OPTS = [
help='Source for samples emitted on this instance.'),
]
cfg.CONF.register_opts(OPTS)
# Fields explanation:
#

View File

@ -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='<your_hostname>',
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 +

View File

@ -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."""

View File

@ -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."""

View File

@ -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:

View File

@ -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'),

View File

@ -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']

View File

@ -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()

View File

@ -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',

View File

@ -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'])

View File

@ -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'),

View File

@ -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

View File

@ -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': {

View File

@ -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):

View File

@ -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))

View File

@ -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)

View File

@ -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)

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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