]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Use proper config option to connect to keystone
authorSzymon Borkowski <szymon.borkowski@intel.com>
Tue, 1 Dec 2015 13:12:03 +0000 (14:12 +0100)
committerMichał Dulko <michal.dulko@intel.com>
Thu, 3 Dec 2015 14:21:01 +0000 (15:21 +0100)
Earlier, quotas used to authenticate to endpoint from not required
option located in keymgr.encryption_auth_url. Now, the required
auth_uri option from config file is used to authenticate to
keystone.

Co-Authored-By: Michal Dulko <michal.dulko@intel.com>
Change-Id: I1076527704f8def2c6755c060df49232e5ebe805
Closes-Bug: 1516085

cinder/api/contrib/quotas.py
cinder/tests/unit/api/contrib/test_quotas.py
releasenotes/notes/a7401ead26a7c83b-keystone-url.yaml [new file with mode: 0644]
requirements.txt

index 004f101b97cd20b0a2333cb1bbb1fc2d48f125ae..e513f410b78da84d48deb45e775ac05357a19aad 100644 (file)
 
 import webob
 
+from keystoneclient.auth.identity.generic import token
+from keystoneclient import client
 from keystoneclient import exceptions
-from keystoneclient.v3 import client
+from keystoneclient import session
 
 from cinder.api import extensions
 from cinder.api.openstack import wsgi
@@ -180,9 +182,13 @@ class QuotaSetsController(wsgi.Controller):
         order to do quota operations properly.
         """
         try:
-            keystone = client.Client(auth_url=CONF.keymgr.encryption_auth_url,
-                                     token=context.auth_token,
-                                     project_id=context.project_id)
+            auth_plugin = token.Token(
+                auth_url=CONF.keystone_authtoken.auth_uri,
+                token=context.auth_token,
+                project_id=context.project_id)
+            client_session = session.Session(auth=auth_plugin)
+            keystone = client.Client(auth_url=CONF.keystone_authtoken.auth_uri,
+                                     session=client_session)
             project = keystone.projects.get(id, subtree_as_ids=subtree_as_ids)
         except exceptions.NotFound:
             msg = (_("Tenant ID: %s does not exist.") % id)
index e4f4335bc4a29844f601df0f62034fd570bfbe31..398f096d961500703fec65853a94d106f5f14f10 100644 (file)
@@ -32,7 +32,9 @@ from cinder import db
 from cinder import test
 from cinder.tests.unit import test_db_api
 
+from keystonemiddleware import auth_token
 from oslo_config import cfg
+from oslo_config import fixture as config_fixture
 
 
 CONF = cfg.CONF
@@ -92,7 +94,10 @@ class QuotaSetsControllerTest(test.TestCase):
         self.req.environ['cinder.context'].project_id = 'foo'
 
         self._create_project_hierarchy()
-        self.auth_url = CONF.keymgr.encryption_auth_url
+
+        self.auth_url = 'http://localhost:5000'
+        self.fixture = self.useFixture(config_fixture.Config(auth_token.CONF))
+        self.fixture.config(auth_uri=self.auth_url, group='keystone_authtoken')
 
     def _create_project_hierarchy(self):
         """Sets an environment used for nested quotas tests.
@@ -123,15 +128,16 @@ class QuotaSetsControllerTest(test.TestCase):
     def _get_project(self, context, id, subtree_as_ids=False):
         return self.project_by_id.get(id, self.FakeProject())
 
-    @mock.patch('keystoneclient.v3.client.Client')
-    def test_keystone_client_instantiation(self, ksclient_class):
+    @mock.patch('keystoneclient.client.Client')
+    @mock.patch('keystoneclient.session.Session')
+    def test_keystone_client_instantiation(self, ksclient_session,
+                                           ksclient_class):
         context = self.req.environ['cinder.context']
         self.controller._get_project(context, context.project_id)
         ksclient_class.assert_called_once_with(auth_url=self.auth_url,
-                                               token=context.auth_token,
-                                               project_id=context.project_id)
+                                               session=ksclient_session())
 
-    @mock.patch('keystoneclient.v3.client.Client')
+    @mock.patch('keystoneclient.client.Client')
     def test_get_project(self, ksclient_class):
         context = self.req.environ['cinder.context']
         keystoneclient = ksclient_class.return_value
diff --git a/releasenotes/notes/a7401ead26a7c83b-keystone-url.yaml b/releasenotes/notes/a7401ead26a7c83b-keystone-url.yaml
new file mode 100644 (file)
index 0000000..93e6662
--- /dev/null
@@ -0,0 +1,3 @@
+---
+fixes:
+  - Cinder will now correctly read Keystone's endpoint for quota calls from keystone_authtoken.auth_uri instead of keymgr.encryption_auth_url config option.
index 8f8a77874f8cdde0dc77bb0dd2643e6fa738cf71..35b2da6847ebf6ba50493e6a049cd5d17a082b1b 100644 (file)
@@ -33,6 +33,7 @@ pycrypto>=2.6
 pyparsing>=2.0.1
 python-barbicanclient>=3.3.0
 python-glanceclient>=0.18.0
+python-keystoneclient>=1.6.0,!=1.8.0
 python-novaclient!=2.33.0,>=2.29.0
 python-swiftclient>=2.2.0
 requests>=2.8.1