Merge "switch to oslo-config-generator"

This commit is contained in:
Jenkins 2014-10-14 20:14:52 +00:00 committed by Gerrit Code Review
commit 920cb35422
26 changed files with 191 additions and 541 deletions

View File

@ -29,7 +29,7 @@ from ceilometer.openstack.common import log
LOG = log.getLogger(__name__)
REST_NOTIFIER_OPTS = [
OPTS = [
cfg.StrOpt('rest_notifier_certificate_file',
default='',
help='SSL Client certificate for REST notifier.'
@ -50,7 +50,7 @@ REST_NOTIFIER_OPTS = [
]
cfg.CONF.register_opts(REST_NOTIFIER_OPTS, group="alarm")
cfg.CONF.register_opts(OPTS, group="alarm")
class RestAlarmNotifier(notifier.AlarmNotifier):

View File

@ -18,7 +18,7 @@
from oslo.config import cfg
# Register options for the service
API_SERVICE_OPTS = [
OPTS = [
cfg.IntOpt('port',
default=8777,
deprecated_name='metering_api_port',
@ -41,4 +41,4 @@ CONF = cfg.CONF
opt_group = cfg.OptGroup(name='api',
title='Options for the ceilometer-api service')
CONF.register_group(opt_group)
CONF.register_opts(API_SERVICE_OPTS, opt_group)
CONF.register_opts(OPTS, opt_group)

View File

@ -36,14 +36,14 @@ LOG = log.getLogger(__name__)
CONF = cfg.CONF
CONF.import_opt('debug', 'ceilometer.openstack.common.log')
auth_opts = [
OPTS = [
cfg.StrOpt('api_paste_config',
default="api_paste.ini",
help="Configuration file for WSGI definition of API."
),
]
api_opts = [
API_OPTS = [
cfg.BoolOpt('pecan_debug',
default=CONF.debug,
help='Toggle Pecan Debug Middleware. '
@ -51,8 +51,8 @@ api_opts = [
),
]
CONF.register_opts(auth_opts)
CONF.register_opts(api_opts, group='api')
CONF.register_opts(OPTS)
CONF.register_opts(API_OPTS, group='api')
def get_pecan_config():

View File

@ -28,7 +28,7 @@ libvirt = None
LOG = logging.getLogger(__name__)
libvirt_opts = [
OPTS = [
cfg.StrOpt('libvirt_type',
default='kvm',
help='Libvirt domain type (valid options are: '
@ -40,7 +40,7 @@ libvirt_opts = [
]
CONF = cfg.CONF
CONF.register_opts(libvirt_opts)
CONF.register_opts(OPTS)
def retry_on_disconnect(function):

View File

@ -30,7 +30,7 @@ from ceilometer.openstack.common.gettextutils import _
opt_group = cfg.OptGroup(name='xenapi',
title='Options for XenAPI')
xenapi_opts = [
OPTS = [
cfg.StrOpt('connection_url',
help='URL for connection to XenServer/Xen Cloud Platform.'),
cfg.StrOpt('connection_username',
@ -47,7 +47,7 @@ xenapi_opts = [
CONF = cfg.CONF
CONF.register_group(opt_group)
CONF.register_opts(xenapi_opts, group=opt_group)
CONF.register_opts(OPTS, group=opt_group)
class XenapiException(virt_inspector.InspectorException):

View File

@ -22,7 +22,7 @@ from oslo.config import cfg
from ceilometer import dispatcher
file_dispatcher_opts = [
OPTS = [
cfg.StrOpt('file_path',
help='Name and the location of the file to record '
'meters.'),
@ -34,7 +34,7 @@ file_dispatcher_opts = [
help='The max number of the files to keep.'),
]
cfg.CONF.register_opts(file_dispatcher_opts, group="dispatcher_file")
cfg.CONF.register_opts(OPTS, group="dispatcher_file")
class FileDispatcher(dispatcher.Base):

View File

@ -29,13 +29,13 @@ from ceilometer import sample
LOG = log.getLogger(__name__)
service_types_opts = [
SERVICE_OPTS = [
cfg.StrOpt('kwapi',
default='energy',
help='Kwapi service type.'),
]
cfg.CONF.register_opts(service_types_opts, group='service_types')
cfg.CONF.register_opts(SERVICE_OPTS, group='service_types')
class KwapiClient(object):

View File

@ -39,14 +39,14 @@ OPTS = [
"(default value in glanceclient is used)."),
]
service_types_opts = [
SERVICE_OPTS = [
cfg.StrOpt('glance',
default='image',
help='Glance service type.'),
]
cfg.CONF.register_opts(OPTS)
cfg.CONF.register_opts(service_types_opts, group='service_types')
cfg.CONF.register_opts(SERVICE_OPTS, group='service_types')
class _Base(plugin.CentralPollster):

View File

@ -45,14 +45,14 @@ def get_ordereddict():
OrderedDict = get_ordereddict()
node_manager_init_retry = cfg.IntOpt('node_manager_init_retry',
default=3,
help='Number of retries upon Intel Node '
'Manager initialization failure')
OPTS = [
cfg.IntOpt('node_manager_init_retry',
default=3,
help='Number of retries upon Intel Node '
'Manager initialization failure')
]
CONF = cfg.CONF
CONF.register_opt(node_manager_init_retry, group='ipmi')
CONF.register_opts(OPTS, group='ipmi')
IPMICMD = {"sdr_dump": "sdr dump",
"sdr_info": "sdr info",

View File

@ -23,13 +23,13 @@ from oslo.config import cfg
from ceilometer.openstack.common import log
service_types_opts = [
SERVICE_OPTS = [
cfg.StrOpt('neutron',
default='network',
help='Neutron service type.'),
]
cfg.CONF.register_opts(service_types_opts, group='service_types')
cfg.CONF.register_opts(SERVICE_OPTS, group='service_types')
cfg.CONF.import_group('service_credentials', 'ceilometer.service')
LOG = log.getLogger(__name__)

View File

@ -22,20 +22,20 @@ from oslo.config import cfg
from ceilometer.openstack.common import log
nova_opts = [
OPTS = [
cfg.BoolOpt('nova_http_log_debug',
default=False,
help='Allow novaclient\'s debug log output.'),
]
service_types_opts = [
SERVICE_OPTS = [
cfg.StrOpt('nova',
default='compute',
help='Nova service type.'),
]
cfg.CONF.register_opts(nova_opts)
cfg.CONF.register_opts(service_types_opts, group='service_types')
cfg.CONF.register_opts(OPTS)
cfg.CONF.register_opts(SERVICE_OPTS, group='service_types')
cfg.CONF.import_group('service_credentials', 'ceilometer.service')

View File

@ -40,14 +40,14 @@ OPTS = [
"reseller_prefix in proxy-server.conf."),
]
service_types_opts = [
SERVICE_OPTS = [
cfg.StrOpt('swift',
default='object-store',
help='Swift service type.'),
]
cfg.CONF.register_opts(OPTS)
cfg.CONF.register_opts(service_types_opts, group='service_types')
cfg.CONF.register_opts(SERVICE_OPTS, group='service_types')
cfg.CONF.import_group('service_credentials', 'ceilometer.service')

View File

@ -1,313 +0,0 @@
# Copyright 2012 SINA Corporation
# Copyright 2014 Cisco Systems, Inc.
# All Rights Reserved.
#
# 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.
#
"""Extracts OpenStack config option info from module(s)."""
from __future__ import print_function
import argparse
import imp
import os
import re
import socket
import sys
import textwrap
from oslo.config import cfg
import six
import stevedore.named
from ceilometer.openstack.common import gettextutils
from ceilometer.openstack.common import importutils
gettextutils.install('ceilometer')
STROPT = "StrOpt"
BOOLOPT = "BoolOpt"
INTOPT = "IntOpt"
FLOATOPT = "FloatOpt"
LISTOPT = "ListOpt"
DICTOPT = "DictOpt"
MULTISTROPT = "MultiStrOpt"
OPT_TYPES = {
STROPT: 'string value',
BOOLOPT: 'boolean value',
INTOPT: 'integer value',
FLOATOPT: 'floating point value',
LISTOPT: 'list value',
DICTOPT: 'dict value',
MULTISTROPT: 'multi valued',
}
OPTION_REGEX = re.compile(r"(%s)" % "|".join([STROPT, BOOLOPT, INTOPT,
FLOATOPT, LISTOPT, DICTOPT,
MULTISTROPT]))
PY_EXT = ".py"
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
"../../../../"))
WORDWRAP_WIDTH = 60
def raise_extension_exception(extmanager, ep, err):
raise
def generate(argv):
parser = argparse.ArgumentParser(
description='generate sample configuration file',
)
parser.add_argument('-m', dest='modules', action='append')
parser.add_argument('-l', dest='libraries', action='append')
parser.add_argument('srcfiles', nargs='*')
parsed_args = parser.parse_args(argv)
mods_by_pkg = dict()
for filepath in parsed_args.srcfiles:
pkg_name = filepath.split(os.sep)[1]
mod_str = '.'.join(['.'.join(filepath.split(os.sep)[:-1]),
os.path.basename(filepath).split('.')[0]])
mods_by_pkg.setdefault(pkg_name, list()).append(mod_str)
# NOTE(lzyeval): place top level modules before packages
pkg_names = sorted(pkg for pkg in mods_by_pkg if pkg.endswith(PY_EXT))
ext_names = sorted(pkg for pkg in mods_by_pkg if pkg not in pkg_names)
pkg_names.extend(ext_names)
# opts_by_group is a mapping of group name to an options list
# The options list is a list of (module, options) tuples
opts_by_group = {'DEFAULT': []}
if parsed_args.modules:
for module_name in parsed_args.modules:
module = _import_module(module_name)
if module:
for group, opts in _list_opts(module):
opts_by_group.setdefault(group, []).append((module_name,
opts))
# Look for entry points defined in libraries (or applications) for
# option discovery, and include their return values in the output.
#
# Each entry point should be a function returning an iterable
# of pairs with the group name (or None for the default group)
# and the list of Opt instances for that group.
if parsed_args.libraries:
loader = stevedore.named.NamedExtensionManager(
'oslo.config.opts',
names=list(set(parsed_args.libraries)),
invoke_on_load=False,
on_load_failure_callback=raise_extension_exception
)
for ext in loader:
for group, opts in ext.plugin():
opt_list = opts_by_group.setdefault(group or 'DEFAULT', [])
opt_list.append((ext.name, opts))
for pkg_name in pkg_names:
mods = mods_by_pkg.get(pkg_name)
mods.sort()
for mod_str in mods:
if mod_str.endswith('.__init__'):
mod_str = mod_str[:mod_str.rfind(".")]
mod_obj = _import_module(mod_str)
if not mod_obj:
raise RuntimeError("Unable to import module %s" % mod_str)
for group, opts in _list_opts(mod_obj):
opts_by_group.setdefault(group, []).append((mod_str, opts))
print_group_opts('DEFAULT', opts_by_group.pop('DEFAULT', []))
for group in sorted(opts_by_group.keys()):
print_group_opts(group, opts_by_group[group])
def _import_module(mod_str):
try:
if mod_str.startswith('bin.'):
imp.load_source(mod_str[4:], os.path.join('bin', mod_str[4:]))
return sys.modules[mod_str[4:]]
else:
return importutils.import_module(mod_str)
except Exception as e:
sys.stderr.write("Error importing module %s: %s\n" % (mod_str, str(e)))
return None
def _is_in_group(opt, group):
"""Check if opt is in group."""
for value in group._opts.values():
# NOTE(llu): Temporary workaround for bug #1262148, wait until
# newly released oslo.config support '==' operator.
if not(value['opt'] != opt):
return True
return False
def _guess_groups(opt):
# is it in the DEFAULT group?
if _is_in_group(opt, cfg.CONF):
return 'DEFAULT'
# what other groups is it in?
for value in cfg.CONF.values():
if isinstance(value, cfg.CONF.GroupAttr):
if _is_in_group(opt, value._group):
return value._group.name
raise RuntimeError(
"Unable to find group for option %s, "
"maybe it's defined twice in the same group?"
% opt.name
)
def _list_opts(obj):
def is_opt(o):
return (isinstance(o, cfg.Opt) and
not isinstance(o, cfg.SubCommandOpt))
opts = list()
for attr_str in dir(obj):
attr_obj = getattr(obj, attr_str)
if is_opt(attr_obj):
opts.append(attr_obj)
elif (isinstance(attr_obj, list) and
all(map(lambda x: is_opt(x), attr_obj))):
opts.extend(attr_obj)
ret = {}
for opt in opts:
ret.setdefault(_guess_groups(opt), []).append(opt)
return ret.items()
def print_group_opts(group, opts_by_module):
print("[%s]" % group)
print('')
for mod, opts in opts_by_module:
print('#')
print('# Options defined in %s' % mod)
print('#')
print('')
for opt in opts:
_print_opt(opt)
print('')
def _get_my_ip():
try:
csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
csock.connect(('8.8.8.8', 80))
(addr, port) = csock.getsockname()
csock.close()
return addr
except socket.error:
return None
def _sanitize_default(name, value):
"""Set up a reasonably sensible default for pybasedir, my_ip and host."""
hostname = socket.gethostname()
fqdn = socket.getfqdn()
if value.startswith(sys.prefix):
# NOTE(jd) Don't use os.path.join, because it is likely to think the
# second part is an absolute pathname and therefore drop the first
# part.
value = os.path.normpath("/usr/" + value[len(sys.prefix):])
elif value.startswith(BASEDIR):
return value.replace(BASEDIR, '/usr/lib/python/site-packages')
elif BASEDIR in value:
return value.replace(BASEDIR, '')
elif value == _get_my_ip():
return '10.0.0.1'
elif value in (hostname, fqdn):
if 'host' in name:
return 'ceilometer'
elif value.endswith(hostname):
return value.replace(hostname, 'ceilometer')
elif value.endswith(fqdn):
return value.replace(fqdn, 'ceilometer')
elif value.strip() != value:
return '"%s"' % value
return value
def _print_opt(opt):
opt_name, opt_default, opt_help = opt.dest, opt.default, opt.help
if not opt_help:
sys.stderr.write('WARNING: "%s" is missing help string.\n' % opt_name)
opt_help = ""
try:
opt_type = OPTION_REGEX.search(str(type(opt))).group(0)
except (ValueError, AttributeError) as err:
sys.stderr.write("%s\n" % str(err))
sys.exit(1)
opt_help = u'%s (%s)' % (opt_help,
OPT_TYPES[opt_type])
print('#', "\n# ".join(textwrap.wrap(opt_help, WORDWRAP_WIDTH)))
if opt.deprecated_opts:
for deprecated_opt in opt.deprecated_opts:
if deprecated_opt.name:
deprecated_group = (deprecated_opt.group if
deprecated_opt.group else "DEFAULT")
print('# Deprecated group/name - [%s]/%s' %
(deprecated_group,
deprecated_opt.name))
try:
if opt_default is None:
print('#%s=<None>' % opt_name)
elif opt_type == STROPT:
assert(isinstance(opt_default, six.string_types))
print('#%s=%s' % (opt_name, _sanitize_default(opt_name,
opt_default)))
elif opt_type == BOOLOPT:
assert(isinstance(opt_default, bool))
print('#%s=%s' % (opt_name, str(opt_default).lower()))
elif opt_type == INTOPT:
assert(isinstance(opt_default, int) and
not isinstance(opt_default, bool))
print('#%s=%s' % (opt_name, opt_default))
elif opt_type == FLOATOPT:
assert(isinstance(opt_default, float))
print('#%s=%s' % (opt_name, opt_default))
elif opt_type == LISTOPT:
assert(isinstance(opt_default, list))
print('#%s=%s' % (opt_name, ','.join(opt_default)))
elif opt_type == DICTOPT:
assert(isinstance(opt_default, dict))
opt_default_strlist = [str(key) + ':' + str(value)
for (key, value) in opt_default.items()]
print('#%s=%s' % (opt_name, ','.join(opt_default_strlist)))
elif opt_type == MULTISTROPT:
assert(isinstance(opt_default, list))
if not opt_default:
opt_default = ['']
for default in opt_default:
print('#%s=%s' % (opt_name, default))
print('')
except Exception:
sys.stderr.write('Error in option "%s"\n' % opt_name)
sys.exit(1)
def main():
generate(sys.argv[1:])
if __name__ == '__main__':
main()

131
ceilometer/opts.py Normal file
View File

@ -0,0 +1,131 @@
# Copyright 2014 eNovance
#
# 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.
import itertools
import ceilometer.alarm.notifier.rest
import ceilometer.alarm.rpc
import ceilometer.alarm.service
import ceilometer.api
import ceilometer.api.app
import ceilometer.api.controllers.v2
import ceilometer.central.manager
import ceilometer.cmd.alarm
import ceilometer.collector
import ceilometer.compute.discovery
import ceilometer.compute.notifications
import ceilometer.compute.util
import ceilometer.compute.virt.inspector
import ceilometer.compute.virt.libvirt.inspector
import ceilometer.compute.virt.vmware.inspector
import ceilometer.compute.virt.xenapi.inspector
import ceilometer.coordination
import ceilometer.data_processing.notifications
import ceilometer.dispatcher
import ceilometer.dispatcher.file
import ceilometer.energy.kwapi
import ceilometer.event.converter
import ceilometer.hardware.discovery
import ceilometer.identity.notifications
import ceilometer.image.glance
import ceilometer.image.notifications
import ceilometer.ipmi.notifications.ironic
import ceilometer.ipmi.platform.intel_node_manager
import ceilometer.middleware
import ceilometer.network.notifications
import ceilometer.neutron_client
import ceilometer.notification
import ceilometer.nova_client
import ceilometer.objectstore.swift
import ceilometer.openstack.common.eventlet_backdoor
import ceilometer.openstack.common.lockutils
import ceilometer.openstack.common.log
import ceilometer.openstack.common.policy
import ceilometer.orchestration.notifications
import ceilometer.pipeline
import ceilometer.profiler.notifications
import ceilometer.publisher.messaging
import ceilometer.publisher.utils
import ceilometer.sample
import ceilometer.service
import ceilometer.storage
import ceilometer.utils
import ceilometer.volume.notifications
def list_opts():
return [
('DEFAULT',
itertools.chain(ceilometer.api.app.OPTS,
ceilometer.compute.notifications.OPTS,
ceilometer.compute.util.OPTS,
ceilometer.compute.virt.inspector.OPTS,
ceilometer.compute.virt.libvirt.inspector.OPTS,
ceilometer.data_processing.notifications.OPTS,
ceilometer.dispatcher.OPTS,
ceilometer.identity.notifications.OPTS,
ceilometer.image.glance.OPTS,
ceilometer.image.notifications.OPTS,
ceilometer.ipmi.notifications.ironic.OPTS,
ceilometer.middleware.OPTS,
ceilometer.network.notifications.OPTS,
ceilometer.nova_client.OPTS,
ceilometer.objectstore.swift.OPTS,
(ceilometer.openstack.common.eventlet_backdoor
.eventlet_backdoor_opts),
ceilometer.openstack.common.lockutils.util_opts,
ceilometer.openstack.common.log.common_cli_opts,
ceilometer.openstack.common.log.generic_log_opts,
ceilometer.openstack.common.log.logging_cli_opts,
ceilometer.openstack.common.log.log_opts,
ceilometer.openstack.common.policy.policy_opts,
ceilometer.orchestration.notifications.OPTS,
ceilometer.pipeline.OPTS,
ceilometer.profiler.notifications.OPTS,
ceilometer.sample.OPTS,
ceilometer.service.OPTS,
ceilometer.storage.OLD_OPTS,
ceilometer.utils.OPTS,
ceilometer.volume.notifications.OPTS,)),
('alarm',
itertools.chain(ceilometer.alarm.notifier.rest.OPTS,
ceilometer.alarm.service.OPTS,
ceilometer.alarm.rpc.OPTS,
ceilometer.api.controllers.v2.ALARM_API_OPTS,
ceilometer.cmd.alarm.OPTS)),
('api',
itertools.chain(ceilometer.api.OPTS,
ceilometer.api.app.API_OPTS,)),
('central', ceilometer.central.manager.OPTS),
('collector', ceilometer.collector.OPTS),
('compute', ceilometer.compute.discovery.OPTS),
('coordination', ceilometer.coordination.OPTS),
('database', ceilometer.storage.OPTS),
('dispatcher_file', ceilometer.dispatcher.file.OPTS),
('event', ceilometer.event.converter.OPTS),
('hardware', ceilometer.hardware.discovery.OPTS),
('impi', ceilometer.ipmi.platform.intel_node_manager.OPTS),
('notification', ceilometer.notification.OPTS),
('publisher', ceilometer.publisher.utils.OPTS),
('publisher_notifier', ceilometer.publisher.messaging.NOTIFIER_OPTS),
('publisher_rpc', ceilometer.publisher.messaging.RPC_OPTS),
('service_credentials', ceilometer.service.CLI_OPTS),
('service_types',
itertools.chain(ceilometer.energy.kwapi.SERVICE_OPTS,
ceilometer.image.glance.SERVICE_OPTS,
ceilometer.neutron_client.SERVICE_OPTS,
ceilometer.nova_client.SERVICE_OPTS,
ceilometer.objectstore.swift.SERVICE_OPTS,)),
('vmware', ceilometer.compute.virt.vmware.inspector.OPTS),
('xenapi', ceilometer.compute.virt.xenapi.inspector.OPTS),
]

View File

@ -35,7 +35,7 @@ from ceilometer.publisher import utils
LOG = log.getLogger(__name__)
METER_PUBLISH_RPC_OPTS = [
RPC_OPTS = [
cfg.StrOpt('metering_topic',
default='metering',
help='The topic that ceilometer uses for metering messages.',
@ -43,7 +43,7 @@ METER_PUBLISH_RPC_OPTS = [
),
]
METER_PUBLISH_NOTIFIER_OPTS = [
NOTIFIER_OPTS = [
cfg.StrOpt('metering_topic',
default='metering',
help='The topic that ceilometer uses for metering '
@ -56,9 +56,9 @@ METER_PUBLISH_NOTIFIER_OPTS = [
)
]
cfg.CONF.register_opts(METER_PUBLISH_RPC_OPTS,
cfg.CONF.register_opts(RPC_OPTS,
group="publisher_rpc")
cfg.CONF.register_opts(METER_PUBLISH_NOTIFIER_OPTS,
cfg.CONF.register_opts(NOTIFIER_OPTS,
group="publisher_notifier")
cfg.CONF.import_opt('host', 'ceilometer.service')

View File

@ -26,7 +26,7 @@ import six
from ceilometer import utils
METER_PUBLISH_OPTS = [
OPTS = [
cfg.StrOpt('metering_secret',
secret=True,
default='change this or be hacked',
@ -37,14 +37,7 @@ METER_PUBLISH_OPTS = [
"publisher_rpc")]
),
]
def register_opts(config):
"""Register the options for publishing metering messages."""
config.register_opts(METER_PUBLISH_OPTS, group="publisher")
register_opts(cfg.CONF)
cfg.CONF.register_opts(OPTS, group="publisher")
def compute_signature(message, secret):

View File

@ -46,7 +46,7 @@ OPTS = [
]
cfg.CONF.register_opts(OPTS)
CLI_OPTIONS = [
CLI_OPTS = [
cfg.StrOpt('os-username',
deprecated_group="DEFAULT",
default=os.environ.get('OS_USERNAME', 'ceilometer'),
@ -85,7 +85,7 @@ CLI_OPTIONS = [
help='Disables X.509 certificate validation when an '
'SSL connection to Identity Service is established.'),
]
cfg.CONF.register_cli_opts(CLI_OPTIONS, group="service_credentials")
cfg.CONF.register_cli_opts(CLI_OPTS, group="service_credentials")
cfg.CONF.import_opt('default_log_levels',
'ceilometer.openstack.common.log')

View File

@ -30,17 +30,17 @@ from ceilometer import utils
LOG = log.getLogger(__name__)
OLD_STORAGE_OPTS = [
OLD_OPTS = [
cfg.StrOpt('database_connection',
secret=True,
help='DEPRECATED - Database connection string.',
),
]
cfg.CONF.register_opts(OLD_STORAGE_OPTS)
cfg.CONF.register_opts(OLD_OPTS)
STORAGE_OPTS = [
OPTS = [
cfg.IntOpt('time_to_live',
default=-1,
help="Number of seconds that samples are kept "
@ -59,7 +59,7 @@ STORAGE_OPTS = [
'database. (if unset, connection is used)'),
]
cfg.CONF.register_opts(STORAGE_OPTS, group='database')
cfg.CONF.register_opts(OPTS, group='database')
db_options.set_defaults(cfg.CONF)
cfg.CONF.import_opt('connection', 'oslo.db.options', group='database')

View File

@ -33,12 +33,14 @@ from oslo.utils import timeutils
from oslo.utils import units
import six
rootwrap_conf = cfg.StrOpt('rootwrap_config',
default="/etc/ceilometer/rootwrap.conf",
help='Path to the rootwrap configuration file to'
'use for running commands as root')
OPTS = [
cfg.StrOpt('rootwrap_config',
default="/etc/ceilometer/rootwrap.conf",
help='Path to the rootwrap configuration file to'
'use for running commands as root'),
]
CONF = cfg.CONF
CONF.register_opt(rootwrap_conf)
CONF.register_opts(OPTS)
def _get_root_helper():

View File

@ -1,7 +1,6 @@
[DEFAULT]
# The list of modules to copy from oslo-incubator
module=config
module=context
module=eventlet_backdoor
module=gettextutils

View File

@ -303,6 +303,9 @@ oslo.messaging.notify.drivers =
ceilometer.openstack.common.notifier.rpc_notifier = oslo.messaging.notify._impl_messaging:MessagingDriver
ceilometer.openstack.common.notifier.test_notifier = oslo.messaging.notify._impl_test:TestDriver
oslo.config.opts =
ceilometer = ceilometer.opts:list_opts
[build_sphinx]
all_files = 1
build-dir = doc/build

View File

@ -1,29 +0,0 @@
#!/usr/bin/env bash
PROJECT_NAME=${PROJECT_NAME:-ceilometer}
CFGFILE_NAME=${PROJECT_NAME}.conf.sample
if [ -e etc/${PROJECT_NAME}/${CFGFILE_NAME} ]; then
CFGFILE=etc/${PROJECT_NAME}/${CFGFILE_NAME}
elif [ -e etc/${CFGFILE_NAME} ]; then
CFGFILE=etc/${CFGFILE_NAME}
else
echo "${0##*/}: can not find config file"
exit 1
fi
TEMPDIR=`mktemp -d /tmp/${PROJECT_NAME}.XXXXXX`
trap "rm -rf $TEMPDIR" EXIT
tools/config/generate_sample.sh -b ./ -p ${PROJECT_NAME} -o ${TEMPDIR}
if [ $? != 0 ]
then
exit 1
fi
if ! diff -u ${TEMPDIR}/${CFGFILE_NAME} ${CFGFILE}
then
echo "${0##*/}: ${PROJECT_NAME}.conf.sample is not up to date."
echo "${0##*/}: Please run ${0%%${0##*/}}generate_sample.sh."
exit 1
fi

View File

@ -1,138 +0,0 @@
#!/usr/bin/env bash
# Generate sample configuration for your project.
#
# Aside from the command line flags, it also respects a config file which
# should be named oslo.config.generator.rc and be placed in the same directory.
#
# You can then export the following variables:
# CEILOMETER_CONFIG_GENERATOR_EXTRA_MODULES: list of modules to interrogate for options.
# CEILOMETER_CONFIG_GENERATOR_EXTRA_LIBRARIES: list of libraries to discover.
# CEILOMETER_CONFIG_GENERATOR_EXCLUDED_FILES: list of files to remove from automatic listing.
print_hint() {
echo "Try \`${0##*/} --help' for more information." >&2
}
PARSED_OPTIONS=$(getopt -n "${0##*/}" -o hb:p:m:l:o: \
--long help,base-dir:,package-name:,output-dir:,module:,library: -- "$@")
if [ $? != 0 ] ; then print_hint ; exit 1 ; fi
eval set -- "$PARSED_OPTIONS"
while true; do
case "$1" in
-h|--help)
echo "${0##*/} [options]"
echo ""
echo "options:"
echo "-h, --help show brief help"
echo "-b, --base-dir=DIR project base directory"
echo "-p, --package-name=NAME project package name"
echo "-o, --output-dir=DIR file output directory"
echo "-m, --module=MOD extra python module to interrogate for options"
echo "-l, --library=LIB extra library that registers options for discovery"
exit 0
;;
-b|--base-dir)
shift
BASEDIR=`echo $1 | sed -e 's/\/*$//g'`
shift
;;
-p|--package-name)
shift
PACKAGENAME=`echo $1`
shift
;;
-o|--output-dir)
shift
OUTPUTDIR=`echo $1 | sed -e 's/\/*$//g'`
shift
;;
-m|--module)
shift
MODULES="$MODULES -m $1"
shift
;;
-l|--library)
shift
LIBRARIES="$LIBRARIES -l $1"
shift
;;
--)
break
;;
esac
done
BASEDIR=${BASEDIR:-`pwd`}
if ! [ -d $BASEDIR ]
then
echo "${0##*/}: missing project base directory" >&2 ; print_hint ; exit 1
elif [[ $BASEDIR != /* ]]
then
BASEDIR=$(cd "$BASEDIR" && pwd)
fi
PACKAGENAME=${PACKAGENAME:-$(python setup.py --name)}
TARGETDIR=$BASEDIR/$PACKAGENAME
if ! [ -d $TARGETDIR ]
then
echo "${0##*/}: invalid project package name" >&2 ; print_hint ; exit 1
fi
OUTPUTDIR=${OUTPUTDIR:-$BASEDIR/etc}
# NOTE(bnemec): Some projects put their sample config in etc/,
# some in etc/$PACKAGENAME/
if [ -d $OUTPUTDIR/$PACKAGENAME ]
then
OUTPUTDIR=$OUTPUTDIR/$PACKAGENAME
elif ! [ -d $OUTPUTDIR ]
then
echo "${0##*/}: cannot access \`$OUTPUTDIR': No such file or directory" >&2
exit 1
fi
BASEDIRESC=`echo $BASEDIR | sed -e 's/\//\\\\\//g'`
find $TARGETDIR -type f -name "*.pyc" -delete
FILES=$(find $TARGETDIR -type f -name "*.py" ! -path "*/tests/*" \
-exec grep -l "Opt(" {} + | sed -e "s/^$BASEDIRESC\///g" | sort -u)
RC_FILE="`dirname $0`/oslo.config.generator.rc"
if test -r "$RC_FILE"
then
source "$RC_FILE"
fi
for filename in ${CEILOMETER_CONFIG_GENERATOR_EXCLUDED_FILES}; do
FILES="${FILES[@]/$filename/}"
done
for mod in ${CEILOMETER_CONFIG_GENERATOR_EXTRA_MODULES}; do
MODULES="$MODULES -m $mod"
done
for lib in ${CEILOMETER_CONFIG_GENERATOR_EXTRA_LIBRARIES}; do
LIBRARIES="$LIBRARIES -l $lib"
done
export EVENTLET_NO_GREENDNS=yes
OS_VARS=$(set | sed -n '/^OS_/s/=[^=]*$//gp' | xargs)
[ "$OS_VARS" ] && eval "unset \$OS_VARS"
DEFAULT_MODULEPATH=ceilometer.openstack.common.config.generator
MODULEPATH=${MODULEPATH:-$DEFAULT_MODULEPATH}
OUTPUTFILE=$OUTPUTDIR/$PACKAGENAME.conf.sample
python -m $MODULEPATH $MODULES $LIBRARIES $FILES > $OUTPUTFILE
if [ $? != 0 ]
then
echo "Can not generate $OUTPUTFILE"
exit 1
fi
# Hook to allow projects to append custom config file snippets
CONCAT_FILES=$(ls $BASEDIR/tools/config/*.conf.sample 2>/dev/null)
for CONCAT_FILE in $CONCAT_FILES; do
cat $CONCAT_FILE >> $OUTPUTFILE
done

View File

@ -1,2 +0,0 @@
CEILOMETER_CONFIG_GENERATOR_EXTRA_LIBRARIES="oslo.messaging oslo.db"
CEILOMETER_CONFIG_GENERATOR_EXTRA_MODULES=keystonemiddleware.auth_token

View File

@ -42,7 +42,11 @@ commands =
[testenv:genconfig]
commands =
bash tools/config/generate_sample.sh -b . -p ceilometer -o etc/ceilometer
oslo-config-generator --output-file etc/ceilometer/ceilometer.conf \
--namespace ceilometer \
--namespace oslo.db \
--namespace oslo.messaging \
--namespace keystonemiddleware.auth_token
[testenv:docs]
commands = python setup.py build_sphinx