diff --git a/marconi/common/utils.py b/marconi/common/utils.py index 8798d9869..9d11c9fab 100644 --- a/marconi/common/utils.py +++ b/marconi/common/utils.py @@ -64,18 +64,3 @@ def dict_to_conf(options): opts.append(opt_type(name=k, default=v)) 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) diff --git a/marconi/queues/bootstrap.py b/marconi/queues/bootstrap.py index 03ef15e76..f7f9fe7bb 100644 --- a/marconi/queues/bootstrap.py +++ b/marconi/queues/bootstrap.py @@ -13,14 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import itertools - from oslo.config import cfg from stevedore import driver from marconi.common import decorators from marconi.common import errors -from marconi.common import utils from marconi.openstack.common.cache import cache as oslo_cache from marconi.openstack.common import log from marconi.queues.storage import pipeline @@ -30,7 +27,7 @@ from marconi.queues import transport # NOQA LOG = log.getLogger(__name__) -_GENERAL_OPTIONS = [ +_GENERAL_OPTIONS = ( cfg.BoolOpt('sharding', default=False, help=('Enable sharding across multiple storage backends. ', 'If sharding is enabled, the storage driver ', @@ -38,21 +35,21 @@ _GENERAL_OPTIONS = [ 'catalogue/control plane data is kept.')), cfg.BoolOpt('admin_mode', default=False, help='Activate endpoints to manage shard registry.'), -] +) -_DRIVER_OPTIONS = [ +_DRIVER_OPTIONS = ( cfg.StrOpt('transport', default='wsgi', help='Transport driver to use.'), cfg.StrOpt('storage', default='sqlite', help='Storage driver to use.'), -] +) _DRIVER_GROUP = 'drivers' def _config_options(): - return itertools.chain(utils.options_iter(_GENERAL_OPTIONS), - utils.options_iter(_DRIVER_OPTIONS, _DRIVER_GROUP)) + return [(None, _GENERAL_OPTIONS), + (_DRIVER_GROUP, _DRIVER_OPTIONS)] class Bootstrap(object): diff --git a/marconi/queues/storage/mongodb/options.py b/marconi/queues/storage/mongodb/options.py index 1e8f53faf..998f5743a 100644 --- a/marconi/queues/storage/mongodb/options.py +++ b/marconi/queues/storage/mongodb/options.py @@ -18,10 +18,8 @@ from oslo.config import cfg -from marconi.common import utils - -MONGODB_OPTIONS = [ +MONGODB_OPTIONS = ( cfg.StrOpt('uri', help='Mongodb Connection URI.'), # Database name @@ -63,10 +61,10 @@ MONGODB_OPTIONS = [ 'after a primary node failover. ' 'The actual sleep time increases exponentially (power ' 'of 2) each time the operation is retried.')), -] +) MONGODB_GROUP = 'drivers:storage:mongodb' def _config_options(): - return utils.options_iter(MONGODB_OPTIONS, MONGODB_GROUP) + return [(MONGODB_GROUP, MONGODB_OPTIONS)] diff --git a/marconi/queues/storage/pipeline.py b/marconi/queues/storage/pipeline.py index 5b2d051d4..e3f6e244a 100644 --- a/marconi/queues/storage/pipeline.py +++ b/marconi/queues/storage/pipeline.py @@ -19,7 +19,6 @@ from stevedore import driver from marconi import common from marconi.common import decorators -from marconi.common import utils from marconi.openstack.common.gettextutils import _ from marconi.openstack.common import log as logging from marconi.queues.storage import base @@ -28,7 +27,7 @@ LOG = logging.getLogger(__name__) _PIPELINE_RESOURCES = ('queue', 'message', 'claim') -_PIPELINE_CONFIGS = [ +_PIPELINE_CONFIGS = tuple(( cfg.ListOpt(resource + '_pipeline', default=[], help=_('Pipeline to use for processing {0} operations. ' 'This pipeline will be consumed before calling ' @@ -36,13 +35,13 @@ _PIPELINE_CONFIGS = [ 'which will always be appended to this ' 'pipeline.').format(resource)) for resource in _PIPELINE_RESOURCES -] +)) _PIPELINE_GROUP = 'storage' def _config_options(): - return utils.options_iter(_PIPELINE_CONFIGS, _PIPELINE_GROUP) + return [(_PIPELINE_GROUP, _PIPELINE_CONFIGS)] def _get_storage_pipeline(resource_name, conf): diff --git a/marconi/queues/storage/sharding.py b/marconi/queues/storage/sharding.py index d10ffd670..23edbda15 100644 --- a/marconi/queues/storage/sharding.py +++ b/marconi/queues/storage/sharding.py @@ -21,7 +21,6 @@ from oslo.config import cfg from marconi.common import decorators from marconi.common.storage import select -from marconi.common import utils as common_utils from marconi.openstack.common import log from marconi.queues import storage from marconi.queues.storage import errors @@ -29,10 +28,10 @@ from marconi.queues.storage import utils LOG = log.getLogger(__name__) -_CATALOG_OPTIONS = [ +_CATALOG_OPTIONS = ( cfg.IntOpt('storage', default='sqlite', help='Catalog storage driver.'), -] +) _CATALOG_GROUP = 'sharding:catalog' @@ -49,7 +48,7 @@ _SHARD_CACHE_TTL = 10 def _config_options(): - return common_utils.options_iter(_CATALOG_OPTIONS, _CATALOG_GROUP) + return [(_CATALOG_GROUP, _CATALOG_OPTIONS)] def _shard_cache_key(queue, project=None): diff --git a/marconi/queues/transport/base.py b/marconi/queues/transport/base.py index 7ad612da4..b3869013a 100644 --- a/marconi/queues/transport/base.py +++ b/marconi/queues/transport/base.py @@ -18,15 +18,14 @@ import six from oslo.config import cfg -from marconi.common import utils -_TRANSPORT_OPTIONS = [ - cfg.StrOpt('auth_strategy', default='') -] +_TRANSPORT_OPTIONS = ( + cfg.StrOpt('auth_strategy', default=''), +) def _config_options(): - return utils.options_iter(_TRANSPORT_OPTIONS) + return [(None, _TRANSPORT_OPTIONS)] @six.add_metaclass(abc.ABCMeta) diff --git a/marconi/queues/transport/validation.py b/marconi/queues/transport/validation.py index 608bcf81f..d1bcf6c20 100644 --- a/marconi/queues/transport/validation.py +++ b/marconi/queues/transport/validation.py @@ -17,7 +17,6 @@ import re from oslo.config import cfg -from marconi.common import utils from marconi.openstack.common.gettextutils import _ MIN_MESSAGE_TTL = 60 @@ -25,7 +24,7 @@ MIN_CLAIM_TTL = 60 MIN_CLAIM_GRACE = 60 -_TRANSPORT_LIMITS_OPTIONS = [ +_TRANSPORT_LIMITS_OPTIONS = ( cfg.IntOpt('max_queues_per_page', default=20, deprecated_name='queue_paging_uplimit', deprecated_group='limits:transport'), @@ -51,7 +50,7 @@ _TRANSPORT_LIMITS_OPTIONS = [ cfg.IntOpt('max_claim_grace', default=43200, deprecated_name='claim_grace_max', deprecated_group='limits:transport'), -] +) _TRANSPORT_LIMITS_GROUP = 'transport' @@ -63,8 +62,7 @@ PROJECT_ID_MAX_LEN = 256 def _config_options(): - return utils.options_iter(_TRANSPORT_LIMITS_OPTIONS, - _TRANSPORT_LIMITS_GROUP) + return [(_TRANSPORT_LIMITS_GROUP, _TRANSPORT_LIMITS_OPTIONS)] class ValidationFailed(ValueError): diff --git a/marconi/queues/transport/wsgi/driver.py b/marconi/queues/transport/wsgi/driver.py index 2d86296c3..ce4a310d6 100644 --- a/marconi/queues/transport/wsgi/driver.py +++ b/marconi/queues/transport/wsgi/driver.py @@ -14,7 +14,6 @@ # limitations under the License. import functools -import itertools from wsgiref import simple_server import falcon @@ -22,7 +21,6 @@ from oslo.config import cfg from marconi.common import decorators from marconi.common.transport.wsgi import helpers -from marconi.common import utils from marconi.openstack.common.gettextutils import _ import marconi.openstack.common.log as logging from marconi.queues import transport @@ -31,13 +29,13 @@ from marconi.queues.transport import validation from marconi.queues.transport.wsgi import v1_0 from marconi.queues.transport.wsgi import v1_1 -_WSGI_OPTIONS = [ +_WSGI_OPTIONS = ( cfg.StrOpt('bind', default='127.0.0.1', help='Address on which the self-hosting server will listen.'), cfg.IntOpt('port', default=8888, help='Port on which the self-hosting server will listen.'), -] +) _WSGI_GROUP = 'drivers:transport:wsgi' @@ -45,7 +43,7 @@ LOG = logging.getLogger(__name__) def _config_options(): - return itertools.chain(utils.options_iter(_WSGI_OPTIONS, _WSGI_GROUP)) + return [(_WSGI_GROUP, _WSGI_OPTIONS)] class Driver(transport.DriverBase): diff --git a/marconi/tests/functional/config.py b/marconi/tests/functional/config.py index e66600da6..69a6056dd 100644 --- a/marconi/tests/functional/config.py +++ b/marconi/tests/functional/config.py @@ -18,31 +18,31 @@ import os from oslo.config import cfg -_DEFAULT = [ +_DEFAULT = ( cfg.BoolOpt("run_tests", default=True), -] +) -_AUTH_OPTIONS = [ +_AUTH_OPTIONS = ( cfg.BoolOpt("auth_on", default=False), cfg.StrOpt("url", default="https://127.0.0.1:5000/v2.0/tokens"), cfg.StrOpt("username", default=None), cfg.StrOpt("password", default=None), -] +) -_MARCONI_OPTIONS = [ +_MARCONI_OPTIONS = ( cfg.BoolOpt("run_server", default=True), cfg.StrOpt("url", default="http://127.0.0.1:8888"), cfg.StrOpt("version", default="v1"), cfg.StrOpt("config", default="functional-marconi.conf"), -] +) -_HEADERS_OPTIONS = [ +_HEADERS_OPTIONS = ( cfg.StrOpt("host", default="example.com"), cfg.StrOpt("user_agent", default="FunctionalTests"), cfg.StrOpt("project_id", default="123456"), -] +) def load_config():