Browse Source

Use API V2 instead of V1

Change-Id: Idb4ac050652d1d0107bf3fcd447d7cbedd811809
tags/0.1.0
Saad Zaher 1 year ago
parent
commit
ba9187eff2

+ 30
- 22
freezer_tempest_plugin/services/freezer_api_client.py View File

@@ -14,11 +14,13 @@
14 14
 
15 15
 import urllib
16 16
 
17
+from oslo_log import log
17 18
 from oslo_serialization import jsonutils as json
18 19
 from tempest import config
19 20
 from tempest.lib.common import rest_client
20 21
 
21 22
 CONF = config.CONF
23
+LOG = log.getLogger(__name__)
22 24
 
23 25
 
24 26
 class FreezerApiClient(rest_client.RestClient):
@@ -29,6 +31,9 @@ class FreezerApiClient(rest_client.RestClient):
29 31
             CONF.backup.region or CONF.identity.region,
30 32
             endpoint_type=CONF.backup.endpoint_type
31 33
         )
34
+        LOG.info(self)
35
+        if self.tenant_id:
36
+            LOG.info(self.tenant_id)
32 37
 
33 38
     def get_version(self):
34 39
 
@@ -48,17 +53,17 @@ class FreezerApiClient(rest_client.RestClient):
48 53
     def get_backups(self, backup_id=None, **params):
49 54
 
50 55
         if backup_id is None:
51
-            uri = '/v1/backups'
56
+            uri = '/v2/{0}/backups'.format(self.tenant_id)
52 57
             if params:
53 58
                 uri += '?%s' % urllib.urlencode(params)
54 59
         else:
55
-            uri = '/v1/backups/' + backup_id
60
+            uri = '/v2/{0}/backups/{1}'.format(self.tenant_id, backup_id)
56 61
 
57 62
         resp, response_body = self.get(uri)
58 63
         return resp, json.loads(response_body)
59 64
 
60 65
     def post_backups(self, metadata, backup_id=None):
61
-        uri = '/v1/backups'
66
+        uri = '/v2/{0}/backups'.format(self.tenant_id)
62 67
         if backup_id is not None:
63 68
             uri += '/' + backup_id
64 69
 
@@ -69,18 +74,18 @@ class FreezerApiClient(rest_client.RestClient):
69 74
 
70 75
     def delete_backups(self, backup_id):
71 76
 
72
-        uri = '/v1/backups/' + backup_id
77
+        uri = '/v2/{0}/backups/{1}'.format(self.tenant_id, backup_id)
73 78
         resp, response_body = self.delete(uri)
74 79
         return resp, response_body
75 80
 
76 81
     def get_clients(self, client_id=None, **params):
77 82
 
78 83
         if client_id is None:
79
-            uri = '/v1/clients'
84
+            uri = '/v2/{0}/clients'.format(self.tenant_id)
80 85
             if params:
81 86
                 uri += '?%s' % urllib.urlencode(params)
82 87
         else:
83
-            uri = 'v1/clients/' + client_id
88
+            uri = 'v2/{0}/clients/{1}'.format(self.tenant_id, client_id)
84 89
 
85 90
         resp, response_body = self.get(uri)
86 91
         return resp, response_body
@@ -88,23 +93,24 @@ class FreezerApiClient(rest_client.RestClient):
88 93
     def post_clients(self, client):
89 94
 
90 95
         request_body = json.dumps(client)
91
-        resp, response_body = self.post('/v1/clients', request_body)
96
+        resp, response_body = self.post('/v2/{0}/clients'.format(
97
+            self.tenant_id), request_body)
92 98
         return resp, json.loads(response_body)
93 99
 
94 100
     def delete_clients(self, client_id):
95 101
 
96
-        uri = '/v1/clients/' + client_id
102
+        uri = '/v2/{0}/clients/{1}'.format(self.tenant_id, client_id)
97 103
         resp, response_body = self.delete(uri)
98 104
         return resp, response_body
99 105
 
100 106
     def get_jobs(self, job_id=None, **params):
101 107
 
102 108
         if job_id is None:
103
-            uri = '/v1/jobs'
109
+            uri = '/v2/{0}/jobs'.format(self.tenant_id)
104 110
             if params:
105 111
                 uri += '?%s' % urllib.urlencode(params)
106 112
         else:
107
-            uri = '/v1/jobs/' + job_id
113
+            uri = '/v2/{0}/jobs/{1}'.format(self.tenant_id, job_id)
108 114
 
109 115
         resp, response_body = self.get(uri)
110 116
         return resp, response_body
@@ -112,23 +118,24 @@ class FreezerApiClient(rest_client.RestClient):
112 118
     def post_jobs(self, job):
113 119
 
114 120
         request_body = json.dumps(job)
115
-        resp, response_body = self.post('/v1/jobs', request_body)
121
+        resp, response_body = self.post('/v2/{0}/jobs'.format(
122
+            self.tenant_id), request_body)
116 123
         return resp, json.loads(response_body)
117 124
 
118 125
     def delete_jobs(self, job_id):
119 126
 
120
-        uri = '/v1/jobs/' + job_id
127
+        uri = '/v2/{0}/jobs/{1}'.format(self.tenant_id, job_id)
121 128
         resp, response_body = self.delete(uri)
122 129
         return resp, response_body
123 130
 
124 131
     def get_actions(self, action_id=None, **params):
125 132
 
126 133
         if action_id is None:
127
-            uri = '/v1/actions'
134
+            uri = '/v2/{0}/actions'.format(self.tenant_id)
128 135
             if params:
129 136
                 uri += '?%s' % urllib.urlencode(params)
130 137
         else:
131
-            uri = '/v1/actions/' + action_id
138
+            uri = '/v2/{0}/actions/{1}'.format(self.tenant_id, action_id)
132 139
 
133 140
         resp, response_body = self.get(uri)
134 141
         return resp, response_body
@@ -138,9 +145,9 @@ class FreezerApiClient(rest_client.RestClient):
138 145
         request_body = json.dumps(action)
139 146
 
140 147
         if action_id is None:
141
-            uri = '/v1/actions'
148
+            uri = '/v2/{0}/actions'.format(self.tenant_id)
142 149
         else:
143
-            uri = '/v1/actions/' + action_id
150
+            uri = '/v2/{0}/actions/{1}'.format(self.tenant_id, action_id)
144 151
 
145 152
         resp, response_body = self.post(uri, request_body)
146 153
         return resp, json.loads(response_body)
@@ -149,24 +156,24 @@ class FreezerApiClient(rest_client.RestClient):
149 156
 
150 157
         request_body = json.dumps(action)
151 158
 
152
-        uri = '/v1/actions/' + action_id
159
+        uri = '/v2/{0}/actions/{1}'.format(self.tenant_id, action_id)
153 160
         resp, response_body = self.patch(uri, request_body)
154 161
         return resp, json.loads(response_body)
155 162
 
156 163
     def delete_actions(self, id):
157 164
 
158
-        uri = '/v1/actions/' + id
165
+        uri = '/v2/{0}/actions/{1}'.format(self.tenant_id, id)
159 166
         resp, response_body = self.delete(uri)
160 167
         return resp, response_body
161 168
 
162 169
     def get_sessions(self, session_id=None, **params):
163 170
 
164 171
         if session_id is None:
165
-            uri = '/v1/sessions'
172
+            uri = '/v2/{0}/sessions'.format(self.tenant_id)
166 173
             if params:
167 174
                 uri += '?%s' % urllib.urlencode(params)
168 175
         else:
169
-            uri = 'v1/sessions/' + session_id
176
+            uri = '/v2/{0}/sessions/'.format(self.tenant_id, session_id)
170 177
 
171 178
         resp, response_body = self.get(uri)
172 179
         return resp, response_body
@@ -174,11 +181,12 @@ class FreezerApiClient(rest_client.RestClient):
174 181
     def post_sessions(self, session):
175 182
 
176 183
         request_body = json.dumps(session)
177
-        resp, response_body = self.post('/v1/sessions', request_body)
184
+        resp, response_body = self.post('/v2/{0}/sessions'.format(
185
+            self.tenant_id), request_body)
178 186
         return resp, json.loads(response_body)
179 187
 
180 188
     def delete_sessions(self, session_id):
181 189
 
182
-        uri = '/v1/sessions/' + session_id
190
+        uri = '/v2/{0}/sessions/{1}'.format(self.tenant_id, session_id)
183 191
         resp, response_body = self.delete(uri)
184 192
         return resp, response_body

+ 2
- 1
freezer_tempest_plugin/tests/freezer_api/api/test_api_backups.py View File

@@ -163,7 +163,7 @@ class TestFreezerApiBackups(base.BaseFreezerApiTest):
163 163
         """
164 164
         metadata = self._build_metadata("test_freezer_backups")
165 165
 
166
-        uri = '/v1/backups'
166
+        uri = '/v2/{0}/backups'.format(self.freezer_api_client.tenant_id)
167 167
         request_body = json.dumps(metadata)
168 168
 
169 169
         # Passing in an empty dict for headers to avoid automatically
@@ -231,6 +231,7 @@ class TestFreezerApiBackups(base.BaseFreezerApiTest):
231 231
         return {
232 232
             'user_name': self.os_primary.credentials.username,
233 233
             'user_id': self.os_primary.credentials.user_id,
234
+            'project_id': self.freezer_api_client.tenant_id,
234 235
             'backup_metadata': metadata
235 236
         }
236 237
 

+ 1
- 0
freezer_tempest_plugin/tests/freezer_api/api/test_api_sessions.py View File

@@ -111,6 +111,7 @@ class TestFreezerApiSessions(base.BaseFreezerApiTest):
111 111
             "time_ended": 1234,
112 112
             "status": "completed",
113 113
             "result": "success",
114
+            "project_id": self.freezer_api_client.tenant_id,
114 115
             "user_id": "user-id-1"
115 116
         }
116 117
 

Loading…
Cancel
Save