From 6515ff80d6e95e88b575d8bba1cd955e77af57f8 Mon Sep 17 00:00:00 2001 From: Abitha Palaniappan Date: Thu, 13 Aug 2015 11:47:52 -0700 Subject: [PATCH] Keystone v3 support Change-Id: Ib42448410ed44938058c228cf549ac56937dcde9 --- cuedashboard/api.py | 17 +++++++++++++---- cuedashboard/tests/settings.py | 6 +++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cuedashboard/api.py b/cuedashboard/api.py index db6959b..e5a1948 100644 --- a/cuedashboard/api.py +++ b/cuedashboard/api.py @@ -21,6 +21,7 @@ from cueclient.v1 import client from django.conf import settings from horizon.utils.memoized import memoized # noqa from keystoneclient.auth.identity import v2 +from keystoneclient.auth.identity import v3 from keystoneclient import session as ksc_session from openstack_dashboard import api @@ -28,10 +29,18 @@ from openstack_dashboard import api @memoized def cueclient(request): cacert = getattr(settings, 'OPENSTACK_SSL_CACERT', None) - auth_url = api.base.url_for(request, 'identity') - auth = v2.Token(auth_url, request.user.token.id, - tenant_id=request.user.tenant_id, - tenant_name=request.user.tenant_name) + auth_url = getattr(settings, 'OPENSTACK_KEYSTONE_URL') + auth_version = getattr(settings, + 'OPENSTACK_API_VERSIONS', {}).get('identity', 2.0) + if auth_version == 3: + auth = v3.Token(auth_url, request.user.token.id, + project_id=request.user.project_id, + project_name=request.user.project_name) + elif auth_version == 2 or auth_version == 2.0: + auth = v2.Token(auth_url, request.user.token.id, + tenant_id=request.user.tenant_id, + tenant_name=request.user.tenant_name) + session = ksc_session.Session(auth=auth, verify=cacert) return client.Client(session=session) diff --git a/cuedashboard/tests/settings.py b/cuedashboard/tests/settings.py index 96e2709..c49ea35 100644 --- a/cuedashboard/tests/settings.py +++ b/cuedashboard/tests/settings.py @@ -79,11 +79,11 @@ HORIZON_CONFIG = { HORIZON_IMAGES_ALLOW_UPLOAD = True AVAILABLE_REGIONS = [ - ('http://localhost:5000/v2.0', 'local'), - ('http://remote:5000/v2.0', 'remote'), + ('http://localhost:5000/v3', 'local'), + ('http://remote:5000/v3', 'remote'), ] -OPENSTACK_KEYSTONE_URL = "http://localhost:5000/v2.0" +OPENSTACK_KEYSTONE_URL = "http://localhost:5000/v3" OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_" OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True