summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-10-30 01:13:11 +0000
committerGerrit Code Review <review@openstack.org>2018-10-30 01:13:11 +0000
commit757bd202ed6dcd49e56326d998f27432676ab7a1 (patch)
treefe26b3d9908875ffde0f28bdb8781cbca8536ad0
parentd65faf3595a890d9871ea0b9e4f00f5e148755d5 (diff)
parent6b2b3957968af91891661ead58a8e2627c9cb26d (diff)
Merge "Support freezer API v2"
-rw-r--r--disaster_recovery/api/api.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/disaster_recovery/api/api.py b/disaster_recovery/api/api.py
index cab9756..d594f66 100644
--- a/disaster_recovery/api/api.py
+++ b/disaster_recovery/api/api.py
@@ -17,7 +17,13 @@ from oslo_log import log
17 17
18from django.conf import settings 18from django.conf import settings
19from horizon.utils.memoized import memoized # noqa 19from horizon.utils.memoized import memoized # noqa
20from freezerclient.v1 import client as freezer_client 20
21# When python-freezerclient 2.0 released, directly use freezerclient.client
22# as freezer_client.
23# The current python-freezerclient version hasn't freezerclient.client module.
24# from freezerclient import client as freezer_client
25
26from freezerclient.v2 import client as freezer_client
21 27
22from disaster_recovery import utils 28from disaster_recovery import utils
23 29
@@ -29,26 +35,17 @@ LOG = log.getLogger(__name__)
29def client(request): 35def client(request):
30 """Return a freezer client object""" 36 """Return a freezer client object"""
31 api_url = _get_service_url(request) 37 api_url = _get_service_url(request)
32
33 # get keystone version to connect to 38 # get keystone version to connect to
34 ks_version = getattr(settings,
35 'OPENSTACK_API_VERSIONS', {}).get('identity', 2.0)
36
37 cacert = getattr(settings, 'OPENSTACK_SSL_CACERT', None)
38 39
39 credentials = { 40 credentials = {
40 'token': request.user.token.id, 41 'token': request.user.token.id,
41 'auth_url': getattr(settings, 'OPENSTACK_KEYSTONE_URL'), 42 'auth_url': getattr(settings, 'OPENSTACK_KEYSTONE_URL'),
42 'endpoint': api_url, 43 'endpoint': api_url,
43 'version': ks_version, 44 'project_id': request.user.project_id,
44 'cacert': cacert
45 } 45 }
46 46
47 if ks_version == 3: 47 credentials['project_domain_name'] = \
48 credentials['project_name'] = request.user.project_name 48 request.user.domain_name or 'Default'
49 credentials['project_id'] = request.user.project_id
50 credentials['project_domain_name'] = \
51 request.user.domain_name or 'Default'
52 49
53 return freezer_client.Client(**credentials) 50 return freezer_client.Client(**credentials)
54 51
@@ -426,6 +423,7 @@ class Client(object):
426 423
427 def __init__(self, request): 424 def __init__(self, request):
428 self.request = request 425 self.request = request
426
429 self.client = client(request) 427 self.client = client(request)
430 428
431 def list(self, json=False, limit=500, offset=0, search=None): 429 def list(self, json=False, limit=500, offset=0, search=None):