From 35581c768ce5e9e0fe49014d756ce89540aebec0 Mon Sep 17 00:00:00 2001 From: Stewart Francis Date: Thu, 5 Dec 2024 14:37:43 +0000 Subject: [PATCH] Use datasets.write instead of cp to populate JCL Signed-off-by: Stewart Francis --- plugins/module_utils/_data_set_utils.py | 18 +++++++++--------- plugins/modules/region_jcl.py | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/module_utils/_data_set_utils.py b/plugins/module_utils/_data_set_utils.py index a6ec727..6cd445e 100644 --- a/plugins/module_utils/_data_set_utils.py +++ b/plugins/module_utils/_data_set_utils.py @@ -15,6 +15,7 @@ from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.zos_mvs_raw import MVSCmd from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.dd_statement import DDStatement, StdoutDefinition, StdinDefinition from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.job import job_output +from zoautil_py import datasets MVS_CMD_RETRY_ATTEMPTS = 10 @@ -359,22 +360,21 @@ def _read_data_set_content(data_set_name): rc, data_set_name), executions) return executions, stdout - def _write_jcl_to_data_set(jcl, data_set_name): """Writes generated JCL content to the specified data set """ executions = [] - temp = tempfile.NamedTemporaryFile(delete=True) - with open(temp.name, "w") as f: - f.write(jcl) - rc, stdout, stderr = _execute_command("cp -O u {0} \"//'{1}'\"".format(temp.name, data_set_name)) + response = datasets._write(data_set_name, jcl) + executions.append( _execution( name="Copy JCL contents to data set", - rc=rc, - stdout=stdout, - stderr=stderr)) - if rc != 0: + rc=response.rc, + stdout=response.stdout_response, + stderr=response.stderr_response + ) + ) + if response.rc != 0: raise MVSExecutionException("Failed to copy JCL content to data set", executions) return executions diff --git a/plugins/modules/region_jcl.py b/plugins/modules/region_jcl.py index 0697ad3..a31b430 100644 --- a/plugins/modules/region_jcl.py +++ b/plugins/modules/region_jcl.py @@ -352,7 +352,7 @@ def create_data_set(self): # type: () -> None primary_unit=self.primary_unit, secondary_unit=self.secondary_unit, volumes=self.volumes, - block_size=4096, + block_size=32720, record_length=80, record_format="FB", disposition="NEW",