Browse Source

Merge "Support freezer API v2"

tags/7.0.0
Zuul 8 months ago
parent
commit
757bd202ed
1 changed files with 11 additions and 13 deletions
  1. 11
    13
      disaster_recovery/api/api.py

+ 11
- 13
disaster_recovery/api/api.py View File

@@ -17,7 +17,13 @@ from oslo_log import log
17 17
 
18 18
 from django.conf import settings
19 19
 from horizon.utils.memoized import memoized  # noqa
20
-from 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
+
26
+from freezerclient.v2 import client as freezer_client
21 27
 
22 28
 from disaster_recovery import utils
23 29
 
@@ -29,26 +35,17 @@ LOG = log.getLogger(__name__)
29 35
 def client(request):
30 36
     """Return a freezer client object"""
31 37
     api_url = _get_service_url(request)
32
-
33 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 40
     credentials = {
40 41
         'token': request.user.token.id,
41 42
         'auth_url': getattr(settings, 'OPENSTACK_KEYSTONE_URL'),
42 43
         'endpoint': api_url,
43
-        'version': ks_version,
44
-        'cacert': cacert
44
+        'project_id': request.user.project_id,
45 45
     }
46 46
 
47
-    if ks_version == 3:
48
-        credentials['project_name'] = request.user.project_name
49
-        credentials['project_id'] = request.user.project_id
50
-        credentials['project_domain_name'] = \
51
-            request.user.domain_name or 'Default'
47
+    credentials['project_domain_name'] = \
48
+        request.user.domain_name or 'Default'
52 49
 
53 50
     return freezer_client.Client(**credentials)
54 51
 
@@ -426,6 +423,7 @@ class Client(object):
426 423
 
427 424
     def __init__(self, request):
428 425
         self.request = request
426
+
429 427
         self.client = client(request)
430 428
 
431 429
     def list(self, json=False, limit=500, offset=0, search=None):

Loading…
Cancel
Save