Add a _config_options function to Marconi
This function is necessary for options discoverability and manual options registration. This first patch adds a config function to every module defining options in marconi. Those functions were registered as entrypoints that will then be loaded by the configuration sample generator. Change-Id: I2c351c14c7e1b104926162336ed3567696c62dfb
This commit is contained in:
parent
dcd341d5b8
commit
436557d5f6
@ -63,3 +63,18 @@ def dict_to_conf(options):
|
|||||||
opts.append(opt_type(name=k, default=v))
|
opts.append(opt_type(name=k, default=v))
|
||||||
|
|
||||||
return opts
|
return opts
|
||||||
|
|
||||||
|
|
||||||
|
def options_iter(options, group=None):
|
||||||
|
"""Returns an options iterable
|
||||||
|
|
||||||
|
This function returns an iterable of
|
||||||
|
(option, config) pairs.
|
||||||
|
|
||||||
|
:param options: Iterable of options
|
||||||
|
:type options: iter
|
||||||
|
:param group: Group `options` belong to
|
||||||
|
:type group: six.text_type
|
||||||
|
"""
|
||||||
|
for opt in options:
|
||||||
|
yield (opt, group)
|
||||||
|
@ -13,11 +13,14 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import itertools
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from stevedore import driver
|
from stevedore import driver
|
||||||
|
|
||||||
from marconi.common import decorators
|
from marconi.common import decorators
|
||||||
from marconi.common import errors
|
from marconi.common import errors
|
||||||
|
from marconi.common import utils
|
||||||
from marconi.openstack.common.cache import cache as oslo_cache
|
from marconi.openstack.common.cache import cache as oslo_cache
|
||||||
from marconi.openstack.common.gettextutils import _
|
from marconi.openstack.common.gettextutils import _
|
||||||
from marconi.openstack.common import log
|
from marconi.openstack.common import log
|
||||||
@ -48,6 +51,11 @@ _DRIVER_OPTIONS = [
|
|||||||
_DRIVER_GROUP = 'drivers'
|
_DRIVER_GROUP = 'drivers'
|
||||||
|
|
||||||
|
|
||||||
|
def _config_options():
|
||||||
|
return itertools.chain(utils.options_iter(_GENERAL_OPTIONS),
|
||||||
|
utils.options_iter(_DRIVER_OPTIONS, _DRIVER_GROUP))
|
||||||
|
|
||||||
|
|
||||||
class Bootstrap(object):
|
class Bootstrap(object):
|
||||||
"""Defines the Marconi bootstrapper.
|
"""Defines the Marconi bootstrapper.
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@ import six
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
from marconi.common import utils
|
||||||
|
|
||||||
|
|
||||||
_LIMITS_OPTIONS = [
|
_LIMITS_OPTIONS = [
|
||||||
cfg.IntOpt('default_queue_paging', default=10,
|
cfg.IntOpt('default_queue_paging', default=10,
|
||||||
help='Default queue pagination size'),
|
help='Default queue pagination size'),
|
||||||
@ -31,6 +34,10 @@ _LIMITS_OPTIONS = [
|
|||||||
_LIMITS_GROUP = 'limits:storage'
|
_LIMITS_GROUP = 'limits:storage'
|
||||||
|
|
||||||
|
|
||||||
|
def _config_options():
|
||||||
|
return utils.options_iter(_LIMITS_OPTIONS, _LIMITS_GROUP)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
class DriverBase(object):
|
class DriverBase(object):
|
||||||
"""Base class for both data and control plane drivers
|
"""Base class for both data and control plane drivers
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
from marconi.common import utils
|
||||||
|
|
||||||
|
|
||||||
MONGODB_OPTIONS = [
|
MONGODB_OPTIONS = [
|
||||||
cfg.StrOpt('uri', help='Mongodb Connection URI'),
|
cfg.StrOpt('uri', help='Mongodb Connection URI'),
|
||||||
@ -54,3 +56,7 @@ MONGODB_OPTIONS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
MONGODB_GROUP = 'drivers:storage:mongodb'
|
MONGODB_GROUP = 'drivers:storage:mongodb'
|
||||||
|
|
||||||
|
|
||||||
|
def _config_options():
|
||||||
|
return utils.options_iter(MONGODB_OPTIONS, MONGODB_GROUP)
|
||||||
|
@ -19,6 +19,7 @@ from stevedore import driver
|
|||||||
|
|
||||||
from marconi import common
|
from marconi import common
|
||||||
from marconi.common import decorators
|
from marconi.common import decorators
|
||||||
|
from marconi.common import utils
|
||||||
from marconi.openstack.common.gettextutils import _
|
from marconi.openstack.common.gettextutils import _
|
||||||
from marconi.openstack.common import log as logging
|
from marconi.openstack.common import log as logging
|
||||||
from marconi.queues.storage import base
|
from marconi.queues.storage import base
|
||||||
@ -40,6 +41,10 @@ _PIPELINE_CONFIGS = [
|
|||||||
_PIPELINE_GROUP = 'storage'
|
_PIPELINE_GROUP = 'storage'
|
||||||
|
|
||||||
|
|
||||||
|
def _config_options():
|
||||||
|
return utils.options_iter(_PIPELINE_CONFIGS, _PIPELINE_GROUP)
|
||||||
|
|
||||||
|
|
||||||
def _get_storage_pipeline(resource_name, conf):
|
def _get_storage_pipeline(resource_name, conf):
|
||||||
"""Constructs and returns a storage resource pipeline.
|
"""Constructs and returns a storage resource pipeline.
|
||||||
|
|
||||||
|
@ -49,6 +49,10 @@ _SHARD_CACHE_PREFIX = 'sharding:'
|
|||||||
_SHARD_CACHE_TTL = 10
|
_SHARD_CACHE_TTL = 10
|
||||||
|
|
||||||
|
|
||||||
|
def _config_options():
|
||||||
|
return common_utils.options_iter(_CATALOG_OPTIONS, _CATALOG_GROUP)
|
||||||
|
|
||||||
|
|
||||||
def _shard_cache_key(queue, project=None):
|
def _shard_cache_key(queue, project=None):
|
||||||
# NOTE(kgriffs): Use string concatenation for performance,
|
# NOTE(kgriffs): Use string concatenation for performance,
|
||||||
# also put project first since it is guaranteed to be
|
# also put project first since it is guaranteed to be
|
||||||
|
@ -18,29 +18,21 @@ import json
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from oslo.config import cfg
|
|
||||||
|
|
||||||
from marconi.common import decorators
|
from marconi.common import decorators
|
||||||
from marconi.queues import storage
|
from marconi.queues import storage
|
||||||
from marconi.queues.storage.sqlite import controllers
|
from marconi.queues.storage.sqlite import controllers
|
||||||
|
from marconi.queues.storage.sqlite import options
|
||||||
from marconi.queues.storage.sqlite import utils
|
from marconi.queues.storage.sqlite import utils
|
||||||
|
|
||||||
|
|
||||||
_SQLITE_OPTIONS = [
|
|
||||||
cfg.StrOpt('database', default=':memory:',
|
|
||||||
help='Sqlite database to use.')
|
|
||||||
]
|
|
||||||
|
|
||||||
_SQLITE_GROUP = 'drivers:storage:sqlite'
|
|
||||||
|
|
||||||
|
|
||||||
class DataDriver(storage.DataDriverBase):
|
class DataDriver(storage.DataDriverBase):
|
||||||
|
|
||||||
def __init__(self, conf, cache):
|
def __init__(self, conf, cache):
|
||||||
super(DataDriver, self).__init__(conf, cache)
|
super(DataDriver, self).__init__(conf, cache)
|
||||||
|
|
||||||
self.conf.register_opts(_SQLITE_OPTIONS, group=_SQLITE_GROUP)
|
self.conf.register_opts(options.SQLITE_OPTIONS,
|
||||||
self.sqlite_conf = self.conf[_SQLITE_GROUP]
|
group=options.SQLITE_GROUP)
|
||||||
|
self.sqlite_conf = self.conf[options.SQLITE_GROUP]
|
||||||
|
|
||||||
self.__path = self.sqlite_conf.database
|
self.__path = self.sqlite_conf.database
|
||||||
|
|
||||||
@ -214,8 +206,9 @@ class ControlDriver(storage.ControlDriverBase):
|
|||||||
def __init__(self, conf, cache):
|
def __init__(self, conf, cache):
|
||||||
super(ControlDriver, self).__init__(conf, cache)
|
super(ControlDriver, self).__init__(conf, cache)
|
||||||
|
|
||||||
self.conf.register_opts(_SQLITE_OPTIONS, group=_SQLITE_GROUP)
|
self.conf.register_opts(options.SQLITE_OPTIONS,
|
||||||
self.sqlite_conf = self.conf[_SQLITE_GROUP]
|
group=options.SQLITE_GROUP)
|
||||||
|
self.sqlite_conf = self.conf[options.SQLITE_GROUP]
|
||||||
|
|
||||||
self.__path = self.sqlite_conf.database
|
self.__path = self.sqlite_conf.database
|
||||||
|
|
||||||
|
29
marconi/queues/storage/sqlite/options.py
Normal file
29
marconi/queues/storage/sqlite/options.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# Copyright (c) 2013 Rackspace, 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 oslo.config import cfg
|
||||||
|
|
||||||
|
from marconi.common import utils
|
||||||
|
|
||||||
|
SQLITE_OPTIONS = [
|
||||||
|
cfg.StrOpt('database', default=':memory:',
|
||||||
|
help='Sqlite database to use.')
|
||||||
|
]
|
||||||
|
|
||||||
|
SQLITE_GROUP = 'drivers:storage:sqlite'
|
||||||
|
|
||||||
|
|
||||||
|
def _config_options():
|
||||||
|
return utils.options_iter(SQLITE_OPTIONS, SQLITE_GROUP)
|
@ -18,11 +18,17 @@ import six
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
from marconi.common import utils
|
||||||
|
|
||||||
_TRANSPORT_OPTIONS = [
|
_TRANSPORT_OPTIONS = [
|
||||||
cfg.StrOpt('auth_strategy', default='')
|
cfg.StrOpt('auth_strategy', default='')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def _config_options():
|
||||||
|
return utils.options_iter(_TRANSPORT_OPTIONS)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
class DriverBase(object):
|
class DriverBase(object):
|
||||||
"""Base class for Transport Drivers to document the expected interface.
|
"""Base class for Transport Drivers to document the expected interface.
|
||||||
|
@ -17,6 +17,7 @@ import re
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
from marconi.common import utils
|
||||||
from marconi.openstack.common.gettextutils import _
|
from marconi.openstack.common.gettextutils import _
|
||||||
|
|
||||||
|
|
||||||
@ -39,6 +40,11 @@ QUEUE_NAME_MAX_LEN = 64
|
|||||||
PROJECT_ID_MAX_LEN = 256
|
PROJECT_ID_MAX_LEN = 256
|
||||||
|
|
||||||
|
|
||||||
|
def _config_options():
|
||||||
|
return utils.options_iter(_TRANSPORT_LIMITS_OPTIONS,
|
||||||
|
_TRANSPORT_LIMITS_GROUP)
|
||||||
|
|
||||||
|
|
||||||
class ValidationFailed(ValueError):
|
class ValidationFailed(ValueError):
|
||||||
"""User input did not follow API restrictions."""
|
"""User input did not follow API restrictions."""
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import abc
|
import abc
|
||||||
import functools
|
import functools
|
||||||
|
import itertools
|
||||||
from wsgiref import simple_server
|
from wsgiref import simple_server
|
||||||
|
|
||||||
import falcon
|
import falcon
|
||||||
@ -24,6 +25,7 @@ import six
|
|||||||
from marconi.common import decorators
|
from marconi.common import decorators
|
||||||
from marconi.common.transport import version
|
from marconi.common.transport import version
|
||||||
from marconi.common.transport.wsgi import helpers
|
from marconi.common.transport.wsgi import helpers
|
||||||
|
from marconi.common import utils
|
||||||
from marconi.openstack.common.gettextutils import _
|
from marconi.openstack.common.gettextutils import _
|
||||||
import marconi.openstack.common.log as logging
|
import marconi.openstack.common.log as logging
|
||||||
from marconi.queues import transport
|
from marconi.queues import transport
|
||||||
@ -46,6 +48,10 @@ _WSGI_GROUP = 'drivers:transport:wsgi'
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def _config_options():
|
||||||
|
return itertools.chain(utils.options_iter(_WSGI_OPTIONS, _WSGI_GROUP))
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
@six.add_metaclass(abc.ABCMeta)
|
||||||
class DriverBase(transport.DriverBase):
|
class DriverBase(transport.DriverBase):
|
||||||
|
|
||||||
|
11
setup.cfg
11
setup.cfg
@ -48,6 +48,17 @@ marconi.queues.admin.transport =
|
|||||||
marconi.openstack.common.cache.backends =
|
marconi.openstack.common.cache.backends =
|
||||||
memory = marconi.openstack.common.cache._backends.memory:MemoryBackend
|
memory = marconi.openstack.common.cache._backends.memory:MemoryBackend
|
||||||
|
|
||||||
|
oslo.config.opts =
|
||||||
|
marconi.bootstrap = marconi.queues.bootstrap._config_options
|
||||||
|
marconi.storage.base = marconi.queues.storage.base._config_options
|
||||||
|
marconi.storage.pipeline = marconi.queues.storage.pipeline._config_options
|
||||||
|
marconi.storage.sharding = marconi.queues.storage.sharding._config_options
|
||||||
|
marconi.storage.mongodb = marconi.queues.storage.mongodb.options._config_options
|
||||||
|
marconi.storage.sqlite = marconi.queues.storage.sqlite.options._config_options
|
||||||
|
marconi.transport.wsgi = marconi.queues.transport.wsgi.driver._config_options
|
||||||
|
marconi.transport.base = marconi.queues.transport.base._config_options
|
||||||
|
marconi.transport.validation = marconi.queues.transport.validation._config_options
|
||||||
|
|
||||||
[nosetests]
|
[nosetests]
|
||||||
where=tests
|
where=tests
|
||||||
verbosity=2
|
verbosity=2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user