Skip to content

Commit f209a26

Browse files
[Enhancement] - [zos_job_submit, zos_job_query, zos_job_output] - adding new params(cpu_time, execution_node, origin_node) (#2056)
* Adding cpu_time, execution_node and origin_code params in zos_job_* modules response * Updating testcase as respective error description got changed in zoau 1.3.5 * Updating waiting time for testcase * Update test_zos_job_submit_func.py * Create 2056-zos_job-modules-adding-cpu_time-execution_node-origin_node.yml * Update changelogs/fragments/2056-zos_job-modules-adding-cpu_time-execution_node-origin_node.yml Co-authored-by: Alex Moreno <[email protected]> * Update changelogs/fragments/2056-zos_job-modules-adding-cpu_time-execution_node-origin_node.yml Co-authored-by: Alex Moreno <[email protected]> * Update changelogs/fragments/2056-zos_job-modules-adding-cpu_time-execution_node-origin_node.yml Co-authored-by: Alex Moreno <[email protected]> * Updating execution node description * Updating description * updating wait_times_s to wait_time_s in zos_job_submit --------- Co-authored-by: Alex Moreno <[email protected]>
1 parent ecfb60f commit f209a26

File tree

8 files changed

+122
-8
lines changed

8 files changed

+122
-8
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
minor_changes:
2+
- zos_job_submit - Adds new fields cpu_time, origin_node and execution_node to response.
3+
(https://github.com/ansible-collections/ibm_zos_core/pull/2056).
4+
5+
- zos_job_query - Adds new fields cpu_time, origin_node and execution_node to response.
6+
(https://github.com/ansible-collections/ibm_zos_core/pull/2056).
7+
8+
- zos_job_output - Adds new fields cpu_time, origin_node and execution_node to response.
9+
(https://github.com/ansible-collections/ibm_zos_core/pull/2056).

plugins/module_utils/job.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ def _job_not_found(job_id, owner, job_name, dd_name):
172172
job["subsystem"] = None
173173
job["system"] = None
174174
job["owner"] = owner
175+
job["cpu_time"] = None
176+
job["execution_node"] = None
177+
job["origin_node"] = None
175178

176179
job["ret_code"] = {}
177180
job["ret_code"]["msg"] = None
@@ -351,6 +354,9 @@ def _get_job_status(job_id="*", owner="*", job_name="*", dd_name=None, dd_scan=T
351354
job["subsystem"] = ""
352355
job["system"] = ""
353356
job["owner"] = entry.owner
357+
job["cpu_time"] = None
358+
job["execution_node"] = None
359+
job["origin_node"] = None
354360
# Sometimes, with job type STC, the first entry will have an extra
355361
# space at the end of it.
356362
job["content_type"] = entry.job_type.strip()
@@ -384,6 +390,12 @@ def _get_job_status(job_id="*", owner="*", job_name="*", dd_name=None, dd_scan=T
384390
job["system"] = entry.system
385391
if hasattr(entry, "subsystem"):
386392
job["subsystem"] = entry.subsystem
393+
if hasattr(entry, "cpu_time"):
394+
job["cpu_time"] = entry.cpu_time
395+
if hasattr(entry, "execution_node"):
396+
job["execution_node"] = entry.execution_node
397+
if hasattr(entry, "origin_node"):
398+
job["origin_node"] = entry.origin_node
387399

388400
if dd_scan:
389401
# If true, it means the job is not ready for DD queries and the duration and

plugins/modules/zos_job_output.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,31 @@
112112
The name of the batch job.
113113
type: str
114114
sample: HELLO
115+
system:
116+
description:
117+
The job entry system that MVS uses to do work.
118+
type: str
119+
sample: STL1
115120
subsystem:
116121
description:
117122
The job entry subsystem that MVS uses to do work.
118123
type: str
119124
sample: STL1
125+
cpu_time:
126+
description:
127+
Sum of the CPU time used by each job step, in microseconds.
128+
type: int
129+
sample: 5
130+
execution_node:
131+
description:
132+
Execution node that picked the job and executed it.
133+
type: str
134+
sample: "STL1"
135+
origin_node:
136+
description:
137+
Origin node that submitted the job.
138+
type: str
139+
sample: "STL1"
120140
class:
121141
description:
122142
Identifies the data set used in a system output data set, usually called a sysout data set.
@@ -425,7 +445,11 @@
425445
}
426446
]
427447
},
428-
"subsystem": "STL1"
448+
"system": "STL1",
449+
"subsystem": "STL1",
450+
"cpu_time": 1414,
451+
"execution_node": "STL1",
452+
"origin_node": "STL1"
429453
}
430454
]
431455
changed:

plugins/modules/zos_job_query.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,21 @@
153153
The job entry subsystem that MVS uses to do work.
154154
type: str
155155
sample: STL1
156+
cpu_time:
157+
description:
158+
Sum of the CPU time used by each job step, in microseconds.
159+
type: int
160+
sample: 5
161+
execution_node:
162+
description:
163+
Execution node that picked the job and executed it.
164+
type: str
165+
sample: "STL1"
166+
origin_node:
167+
description:
168+
Origin node that submitted the job.
169+
type: str
170+
sample: "STL1"
156171
ret_code:
157172
description:
158173
Return code output collected from job log.
@@ -271,7 +286,12 @@
271286
"creation_date": "2023-05-03",
272287
"creation_time": "12:13:00",
273288
"queue_position": 3,
274-
"execution_time": "00:00:02"
289+
"execution_time": "00:00:02",
290+
"system": "STL1",
291+
"subsystem": "STL1",
292+
"cpu_time": 1414,
293+
"execution_node": "STL1",
294+
"origin_node": "STL1"
275295
},
276296
{
277297
"job_name": "LINKCBL",
@@ -286,7 +306,12 @@
286306
"creation_date": "2023-05-03",
287307
"creation_time": "12:14:00",
288308
"queue_position": 0,
289-
"execution_time": "00:00:03"
309+
"execution_time": "00:00:03",
310+
"system": "STL1",
311+
"subsystem": "STL1",
312+
"cpu_time": 1414,
313+
"execution_node": "STL1",
314+
"origin_node": "STL1"
290315
},
291316
]
292317
message:
@@ -456,6 +481,9 @@ def parsing_jobs(jobs_raw):
456481
"content_type": job.get("content_type"),
457482
"system": job.get("system"),
458483
"subsystem": job.get("subsystem"),
484+
"cpu_time": job.get("cpu_time"),
485+
"execution_node": job.get("execution_node"),
486+
"origin_node": job.get("origin_node"),
459487
"ret_code": ret_code,
460488
"job_class": job.get("job_class"),
461489
"svc_class": job.get("svc_class"),

plugins/modules/zos_job_submit.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,31 @@
367367
The name of the program found in the job's last completed step found in the PGM parameter.
368368
type: str
369369
sample: "IEBGENER"
370+
system:
371+
description:
372+
The job entry system that MVS uses to do work.
373+
type: str
374+
sample: STL1
375+
subsystem:
376+
description:
377+
The job entry subsystem that MVS uses to do work.
378+
type: str
379+
sample: STL1
380+
cpu_time:
381+
description:
382+
Sum of the CPU time used by each job step, in microseconds.
383+
type: int
384+
sample: 5
385+
execution_node:
386+
description:
387+
Execution node that picked the job and executed it.
388+
type: str
389+
sample: "STL1"
390+
origin_node:
391+
description:
392+
Origin node that submitted the job.
393+
type: str
394+
sample: "STL1"
370395
371396
sample:
372397
[
@@ -591,7 +616,10 @@
591616
"creation_time": "12:13:00",
592617
"queue_position": 3,
593618
"subsystem": "STL1",
594-
"system": "STL1"
619+
"system": "STL1",
620+
"cpu_time": 1,
621+
"execution_node": "STL1",
622+
"origin_node": "STL1"
595623
}
596624
]
597625
"""
@@ -1095,10 +1123,10 @@ def run_module():
10951123
_msg = ("The JCL submitted with job id {0} but appears to be a long "
10961124
"running job that exceeded its maximum wait time of {1} "
10971125
"second(s). Consider using module zos_job_query to poll for "
1098-
"a long running job or increase option 'wait_times_s' to a value "
1126+
"a long running job or increase option 'wait_time_s' to a value "
10991127
"greater than {2}.".format(str(job_submitted_id), str(wait_time_s), str(duration)))
11001128
_msg_suffix = ("Consider using module zos_job_query to poll for "
1101-
"a long running job or increase option 'wait_times_s' to a value "
1129+
"a long running job or increase option 'wait_time_s' to a value "
11021130
"greater than {0}.".format(str(duration)))
11031131

11041132
if job_output_txt is not None:

tests/functional/modules/test_zos_job_output_func.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ def test_zos_job_output_job_exists(ansible_zos_module):
117117
assert result.get("jobs")[0].get("ret_code").get("steps")[0].get("step_name") == "STEP0001"
118118
assert result.get("jobs")[0].get("content_type") == "JOB"
119119
assert result.get("jobs")[0].get("execution_time") is not None
120+
assert "system" in result.get("jobs")[0]
121+
assert "subsystem" in result.get("jobs")[0]
122+
assert "cpu_time" in result.get("jobs")[0]
123+
assert "execution_node" in result.get("jobs")[0]
124+
assert "origin_node" in result.get("jobs")[0]
120125
finally:
121126
hosts.all.file(path=TEMP_PATH, state="absent")
122127

tests/functional/modules/test_zos_job_query_func.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ def test_zos_job_id_query_multi_wildcards_func(ansible_zos_module):
9898
assert qresult.get("jobs")[0].get("execution_time") is not None
9999
assert qresult.get("jobs")[0].get("system") is not None
100100
assert qresult.get("jobs")[0].get("subsystem") is not None
101+
assert "cpu_time" in result.get("jobs")[0]
102+
assert "execution_node" in result.get("jobs")[0]
103+
assert "origin_node" in result.get("jobs")[0]
101104

102105
finally:
103106
hosts.all.file(path=temp_path, state="absent")

tests/functional/modules/test_zos_job_submit_func.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,11 @@ def test_job_submit_pds(ansible_zos_module, location):
486486
assert result.get("jobs")[0].get("ret_code").get("msg_code") == "0000"
487487
assert result.get("jobs")[0].get("ret_code").get("code") == 0
488488
assert result.get("changed") is True
489+
assert "system" in result.get("jobs")[0]
490+
assert "subsystem" in result.get("jobs")[0]
491+
assert "cpu_time" in result.get("jobs")[0]
492+
assert "execution_node" in result.get("jobs")[0]
493+
assert "origin_node" in result.get("jobs")[0]
489494
finally:
490495
hosts.all.file(path=temp_path, state="absent")
491496
hosts.all.zos_data_set(name=data_set_name, state="absent")
@@ -771,11 +776,11 @@ def test_job_submit_pds_30_sec_job_wait_10_negative(ansible_zos_module):
771776
@pytest.mark.parametrize("args", [
772777
{
773778
"max_rc":None,
774-
"wait_time_s":10
779+
"wait_time_s":20
775780
},
776781
{
777782
"max_rc":4,
778-
"wait_time_s":10
783+
"wait_time_s":20
779784
},
780785
{
781786
"max_rc":12,

0 commit comments

Comments
 (0)