Skip to content

Commit 01bf407

Browse files
Changes already merged to staging1.16 for 761 and 2123 (#2215)
* 761 changes already merged to staging1.16 * chnages merged to statging v1.16 as part of 2213 PR * resolving sanity issue in new file creation * Updated zos_job_output * Updated wrong line * Updated tests --------- Co-authored-by: Fernando Flores <[email protected]>
1 parent 9e6a4eb commit 01bf407

File tree

9 files changed

+102
-11
lines changed

9 files changed

+102
-11
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
minor_changes:
2+
- zos_job_output - Adds support to query SYSIN DDs from a job with new option input.
3+
(https://github.com/ansible-collections/ibm_zos_core/pull/2207)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
trivial:
2+
- test_zos_copy_func.py - modified test case `test_job_script_async`
3+
to resolve porting issues to ansible 2.19.
4+
(https://github.com/ansible-collections/ibm_zos_core/pull/2213).
5+
6+
- test_zos_job_submit_func.py - modified test case `test_job_submit_async`
7+
to resolve porting issues to ansible 2.19.
8+
(https://github.com/ansible-collections/ibm_zos_core/pull/2213).
9+
10+
- test_zos_script_func.py - modified test case `test_job_script_async`
11+
to resolve porting issues to ansible 2.19.
12+
(https://github.com/ansible-collections/ibm_zos_core/pull/2213).
13+
14+
- test_zos_unarchive_func.py - modified test case `test_zos_unarchive_async`
15+
to resolve porting issues to ansible 2.19.
16+
(https://github.com/ansible-collections/ibm_zos_core/pull/2213).

plugins/module_utils/job.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
])
5959

6060

61-
def job_output(job_id=None, owner=None, job_name=None, dd_name=None, dd_scan=True, duration=0, timeout=0, start_time=timer()):
61+
def job_output(job_id=None, owner=None, job_name=None, dd_name=None, sysin=False, dd_scan=True, duration=0, timeout=0, start_time=timer()):
6262
"""Get the output from a z/OS job based on various search criteria.
6363
6464
Keyword Parameters
@@ -71,6 +71,8 @@ def job_output(job_id=None, owner=None, job_name=None, dd_name=None, dd_scan=Tru
7171
The job name search for (default: {None}).
7272
dd_name : str
7373
The data definition to retrieve (default: {None}).
74+
sysin : bool
75+
The input DD to retrieve SYSIN value (default: {False}).
7476
dd_scan : bool
7577
Whether or not to pull information from the dd's for this job {default: {True}}.
7678
duration : int
@@ -112,6 +114,7 @@ def job_output(job_id=None, owner=None, job_name=None, dd_name=None, dd_scan=Tru
112114
job_name=job_name,
113115
dd_name=dd_name,
114116
duration=duration,
117+
sysin=sysin,
115118
dd_scan=dd_scan,
116119
timeout=timeout,
117120
start_time=start_time
@@ -128,6 +131,7 @@ def job_output(job_id=None, owner=None, job_name=None, dd_name=None, dd_scan=Tru
128131
owner=owner,
129132
job_name=job_name,
130133
dd_name=dd_name,
134+
sysin=sysin,
131135
dd_scan=dd_scan,
132136
duration=duration,
133137
timeout=timeout,
@@ -300,7 +304,7 @@ def _parse_steps(job_str):
300304
return stp
301305

302306

303-
def _get_job_status(job_id="*", owner="*", job_name="*", dd_name=None, dd_scan=True, duration=0, timeout=0, start_time=timer()):
307+
def _get_job_status(job_id="*", owner="*", job_name="*", dd_name=None, sysin=False, dd_scan=True, duration=0, timeout=0, start_time=timer()):
304308
"""Get job status.
305309
306310
Parameters
@@ -313,6 +317,8 @@ def _get_job_status(job_id="*", owner="*", job_name="*", dd_name=None, dd_scan=T
313317
The job name search for (default: {None}).
314318
dd_name : str
315319
The data definition to retrieve (default: {None}).
320+
sysin : bool
321+
The input DD SYSIN (default: {False}).
316322
dd_scan : bool
317323
Whether or not to pull information from the dd's for this job {default: {True}}.
318324
duration : int
@@ -418,7 +424,7 @@ def _get_job_status(job_id="*", owner="*", job_name="*", dd_name=None, dd_scan=T
418424
list_of_dds = []
419425

420426
try:
421-
list_of_dds = jobs.list_dds(entry.job_id)
427+
list_of_dds = jobs.list_dds(entry.job_id, sysin=sysin)
422428
except exceptions.DDQueryException:
423429
is_dd_query_exception = True
424430

@@ -437,7 +443,7 @@ def _get_job_status(job_id="*", owner="*", job_name="*", dd_name=None, dd_scan=T
437443
try:
438444
# Note, in the event of an exception, eg job has TYPRUN=HOLD
439445
# list_of_dds will still be populated with valuable content
440-
list_of_dds = jobs.list_dds(entry.job_id)
446+
list_of_dds = jobs.list_dds(entry.job_id, sysin=sysin)
441447
is_jesjcl = True if search_dictionaries("dd_name", "JESJCL", list_of_dds) else False
442448
is_job_error_status = True if entry.status in JOB_ERROR_STATUSES else False
443449
except exceptions.DDQueryException:

plugins/modules/zos_job_output.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
like "*".
3434
- If there is no dd_name, or if dd_name="?", output of all the dds under
3535
the given job will be displayed.
36+
- If SYSIN DDs are needed, C(input) should be set to C(true).
3637
version_added: "1.0.0"
3738
author:
3839
- "Jack Ho (@jacklotusho)"
@@ -62,6 +63,12 @@
6263
type: str
6364
required: false
6465
aliases: [ ddname ]
66+
input:
67+
description:
68+
- Whether to include SYSIN DDs as part of the output.
69+
type: bool
70+
default: false
71+
required: false
6572
6673
attributes:
6774
action:
@@ -91,6 +98,11 @@
9198
job_name: "*"
9299
owner: "IBMUSER"
93100
dd_name: "?"
101+
102+
- name: Query a job's output including SYSIN DDs
103+
zos_job_output:
104+
job_id: "JOB00548"
105+
input: true
94106
"""
95107

96108
RETURN = r"""
@@ -496,6 +508,7 @@ def run_module():
496508
job_id=dict(type="str", required=False),
497509
job_name=dict(type="str", required=False),
498510
owner=dict(type="str", required=False),
511+
input=dict(type="bool", required=False, default=False),
499512
dd_name=dict(type="str", required=False, aliases=['ddname']),
500513
)
501514

@@ -505,6 +518,7 @@ def run_module():
505518
job_id=dict(type="job_identifier", required=False),
506519
job_name=dict(type="job_identifier", required=False),
507520
owner=dict(type="str", required=False),
521+
input=dict(type="bool", required=False, default=False),
508522
dd_name=dict(type="str", required=False, aliases=['ddname']),
509523
)
510524

@@ -524,14 +538,15 @@ def run_module():
524538
job_id = module.params.get("job_id")
525539
job_name = module.params.get("job_name")
526540
owner = module.params.get("owner")
541+
sysin = module.params.get("input")
527542
dd_name = module.params.get("dd_name")
528543

529544
if not job_id and not job_name and not owner:
530545
module.fail_json(msg="Please provide a job_id or job_name or owner", stderr="", **results)
531546

532547
try:
533548
results = {}
534-
results["jobs"] = job_output(job_id=job_id, owner=owner, job_name=job_name, dd_name=dd_name)
549+
results["jobs"] = job_output(job_id=job_id, owner=owner, job_name=job_name, dd_name=dd_name, sysin=sysin)
535550
for job in results["jobs"]:
536551
if "job_not_found" in job:
537552
results["changed"] = False

tests/functional/modules/test_zos_copy_func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@
257257
async_status:
258258
jid: "{{{{ copy_output.ansible_job_id }}}}"
259259
register: job_result
260-
until: job_result.finished
260+
until: job_result.finished | bool
261261
retries: 10
262262
delay: 30
263263

tests/functional/modules/test_zos_job_output_func.py

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
__metaclass__ = type
1717

1818
from shellescape import quote
19+
from ibm_zos_core.tests.helpers.dataset import get_tmp_ds_name
1920

2021

2122
JCL_FILE_CONTENTS = """//HELLO JOB (T043JM,JM00,1,0,0,0),'HELLO WORLD - JRM',CLASS=R,
@@ -30,6 +31,19 @@
3031
//
3132
"""
3233

34+
JCL_FILE_CONTENTS_SYSIN = """//SYSINS JOB (T043JM,JM00,1,0,0,0),'SYSINS - JRM',CLASS=R,
35+
// MSGCLASS=X,MSGLEVEL=1,NOTIFY=OMVSADM
36+
//STEP1 EXEC PGM=BPXBATCH,PARM='SH sleep 1'
37+
//STDOUT DD SYSOUT=*
38+
//STDERR DD SYSOUT=*
39+
//LISTCAT EXEC PGM=IDCAMS,REGION=4M
40+
//SYSPRINT DD SYSOUT=*
41+
//SYSIN DD *
42+
LISTCAT ENTRIES('{0}') ALL
43+
/*
44+
//
45+
"""
46+
3347
TEMP_PATH = "/tmp/jcl"
3448

3549
def test_zos_job_output_no_job_id(ansible_zos_module):
@@ -249,7 +263,7 @@ def test_zos_job_output_job_exists(ansible_zos_module):
249263
hosts.all.file(path=TEMP_PATH, state="absent")
250264

251265

252-
def test_zos_job_output_job_exists_with_filtered_ddname(ansible_zos_module):
266+
def test_zos_job_output_job_exists_with_filtered_dd_name(ansible_zos_module):
253267
try:
254268
hosts = ansible_zos_module
255269
hosts.all.file(path=TEMP_PATH, state="directory")
@@ -261,7 +275,7 @@ def test_zos_job_output_job_exists_with_filtered_ddname(ansible_zos_module):
261275
)
262276
hosts.all.file(path=TEMP_PATH, state="absent")
263277
dd_name = "JESMSGLG"
264-
results = hosts.all.zos_job_output(job_name="HELLO", ddname=dd_name)
278+
results = hosts.all.zos_job_output(job_name="HELLO", dd_name=dd_name)
265279
for result in results.contacted.values():
266280
assert result.get("changed") is True
267281
assert result.get("msg", False) is False
@@ -310,6 +324,43 @@ def test_zos_job_output_job_exists_with_filtered_ddname(ansible_zos_module):
310324
hosts.all.file(path=TEMP_PATH, state="absent")
311325

312326

327+
def test_zos_job_output_job_exists_with_sysin(ansible_zos_module):
328+
try:
329+
hosts = ansible_zos_module
330+
hosts.all.file(path=TEMP_PATH, state="directory")
331+
data_set_name = get_tmp_ds_name()
332+
result = hosts.all.zos_data_set(
333+
name=data_set_name,
334+
type="seq",
335+
state="present"
336+
)
337+
print(f"job_submit_result: {result.contacted.values()}")
338+
hosts.all.shell(
339+
cmd=f"echo {quote(JCL_FILE_CONTENTS_SYSIN.format(data_set_name))} > {TEMP_PATH}/SYSIN"
340+
)
341+
result = hosts.all.zos_job_submit(
342+
src=f"{TEMP_PATH}/SYSIN", remote_src=True, volume=None
343+
)
344+
print(f"job_submit_result: {result.contacted.values()}")
345+
hosts.all.file(path=TEMP_PATH, state="absent")
346+
sysin = True
347+
results = hosts.all.zos_job_output(job_name="SYSINS", input=sysin)
348+
for result in results.contacted.values():
349+
print(f"job_output_result: {result}")
350+
assert result.get("changed") is True
351+
for job in result.get("jobs"):
352+
assert len(job.get("dds")) >= 1
353+
sysin_found = False
354+
for ddname_entry in job.get("dds"):
355+
if ddname_entry.get("dd_name") == "SYSIN":
356+
sysin_found = True
357+
break
358+
assert sysin_found
359+
finally:
360+
hosts.all.zos_data_set(name=data_set_name, state="absent")
361+
hosts.all.file(path=TEMP_PATH, state="absent")
362+
363+
313364
def test_zos_job_submit_job_id_and_owner_included(ansible_zos_module):
314365
hosts = ansible_zos_module
315366
results = hosts.all.zos_job_output(job_id="STC00*", owner="MASTER")

tests/functional/modules/test_zos_job_submit_func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@
425425
async_status:
426426
jid: "{{{{ job_task.ansible_job_id }}}}"
427427
register: job_result
428-
until: job_result.finished
428+
until: job_result.finished | bool
429429
retries: 20
430430
delay: 5
431431
"""

tests/functional/modules/test_zos_script_func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
async_status:
8888
jid: "{{{{ job_task.ansible_job_id }}}}"
8989
register: job_result
90-
until: job_result.finished
90+
until: job_result.finished | bool
9191
retries: 20
9292
delay: 5
9393
"""

tests/functional/modules/test_zos_unarchive_func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
async_status:
7373
jid: "{{{{ job_task.ansible_job_id }}}}"
7474
register: job_result
75-
until: job_result.finished
75+
until: job_result.finished | bool
7676
retries: 20
7777
delay: 5
7878
"""

0 commit comments

Comments
 (0)