Skip to content

Commit 0a5ef16

Browse files
[Enhancement] [zos_job_submit, zos_script, zos_unarchive] Remove use of deep copy when calling action modules (#1561)
* add workaround fix * Use correct action loader * Changed action plugin * Added changelog fragment * Added unarchive docs * Added changelog * Added changelog * Fixed sanity issues * fixed pyflakes
1 parent 4b9a7e9 commit 0a5ef16

File tree

6 files changed

+38
-31
lines changed

6 files changed

+38
-31
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
minor_changes:
2+
- zos_job_submit - Improved the copy to remote mechanic to avoid using deepcopy that could
3+
result in failure for some systems.
4+
(https://github.com/ansible-collections/ibm_zos_core/pull/1561).
5+
- zos_script - Improved the copy to remote mechanic to avoid using deepcopy that could
6+
result in failure for some systems.
7+
(https://github.com/ansible-collections/ibm_zos_core/pull/1561).
8+
- zos_unarchive - Improved the copy to remote mechanic to avoid using deepcopy that could
9+
result in failure for some systems.
10+
(https://github.com/ansible-collections/ibm_zos_core/pull/1561).

plugins/action/zos_job_submit.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020
from ansible.module_utils.common.text.converters import to_bytes, to_text
2121
from ansible.module_utils.parsing.convert_bool import boolean
2222
import os
23-
import copy
2423

2524
from ansible_collections.ibm.ibm_zos_core.plugins.module_utils import template
26-
from ansible_collections.ibm.ibm_zos_core.plugins.action.zos_copy import ActionModule as ZosCopyActionModule
2725

2826

2927
display = Display()
@@ -151,15 +149,17 @@ def run(self, tmp=None, task_vars=None):
151149
remote_src=True,
152150
)
153151
)
154-
copy_task = copy.deepcopy(self._task)
152+
copy_task = self._task.copy()
155153
copy_task.args = copy_module_args
156-
zos_copy_action_module = ZosCopyActionModule(task=copy_task,
157-
connection=self._connection,
158-
play_context=self._play_context,
159-
loader=self._loader,
160-
templar=self._templar,
161-
shared_loader_obj=self._shared_loader_obj)
162-
result.update(zos_copy_action_module.run(task_vars=task_vars))
154+
copy_action = self._shared_loader_obj.action_loader.get(
155+
'ibm.ibm_zos_core.zos_copy',
156+
task=copy_task,
157+
connection=self._connection,
158+
play_context=self._play_context,
159+
loader=self._loader,
160+
templar=self._templar,
161+
shared_loader_obj=self._shared_loader_obj)
162+
result.update(copy_action.run(task_vars=task_vars))
163163
if result.get("msg") is None:
164164
module_args["src"] = dest_path
165165
result.update(

plugins/action/zos_script.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
from __future__ import absolute_import, division, print_function
1313
__metaclass__ = type
1414

15-
import copy
1615
import shlex
1716
from os import path
1817

1918
from ansible.plugins.action import ActionBase
2019
from ansible.module_utils.parsing.convert_bool import boolean
21-
from ansible_collections.ibm.ibm_zos_core.plugins.action.zos_copy import ActionModule as ZosCopyActionModule
2220

2321
from ansible.utils.display import Display
2422
display = Display()
@@ -90,7 +88,7 @@ def run(self, tmp=None, task_vars=None):
9088
tempfile_path = tempfile_result.get('path')
9189

9290
# Letting zos_copy handle the transfer of the script.
93-
zos_copy_args = dict(
91+
copy_module_args = dict(
9492
src=script_path,
9593
dest=tempfile_path,
9694
force=True,
@@ -99,18 +97,17 @@ def run(self, tmp=None, task_vars=None):
9997
use_template=module_args.get('use_template', False),
10098
template_parameters=module_args.get('template_parameters', dict())
10199
)
102-
copy_task = copy.deepcopy(self._task)
103-
copy_task.args = zos_copy_args
104-
zos_copy_action_plugin = ZosCopyActionModule(
100+
copy_task = self._task.copy()
101+
copy_task.args = copy_module_args
102+
copy_action = self._shared_loader_obj.action_loader.get(
103+
'ibm.ibm_zos_core.zos_copy',
105104
task=copy_task,
106105
connection=self._connection,
107106
play_context=self._play_context,
108107
loader=self._loader,
109108
templar=self._templar,
110-
shared_loader_obj=self._shared_loader_obj
111-
)
112-
113-
zos_copy_result = zos_copy_action_plugin.run(task_vars=task_vars)
109+
shared_loader_obj=self._shared_loader_obj)
110+
zos_copy_result = copy_action.run(task_vars=task_vars)
114111
result.update(zos_copy_result)
115112

116113
if not result.get("changed") or result.get("failed"):

plugins/action/zos_unarchive.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
from ansible.utils.display import Display
1818
from ansible.module_utils.parsing.convert_bool import boolean
1919
import os
20-
import copy
21-
from ansible_collections.ibm.ibm_zos_core.plugins.action.zos_copy import ActionModule as ZosCopyActionModule
2220

2321

2422
USS_SUPPORTED_FORMATS = ['tar', 'zip', 'bz2', 'pax', 'gz']
@@ -102,15 +100,17 @@ def run(self, tmp=None, task_vars=None):
102100
is_binary=True,
103101
)
104102
)
105-
copy_task = copy.deepcopy(self._task)
103+
copy_task = self._task.copy()
106104
copy_task.args = copy_module_args
107-
zos_copy_action_module = ZosCopyActionModule(task=copy_task,
108-
connection=self._connection,
109-
play_context=self._play_context,
110-
loader=self._loader,
111-
templar=self._templar,
112-
shared_loader_obj=self._shared_loader_obj)
113-
result.update(zos_copy_action_module.run(task_vars=task_vars))
105+
copy_action = self._shared_loader_obj.action_loader.get(
106+
'ibm.ibm_zos_core.zos_copy',
107+
task=copy_task,
108+
connection=self._connection,
109+
play_context=self._play_context,
110+
loader=self._loader,
111+
templar=self._templar,
112+
shared_loader_obj=self._shared_loader_obj)
113+
result.update(copy_action.run(task_vars=task_vars))
114114
display.vvv(u"Copy result {0}".format(result), host=self._play_context.remote_addr)
115115
if result.get("msg") is None:
116116
module_args["src"] = dest

plugins/modules/zos_job_submit.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,6 @@ def submit_src_jcl(module, src, src_name=None, timeout=0, is_unix=True, start_ti
710710
"fetch_max_retries": timeout,
711711
}
712712

713-
present = False
714713
duration = 0
715714
job_submitted = None
716715
result = {}

plugins/modules/zos_unarchive.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- The remote absolute path or data set of the archive to be uncompressed.
3636
- I(src) can be a USS file or MVS data set name.
3737
- USS file paths should be absolute paths.
38+
- MVS data sets supported types are C(SEQ), C(PDS), C(PDSE).
3839
- GDS relative names are supported C(e.g. USER.GDG(-1)).
3940
type: str
4041
required: true

0 commit comments

Comments
 (0)