Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use datasets.write instead of cp to populate JCL #149

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions plugins/module_utils/_data_set_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion plugins/modules/region_jcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading