summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCai Hui <cai.hui@zte.com.cn>2018-10-24 02:23:30 -0400
committerCai Hui <cai.hui@zte.com.cn>2018-10-29 07:50:22 -0400
commit6b2b3957968af91891661ead58a8e2627c9cb26d (patch)
tree1fcb5d9aef04105d4d01d230353fa500e463e6a0
parent7be38ca793a08ab54d818ea7cdd4193f9a6a1bb9 (diff)
Support freezer API v2
The web-ui support API v2. Change-Id: I2a27d092bb38c3ebff1e89b333e017cc12e67624 Story: 2003973 Task: 26915
Notes
Notes (review): Code-Review+2: gecong <ge.cong@zte.com.cn> Code-Review+2: gengchc2 <geng.changcai2@zte.com.cn> Workflow+1: gengchc2 <geng.changcai2@zte.com.cn> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 30 Oct 2018 01:13:11 +0000 Reviewed-on: https://review.openstack.org/612890 Project: openstack/freezer-web-ui Branch: refs/heads/master
-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):