Merge "Change configuration section names"
This commit is contained in:
commit
da54a587c5
@ -30,46 +30,59 @@ from cloudkitty import utils as ck_utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
GNOCCHI_COLLECTOR_OPTS = 'gnocchi_collector'
|
||||
gnocchi_collector_opts = ks_loading.get_auth_common_conf_options()
|
||||
gcollector_opts = [
|
||||
# NOTE(mc): The deprecated section should be removed in a future release.
|
||||
COLLECTOR_GNOCCHI_OPTS = 'collector_gnocchi'
|
||||
DEPRECATED_COLLECTOR_GNOCCHI_OPTS = 'gnocchi_collector'
|
||||
|
||||
keystone_opts = ks_loading.get_auth_common_conf_options() + \
|
||||
ks_loading.get_session_conf_options()
|
||||
|
||||
keystone_opts = [
|
||||
cfg.Opt(
|
||||
o.name,
|
||||
type=o.type,
|
||||
deprecated_group=DEPRECATED_COLLECTOR_GNOCCHI_OPTS,
|
||||
) for o in keystone_opts
|
||||
]
|
||||
|
||||
collector_gnocchi_opts = [
|
||||
cfg.StrOpt(
|
||||
'gnocchi_auth_type',
|
||||
default='keystone',
|
||||
choices=['keystone', 'basic'],
|
||||
help='Gnocchi auth type (keystone or basic). Keystone credentials '
|
||||
'can be specified through the "auth_section" parameter',
|
||||
deprecated_group=DEPRECATED_COLLECTOR_GNOCCHI_OPTS,
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'gnocchi_user',
|
||||
default='',
|
||||
help='Gnocchi user (for basic auth only)',
|
||||
deprecated_group=DEPRECATED_COLLECTOR_GNOCCHI_OPTS,
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'gnocchi_endpoint',
|
||||
default='',
|
||||
help='Gnocchi endpoint (for basic auth only)',
|
||||
deprecated_group=DEPRECATED_COLLECTOR_GNOCCHI_OPTS,
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'interface',
|
||||
default='internalURL',
|
||||
help='Endpoint URL type (for keystone auth only)',
|
||||
deprecated_group=DEPRECATED_COLLECTOR_GNOCCHI_OPTS,
|
||||
),
|
||||
cfg.StrOpt(
|
||||
'region_name',
|
||||
default='RegionOne',
|
||||
help='Region Name',
|
||||
deprecated_group=DEPRECATED_COLLECTOR_GNOCCHI_OPTS,
|
||||
),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(gnocchi_collector_opts, GNOCCHI_COLLECTOR_OPTS)
|
||||
cfg.CONF.register_opts(gcollector_opts, GNOCCHI_COLLECTOR_OPTS)
|
||||
ks_loading.register_session_conf_options(
|
||||
cfg.CONF,
|
||||
GNOCCHI_COLLECTOR_OPTS)
|
||||
ks_loading.register_auth_conf_options(
|
||||
cfg.CONF,
|
||||
GNOCCHI_COLLECTOR_OPTS)
|
||||
cfg.CONF.register_opts(keystone_opts, COLLECTOR_GNOCCHI_OPTS)
|
||||
cfg.CONF.register_opts(collector_gnocchi_opts, COLLECTOR_GNOCCHI_OPTS)
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
GNOCCHI_EXTRA_SCHEMA = {
|
||||
@ -92,23 +105,23 @@ class GnocchiCollector(collector.BaseCollector):
|
||||
super(GnocchiCollector, self).__init__(transformers, **kwargs)
|
||||
|
||||
adapter_options = {'connect_retries': 3}
|
||||
if CONF.gnocchi_collector.gnocchi_auth_type == 'keystone':
|
||||
if CONF.collector_gnocchi.gnocchi_auth_type == 'keystone':
|
||||
auth_plugin = ks_loading.load_auth_from_conf_options(
|
||||
CONF,
|
||||
'gnocchi_collector',
|
||||
COLLECTOR_GNOCCHI_OPTS,
|
||||
)
|
||||
adapter_options['interface'] = CONF.gnocchi_collector.interface
|
||||
adapter_options['interface'] = CONF.collector_gnocchi.interface
|
||||
else:
|
||||
auth_plugin = gauth.GnocchiBasicPlugin(
|
||||
user=CONF.gnocchi_collector.gnocchi_user,
|
||||
endpoint=CONF.gnocchi_collector.gnocchi_endpoint,
|
||||
user=CONF.collector_gnocchi.gnocchi_user,
|
||||
endpoint=CONF.collector_gnocchi.gnocchi_endpoint,
|
||||
)
|
||||
adapter_options['region_name'] = CONF.gnocchi_collector.region_name
|
||||
adapter_options['region_name'] = CONF.collector_gnocchi.region_name
|
||||
|
||||
verify = True
|
||||
if CONF.gnocchi_collector.cafile:
|
||||
verify = CONF.gnocchi_collector.cafile
|
||||
elif CONF.gnocchi_collector.insecure:
|
||||
if CONF.collector_gnocchi.cafile:
|
||||
verify = CONF.collector_gnocchi.cafile
|
||||
elif CONF.collector_gnocchi.insecure:
|
||||
verify = False
|
||||
|
||||
self._conn = gclient.Client(
|
||||
|
@ -35,8 +35,8 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
MONASCA_API_VERSION = '2_0'
|
||||
COLLECTOR_MONASCA_OPTS = 'collector_monasca'
|
||||
collector_monasca_opts = ks_loading.get_auth_common_conf_options()
|
||||
mcollector_opts = [
|
||||
|
||||
collector_monasca_opts = [
|
||||
cfg.StrOpt(
|
||||
'interface',
|
||||
default='internal',
|
||||
@ -50,7 +50,6 @@ mcollector_opts = [
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(collector_monasca_opts, COLLECTOR_MONASCA_OPTS)
|
||||
cfg.CONF.register_opts(mcollector_opts, COLLECTOR_MONASCA_OPTS)
|
||||
ks_loading.register_session_conf_options(
|
||||
cfg.CONF,
|
||||
COLLECTOR_MONASCA_OPTS)
|
||||
|
@ -33,7 +33,7 @@ from cloudkitty import utils as ck_utils
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
PROMETHEUS_COLLECTOR_OPTS = 'prometheus_collector'
|
||||
PROMETHEUS_COLLECTOR_OPTS = 'collector_prometheus'
|
||||
pcollector_collector_opts = [
|
||||
cfg.StrOpt(
|
||||
'prometheus_url',
|
||||
@ -137,7 +137,7 @@ class PrometheusCollector(collector.BaseCollector):
|
||||
"""Returns metrics to be valorized."""
|
||||
# NOTE(mc): Remove potential trailing '/' to avoid
|
||||
# url building problems
|
||||
url = CONF.prometheus_collector.prometheus_url
|
||||
url = CONF.collector_prometheus.prometheus_url
|
||||
if url.endswith('/'):
|
||||
url = url[:-1]
|
||||
|
||||
|
@ -38,20 +38,19 @@ _opts = [
|
||||
cloudkitty.api.app.api_opts,))),
|
||||
('collect', list(itertools.chain(
|
||||
cloudkitty.collector.collect_opts))),
|
||||
('collector_gnocchi', list(itertools.chain(
|
||||
cloudkitty.collector.gnocchi.keystone_opts,
|
||||
cloudkitty.collector.gnocchi.collector_gnocchi_opts))),
|
||||
('collector_monasca', list(itertools.chain(
|
||||
cloudkitty.collector.monasca.collector_monasca_opts,
|
||||
cloudkitty.collector.monasca.mcollector_opts))),
|
||||
('gnocchi_collector', list(itertools.chain(
|
||||
cloudkitty.collector.gnocchi.gcollector_opts,
|
||||
cloudkitty.collector.gnocchi.gnocchi_collector_opts))),
|
||||
cloudkitty.collector.monasca.collector_monasca_opts))),
|
||||
('fetcher_gnocchi', list(itertools.chain(
|
||||
cloudkitty.fetcher.gnocchi.gfetcher_opts,
|
||||
cloudkitty.fetcher.gnocchi.fetcher_gnocchi_opts))),
|
||||
('keystone_fetcher', list(itertools.chain(
|
||||
cloudkitty.fetcher.keystone.keystone_fetcher_opts,
|
||||
cloudkitty.fetcher.keystone.keystone_common_opts))),
|
||||
('source_fetcher', list(itertools.chain(
|
||||
cloudkitty.fetcher.source.source_fetcher_opts))),
|
||||
('fetcher_keystone', list(itertools.chain(
|
||||
cloudkitty.fetcher.keystone.keystone_opts,
|
||||
cloudkitty.fetcher.keystone.fetcher_keystone_opts))),
|
||||
('fetcher_source', list(itertools.chain(
|
||||
cloudkitty.fetcher.source.fetcher_source_opts))),
|
||||
('orchestrator', list(itertools.chain(
|
||||
cloudkitty.orchestrator.orchestrator_opts))),
|
||||
('output', list(itertools.chain(
|
||||
|
@ -25,21 +25,42 @@ from oslo_config import cfg
|
||||
from cloudkitty import fetcher
|
||||
|
||||
|
||||
KEYSTONE_FETCHER_OPTS = 'keystone_fetcher'
|
||||
keystone_common_opts = ks_loading.get_auth_common_conf_options()
|
||||
keystone_fetcher_opts = [
|
||||
cfg.StrOpt('keystone_version',
|
||||
default='2',
|
||||
help='Keystone version to use.'), ]
|
||||
# NOTE(mc): The deprecated section should be removed in a future release.
|
||||
FETCHER_KEYSTONE_OPTS = 'fetcher_keystone'
|
||||
DEPRECATED_FETCHER_KEYSTONE_OPTS = 'keystone_fetcher'
|
||||
|
||||
keystone_opts = ks_loading.get_auth_common_conf_options() + \
|
||||
ks_loading.get_session_conf_options()
|
||||
|
||||
keystone_opts = [
|
||||
cfg.Opt(
|
||||
opt.name,
|
||||
type=opt.type,
|
||||
help=opt.help,
|
||||
secret=opt.secret,
|
||||
required=opt.required,
|
||||
deprecated_group=DEPRECATED_FETCHER_KEYSTONE_OPTS,
|
||||
) for opt in keystone_opts
|
||||
]
|
||||
|
||||
fetcher_keystone_opts = [
|
||||
cfg.StrOpt(
|
||||
'keystone_version',
|
||||
default='2',
|
||||
help='Keystone version to use.',
|
||||
deprecated_group=DEPRECATED_FETCHER_KEYSTONE_OPTS,
|
||||
),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(keystone_opts, FETCHER_KEYSTONE_OPTS)
|
||||
if cfg.CONF[FETCHER_KEYSTONE_OPTS].auth_section:
|
||||
cfg.CONF.register_opts(
|
||||
keystone_opts,
|
||||
cfg.CONF[FETCHER_KEYSTONE_OPTS].auth_section,
|
||||
)
|
||||
|
||||
cfg.CONF.register_opts(fetcher_keystone_opts, FETCHER_KEYSTONE_OPTS)
|
||||
|
||||
cfg.CONF.register_opts(keystone_common_opts, KEYSTONE_FETCHER_OPTS)
|
||||
cfg.CONF.register_opts(keystone_fetcher_opts, KEYSTONE_FETCHER_OPTS)
|
||||
ks_loading.register_session_conf_options(
|
||||
cfg.CONF,
|
||||
KEYSTONE_FETCHER_OPTS)
|
||||
ks_loading.register_auth_conf_options(
|
||||
cfg.CONF,
|
||||
KEYSTONE_FETCHER_OPTS)
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
@ -51,19 +72,19 @@ class KeystoneFetcher(fetcher.BaseFetcher):
|
||||
def __init__(self):
|
||||
self.auth = ks_loading.load_auth_from_conf_options(
|
||||
CONF,
|
||||
KEYSTONE_FETCHER_OPTS)
|
||||
FETCHER_KEYSTONE_OPTS)
|
||||
self.session = ks_loading.load_session_from_conf_options(
|
||||
CONF,
|
||||
KEYSTONE_FETCHER_OPTS,
|
||||
FETCHER_KEYSTONE_OPTS,
|
||||
auth=self.auth)
|
||||
self.admin_ks = kclient.Client(
|
||||
version=CONF.keystone_fetcher.keystone_version,
|
||||
version=CONF.fetcher_keystone.keystone_version,
|
||||
session=self.session,
|
||||
auth_url=self.auth.auth_url)
|
||||
|
||||
def get_tenants(self):
|
||||
keystone_version = discover.normalize_version_number(
|
||||
CONF.keystone_fetcher.keystone_version)
|
||||
CONF.fetcher_keystone.keystone_version)
|
||||
auth_dispatch = {(3,): ('project', 'projects', 'list'),
|
||||
(2,): ('tenant', 'tenants', 'roles_for_user')}
|
||||
for auth_version, auth_version_mapping in auth_dispatch.items():
|
||||
|
@ -20,13 +20,21 @@ from oslo_config import cfg
|
||||
from cloudkitty import fetcher
|
||||
|
||||
|
||||
SOURCE_FETCHER_OPTS = 'source_fetcher'
|
||||
source_fetcher_opts = [
|
||||
cfg.ListOpt('sources',
|
||||
default=list(),
|
||||
help='list of source identifiers'), ]
|
||||
# NOTE(mc): The deprecated section should be removed in a future release.
|
||||
FETCHER_SOURCE_OPTS = 'fetcher_source'
|
||||
DEPRECATED_FETCHER_SOURCE_OPTS = 'source_fetcher'
|
||||
|
||||
fetcher_source_opts = [
|
||||
cfg.ListOpt(
|
||||
'sources',
|
||||
default=list(),
|
||||
help='list of source identifiers',
|
||||
deprecated_group=DEPRECATED_FETCHER_SOURCE_OPTS,
|
||||
),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(fetcher_source_opts, FETCHER_SOURCE_OPTS)
|
||||
|
||||
cfg.CONF.register_opts(source_fetcher_opts, SOURCE_FETCHER_OPTS)
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
@ -36,4 +44,4 @@ class SourceFetcher(fetcher.BaseFetcher):
|
||||
name = 'source'
|
||||
|
||||
def get_tenants(self):
|
||||
return CONF.source_fetcher.sources
|
||||
return CONF.fetcher_source.sources
|
||||
|
@ -26,16 +26,23 @@ from cloudkitty.storage.v1.hybrid import models
|
||||
from cloudkitty import utils as ck_utils
|
||||
|
||||
|
||||
# NOTE(mc): The deprecated section should be removed in a future release.
|
||||
DEPRECATED_STORAGE_HYBRID_OPTS = 'hybrid_storage'
|
||||
STORAGE_HYBRID_OPTS = 'storage_hybrid'
|
||||
|
||||
storage_opts = [
|
||||
cfg.StrOpt(
|
||||
'backend',
|
||||
default='gnocchi',
|
||||
help='Name of the storage backend that should be used '
|
||||
'by the hybrid storage')
|
||||
'by the hybrid storage',
|
||||
deprecated_group=DEPRECATED_STORAGE_HYBRID_OPTS,
|
||||
)
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(storage_opts, group='hybrid_storage')
|
||||
|
||||
CONF.register_opts(storage_opts, group=STORAGE_HYBRID_OPTS)
|
||||
|
||||
HYBRID_BACKENDS_NAMESPACE = 'cloudkitty.storage.hybrid.backends'
|
||||
|
||||
@ -53,7 +60,7 @@ class HybridStorage(BaseStorage):
|
||||
super(HybridStorage, self).__init__(**kwargs)
|
||||
self._hybrid_backend = driver.DriverManager(
|
||||
HYBRID_BACKENDS_NAMESPACE,
|
||||
cfg.CONF.hybrid_storage.backend,
|
||||
cfg.CONF.storage_hybrid.backend,
|
||||
invoke_on_load=True).driver
|
||||
self._sql_session = {}
|
||||
|
||||
|
@ -74,11 +74,11 @@ class KeystoneFetcherTest(tests.TestCase):
|
||||
def setUp(self):
|
||||
super(KeystoneFetcherTest, self).setUp()
|
||||
self.conf.set_override('backend', 'keystone', 'tenant_fetcher')
|
||||
self.conf.import_group('keystone_fetcher',
|
||||
self.conf.import_group('fetcher_keystone',
|
||||
'cloudkitty.fetcher.keystone')
|
||||
|
||||
@unittest.SkipTest
|
||||
def test_keystone_fetcher_filter_list(self):
|
||||
def test_fetcher_keystone_filter_list(self):
|
||||
kclient = 'keystoneclient.client.Client'
|
||||
with mock.patch(kclient) as kclientmock:
|
||||
kclientmock.return_value = Client()
|
||||
|
@ -43,7 +43,7 @@ class OrchestratorTest(tests.TestCase):
|
||||
messaging_conf = self.useFixture(conffixture.ConfFixture(self.conf))
|
||||
messaging_conf.transport_url = 'fake:/'
|
||||
self.conf.set_override('backend', 'keystone', 'fetcher')
|
||||
self.conf.import_group('keystone_fetcher',
|
||||
self.conf.import_group('fetcher_keystone',
|
||||
'cloudkitty.fetcher.keystone')
|
||||
|
||||
def setup_fake_modules(self):
|
||||
|
@ -159,8 +159,8 @@ function configure_cloudkitty {
|
||||
iniset $CLOUDKITTY_CONF authinfos project_domain_name default
|
||||
iniset $CLOUDKITTY_CONF authinfos debug "$ENABLE_DEBUG_LOG_LEVEL"
|
||||
|
||||
iniset $CLOUDKITTY_CONF keystone_fetcher auth_section authinfos
|
||||
iniset $CLOUDKITTY_CONF keystone_fetcher keystone_version 3
|
||||
iniset $CLOUDKITTY_CONF fetcher_keystone auth_section authinfos
|
||||
iniset $CLOUDKITTY_CONF fetcher_keystone keystone_version 3
|
||||
|
||||
# collect
|
||||
iniset $CLOUDKITTY_CONF collect collector $CLOUDKITTY_COLLECTOR
|
||||
|
@ -69,7 +69,7 @@ The following shows the basic configuration items:
|
||||
[database]
|
||||
connection = mysql+pymysql://CK_DBUSER:CK_DBPASSWORD@DB_HOST/cloudkitty
|
||||
|
||||
[keystone_fetcher]
|
||||
[fetcher_keystone]
|
||||
auth_section = ks_auth
|
||||
keystone_version = 3
|
||||
|
||||
@ -96,13 +96,7 @@ available: ``sqlalchemy`` and ``hybrid`` (SQLalchemy being the recommended one).
|
||||
As you will see in the following example, collector and storage backends
|
||||
sometimes need additional configuration sections. (The tenant fetcher works the
|
||||
same way). The section's name has the following format:
|
||||
``{backend_name}_{backend_type}`` (``gnocchi_collector`` for example), except
|
||||
for ``storage_gnocchi``.
|
||||
|
||||
.. note::
|
||||
|
||||
The section name format should become ``{backend_type}_{backend_name}`` for
|
||||
all sections in the future (``storage_gnocchi`` style).
|
||||
``{backend_type}_{backend_name}`` (``collector_gnocchi`` for example).
|
||||
|
||||
If you want to use the hybrid storage with a gnocchi backend, add the following
|
||||
entry:
|
||||
@ -126,7 +120,7 @@ without modifying source code or Cloudkitty configuration file.
|
||||
[collect]
|
||||
metrics_conf = /etc/cloudkitty/metrics.yml
|
||||
|
||||
[gnocchi_collector]
|
||||
[collector_gnocchi]
|
||||
auth_section = ks_auth
|
||||
|
||||
The ``/etc/cloudkitty/metrics.yml`` file looks like this:
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
deprecations:
|
||||
- |
|
||||
The 'gnocchi_collector', 'hybrid_storage', 'keystone_fetcher' and 'source_fetcher' group names have been deprecated and will be removed
|
||||
in the future. Use the 'collector_gnocchi', 'storage_hybrid', 'fetcher_keystone' and 'fetcher_source' group names instead.
|
Loading…
x
Reference in New Issue
Block a user