From cc58b62f1120f5a1b436618be82aea7c1a16a281 Mon Sep 17 00:00:00 2001 From: Samuel de Medeiros Queiroz Date: Mon, 13 Jun 2016 13:21:06 -0300 Subject: [PATCH] Move auth token opts calculation into auth_token The list of all auth token opts is currently calculated in opts.py. That module is included in auth_token/__init__.py, which in turn owns some opts that are needed by the former. This creates a circular import dependency. In order to fix such situation, this patch proposes to move the auth token opts calculation into auth_token/__init__.py, so that it will no longer need opts.py. Co-Authored-By: Alfredo Moralejo Closes-Bug: #1591913 Change-Id: If67d8bdb68a5ab9c07b960ad0111e2310ad82c83 --- keystonemiddleware/auth_token/__init__.py | 35 +++++++++++++++++++++-- keystonemiddleware/opts.py | 35 ++--------------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/keystonemiddleware/auth_token/__init__.py b/keystonemiddleware/auth_token/__init__.py index 42d5d155..8603b1c5 100644 --- a/keystonemiddleware/auth_token/__init__.py +++ b/keystonemiddleware/auth_token/__init__.py @@ -207,6 +207,7 @@ object is stored. """ import binascii +import copy import datetime import logging @@ -228,11 +229,11 @@ from keystonemiddleware.auth_token import _base from keystonemiddleware.auth_token import _cache from keystonemiddleware.auth_token import _exceptions as ksm_exceptions from keystonemiddleware.auth_token import _identity +from keystonemiddleware.auth_token import _opts from keystonemiddleware.auth_token import _request from keystonemiddleware.auth_token import _revocations from keystonemiddleware.auth_token import _signing_dir from keystonemiddleware.auth_token import _user_plugin -from keystonemiddleware import opts from keystonemiddleware.i18n import _, _LC, _LE, _LI, _LW @@ -240,6 +241,36 @@ _LOG = logging.getLogger(__name__) _CACHE_INVALID_INDICATOR = 'invalid' +AUTH_TOKEN_OPTS = [ + (_base.AUTHTOKEN_GROUP, + _opts._OPTS + _auth.OPTS + loading.get_auth_common_conf_options()) +] + + +def list_opts(): + """Return a list of oslo_config options available in auth_token middleware. + + The returned list includes all oslo_config options which may be registered + at runtime by the project. + + Each element of the list is a tuple. The first element is the name of the + group under which the list of elements in the second element will be + registered. A group name of None corresponds to the [DEFAULT] group in + config files. + + NOTE: This function is no longer used for oslo_config sample generation. + Some services rely on this function for listing ALL (including deprecated) + options and registering them into their own config objects which we do not + want for sample config files. + + See: :py:func:`keystonemiddleware.auth_token._opts.list_opts` for sample + config files. + + :returns: a list of (group_name, opts) tuples + """ + return [(g, copy.deepcopy(o)) for g, o in AUTH_TOKEN_OPTS] + + class _BIND_MODE(object): DISABLED = 'disabled' PERMISSIVE = 'permissive' @@ -464,7 +495,7 @@ class AuthProtocol(BaseAuthProtocol): self._conf = config.Config('auth_token', _base.AUTHTOKEN_GROUP, - opts.list_auth_token_opts(), + list_opts(), conf) super(AuthProtocol, self).__init__( diff --git a/keystonemiddleware/opts.py b/keystonemiddleware/opts.py index d563da89..fa59a3a1 100644 --- a/keystonemiddleware/opts.py +++ b/keystonemiddleware/opts.py @@ -16,39 +16,8 @@ __all__ = ( 'list_auth_token_opts', ) -import copy - -from keystoneauth1 import loading - -from keystonemiddleware.auth_token import _auth -from keystonemiddleware.auth_token import _base -from keystonemiddleware.auth_token import _opts - -auth_token_opts = [ - (_base.AUTHTOKEN_GROUP, - _opts._OPTS + _auth.OPTS + loading.get_auth_common_conf_options()) -] +from keystonemiddleware import auth_token def list_auth_token_opts(): - """Return a list of oslo_config options available in auth_token middleware. - - The returned list includes all oslo_config options which may be registered - at runtime by the project. - - Each element of the list is a tuple. The first element is the name of the - group under which the list of elements in the second element will be - registered. A group name of None corresponds to the [DEFAULT] group in - config files. - - NOTE: This function is no longer used for oslo_config sample generation. - Some services rely on this function for listing ALL (including deprecated) - options and registering them into their own config objects which we do not - want for sample config files. - - See: :py:func:`keystonemiddleware.auth_token._opts.list_opts` for sample - config files. - - :returns: a list of (group_name, opts) tuples - """ - return [(g, copy.deepcopy(o)) for g, o in auth_token_opts] + return auth_token.list_opts()