Skip to content

Commit

Permalink
Clean temporary data sets created during XMIT unarchive operation (#1049
Browse files Browse the repository at this point in the history
)

* Added a temp cleanup

* Added changelog

* Modified changelog

* Added removal of src if remote_src is False

Signed-off-by: Fernando Flores <[email protected]>

* Modified changelog fragments

---------

Signed-off-by: Fernando Flores <[email protected]>
  • Loading branch information
fernandofloresg authored Nov 8, 2023
1 parent dc5cdf6 commit b9ace90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions changelogs/fragments/1049-xmit-temporary-data-sets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bugfixes:
- zos_unarchive - When zos_unarchive fails during unpack either with xmit or terse it does not clean the
temporary data sets created. Fix now removes the temporary data sets.
(https://github.com/ansible-collections/ibm_zos_core/pull/1049).
5 changes: 4 additions & 1 deletion plugins/modules/zos_unarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,8 @@ def unpack(self, src, dest):
dds = {'args': 'UNPACK', 'sysut1': src, 'sysut2': dest}
rc, out, err = mvs_cmd.amaterse(cmd="", dds=dds)
if rc != 0:
self.clean_environment(data_sets=[dest], uss_files=[], remove_targets=True)
ds_remove_list = [dest, src] if not self.remote_src else [dest]
self.clean_environment(data_sets=ds_remove_list, uss_files=[], remove_targets=True)
self.module.fail_json(
msg="Failed executing AMATERSE to restore {0} into {1}".format(src, dest),
stdout=out,
Expand Down Expand Up @@ -881,6 +882,8 @@ def unpack(self, src, dest):
""".format(src, dest)
rc, out, err = mvs_cmd.ikjeft01(cmd=unpack_cmd, authorized=True)
if rc != 0:
ds_remove_list = [dest, src] if not self.remote_src else [dest]
self.clean_environment(data_sets=ds_remove_list, uss_files=[], remove_targets=True)
self.module.fail_json(
msg="Failed executing RECEIVE to restore {0} into {1}".format(src, dest),
stdout=out,
Expand Down

0 comments on commit b9ace90

Please sign in to comment.