From 19dd18b17f2fbcca37b0c6633f47c0b7cdace9a7 Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Mon, 27 Aug 2018 16:39:37 +0800 Subject: [PATCH] Remove auth_uri usage auth_uri in keystonemiddleware was deprecated and will be removed in Stein. This patch changed it to auth_url or www_authenticate_uri correctly Change-Id: I754f6b27b3ebb87d4479aa366c9ee04af34fcaab --- cinder/quota_utils.py | 8 ++++---- cinder/test.py | 6 ++++++ cinder/tests/unit/api/contrib/test_quotas.py | 2 +- cinder/tests/unit/conf_fixture.py | 2 +- cinder/tests/unit/test_quota.py | 2 +- cinder/tests/unit/test_quota_utils.py | 2 +- doc/source/install/cinder-controller-install-obs.rst | 2 +- doc/source/install/cinder-controller-install-rdo.rst | 2 +- doc/source/install/cinder-storage-install-obs.rst | 2 +- doc/source/install/cinder-storage-install-ubuntu.rst | 2 +- 10 files changed, 18 insertions(+), 12 deletions(-) diff --git a/cinder/quota_utils.py b/cinder/quota_utils.py index 56fe1cb805e..4a6fbc35cc1 100644 --- a/cinder/quota_utils.py +++ b/cinder/quota_utils.py @@ -25,8 +25,8 @@ from cinder import exception from cinder.i18n import _ CONF = cfg.CONF -CONF.import_opt('auth_uri', 'keystonemiddleware.auth_token.__init__', - 'keystone_authtoken') +CONF.import_group('keystone_authtoken', + 'keystonemiddleware.auth_token.__init__') LOG = logging.getLogger(__name__) @@ -227,7 +227,7 @@ def _keystone_client(context, version=(3, 0)): :return: keystoneclient.client.Client object """ auth_plugin = identity.Token( - auth_url=CONF.keystone_authtoken.auth_uri, + auth_url=CONF.keystone_authtoken.auth_url, token=context.auth_token, project_id=context.project_id) @@ -237,7 +237,7 @@ def _keystone_client(context, version=(3, 0)): cacert=CONF.keystone_authtoken.cafile, key=CONF.keystone_authtoken.keyfile, cert=CONF.keystone_authtoken.certfile) - return client.Client(auth_url=CONF.keystone_authtoken.auth_uri, + return client.Client(auth_url=CONF.keystone_authtoken.auth_url, session=client_session, version=version) diff --git a/cinder/test.py b/cinder/test.py index 85fb55832f7..be61f4aa04c 100644 --- a/cinder/test.py +++ b/cinder/test.py @@ -28,6 +28,7 @@ import uuid from eventlet import tpool import fixtures +from keystonemiddleware import auth_token import mock from oslo_concurrency import lockutils from oslo_config import fixture as config_fixture @@ -215,6 +216,11 @@ class TestCase(testtools.TestCase): rpc.LAST_OBJ_VERSIONS = {} rpc.LAST_RPC_VERSIONS = {} + # Init AuthProtocol to register some base options first, such as + # auth_url. + auth_token.AuthProtocol('fake_app', {'auth_type': 'password', + 'auth_url': 'fake_url'}) + conf_fixture.set_defaults(CONF) CONF([], default_config_files=[]) diff --git a/cinder/tests/unit/api/contrib/test_quotas.py b/cinder/tests/unit/api/contrib/test_quotas.py index 6a6b9a89a5d..4c582969731 100644 --- a/cinder/tests/unit/api/contrib/test_quotas.py +++ b/cinder/tests/unit/api/contrib/test_quotas.py @@ -117,7 +117,7 @@ class QuotaSetsControllerTestBase(test.TestCase): self.auth_url = 'http://localhost:5000' self.fixture = self.useFixture(config_fixture.Config(CONF)) - self.fixture.config(auth_uri=self.auth_url, group='keystone_authtoken') + self.fixture.config(auth_url=self.auth_url, group='keystone_authtoken') def _create_project_hierarchy(self): r"""Sets an environment used for nested quotas tests. diff --git a/cinder/tests/unit/conf_fixture.py b/cinder/tests/unit/conf_fixture.py index f2063b2bd85..d8870b976f0 100644 --- a/cinder/tests/unit/conf_fixture.py +++ b/cinder/tests/unit/conf_fixture.py @@ -56,4 +56,4 @@ def set_defaults(conf): conf.set_default('policy_dirs', [], group='oslo_policy') # This is where we don't authenticate conf.set_default('auth_strategy', 'noauth') - conf.set_default('auth_uri', 'fake', 'keystone_authtoken') + conf.set_default('auth_url', 'fake', 'keystone_authtoken') diff --git a/cinder/tests/unit/test_quota.py b/cinder/tests/unit/test_quota.py index fa3a4e7384e..90a55370441 100644 --- a/cinder/tests/unit/test_quota.py +++ b/cinder/tests/unit/test_quota.py @@ -1451,7 +1451,7 @@ class NestedDbQuotaDriverBaseTestCase(DbQuotaDriverBaseTestCase): self.addCleanup(keystone_patcher.stop) self.fixture = self.useFixture(config_fixture.Config(CONF)) - self.fixture.config(auth_uri=self.auth_url, group='keystone_authtoken') + self.fixture.config(auth_url=self.auth_url, group='keystone_authtoken') self.driver = quota.NestedDbQuotaDriver() def _mock_get_by_subproject(self): diff --git a/cinder/tests/unit/test_quota_utils.py b/cinder/tests/unit/test_quota_utils.py index d1b4b4b3781..bc27539c47a 100644 --- a/cinder/tests/unit/test_quota_utils.py +++ b/cinder/tests/unit/test_quota_utils.py @@ -43,7 +43,7 @@ class QuotaUtilsTest(test.TestCase): self.auth_url = 'http://localhost:5000' self.context = context.RequestContext('fake_user', 'fake_proj_id') self.fixture = self.useFixture(config_fixture.Config(CONF)) - self.fixture.config(auth_uri=self.auth_url, group='keystone_authtoken') + self.fixture.config(auth_url=self.auth_url, group='keystone_authtoken') @mock.patch('keystoneclient.client.Client') @mock.patch('keystoneauth1.session.Session') diff --git a/doc/source/install/cinder-controller-install-obs.rst b/doc/source/install/cinder-controller-install-obs.rst index 0bc70239fa9..1cb2aee943c 100644 --- a/doc/source/install/cinder-controller-install-obs.rst +++ b/doc/source/install/cinder-controller-install-obs.rst @@ -277,7 +277,7 @@ Install and configure components [keystone_authtoken] # ... - auth_uri = http://controller:5000 + www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000 memcached_servers = controller:11211 auth_type = password diff --git a/doc/source/install/cinder-controller-install-rdo.rst b/doc/source/install/cinder-controller-install-rdo.rst index 306b277c72b..46ced92a247 100644 --- a/doc/source/install/cinder-controller-install-rdo.rst +++ b/doc/source/install/cinder-controller-install-rdo.rst @@ -276,7 +276,7 @@ Install and configure components [keystone_authtoken] # ... - auth_uri = http://controller:5000 + www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000 memcached_servers = controller:11211 auth_type = password diff --git a/doc/source/install/cinder-storage-install-obs.rst b/doc/source/install/cinder-storage-install-obs.rst index 281bf311040..350b6b8c4b6 100644 --- a/doc/source/install/cinder-storage-install-obs.rst +++ b/doc/source/install/cinder-storage-install-obs.rst @@ -158,7 +158,7 @@ Install and configure components [keystone_authtoken] # ... - auth_uri = http://controller:5000 + www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000 memcached_servers = controller:11211 auth_type = password diff --git a/doc/source/install/cinder-storage-install-ubuntu.rst b/doc/source/install/cinder-storage-install-ubuntu.rst index 01a8850a2f8..edec103ddee 100644 --- a/doc/source/install/cinder-storage-install-ubuntu.rst +++ b/doc/source/install/cinder-storage-install-ubuntu.rst @@ -156,7 +156,7 @@ Install and configure components [keystone_authtoken] # ... - auth_uri = http://controller:5000 + www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000 memcached_servers = controller:11211 auth_type = password