zosmfrestapi 0.2.0__py3-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.
- zosmfrestapi/__init__.py +93 -0
- zosmfrestapi/client.py +47 -0
- zosmfrestapi/exceptions/__init__.py +18 -0
- zosmfrestapi/exceptions/authentication.py +17 -0
- zosmfrestapi/exceptions/dataset.py +17 -0
- zosmfrestapi/exceptions/software.py +34 -0
- zosmfrestapi/exceptions/workflow.py +30 -0
- zosmfrestapi/models/__init__.py +0 -0
- zosmfrestapi/models/authentication.py +16 -0
- zosmfrestapi/models/software.py +231 -0
- zosmfrestapi/models/software_updates.py +99 -0
- zosmfrestapi/models/topology.py +28 -0
- zosmfrestapi/models/workflow.py +114 -0
- zosmfrestapi/py.typed +0 -0
- zosmfrestapi/services/__init__.py +176 -0
- zosmfrestapi/services/authentication.py +52 -0
- zosmfrestapi/services/dataset.py +42 -0
- zosmfrestapi/services/software.py +477 -0
- zosmfrestapi/services/software_updates.py +949 -0
- zosmfrestapi/services/topology.py +49 -0
- zosmfrestapi/services/workflow.py +350 -0
- zosmfrestapi/testing/__init__.py +11 -0
- zosmfrestapi/testing/authentication.py +48 -0
- zosmfrestapi/testing/helpers.py +9 -0
- zosmfrestapi/testing/software.py +392 -0
- zosmfrestapi/testing/software_updates.py +281 -0
- zosmfrestapi/testing/topology.py +19 -0
- zosmfrestapi/testing/workflows.py +320 -0
- zosmfrestapi/utils.py +76 -0
- zosmfrestapi/zcrypto.py +55 -0
- zosmfrestapi/zcrypto_client.py +68 -0
- zosmfrestapi-0.2.0.dist-info/METADATA +172 -0
- zosmfrestapi-0.2.0.dist-info/RECORD +35 -0
- zosmfrestapi-0.2.0.dist-info/WHEEL +4 -0
- zosmfrestapi-0.2.0.dist-info/licenses/LICENSE +10 -0
|
@@ -0,0 +1,949 @@
|
|
|
1
|
+
import time
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import pendulum
|
|
5
|
+
from dacite import Config, from_dict
|
|
6
|
+
from zosmfrestapi.models.software_updates import (
|
|
7
|
+
MissingFixcat,
|
|
8
|
+
MissingUpdate,
|
|
9
|
+
SoftwareUpdate,
|
|
10
|
+
UpdateProcess,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from zosmfrestapi.exceptions.software import (
|
|
14
|
+
ZosmfSoftwareManagementError,
|
|
15
|
+
ZosmfSoftwareInstanceNotFoundError,
|
|
16
|
+
ZosmfSoftwareManagementRequestError,
|
|
17
|
+
)
|
|
18
|
+
from zosmfrestapi.utils import _parse_datetime
|
|
19
|
+
|
|
20
|
+
from . import ZosmfBase
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class SoftwareUpdatesServices(ZosmfBase):
|
|
24
|
+
"""Search, inspect, start, cancel, resume, and collect update processes.
|
|
25
|
+
|
|
26
|
+
Starting or resuming an update can change the selected target zone. Methods
|
|
27
|
+
with ``wait=True`` poll z/OSMF until the process is no longer running;
|
|
28
|
+
without waiting, they return the process ID so callers can monitor it later.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def _list_sw_updates(self, path: str) -> list[UpdateProcess]:
|
|
32
|
+
resp = self.http.get(path)
|
|
33
|
+
if resp.status_code == 404:
|
|
34
|
+
return []
|
|
35
|
+
self._raise_for_status(resp, exc_handler=ZosmfSoftwareManagementRequestError)
|
|
36
|
+
return [
|
|
37
|
+
from_dict(
|
|
38
|
+
data_class=UpdateProcess,
|
|
39
|
+
data=upd,
|
|
40
|
+
config=Config(
|
|
41
|
+
type_hooks={
|
|
42
|
+
pendulum.DateTime: _parse_datetime,
|
|
43
|
+
},
|
|
44
|
+
convert_key=lambda k: k.replace("_", "-"),
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
for upd in resp.json()["update-processes"]
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
def list_sw_updates_by_uuid(self, swiuuid: str, last: bool = False) -> list[UpdateProcess]:
|
|
51
|
+
"""List update processes for a software instance identified by UUID.
|
|
52
|
+
|
|
53
|
+
If z/OSMF reports that the software instance has no update-process
|
|
54
|
+
history (HTTP 404), this method returns an empty list.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
swiuuid: UUID of the software instance.
|
|
58
|
+
last: If true, retrieve the most recent process; otherwise retrieve
|
|
59
|
+
all recorded processes.
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
A list of ``UpdateProcess`` objects.
|
|
63
|
+
|
|
64
|
+
Raises:
|
|
65
|
+
ZosmfAuthError: If z/OSMF returns HTTP 401.
|
|
66
|
+
ZosmfSoftwareManagementRequestError: If z/OSMF returns another
|
|
67
|
+
unsuccessful HTTP status.
|
|
68
|
+
httpx2.RequestError: If the request fails before an HTTP response
|
|
69
|
+
is received.
|
|
70
|
+
"""
|
|
71
|
+
return self._list_sw_updates(
|
|
72
|
+
f"/zosmf/swmgmt/swi/{swiuuid}/swupdate{'' if last else '/all'}"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
def list_sw_updates_by_name(
|
|
76
|
+
self, name: str, system: str, last: bool = False
|
|
77
|
+
) -> list[UpdateProcess]:
|
|
78
|
+
"""List update processes for a software instance identified by name.
|
|
79
|
+
|
|
80
|
+
If z/OSMF reports that the software instance has no update-process
|
|
81
|
+
history (HTTP 404), this method returns an empty list.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
name: Name of the software instance.
|
|
85
|
+
system: System where the software instance is defined.
|
|
86
|
+
last: If true, retrieve the most recent process; otherwise retrieve
|
|
87
|
+
all recorded processes.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
A list of ``UpdateProcess`` objects.
|
|
91
|
+
|
|
92
|
+
Raises:
|
|
93
|
+
ZosmfAuthError: If z/OSMF returns HTTP 401.
|
|
94
|
+
ZosmfSoftwareManagementRequestError: If z/OSMF returns another
|
|
95
|
+
unsuccessful HTTP status.
|
|
96
|
+
httpx2.RequestError: If the request fails before an HTTP response
|
|
97
|
+
is received.
|
|
98
|
+
"""
|
|
99
|
+
return self._list_sw_updates(
|
|
100
|
+
f"/zosmf/swmgmt/swi/{system}/{name}/swupdate{'' if last else '/all'}"
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
def get_sw_updates(self, process_id: int, wait: bool = False) -> list[UpdateProcess]:
|
|
104
|
+
"""Get the update-process records for a process ID.
|
|
105
|
+
|
|
106
|
+
Args:
|
|
107
|
+
process_id: ID returned when the update process was started.
|
|
108
|
+
wait: If true, poll every two seconds while any process is running.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
A list of parsed ``UpdateProcess`` records from the latest status
|
|
112
|
+
response. With ``wait=True``, this is the final polled response.
|
|
113
|
+
|
|
114
|
+
Raises:
|
|
115
|
+
ZosmfAuthError: If a status request returns HTTP 401.
|
|
116
|
+
ZosmfSoftwareManagementRequestError: If a status request returns another
|
|
117
|
+
unsuccessful HTTP status.
|
|
118
|
+
httpx2.RequestError: If a status request fails before an HTTP
|
|
119
|
+
response is received.
|
|
120
|
+
"""
|
|
121
|
+
updates = self._get_sw_updates(process_id)
|
|
122
|
+
while any(upd["status"] == "RUNNING" for upd in updates) and wait:
|
|
123
|
+
time.sleep(2)
|
|
124
|
+
updates = self._get_sw_updates(process_id)
|
|
125
|
+
return [
|
|
126
|
+
from_dict(
|
|
127
|
+
data_class=UpdateProcess,
|
|
128
|
+
data=process,
|
|
129
|
+
config=Config(
|
|
130
|
+
type_hooks={
|
|
131
|
+
pendulum.DateTime: _parse_datetime,
|
|
132
|
+
},
|
|
133
|
+
convert_key=lambda k: k.replace("_", "-"),
|
|
134
|
+
),
|
|
135
|
+
)
|
|
136
|
+
for process in updates
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
def _get_missing_updates_or_fixcat(self, path: str, updates: bool) -> dict[
|
|
140
|
+
str,
|
|
141
|
+
pendulum.Date
|
|
142
|
+
| pendulum.Time
|
|
143
|
+
| pendulum.DateTime
|
|
144
|
+
| pendulum.Duration
|
|
145
|
+
| list[MissingUpdate]
|
|
146
|
+
| list[MissingFixcat],
|
|
147
|
+
]:
|
|
148
|
+
resp = self.http.post(path)
|
|
149
|
+
if resp.status_code == 404:
|
|
150
|
+
raise ZosmfSoftwareInstanceNotFoundError(resp)
|
|
151
|
+
self._raise_for_status(resp, exc_handler=ZosmfSoftwareManagementRequestError)
|
|
152
|
+
status_monitor_url = resp.json()["statusurl"]
|
|
153
|
+
status = self.http.get(status_monitor_url)
|
|
154
|
+
while status.json()["status"] == "running":
|
|
155
|
+
time.sleep(2)
|
|
156
|
+
status = self.http.get(status_monitor_url)
|
|
157
|
+
self._raise_for_status(status, exc_handler=ZosmfSoftwareManagementRequestError)
|
|
158
|
+
if updates:
|
|
159
|
+
return {
|
|
160
|
+
"lastholdrecvdate": pendulum.parse(status.json()["lastholdrecvdate"]),
|
|
161
|
+
"list": [
|
|
162
|
+
from_dict(
|
|
163
|
+
data_class=MissingUpdate,
|
|
164
|
+
data=missing,
|
|
165
|
+
)
|
|
166
|
+
for missing in status.json()["missingcriticalupdates"]
|
|
167
|
+
],
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
"lastholdrecvdate": pendulum.parse(status.json()["lastholdrecvdate"]),
|
|
171
|
+
"list": [
|
|
172
|
+
from_dict(data_class=MissingFixcat, data=missing)
|
|
173
|
+
for missing in status.json()["missingfixcatupdates"]
|
|
174
|
+
],
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
def get_missing_updates_by_uuid(self, uuid: str) -> dict[
|
|
178
|
+
str,
|
|
179
|
+
pendulum.Date
|
|
180
|
+
| pendulum.Time
|
|
181
|
+
| pendulum.DateTime
|
|
182
|
+
| pendulum.Duration
|
|
183
|
+
| list[MissingUpdate]
|
|
184
|
+
| list[MissingFixcat],
|
|
185
|
+
]:
|
|
186
|
+
"""Get missing critical updates for a software instance by UUID.
|
|
187
|
+
|
|
188
|
+
Args:
|
|
189
|
+
uuid: UUID of the software instance.
|
|
190
|
+
|
|
191
|
+
Returns:
|
|
192
|
+
A dictionary with ``lastholdrecvdate`` (parsed by Pendulum) and
|
|
193
|
+
``list`` (a list of ``MissingUpdate`` models) keys.
|
|
194
|
+
|
|
195
|
+
Raises:
|
|
196
|
+
ZosmfSoftwareInstanceNotFoundError: If the software instance does not exist.
|
|
197
|
+
ZosmfAuthError: If a request returns HTTP 401.
|
|
198
|
+
ZosmfSoftwareManagementRequestError: If a request returns another
|
|
199
|
+
unsuccessful HTTP status.
|
|
200
|
+
httpx2.RequestError: If a request fails before an HTTP response is
|
|
201
|
+
received.
|
|
202
|
+
"""
|
|
203
|
+
return self._get_missing_updates_or_fixcat(
|
|
204
|
+
f"/zosmf/swmgmt/swi/{uuid}/missingcriticalupdates", updates=True
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
def get_missing_updates_by_name(self, name: str, system: str) -> dict[
|
|
208
|
+
str,
|
|
209
|
+
pendulum.Date
|
|
210
|
+
| pendulum.Time
|
|
211
|
+
| pendulum.DateTime
|
|
212
|
+
| pendulum.Duration
|
|
213
|
+
| list[MissingUpdate]
|
|
214
|
+
| list[MissingFixcat],
|
|
215
|
+
]:
|
|
216
|
+
"""Get missing critical updates for a software instance by name and system.
|
|
217
|
+
|
|
218
|
+
Args:
|
|
219
|
+
name: Name of the software instance.
|
|
220
|
+
system: System of the software instance.
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
A dictionary with ``lastholdrecvdate`` (parsed by Pendulum) and
|
|
224
|
+
``list`` (a list of ``MissingUpdate`` models) keys.
|
|
225
|
+
|
|
226
|
+
Raises:
|
|
227
|
+
ZosmfSoftwareInstanceNotFoundError: If the software instance does not exist.
|
|
228
|
+
ZosmfAuthError: If a request returns HTTP 401.
|
|
229
|
+
ZosmfSoftwareManagementRequestError: If a request returns another
|
|
230
|
+
unsuccessful HTTP status.
|
|
231
|
+
httpx2.RequestError: If a request fails before an HTTP response is
|
|
232
|
+
received.
|
|
233
|
+
"""
|
|
234
|
+
return self._get_missing_updates_or_fixcat(
|
|
235
|
+
f"/zosmf/swmgmt/swi/{system}/{name}/missingcriticalupdates", updates=True
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
def get_missing_fixcat_by_uuid(self, uuid: str) -> dict[
|
|
239
|
+
str,
|
|
240
|
+
pendulum.Date
|
|
241
|
+
| pendulum.Time
|
|
242
|
+
| pendulum.DateTime
|
|
243
|
+
| pendulum.Duration
|
|
244
|
+
| list[MissingUpdate]
|
|
245
|
+
| list[MissingFixcat],
|
|
246
|
+
]:
|
|
247
|
+
"""Get updates missing the requested fix categories for an instance by UUID.
|
|
248
|
+
|
|
249
|
+
Args:
|
|
250
|
+
uuid: UUID of the software instance.
|
|
251
|
+
|
|
252
|
+
Returns:
|
|
253
|
+
A dictionary with ``lastholdrecvdate`` (parsed by Pendulum) and
|
|
254
|
+
``list`` (a list of ``MissingFixcat`` models) keys.
|
|
255
|
+
|
|
256
|
+
Raises:
|
|
257
|
+
ZosmfSoftwareInstanceNotFoundError: If the software instance does not exist.
|
|
258
|
+
ZosmfAuthError: If a request returns HTTP 401.
|
|
259
|
+
ZosmfSoftwareManagementRequestError: If a request returns another
|
|
260
|
+
unsuccessful HTTP status.
|
|
261
|
+
httpx2.RequestError: If a request fails before an HTTP response is
|
|
262
|
+
received.
|
|
263
|
+
"""
|
|
264
|
+
return self._get_missing_updates_or_fixcat(
|
|
265
|
+
f"/zosmf/swmgmt/swi/{uuid}/missingfixcatupdates", updates=False
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
def get_missing_fixcat_by_name(self, name: str, system: str) -> dict[
|
|
269
|
+
str,
|
|
270
|
+
pendulum.Date
|
|
271
|
+
| pendulum.Time
|
|
272
|
+
| pendulum.DateTime
|
|
273
|
+
| pendulum.Duration
|
|
274
|
+
| list[MissingUpdate]
|
|
275
|
+
| list[MissingFixcat],
|
|
276
|
+
]:
|
|
277
|
+
"""Get updates missing the requested fix categories by name and system.
|
|
278
|
+
|
|
279
|
+
Args:
|
|
280
|
+
name: Name of the software instance.
|
|
281
|
+
system: System of the software instance.
|
|
282
|
+
|
|
283
|
+
Returns:
|
|
284
|
+
A dictionary with ``lastholdrecvdate`` (parsed by Pendulum) and
|
|
285
|
+
``list`` (a list of ``MissingFixcat`` models) keys.
|
|
286
|
+
|
|
287
|
+
Raises:
|
|
288
|
+
ZosmfSoftwareInstanceNotFoundError: If the software instance does not exist.
|
|
289
|
+
ZosmfAuthError: If a request returns HTTP 401.
|
|
290
|
+
ZosmfSoftwareManagementRequestError: If a request returns another
|
|
291
|
+
unsuccessful HTTP status.
|
|
292
|
+
httpx2.RequestError: If a request fails before an HTTP response is
|
|
293
|
+
received.
|
|
294
|
+
"""
|
|
295
|
+
return self._get_missing_updates_or_fixcat(
|
|
296
|
+
f"/zosmf/swmgmt/swi/{system}/{name}/missingfixcatupdates", updates=False
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
def _get_sw_updates(self, process_id: int) -> list[dict[str, Any]]:
|
|
300
|
+
path = f"/zosmf/swmgmt/swupdate/{process_id}"
|
|
301
|
+
resp = self.http.get(path)
|
|
302
|
+
self._raise_for_status(resp, exc_handler=ZosmfSoftwareManagementRequestError)
|
|
303
|
+
return resp.json()["update-processes"]
|
|
304
|
+
|
|
305
|
+
def search_sw_updates_by_uuid(
|
|
306
|
+
self,
|
|
307
|
+
uuid: str,
|
|
308
|
+
updates: list[str] | None,
|
|
309
|
+
zosmf_userid: str | None = None,
|
|
310
|
+
zosmf_password: str | None = None,
|
|
311
|
+
proxy_userid: str | None = None,
|
|
312
|
+
proxy_password: str | None = None,
|
|
313
|
+
) -> list[SoftwareUpdate]:
|
|
314
|
+
"""Search for software updates in an instance identified by UUID.
|
|
315
|
+
|
|
316
|
+
The search is submitted to z/OSMF and polled until it completes.
|
|
317
|
+
|
|
318
|
+
Args:
|
|
319
|
+
uuid: UUID of the software instance to search.
|
|
320
|
+
updates: SYSMOD IDs to include in the search.
|
|
321
|
+
zosmf_userid: Optional z/OSMF user ID; currently not applied here.
|
|
322
|
+
zosmf_password: Optional z/OSMF password; currently not applied here.
|
|
323
|
+
proxy_userid: Optional proxy user ID; currently not applied here.
|
|
324
|
+
proxy_password: Optional proxy password; currently not applied here.
|
|
325
|
+
|
|
326
|
+
Returns:
|
|
327
|
+
A list of matching ``SoftwareUpdate`` objects.
|
|
328
|
+
|
|
329
|
+
Raises:
|
|
330
|
+
ZosmfAuthError: If a request returns HTTP 401.
|
|
331
|
+
ZosmfSoftwareManagementRequestError: If a request returns another
|
|
332
|
+
unsuccessful HTTP status.
|
|
333
|
+
httpx2.RequestError: If a request fails before an HTTP response is
|
|
334
|
+
received.
|
|
335
|
+
"""
|
|
336
|
+
return self._search_sw_updates(
|
|
337
|
+
f"/zosmf/swmgmt/swi/{uuid}/softwareupdatesearch", updates
|
|
338
|
+
)
|
|
339
|
+
|
|
340
|
+
def search_sw_updates_by_name(
|
|
341
|
+
self,
|
|
342
|
+
name: str,
|
|
343
|
+
system: str,
|
|
344
|
+
updates: list[str] | None,
|
|
345
|
+
zosmf_userid: str | None = None,
|
|
346
|
+
zosmf_password: str | None = None,
|
|
347
|
+
proxy_userid: str | None = None,
|
|
348
|
+
proxy_password: str | None = None,
|
|
349
|
+
) -> list[SoftwareUpdate]:
|
|
350
|
+
"""Search for software updates in an instance identified by name/system.
|
|
351
|
+
|
|
352
|
+
The search is submitted to z/OSMF and polled until it completes.
|
|
353
|
+
|
|
354
|
+
Args:
|
|
355
|
+
name: Name of the software instance to search.
|
|
356
|
+
system: System where the software instance is defined.
|
|
357
|
+
updates: SYSMOD IDs to include in the search.
|
|
358
|
+
zosmf_userid: Optional z/OSMF user ID; currently not applied here.
|
|
359
|
+
zosmf_password: Optional z/OSMF password; currently not applied here.
|
|
360
|
+
proxy_userid: Optional proxy user ID; currently not applied here.
|
|
361
|
+
proxy_password: Optional proxy password; currently not applied here.
|
|
362
|
+
|
|
363
|
+
Returns:
|
|
364
|
+
A list of matching ``SoftwareUpdate`` objects.
|
|
365
|
+
|
|
366
|
+
Raises:
|
|
367
|
+
ZosmfAuthError: If a request returns HTTP 401.
|
|
368
|
+
ZosmfSoftwareManagementRequestError: If a request returns another
|
|
369
|
+
unsuccessful HTTP status.
|
|
370
|
+
httpx2.RequestError: If a request fails before an HTTP response is
|
|
371
|
+
received.
|
|
372
|
+
"""
|
|
373
|
+
return self._search_sw_updates(
|
|
374
|
+
f"/zosmf/swmgmt/swi/{system}/{name}/softwareupdatesearch", updates
|
|
375
|
+
)
|
|
376
|
+
|
|
377
|
+
def _search_sw_updates(
|
|
378
|
+
self,
|
|
379
|
+
path: str,
|
|
380
|
+
updates: list[str] | None,
|
|
381
|
+
zosmf_userid: str | None = None,
|
|
382
|
+
zosmf_password: str | None = None,
|
|
383
|
+
proxy_userid: str | None = None,
|
|
384
|
+
proxy_password: str | None = None,
|
|
385
|
+
) -> list[SoftwareUpdate]:
|
|
386
|
+
resp = self.http.post(path, json={"updates": updates or None})
|
|
387
|
+
self._raise_for_status(resp, exc_handler=ZosmfSoftwareManagementRequestError)
|
|
388
|
+
status_monitor_url = resp.json()["statusurl"]
|
|
389
|
+
status = self.http.get(status_monitor_url)
|
|
390
|
+
while status.json()["status"] == "running":
|
|
391
|
+
time.sleep(2)
|
|
392
|
+
status = self.http.get(status_monitor_url)
|
|
393
|
+
self._raise_for_status(status, exc_handler=ZosmfSoftwareManagementRequestError)
|
|
394
|
+
return [
|
|
395
|
+
from_dict(
|
|
396
|
+
data_class=SoftwareUpdate,
|
|
397
|
+
data=sw_upd,
|
|
398
|
+
config=Config(
|
|
399
|
+
type_hooks={
|
|
400
|
+
pendulum.DateTime: _parse_datetime,
|
|
401
|
+
}
|
|
402
|
+
),
|
|
403
|
+
)
|
|
404
|
+
for sw_upd in status.json().get("updates", [])
|
|
405
|
+
]
|
|
406
|
+
|
|
407
|
+
def _start_sw_update(
|
|
408
|
+
self,
|
|
409
|
+
path: str,
|
|
410
|
+
tgtzone: str,
|
|
411
|
+
updates: list[str],
|
|
412
|
+
sourceids: list[str],
|
|
413
|
+
fixcats: list[str],
|
|
414
|
+
zosmf_auth: tuple[str, ...],
|
|
415
|
+
proxy_auth: tuple[str, ...],
|
|
416
|
+
step: list[str],
|
|
417
|
+
holds: list[str],
|
|
418
|
+
notes: str,
|
|
419
|
+
exclude_updates: list[str],
|
|
420
|
+
wait: bool,
|
|
421
|
+
) -> int | list[UpdateProcess]:
|
|
422
|
+
if (
|
|
423
|
+
(not updates and not sourceids and not fixcats)
|
|
424
|
+
or (updates and sourceids)
|
|
425
|
+
or (updates and fixcats)
|
|
426
|
+
or (sourceids and fixcats)
|
|
427
|
+
):
|
|
428
|
+
raise ZosmfSoftwareManagementError(
|
|
429
|
+
"At most one of updates, sourceids, or fixcats must be provided"
|
|
430
|
+
)
|
|
431
|
+
resp = self.http.post(
|
|
432
|
+
path,
|
|
433
|
+
json={
|
|
434
|
+
"targetzone": tgtzone,
|
|
435
|
+
"updates": updates or None,
|
|
436
|
+
"sourceids": sourceids or None,
|
|
437
|
+
"fixcats": fixcats or None,
|
|
438
|
+
"suspend-steps": step,
|
|
439
|
+
"resolve-holds": holds,
|
|
440
|
+
"exclude-updates": exclude_updates,
|
|
441
|
+
"notes": notes,
|
|
442
|
+
},
|
|
443
|
+
)
|
|
444
|
+
self._raise_for_status(resp, exc_handler=ZosmfSoftwareManagementRequestError)
|
|
445
|
+
process_id = int(resp.json()["processid"])
|
|
446
|
+
if not wait:
|
|
447
|
+
return process_id
|
|
448
|
+
|
|
449
|
+
upd_processes = self.check_sw_update_status(process_id)
|
|
450
|
+
while any(upd.status == "RUNNING" for upd in upd_processes):
|
|
451
|
+
time.sleep(2)
|
|
452
|
+
upd_processes = self.check_sw_update_status(process_id)
|
|
453
|
+
return upd_processes
|
|
454
|
+
|
|
455
|
+
def start_sw_update_by_uuid(
|
|
456
|
+
self,
|
|
457
|
+
uuid: str,
|
|
458
|
+
tgtzone: str,
|
|
459
|
+
updates: list[str] = [],
|
|
460
|
+
sourceids: list[str] = [],
|
|
461
|
+
fixcats: list[str] = [],
|
|
462
|
+
step: list[str] = [],
|
|
463
|
+
holds: list[str] = [],
|
|
464
|
+
notes: str = "",
|
|
465
|
+
exclude_updates: list[str] = [],
|
|
466
|
+
zosmf_auth: tuple[str, ...] = (),
|
|
467
|
+
proxy_auth: tuple[str, ...] = (),
|
|
468
|
+
wait: bool = False,
|
|
469
|
+
) -> int | list[UpdateProcess]:
|
|
470
|
+
"""Start a software update for a software instance identified by its UUID.
|
|
471
|
+
|
|
472
|
+
This submits an update operation to the specified target zone and may
|
|
473
|
+
change the software instance. Exactly one of ``updates``, ``sourceids``,
|
|
474
|
+
or ``fixcats`` must be non-empty. When ``wait`` is false, the request
|
|
475
|
+
returns the process ID; when true, the method polls until no process is
|
|
476
|
+
reported as running.
|
|
477
|
+
|
|
478
|
+
Args:
|
|
479
|
+
uuid: UUID of the software instance to update.
|
|
480
|
+
tgtzone: Target zone where the update will be applied.
|
|
481
|
+
updates: SYSMOD IDs to select.
|
|
482
|
+
sourceids: Source IDs to select.
|
|
483
|
+
fixcats: Fix categories to select.
|
|
484
|
+
step: Steps to suspend during the update.
|
|
485
|
+
holds: Holds to resolve during the update.
|
|
486
|
+
notes: Notes for the update process.
|
|
487
|
+
exclude_updates: Updates to exclude from the process.
|
|
488
|
+
zosmf_auth: Reserved compatibility argument; currently not applied.
|
|
489
|
+
proxy_auth: Reserved compatibility argument; currently not applied.
|
|
490
|
+
wait: Whether to wait for the update process to finish.
|
|
491
|
+
|
|
492
|
+
Returns:
|
|
493
|
+
The process ID if ``wait`` is false, otherwise a list of
|
|
494
|
+
``UpdateProcess`` records.
|
|
495
|
+
|
|
496
|
+
Raises:
|
|
497
|
+
ZosmfSoftwareManagementBaseError: If none or multiple selection
|
|
498
|
+
lists are non-empty.
|
|
499
|
+
ZosmfAuthError: If a request returns HTTP 401.
|
|
500
|
+
ZosmfSoftwareManagementError: If a request returns another
|
|
501
|
+
unsuccessful HTTP status.
|
|
502
|
+
httpx2.RequestError: If a request fails before an HTTP response is
|
|
503
|
+
received.
|
|
504
|
+
"""
|
|
505
|
+
return self._start_sw_update(
|
|
506
|
+
f"/zosmf/swmgmt/swi/{uuid}/swupdate",
|
|
507
|
+
tgtzone,
|
|
508
|
+
updates,
|
|
509
|
+
sourceids,
|
|
510
|
+
fixcats,
|
|
511
|
+
step=step,
|
|
512
|
+
holds=holds,
|
|
513
|
+
notes=notes,
|
|
514
|
+
exclude_updates=exclude_updates,
|
|
515
|
+
zosmf_auth=zosmf_auth,
|
|
516
|
+
proxy_auth=proxy_auth,
|
|
517
|
+
wait=wait,
|
|
518
|
+
)
|
|
519
|
+
|
|
520
|
+
def start_sw_update_by_name(
|
|
521
|
+
self,
|
|
522
|
+
name: str,
|
|
523
|
+
system: str,
|
|
524
|
+
tgtzone: str,
|
|
525
|
+
updates: list[str] = [],
|
|
526
|
+
sourceids: list[str] = [],
|
|
527
|
+
fixcats: list[str] = [],
|
|
528
|
+
step: list[str] = [],
|
|
529
|
+
holds: list[str] = [],
|
|
530
|
+
notes: str = "",
|
|
531
|
+
exclude_updates: list[str] = [],
|
|
532
|
+
zosmf_auth: tuple[str, ...] = (),
|
|
533
|
+
proxy_auth: tuple[str, ...] = (),
|
|
534
|
+
wait: bool = False,
|
|
535
|
+
) -> int | list[UpdateProcess]:
|
|
536
|
+
"""Start a software update for a software instance identified by its name and system.
|
|
537
|
+
|
|
538
|
+
This submits an update operation to the specified target zone and may
|
|
539
|
+
change the software instance. Exactly one of ``updates``, ``sourceids``,
|
|
540
|
+
or ``fixcats`` must be non-empty. When ``wait`` is false, the request
|
|
541
|
+
returns the process ID; when true, the method polls until no process is
|
|
542
|
+
reported as running.
|
|
543
|
+
|
|
544
|
+
Args:
|
|
545
|
+
name: Name of the software instance to update.
|
|
546
|
+
system: System of the software instance to update.
|
|
547
|
+
tgtzone: Target zone where the update will be applied.
|
|
548
|
+
updates: SYSMOD IDs to select.
|
|
549
|
+
sourceids: Source IDs to select.
|
|
550
|
+
fixcats: Fix categories to select.
|
|
551
|
+
step: Steps to suspend during the update.
|
|
552
|
+
holds: Holds to resolve during the update.
|
|
553
|
+
notes: Notes for the update process.
|
|
554
|
+
exclude_updates: Updates to exclude from the process.
|
|
555
|
+
zosmf_auth: Reserved compatibility argument; currently not applied.
|
|
556
|
+
proxy_auth: Reserved compatibility argument; currently not applied.
|
|
557
|
+
wait: Whether to wait for the update process to finish.
|
|
558
|
+
|
|
559
|
+
Returns:
|
|
560
|
+
The process ID if ``wait`` is false, otherwise a list of
|
|
561
|
+
``UpdateProcess`` records.
|
|
562
|
+
|
|
563
|
+
Raises:
|
|
564
|
+
ZosmfSoftwareManagementBaseError: If none or multiple selection
|
|
565
|
+
lists are non-empty.
|
|
566
|
+
ZosmfAuthError: If a request returns HTTP 401.
|
|
567
|
+
ZosmfSoftwareManagementError: If a request returns another
|
|
568
|
+
unsuccessful HTTP status.
|
|
569
|
+
httpx2.RequestError: If a request fails before an HTTP response is
|
|
570
|
+
received.
|
|
571
|
+
"""
|
|
572
|
+
return self._start_sw_update(
|
|
573
|
+
f"/zosmf/swmgmt/swi/{system}/{name}/swupdate",
|
|
574
|
+
tgtzone,
|
|
575
|
+
updates,
|
|
576
|
+
sourceids,
|
|
577
|
+
fixcats,
|
|
578
|
+
step=step,
|
|
579
|
+
holds=holds,
|
|
580
|
+
notes=notes,
|
|
581
|
+
exclude_updates=exclude_updates,
|
|
582
|
+
zosmf_auth=zosmf_auth,
|
|
583
|
+
proxy_auth=proxy_auth,
|
|
584
|
+
wait=wait,
|
|
585
|
+
)
|
|
586
|
+
|
|
587
|
+
def _cancel_sw_update(self, path: str) -> int:
|
|
588
|
+
resp = self.http.post(path)
|
|
589
|
+
self._raise_for_status(resp, exc_handler=ZosmfSoftwareManagementError)
|
|
590
|
+
return int(resp.json()["processid"])
|
|
591
|
+
|
|
592
|
+
def cancel_sw_update_by_process(self, processid: int) -> int:
|
|
593
|
+
"""Request cancellation of an update process by its process ID.
|
|
594
|
+
|
|
595
|
+
This method submits the cancellation request and does not wait for the
|
|
596
|
+
process to reach a terminal state.
|
|
597
|
+
|
|
598
|
+
Args:
|
|
599
|
+
processid: Process ID of the software update to cancel.
|
|
600
|
+
Returns:
|
|
601
|
+
The process ID returned by z/OSMF for the cancellation request.
|
|
602
|
+
|
|
603
|
+
Raises:
|
|
604
|
+
ZosmfAuthError: If z/OSMF returns HTTP 401.
|
|
605
|
+
ZosmfSoftwareManagementError: If z/OSMF returns another
|
|
606
|
+
unsuccessful HTTP status.
|
|
607
|
+
httpx2.RequestError: If the request fails before an HTTP response
|
|
608
|
+
is received.
|
|
609
|
+
"""
|
|
610
|
+
return self._cancel_sw_update(f"/zosmf/swmgmt/swupdate/cancel/{processid}")
|
|
611
|
+
|
|
612
|
+
def cancel_sw_update_by_uuid(self, uuid: str) -> int:
|
|
613
|
+
"""Cancel a software update for a software instance identified by its UUID.
|
|
614
|
+
|
|
615
|
+
Cancel the software update identified by the given UUID. While GIMSMP is
|
|
616
|
+
executing, the cancellation request may be not be possible.
|
|
617
|
+
|
|
618
|
+
Args:
|
|
619
|
+
uuid: UUID of the software instance to update.
|
|
620
|
+
|
|
621
|
+
Returns:
|
|
622
|
+
The process ID.
|
|
623
|
+
|
|
624
|
+
Raises:
|
|
625
|
+
ZosmfAuthError: If z/OSMF returns HTTP 401.
|
|
626
|
+
ZosmfSoftwareManagementError: If z/OSMF returns another
|
|
627
|
+
unsuccessful HTTP status.
|
|
628
|
+
httpx2.RequestError: If the request fails before an HTTP response
|
|
629
|
+
is received.
|
|
630
|
+
"""
|
|
631
|
+
return self._cancel_sw_update(f"/zosmf/swmgmt/swi/{uuid}/swupdate/cancel")
|
|
632
|
+
|
|
633
|
+
def cancel_sw_update_by_name(self, name: str, system: str) -> int:
|
|
634
|
+
"""Cancel a software update for a software instance identified by its name and system.
|
|
635
|
+
|
|
636
|
+
Cancel the software update identified by the given name and system. While GIMSMP is
|
|
637
|
+
executing, the cancellation request may be not be possible.
|
|
638
|
+
|
|
639
|
+
Args:
|
|
640
|
+
name: Name of the software instance to update.
|
|
641
|
+
system: System of the software instance to update.
|
|
642
|
+
|
|
643
|
+
Returns:
|
|
644
|
+
The process ID.
|
|
645
|
+
|
|
646
|
+
Raises:
|
|
647
|
+
ZosmfAuthError: If z/OSMF returns HTTP 401.
|
|
648
|
+
ZosmfSoftwareManagementError: If z/OSMF returns another
|
|
649
|
+
unsuccessful HTTP status.
|
|
650
|
+
httpx2.RequestError: If the request fails before an HTTP response
|
|
651
|
+
is received.
|
|
652
|
+
"""
|
|
653
|
+
return self._cancel_sw_update(f"/zosmf/swmgmt/swi/{system}/{name}/swupdate/cancel")
|
|
654
|
+
|
|
655
|
+
def _resume_sw_update(
|
|
656
|
+
self,
|
|
657
|
+
path: str,
|
|
658
|
+
steps: list[str],
|
|
659
|
+
holds: list[str],
|
|
660
|
+
notes: str,
|
|
661
|
+
exclude_updates: list[str],
|
|
662
|
+
zosmf_auth: tuple[str, ...],
|
|
663
|
+
proxy_auth: tuple[str, ...],
|
|
664
|
+
wait: bool,
|
|
665
|
+
) -> int | list[UpdateProcess]:
|
|
666
|
+
resp = self.http.post(
|
|
667
|
+
path,
|
|
668
|
+
json={
|
|
669
|
+
"suspend-steps": steps,
|
|
670
|
+
"resolve-holds": holds,
|
|
671
|
+
"exclude-updates": exclude_updates,
|
|
672
|
+
"notes": notes,
|
|
673
|
+
},
|
|
674
|
+
)
|
|
675
|
+
self._raise_for_status(resp, exc_handler=ZosmfSoftwareManagementError)
|
|
676
|
+
process_id = int(resp.json()["processid"])
|
|
677
|
+
if not wait:
|
|
678
|
+
return process_id
|
|
679
|
+
|
|
680
|
+
upd_processes = self.check_sw_update_status(process_id)
|
|
681
|
+
while any(upd.status == "RUNNING" for upd in upd_processes):
|
|
682
|
+
time.sleep(2)
|
|
683
|
+
upd_processes = self.check_sw_update_status(process_id)
|
|
684
|
+
return upd_processes
|
|
685
|
+
|
|
686
|
+
def resume_sw_update_by_process(
|
|
687
|
+
self,
|
|
688
|
+
processid: int,
|
|
689
|
+
steps: list[str] = [],
|
|
690
|
+
holds: list[str] = [],
|
|
691
|
+
notes: str = "",
|
|
692
|
+
exclude_updates: list[str] = [],
|
|
693
|
+
zosmf_auth: tuple[str, ...] = (),
|
|
694
|
+
proxy_auth: tuple[str, ...] = (),
|
|
695
|
+
wait: bool = False,
|
|
696
|
+
) -> int | list[UpdateProcess]:
|
|
697
|
+
"""Resume a software update for a software instance identified by process ID.
|
|
698
|
+
|
|
699
|
+
Resume the software update identified by the given process ID. When
|
|
700
|
+
``wait`` is false, return the process ID as soon as z/OSMF accepts the
|
|
701
|
+
request. When true, poll the process until it is no longer running and
|
|
702
|
+
return its update-process records.
|
|
703
|
+
|
|
704
|
+
Args:
|
|
705
|
+
processid: Process ID of the software update to resume.
|
|
706
|
+
steps: Steps to suspend during the update.
|
|
707
|
+
holds: Holds to resolve during the update.
|
|
708
|
+
notes: Notes for the update process.
|
|
709
|
+
exclude_updates: Updates to exclude from the process.
|
|
710
|
+
zosmf_auth: Reserved compatibility argument; currently not applied.
|
|
711
|
+
proxy_auth: Reserved compatibility argument; currently not applied.
|
|
712
|
+
wait: Whether to wait for the update process to finish.
|
|
713
|
+
|
|
714
|
+
Returns:
|
|
715
|
+
The process ID if ``wait`` is false, otherwise a list of
|
|
716
|
+
``UpdateProcess`` records.
|
|
717
|
+
|
|
718
|
+
Raises:
|
|
719
|
+
ZosmfAuthError: If a request returns HTTP 401.
|
|
720
|
+
ZosmfSoftwareManagementError: If a request returns another
|
|
721
|
+
unsuccessful HTTP status.
|
|
722
|
+
httpx2.RequestError: If a request fails before an HTTP response is
|
|
723
|
+
received.
|
|
724
|
+
"""
|
|
725
|
+
return self._resume_sw_update(
|
|
726
|
+
f"/zosmf/swmgmt/swupdate/resume/{processid}",
|
|
727
|
+
steps=steps,
|
|
728
|
+
holds=holds,
|
|
729
|
+
notes=notes,
|
|
730
|
+
exclude_updates=exclude_updates,
|
|
731
|
+
zosmf_auth=zosmf_auth,
|
|
732
|
+
proxy_auth=proxy_auth,
|
|
733
|
+
wait=wait,
|
|
734
|
+
)
|
|
735
|
+
|
|
736
|
+
def resume_sw_update_by_uuid(
|
|
737
|
+
self,
|
|
738
|
+
uuid: str,
|
|
739
|
+
steps: list[str] = [],
|
|
740
|
+
holds: list[str] = [],
|
|
741
|
+
notes: str = "",
|
|
742
|
+
exclude_updates: list[str] = [],
|
|
743
|
+
zosmf_auth: tuple[str, ...] = (),
|
|
744
|
+
proxy_auth: tuple[str, ...] = (),
|
|
745
|
+
wait: bool = False,
|
|
746
|
+
) -> int | list[UpdateProcess]:
|
|
747
|
+
"""Resume a software update for a software instance identified by its UUID.
|
|
748
|
+
|
|
749
|
+
Resume the software update identified by the given UUID. When ``wait``
|
|
750
|
+
is false, return the process ID as soon as z/OSMF accepts the request.
|
|
751
|
+
When true, poll the process until it is no longer running and return its
|
|
752
|
+
update-process records.
|
|
753
|
+
|
|
754
|
+
Args:
|
|
755
|
+
uuid: UUID of the software instance to update.
|
|
756
|
+
steps: Steps to suspend during the update.
|
|
757
|
+
holds: Holds to resolve during the update.
|
|
758
|
+
notes: Notes for the update process.
|
|
759
|
+
exclude_updates: Updates to exclude from the process.
|
|
760
|
+
zosmf_auth: Reserved compatibility argument; currently not applied.
|
|
761
|
+
proxy_auth: Reserved compatibility argument; currently not applied.
|
|
762
|
+
wait: Whether to wait for the update process to finish.
|
|
763
|
+
|
|
764
|
+
Returns:
|
|
765
|
+
The process ID if ``wait`` is false, otherwise a list of
|
|
766
|
+
``UpdateProcess`` records.
|
|
767
|
+
|
|
768
|
+
Raises:
|
|
769
|
+
ZosmfAuthError: If a request returns HTTP 401.
|
|
770
|
+
ZosmfSoftwareManagementError: If a request returns another
|
|
771
|
+
unsuccessful HTTP status.
|
|
772
|
+
httpx2.RequestError: If a request fails before an HTTP response is
|
|
773
|
+
received.
|
|
774
|
+
"""
|
|
775
|
+
return self._resume_sw_update(
|
|
776
|
+
f"/zosmf/swmgmt/swi/{uuid}/swupdate/resume",
|
|
777
|
+
steps=steps,
|
|
778
|
+
holds=holds,
|
|
779
|
+
notes=notes,
|
|
780
|
+
exclude_updates=exclude_updates,
|
|
781
|
+
zosmf_auth=zosmf_auth,
|
|
782
|
+
proxy_auth=proxy_auth,
|
|
783
|
+
wait=wait,
|
|
784
|
+
)
|
|
785
|
+
|
|
786
|
+
def resume_sw_update_by_name(
|
|
787
|
+
self,
|
|
788
|
+
name: str,
|
|
789
|
+
system: str,
|
|
790
|
+
steps: list[str] = [],
|
|
791
|
+
holds: list[str] = [],
|
|
792
|
+
notes: str = "",
|
|
793
|
+
exclude_updates: list[str] = [],
|
|
794
|
+
zosmf_auth: tuple[str, ...] = (),
|
|
795
|
+
proxy_auth: tuple[str, ...] = (),
|
|
796
|
+
wait: bool = False,
|
|
797
|
+
) -> int | list[UpdateProcess]:
|
|
798
|
+
"""Resume a software update for a software instance identified by its name and system.
|
|
799
|
+
|
|
800
|
+
Resume the software update identified by the given name and system. When
|
|
801
|
+
``wait`` is false, return the process ID as soon as z/OSMF accepts the
|
|
802
|
+
request. When true, poll the process until it is no longer running and
|
|
803
|
+
return its update-process records.
|
|
804
|
+
|
|
805
|
+
Args:
|
|
806
|
+
name: Name of the software instance to update.
|
|
807
|
+
system: System of the software instance to update.
|
|
808
|
+
steps: Steps to suspend during the update.
|
|
809
|
+
holds: Holds to resolve during the update.
|
|
810
|
+
notes: Notes for the update process.
|
|
811
|
+
exclude_updates: Updates to exclude from the process.
|
|
812
|
+
zosmf_auth: Reserved compatibility argument; currently not applied.
|
|
813
|
+
proxy_auth: Reserved compatibility argument; currently not applied.
|
|
814
|
+
wait: Whether to wait for the update process to finish.
|
|
815
|
+
|
|
816
|
+
Returns:
|
|
817
|
+
The process ID if ``wait`` is false, otherwise a list of
|
|
818
|
+
``UpdateProcess`` records.
|
|
819
|
+
|
|
820
|
+
Raises:
|
|
821
|
+
ZosmfAuthError: If a request returns HTTP 401.
|
|
822
|
+
ZosmfSoftwareManagementError: If a request returns another
|
|
823
|
+
unsuccessful HTTP status.
|
|
824
|
+
httpx2.RequestError: If a request fails before an HTTP response is
|
|
825
|
+
received.
|
|
826
|
+
"""
|
|
827
|
+
return self._resume_sw_update(
|
|
828
|
+
f"/zosmf/swmgmt/swi/{system}/{name}/swupdate/resume",
|
|
829
|
+
steps=steps,
|
|
830
|
+
holds=holds,
|
|
831
|
+
notes=notes,
|
|
832
|
+
exclude_updates=exclude_updates,
|
|
833
|
+
zosmf_auth=zosmf_auth,
|
|
834
|
+
proxy_auth=proxy_auth,
|
|
835
|
+
wait=wait,
|
|
836
|
+
)
|
|
837
|
+
|
|
838
|
+
def check_sw_update_status(self, process_id: int) -> list[UpdateProcess]:
|
|
839
|
+
"""Retrieve the latest update-process records for a process ID.
|
|
840
|
+
|
|
841
|
+
This method performs one status request; it does not poll while the
|
|
842
|
+
process is running. Use :meth:`get_sw_updates` with ``wait=True`` to
|
|
843
|
+
poll until the process is no longer running.
|
|
844
|
+
|
|
845
|
+
Args:
|
|
846
|
+
process_id: ID returned when the update process was started.
|
|
847
|
+
|
|
848
|
+
Returns:
|
|
849
|
+
Parsed update-process records returned for this process.
|
|
850
|
+
|
|
851
|
+
Raises:
|
|
852
|
+
ZosmfAuthError: If z/OSMF returns HTTP 401.
|
|
853
|
+
ZosmfSoftwareManagementError: If z/OSMF returns another
|
|
854
|
+
unsuccessful HTTP status.
|
|
855
|
+
httpx2.RequestError: If the request fails before an HTTP response
|
|
856
|
+
is received.
|
|
857
|
+
"""
|
|
858
|
+
path = f"/zosmf/swmgmt/swupdate/{process_id}"
|
|
859
|
+
resp = self.http.get(path)
|
|
860
|
+
self._raise_for_status(resp, exc_handler=ZosmfSoftwareManagementError)
|
|
861
|
+
return [
|
|
862
|
+
from_dict(
|
|
863
|
+
data_class=UpdateProcess,
|
|
864
|
+
data=process,
|
|
865
|
+
config=Config(
|
|
866
|
+
type_hooks={
|
|
867
|
+
pendulum.DateTime: _parse_datetime,
|
|
868
|
+
},
|
|
869
|
+
convert_key=lambda k: k.replace("_", "-"),
|
|
870
|
+
),
|
|
871
|
+
)
|
|
872
|
+
for process in resp.json()["update-processes"]
|
|
873
|
+
]
|
|
874
|
+
|
|
875
|
+
def _copy_output_sw_update(self, path: str, output_dir: str) -> list[dict[str, Any]]:
|
|
876
|
+
resp = self.http.put(path, params={"dir": output_dir})
|
|
877
|
+
self._raise_for_status(resp, exc_handler=ZosmfSoftwareManagementError)
|
|
878
|
+
return resp.json()["files"]
|
|
879
|
+
|
|
880
|
+
def copy_output_sw_update_by_uuid(self, uuid: str, output_dir: str) -> list[dict[str, Any]]:
|
|
881
|
+
"""Copy output files for a software instance identified by UUID.
|
|
882
|
+
|
|
883
|
+
Args:
|
|
884
|
+
uuid: UUID of the software instance whose update output is copied.
|
|
885
|
+
output_dir: Destination directory on the z/OS UNIX system.
|
|
886
|
+
|
|
887
|
+
Returns:
|
|
888
|
+
File metadata returned by z/OSMF; each entry includes the copied
|
|
889
|
+
file's name/path.
|
|
890
|
+
|
|
891
|
+
Raises:
|
|
892
|
+
ZosmfAuthError: If z/OSMF returns HTTP 401.
|
|
893
|
+
ZosmfSoftwareManagementError: If z/OSMF returns another
|
|
894
|
+
unsuccessful HTTP status.
|
|
895
|
+
httpx2.RequestError: If the request fails before an HTTP response
|
|
896
|
+
is received.
|
|
897
|
+
"""
|
|
898
|
+
return self._copy_output_sw_update(
|
|
899
|
+
f"/zosmf/swmgmt/swi/{uuid}/swupdate", output_dir=output_dir
|
|
900
|
+
)
|
|
901
|
+
|
|
902
|
+
def copy_output_sw_update_by_process(
|
|
903
|
+
self, process: int, output_dir: str
|
|
904
|
+
) -> list[dict[str, Any]]:
|
|
905
|
+
"""Copy output files for an update process.
|
|
906
|
+
|
|
907
|
+
Args:
|
|
908
|
+
process: ID of the update process whose output is copied.
|
|
909
|
+
output_dir: Destination directory on the z/OS UNIX system.
|
|
910
|
+
|
|
911
|
+
Returns:
|
|
912
|
+
File metadata returned by z/OSMF; each entry includes the copied
|
|
913
|
+
file's name/path.
|
|
914
|
+
|
|
915
|
+
Raises:
|
|
916
|
+
ZosmfAuthError: If z/OSMF returns HTTP 401.
|
|
917
|
+
ZosmfSoftwareManagementError: If z/OSMF returns another
|
|
918
|
+
unsuccessful HTTP status.
|
|
919
|
+
httpx2.RequestError: If the request fails before an HTTP response
|
|
920
|
+
is received.
|
|
921
|
+
"""
|
|
922
|
+
return self._copy_output_sw_update(
|
|
923
|
+
f"/zosmf/swmgmt/swupdate/{process}", output_dir=output_dir
|
|
924
|
+
)
|
|
925
|
+
|
|
926
|
+
def copy_output_sw_update_by_name(
|
|
927
|
+
self, name: str, system: str, output_dir: str
|
|
928
|
+
) -> list[dict[str, Any]]:
|
|
929
|
+
"""Copy output files for a software instance identified by name.
|
|
930
|
+
|
|
931
|
+
Args:
|
|
932
|
+
name: Name of the software instance.
|
|
933
|
+
system: System where the software instance is defined.
|
|
934
|
+
output_dir: Destination directory on the z/OS UNIX system.
|
|
935
|
+
|
|
936
|
+
Returns:
|
|
937
|
+
File metadata returned by z/OSMF; each entry includes the copied
|
|
938
|
+
file's name/path.
|
|
939
|
+
|
|
940
|
+
Raises:
|
|
941
|
+
ZosmfAuthError: If z/OSMF returns HTTP 401.
|
|
942
|
+
ZosmfSoftwareManagementError: If z/OSMF returns another
|
|
943
|
+
unsuccessful HTTP status.
|
|
944
|
+
httpx2.RequestError: If the request fails before an HTTP response
|
|
945
|
+
is received.
|
|
946
|
+
"""
|
|
947
|
+
return self._copy_output_sw_update(
|
|
948
|
+
f"/zosmf/swmgmt/swi/{system}/{name}/swupdate", output_dir=output_dir
|
|
949
|
+
)
|