Skip to content

Commit e82f43d

Browse files
Rohitcodes28fernandofloresg
authored andcommitted
Adding error suggestion to generic error while copying GDG if its in edit mode. (#2220)
* adding better error message hint * changing error from zoau for gdg copy * adding chnagelog * Fixing sanity issue * adding review comments * Error code mistake resolution * resolving sanity issue
1 parent f9e9e65 commit e82f43d

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
minor_changes:
2+
- zos_copy - Adds a better error message that gives user a
3+
hint that copy issue can be due to a GDS part of ``src`` GDG is
4+
being used by another process.
5+
(https://github.com/ansible-collections/ibm_zos_core/pull/2220)

plugins/modules/zos_copy.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,9 +1205,23 @@ def copy_to_gdg(self, src, dest):
12051205
# If identical_gdg_copy is False, use the default next generation
12061206
dest_gen_name = f"{dest}(+1)"
12071207
# Perform the copy operation
1208-
rc = datasets.copy(gds.name, dest_gen_name, **copy_args)
1209-
if rc != 0:
1210-
success = False
1208+
1209+
try:
1210+
result = datasets.copy(gds.name, dest_gen_name, **copy_args)
1211+
rc = result.rc if hasattr(result, 'rc') else result
1212+
if rc != 0:
1213+
success = False
1214+
except zoau_exceptions.ZOAUException as e:
1215+
stderr = getattr(e.response, 'stderr_response', str(e))
1216+
if "BGYSC0514E" in stderr :
1217+
raise GenerationDataGroupCreateError(
1218+
msg=(
1219+
"BGYSC0514E An error occurred while attempting to define the file."
1220+
" This might be because the GDS part of the src GDG is being used by another process."
1221+
)
1222+
) from e
1223+
else:
1224+
raise GenerationDataGroupCreateError(msg=f"GDG creation failed. Raw error: {stderr}") from e
12111225
return success
12121226

12131227
def _copy_tree(self, entries, src, dest, dirs_exist_ok=False):
@@ -4357,5 +4371,12 @@ def __init__(
43574371
super().__init__(msg)
43584372

43594373

4374+
class GenerationDataGroupCreateError(Exception):
4375+
def __init__(self, msg):
4376+
"""Error during copy of a Generation Data Group."""
4377+
self.msg = msg
4378+
super().__init__(self.msg)
4379+
4380+
43604381
if __name__ == "__main__":
43614382
main()

0 commit comments

Comments
 (0)