oc-cdtapi 3.9.1__py2-none-any.whl → 3.9.4__py2-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oc_cdtapi/API.py +138 -42
- oc_cdtapi/DevPIAPI.py +30 -30
- oc_cdtapi/DmsAPI.py +120 -54
- oc_cdtapi/DmsGetverAPI.py +218 -155
- oc_cdtapi/ForemanAPI.py +495 -546
- oc_cdtapi/JenkinsAPI.py +171 -160
- oc_cdtapi/NexusAPI.py +1 -2
- {oc_cdtapi-3.9.1.dist-info → oc_cdtapi-3.9.4.dist-info}/METADATA +2 -2
- oc_cdtapi-3.9.4.dist-info/RECORD +15 -0
- oc_cdtapi-3.9.1.dist-info/RECORD +0 -15
- {oc_cdtapi-3.9.1.data → oc_cdtapi-3.9.4.data}/scripts/nexus.py +0 -0
- {oc_cdtapi-3.9.1.dist-info → oc_cdtapi-3.9.4.dist-info}/LICENSE +0 -0
- {oc_cdtapi-3.9.1.dist-info → oc_cdtapi-3.9.4.dist-info}/WHEEL +0 -0
- {oc_cdtapi-3.9.1.dist-info → oc_cdtapi-3.9.4.dist-info}/top_level.txt +0 -0
oc_cdtapi/DmsGetverAPI.py
CHANGED
@@ -1,17 +1,21 @@
|
|
1
|
-
import json
|
1
|
+
import json
|
2
|
+
import logging
|
3
|
+
import time
|
2
4
|
|
3
|
-
from
|
5
|
+
from . import API
|
4
6
|
import posixpath
|
5
7
|
|
8
|
+
|
6
9
|
class DmsGetverAPI (API.HttpAPI):
|
7
10
|
# prefix for credentials environment variables used by HttpAPI
|
8
11
|
_env_prefix = 'DMS'
|
9
12
|
|
13
|
+
def __init__(self, *args, **argv):
|
14
|
+
logging.debug('Reached __init__')
|
15
|
+
logging.debug('Calling base class constructor for availability of HttpAPI methods')
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
logging.debug ('Calling base class constructor for availability of HttpAPI methods')
|
14
|
-
super (DmsGetverAPI, self).__init__ (*args, **argp)
|
17
|
+
# TODO: re-factor when Python2 support will be deprecated
|
18
|
+
super(DmsGetverAPI, self).__init__(*args, **argv)
|
15
19
|
|
16
20
|
# delivery states in process
|
17
21
|
self.waiting_states = ['INITIATED', 'PROCESSING', 'QUEUED']
|
@@ -25,246 +29,294 @@ class DmsGetverAPI (API.HttpAPI):
|
|
25
29
|
# wait for state request interval
|
26
30
|
self.wait_state_sleep = 30
|
27
31
|
|
28
|
-
|
29
|
-
def create_distr_request (self, version = None, source_version = None, distr_type = None, client_filter = None):
|
32
|
+
def create_distr_request(self, version=None, source_version=None, distr_type=None, client_filter=None):
|
30
33
|
"""
|
31
34
|
Creates a new distribution request
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
+
:param str version: required version e.g. 03.44.30.55
|
36
|
+
:param str distr_type: distribution type e.g. CARDS
|
37
|
+
:param client_filter: a set of software components e.g. Diners Club Russia Acquiring;MasterCard;VISA;
|
35
38
|
if not provided an attempt to fetch it from svn will be performed
|
36
39
|
filter fetching is defined in separate class
|
37
40
|
:return: distribution state info as returned by dms
|
38
41
|
"""
|
39
|
-
logging.debug
|
42
|
+
logging.debug('Reached create_distr_request')
|
40
43
|
|
41
|
-
distr_state_info = self._create_distr_request_int
|
42
|
-
|
44
|
+
distr_state_info = self._create_distr_request_int(
|
45
|
+
version=version, source_version=source_version, distr_type=distr_type, client_filter=client_filter)
|
43
46
|
|
47
|
+
return distr_state_info
|
44
48
|
|
45
|
-
def get_distr
|
49
|
+
def get_distr(self, distr_id, distr_option):
|
46
50
|
"""
|
47
51
|
Fetches distribution from dms
|
48
|
-
:
|
49
|
-
:return distr: distribution fetched from dms or None on error
|
50
|
-
:return distr_state_info: distribution info
|
52
|
+
:param str distr_id: distribution id
|
53
|
+
:return tuple(distr, distr_state_info): distribution fetched from dms or None on error, distribution info
|
51
54
|
"""
|
52
|
-
logging.debug
|
53
|
-
logging.debug
|
54
|
-
logging.debug
|
55
|
+
logging.debug('Reached get_distr')
|
56
|
+
logging.debug('Distr id [%s]' % distr_id)
|
57
|
+
logging.debug('Distr option [%s]' % distr_option)
|
55
58
|
distr = None
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
+
|
60
|
+
distr_state_info = self.get_distr_state_info_byid(distr_id, distr_option)
|
61
|
+
if distr_state_info['state'] != 'READY':
|
62
|
+
logging.debug('Distribution [%s] is in not ready state [%s]' % (
|
63
|
+
distr_id, distr_state_info['state']))
|
59
64
|
else:
|
60
|
-
logging.debug
|
65
|
+
logging.debug('Distribution [%s] is in ready state, downloading' % distr_id)
|
61
66
|
url = posixpath.join('dms-getver', 'distribution', 'id:%s' % distr_id, 'download')
|
62
|
-
logging.debug
|
63
|
-
logging.debug
|
64
|
-
distr_resp = self.get
|
67
|
+
logging.debug('Getting from [%s]' % url)
|
68
|
+
logging.debug('Requesting [%s]' % distr_state_info['fileName'])
|
69
|
+
distr_resp = self.get(url)
|
65
70
|
if distr_resp.status_code != 200:
|
66
|
-
logging.debug
|
71
|
+
logging.debug('DMS returned an error response [%s] while getting [%s]' % (
|
72
|
+
distr_resp.status_code, url))
|
67
73
|
else:
|
68
74
|
distr = distr_resp.content
|
69
|
-
logging.debug
|
70
|
-
return distr, distr_state_info
|
75
|
+
logging.debug('Fetched [%s] bytes from [%s]' % (len(distr), url))
|
71
76
|
|
77
|
+
return distr, distr_state_info
|
72
78
|
|
73
|
-
def get_distr_state_info
|
79
|
+
def get_distr_state_info(self, version=None, source_version=None, distr_type=None, client_filter=None):
|
74
80
|
"""
|
75
81
|
Requests distribution state info from dms
|
76
82
|
parameters description see in create_distr_request
|
77
83
|
"""
|
78
|
-
logging.debug
|
84
|
+
logging.debug('Reached get_distr_state_info')
|
79
85
|
|
80
|
-
url, parms = self._get_distr_state_url
|
81
|
-
|
82
|
-
|
86
|
+
url, parms = self._get_distr_state_url(
|
87
|
+
version=version, source_version=source_version, distr_type=distr_type, client_filter=client_filter)
|
88
|
+
distr_state_info = self._get_distr_state_info_int(url, parms)
|
83
89
|
|
90
|
+
return distr_state_info
|
84
91
|
|
85
|
-
def get_distr_state_info_byid
|
92
|
+
def get_distr_state_info_byid(self, distr_id, distr_option):
|
86
93
|
"""
|
87
94
|
Requests distribution state info from dms
|
95
|
+
:param str distr_id: distributive ID (digits-as-string)
|
96
|
+
:param str distr_option: additional distributive option
|
97
|
+
:return distr_state_info: distributive state information
|
88
98
|
"""
|
89
|
-
logging.debug
|
99
|
+
logging.debug('Reached get_distr_state_info_byid')
|
100
|
+
|
90
101
|
if distr_option == 'full':
|
91
|
-
logging.debug
|
102
|
+
logging.debug('Full distr info requested')
|
92
103
|
url = posixpath.join('dms-getver', 'rest', 'api', '1', 'distribution', 'id:%s' % distr_id)
|
93
104
|
else:
|
94
|
-
logging.debug
|
105
|
+
logging.debug('Diff distr info requested')
|
95
106
|
url = posixpath.join('dms-getver', 'rest', 'api', '1', 'distribution-difference', 'id:%s' % distr_id)
|
96
107
|
|
97
|
-
distr_state_info = self._get_distr_state_info_int
|
98
|
-
return distr_state_info
|
108
|
+
distr_state_info = self._get_distr_state_info_int(url)
|
99
109
|
|
110
|
+
return distr_state_info
|
100
111
|
|
101
|
-
def get_dms_gav
|
112
|
+
def get_dms_gav(self, distr_id, distr_option):
|
102
113
|
"""
|
103
114
|
Requests gav by distribution id
|
115
|
+
:param str distr_id: distributive ID (digits-as-string)
|
116
|
+
:param str distr_option: additional distributive option
|
117
|
+
:return str: GAV, or None if not found
|
104
118
|
"""
|
105
|
-
logging.debug
|
106
|
-
logging.debug
|
119
|
+
logging.debug('Reached get_dms_gav')
|
120
|
+
logging.debug('Request for gav for [%s] distr id [%s]' % (
|
121
|
+
distr_option, distr_id))
|
122
|
+
|
107
123
|
if distr_option == 'full':
|
108
124
|
url = posixpath.join('dms-getver', 'rest', 'api', '1', 'distribution', 'id:%s' % distr_id, 'gav')
|
109
125
|
else:
|
110
126
|
url = posixpath.join('dms-getver', 'rest', 'api', '1', 'distribution-difference', 'id:%s' % distr_id, 'gav')
|
111
|
-
|
127
|
+
|
128
|
+
resp = self.get(url)
|
129
|
+
|
112
130
|
if resp.status_code == 200:
|
113
|
-
logging.debug
|
114
|
-
gav = resp.json
|
115
|
-
|
116
|
-
|
131
|
+
logging.debug('OK response from dms-getver')
|
132
|
+
gav = resp.json()
|
133
|
+
# we have to raise an exception if anything were not returned
|
134
|
+
# it is the cause to rid of 'get' method usage
|
135
|
+
gav_text = ':'.join(list(map(lambda x: gav[x], [
|
136
|
+
'groupId', 'artifactId', 'version', 'packaging'])))
|
137
|
+
|
138
|
+
logging.debug('Returning [%s]' % gav_text)
|
117
139
|
else:
|
118
|
-
logging.debug
|
140
|
+
logging.debug('Error response [%s] from dms-getver' % resp.status_code)
|
119
141
|
gav_text = None
|
120
|
-
logging.debug
|
121
|
-
return gav_text
|
142
|
+
logging.debug('Returning None')
|
122
143
|
|
144
|
+
return gav_text
|
123
145
|
|
124
|
-
def get_dms_log
|
146
|
+
def get_dms_log(self, distr_id, distr_option):
|
125
147
|
"""
|
126
148
|
Retrieve dms log
|
149
|
+
:param str distr_id: distributive ID (digits-as-string)
|
150
|
+
:param str distr_option: additional distributive option
|
151
|
+
:return str: DMS log, or None if no logs found or response error
|
127
152
|
"""
|
128
|
-
logging.debug
|
129
|
-
logging.debug
|
153
|
+
logging.debug('Reached get_dms_log')
|
154
|
+
logging.debug('Request for log of processing distr [%s]' % distr_id)
|
130
155
|
|
131
|
-
url = self.get_dms_log_url
|
156
|
+
url = self.get_dms_log_url(distr_id, distr_option)
|
132
157
|
|
133
158
|
log = None
|
134
|
-
resp = self.get
|
159
|
+
resp = self.get(url)
|
135
160
|
status_code = resp.status_code
|
136
|
-
logging.debug
|
161
|
+
logging.debug('Response status code: [%s]' % status_code)
|
137
162
|
|
138
163
|
if status_code != 200:
|
139
|
-
logging.debug
|
164
|
+
logging.debug('Error response from dms')
|
140
165
|
else:
|
141
166
|
log = resp.text
|
142
167
|
|
143
168
|
return log
|
144
169
|
|
170
|
+
def get_dms_log_url(self, distr_id, distr_option):
|
171
|
+
"""
|
172
|
+
Prepare log URL
|
173
|
+
:param str distr_id: distributive ID (digits-as-string)
|
174
|
+
:param str distr_option: additional distributive option
|
175
|
+
:return str: DMS log URL for further requesting
|
176
|
+
"""
|
177
|
+
logging.debug('Reached get_dms_log_url')
|
178
|
+
logging.debug('Request for url for [%s] distr [%s]' % (distr_option, distr_id))
|
145
179
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
url = posixpath.join('dms-getver', 'rest', 'api', '1', 'distribution', 'id:%s' % distr_id, 'log')
|
151
|
-
else:
|
152
|
-
url = posixpath.join('dms-getver', 'rest', 'api', 'distribution-difference', 'id:%s' % distr_id, 'log')
|
153
|
-
logging.debug ('url for log request: [%s]' % url)
|
154
|
-
return url
|
180
|
+
url = posixpath.join('dms-getver', 'rest', 'api', '1', 'distribution%s' % (
|
181
|
+
"-difference" if distr_option != "full" else ""), 'id:%s' % distr_id, 'log')
|
182
|
+
|
183
|
+
logging.debug('url for log request: [%s]' % url)
|
155
184
|
|
185
|
+
return url
|
156
186
|
|
157
|
-
def wait_for_state
|
187
|
+
def wait_for_state(self, distr_id, distr_option):
|
158
188
|
"""
|
159
189
|
Wait until either distr gets into an exit state or a timeout occurs
|
160
190
|
States and timeouts are defined in __init__
|
191
|
+
:param str distr_id: distributive ID (digits-as-string)
|
192
|
+
:param str distr_option: additional distributive option
|
193
|
+
:return distr_state_info: distributive information after wait
|
161
194
|
"""
|
162
|
-
logging.debug
|
195
|
+
logging.debug('Reached wait_for_state')
|
163
196
|
ela = 0
|
164
|
-
st = int
|
197
|
+
st = int(time.time())
|
165
198
|
distr_state_info = {}
|
166
|
-
distr_state_info
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
199
|
+
distr_state_info['state'] = 'TIMEOUT'
|
200
|
+
|
201
|
+
while ela < self.wait_state_timeout:
|
202
|
+
ela = int(time.time()) - st
|
203
|
+
dsi = self.get_distr_state_info_byid(distr_id, distr_option)
|
204
|
+
state = dsi['state']
|
205
|
+
|
171
206
|
if not state in self.waiting_states:
|
172
|
-
logging.debug
|
207
|
+
logging.debug('Distr [%s] is in exit state [%s]' % (distr_id, state))
|
173
208
|
distr_state_info = dsi
|
174
209
|
break
|
175
|
-
logging.debug ('Distr [%s] is in waiting state [%s]' % (distr_id, state) )
|
176
|
-
logging.debug ('Retrying in [%s] sec., [%s] of [%s] sec. in wait' % (self.wait_state_sleep, ela, self.wait_state_timeout) )
|
177
|
-
time.sleep (self.wait_state_sleep)
|
178
|
-
return distr_state_info
|
179
210
|
|
211
|
+
logging.debug('Distr [%s] is in waiting state [%s]' % (distr_id, state))
|
212
|
+
logging.debug('Retrying in [%s] sec., [%s] of [%s] sec. in wait' % (
|
213
|
+
self.wait_state_sleep, ela, self.wait_state_timeout))
|
214
|
+
|
215
|
+
time.sleep(self.wait_state_sleep)
|
216
|
+
|
217
|
+
return distr_state_info
|
180
218
|
|
181
|
-
def _create_distr_request_int
|
219
|
+
def _create_distr_request_int(self, version=None, source_version=None, distr_type=None, client_filter=None):
|
182
220
|
"""
|
183
221
|
Creates a new distribution request
|
222
|
+
:param str versoin: version required
|
223
|
+
:param str source_version: source version for diff-type distributives
|
224
|
+
:param str distr_type: type of distributive requested
|
225
|
+
:param client_filter: components to filter, may be empty
|
226
|
+
:return distr_state_info: or None on error
|
184
227
|
"""
|
185
|
-
|
186
|
-
logging.debug
|
187
|
-
logging.debug
|
188
|
-
logging.debug
|
228
|
+
|
229
|
+
logging.debug('Reached _create_distr_request_int')
|
230
|
+
logging.debug('version = [%s]' % version)
|
231
|
+
logging.debug('source_version = [%s]' % source_version)
|
232
|
+
logging.debug('distr_type = [%s]' % distr_type)
|
233
|
+
|
189
234
|
if client_filter:
|
190
|
-
logging.debug
|
235
|
+
logging.debug('client_filter length = [%s]' % len(client_filter))
|
191
236
|
else:
|
192
|
-
logging.debug
|
237
|
+
logging.debug('Filters not specified')
|
193
238
|
client_filter = ''
|
194
239
|
|
195
240
|
distr_state_info = {}
|
196
241
|
req_parm = {}
|
197
|
-
req_parm
|
242
|
+
req_parm['product'] = distr_type
|
198
243
|
|
199
244
|
if source_version:
|
200
|
-
logging.debug
|
245
|
+
logging.debug('Diff distribution requested')
|
201
246
|
url = posixpath.join('dms-getver', 'rest', 'api', '1', 'distribution-difference')
|
202
|
-
req_parm
|
203
|
-
req_parm
|
204
|
-
req_parm
|
205
|
-
req_parm
|
247
|
+
req_parm['initialVersion'] = source_version
|
248
|
+
req_parm['targetVersion'] = version
|
249
|
+
req_parm['initialFilters'] = client_filter
|
250
|
+
req_parm['targetFilters'] = client_filter
|
206
251
|
else:
|
207
|
-
logging.debug
|
252
|
+
logging.debug('Full distribution requested')
|
208
253
|
url = posixpath.join('dms-getver', 'rest', 'api', '1', 'distribution')
|
209
|
-
req_parm
|
210
|
-
req_parm
|
254
|
+
req_parm['version'] = version
|
255
|
+
req_parm['filter'] = client_filter
|
211
256
|
|
212
|
-
logging.debug
|
213
|
-
resp = self.post
|
257
|
+
logging.debug('request parameters: [%s]' % json.dumps(req_parm, indent=4))
|
258
|
+
resp = self.post(url, json=req_parm)
|
214
259
|
|
215
260
|
# we shold have been expecting 202 here, but it's 200 somehow
|
216
261
|
if resp.status_code != 200:
|
217
|
-
logging.debug
|
218
|
-
logging.debug
|
219
|
-
distr_state_info
|
220
|
-
distr_state_info
|
262
|
+
logging.debug('DMS responds with unexpected status code [%s]' % resp.status_code)
|
263
|
+
logging.debug('DMS response body: %s' % resp.text)
|
264
|
+
distr_state_info['id'] = None
|
265
|
+
distr_state_info['state'] = 'HTTP/%s' % resp.status_code
|
221
266
|
else:
|
222
|
-
distr_state_info = resp.json
|
267
|
+
distr_state_info = resp.json()
|
223
268
|
|
224
|
-
distr_state = distr_state_info
|
225
|
-
distr_id = distr_state_info
|
269
|
+
distr_state = distr_state_info['state']
|
270
|
+
distr_id = distr_state_info['id']
|
226
271
|
|
227
272
|
if distr_state and distr_id:
|
228
|
-
logging.debug
|
229
|
-
distr_state_info = self._normalize_dsi
|
273
|
+
logging.debug('Created dist id [%s] in state [%s]' % (distr_id, distr_state))
|
274
|
+
distr_state_info = self._normalize_dsi(distr_state_info)
|
230
275
|
|
231
276
|
return distr_state_info
|
232
277
|
|
233
|
-
|
234
|
-
def _dumb_404 (self, resp):
|
278
|
+
def _dumb_404(self, resp):
|
235
279
|
"""
|
236
280
|
This is to distinguish a server 404 from an application 404 (which should have been 200)
|
281
|
+
:param resp: response to check
|
282
|
+
:return bool: do we have to return 404 or not
|
237
283
|
"""
|
238
|
-
logging.debug
|
284
|
+
logging.debug('Reached _dumb_404')
|
285
|
+
|
239
286
|
try:
|
240
|
-
j = resp.json
|
287
|
+
j = resp.json()
|
241
288
|
except ValueError as e:
|
242
|
-
logging.debug
|
289
|
+
logging.debug('Failed to get json from dms response, returning False')
|
243
290
|
return False
|
244
|
-
|
245
|
-
|
291
|
+
|
292
|
+
if j.get('code') == 'DMS-GETVER-40001':
|
293
|
+
logging.debug('Found a "dms not found" response code, returning True')
|
246
294
|
return True
|
247
|
-
else:
|
248
|
-
logging.debug ('Json response processed, but no "dms not found" code detected, returning False')
|
249
|
-
return False
|
250
295
|
|
296
|
+
logging.debug('Json response processed, but no "dms not found" code detected, returning False')
|
297
|
+
return False
|
251
298
|
|
252
|
-
def _get_distr_state_info_int
|
299
|
+
def _get_distr_state_info_int(self, url, parms=None):
|
253
300
|
"""
|
254
301
|
Requests and returns distr state
|
255
302
|
states known so far: INITIATED, PROCESSING, FAILED, READY. +
|
256
303
|
NOTFOUND set by this method upon http/404 and TIMEOUT set by wait_for_state
|
304
|
+
:param str url: URL to request
|
305
|
+
:param dict params: additional request parameters
|
306
|
+
:return requests.Response:
|
257
307
|
"""
|
258
|
-
logging.debug
|
259
|
-
logging.debug
|
308
|
+
logging.debug('Reached _get_distr_state_info_int')
|
309
|
+
logging.debug('URL = [%s]' % url)
|
260
310
|
|
261
311
|
try:
|
262
|
-
|
263
|
-
|
264
|
-
|
312
|
+
# TODO: refactor to get rid of this everystic fork if possible
|
313
|
+
# when new version of DMS API will be implemented
|
314
|
+
if 'search' in url.split(posixpath.sep):
|
315
|
+
logging.debug('[search] endpoint, assuming POST')
|
316
|
+
resp = self.post(url, json=parms)
|
265
317
|
else:
|
266
|
-
logging.debug
|
267
|
-
resp = self.get
|
318
|
+
logging.debug('not a [search] endpoint, assuming GET')
|
319
|
+
resp = self.get(url, params=parms)
|
268
320
|
except API.HttpAPIError as e:
|
269
321
|
resp = e.resp
|
270
322
|
|
@@ -272,57 +324,68 @@ class DmsGetverAPI (API.HttpAPI):
|
|
272
324
|
|
273
325
|
# bad status
|
274
326
|
if resp.status_code != 200:
|
275
|
-
logging.debug
|
276
|
-
|
277
|
-
|
278
|
-
distr_state_info
|
327
|
+
logging.debug('DMS reponds with status code [%s]' % resp.status_code)
|
328
|
+
|
329
|
+
if resp.status_code == 404 and self._dumb_404(resp):
|
330
|
+
distr_state_info['state'] = 'NOTFOUND'
|
331
|
+
distr_state_info['id'] = None
|
279
332
|
else:
|
280
|
-
distr_state_info
|
281
|
-
distr_state_info
|
333
|
+
distr_state_info['state'] = 'HTTP/%s' % resp.status_code
|
334
|
+
distr_state_info['id'] = None
|
335
|
+
|
282
336
|
# ok status
|
283
337
|
else:
|
284
|
-
distr_state_info = resp.json
|
338
|
+
distr_state_info = resp.json()
|
285
339
|
|
286
|
-
distr_id = distr_state_info
|
287
|
-
distr_state = distr_state_info
|
340
|
+
distr_id = distr_state_info['id']
|
341
|
+
distr_state = distr_state_info['state']
|
288
342
|
|
289
343
|
if distr_state and distr_id:
|
290
|
-
distr_state_info = self._normalize_dsi
|
291
|
-
logging.debug
|
344
|
+
distr_state_info = self._normalize_dsi(distr_state_info)
|
345
|
+
logging.debug('Found dist id [%s] in state [%s]' % (distr_id, distr_state))
|
292
346
|
|
293
347
|
return distr_state_info
|
294
348
|
|
295
|
-
|
296
|
-
def _get_distr_state_url (self, version, source_version = None, distr_type = None, client_filter = None):
|
349
|
+
def _get_distr_state_url(self, version, source_version=None, distr_type=None, client_filter=None):
|
297
350
|
"""
|
298
351
|
forms an url to be used to get distr state info or request new distribution
|
352
|
+
:param str versoin: version required
|
353
|
+
:param str source_version: source version for diff-type distributives
|
354
|
+
:param str distr_type: type of distributive requested
|
355
|
+
:param client_filter: components to filter, may be empty
|
356
|
+
:return tuple(str, dict): URL for further request, parameters for the request
|
299
357
|
"""
|
300
|
-
logging.debug
|
301
|
-
logging.debug
|
358
|
+
logging.debug('Reached _get_distr_state_url')
|
359
|
+
logging.debug('Request for url version [%s], type [%s], src_ver [%s]' % (version, distr_type, source_version))
|
302
360
|
|
303
361
|
if source_version:
|
304
362
|
url = posixpath.join('dms-getver', 'rest', 'api', '1', 'distribution-difference')
|
305
|
-
parms = {'initialFilters': client_filter, 'initialVersion': source_version,
|
363
|
+
parms = {'initialFilters': client_filter, 'initialVersion': source_version,
|
364
|
+
'product': distr_type, 'targetFilters': client_filter, 'targetVersion': version}
|
306
365
|
else:
|
307
366
|
url = posixpath.join('dms-getver', 'rest', 'api', '1', 'distribution', 'search')
|
308
367
|
parms = {'filter': client_filter, 'product': distr_type, 'version': version}
|
309
|
-
logging.debug ('URL=[%s]' % url)
|
310
|
-
return url, parms
|
311
368
|
|
369
|
+
logging.debug('URL=[%s]' % url)
|
312
370
|
|
313
|
-
|
371
|
+
return url, parms
|
372
|
+
|
373
|
+
def _normalize_dsi(self, distr_state_info):
|
314
374
|
"""
|
315
375
|
Normalize scattered output from different endpoints
|
376
|
+
:param dict distr_state_info: distributive state information
|
377
|
+
:return dict: normalized distr_state_info
|
316
378
|
"""
|
317
|
-
logging.debug ('Reached _normalize_dsi')
|
318
379
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
distr_state_info
|
380
|
+
logging.debug('Reached _normalize_dsi')
|
381
|
+
|
382
|
+
if 'initialFilters' in distr_state_info.keys():
|
383
|
+
logging.debug('Diff distribution meta-info detected, add distOption=diff, filter, version')
|
384
|
+
distr_state_info['distOption'] = 'diff'
|
385
|
+
distr_state_info['filter'] = distr_state_info['targetFilters']
|
386
|
+
distr_state_info['version'] = distr_state_info['targetVersion']
|
324
387
|
else:
|
325
|
-
logging.debug
|
326
|
-
distr_state_info
|
327
|
-
return distr_state_info
|
388
|
+
logging.debug('Full distribution meta-info detected, only add distOption=full')
|
389
|
+
distr_state_info['distOption'] = 'full'
|
328
390
|
|
391
|
+
return distr_state_info
|