Skip to content

Commit 25bf081

Browse files
committed
add rc to executions, generate doc for executions
Signed-off-by: Andrew Twydell <[email protected]>
1 parent 892f13d commit 25bf081

File tree

6 files changed

+145
-15
lines changed

6 files changed

+145
-15
lines changed

docs/source/modules/stop_region.rst

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Return Values
183183
rc
184184
| The return code for the program execution.
185185
186-
| **returned**: on shutdown execution
186+
| **returned**: always
187187
| **type**: int
188188
189189

@@ -204,10 +204,18 @@ Return Values
204204
205205

206206

207+
failed
208+
| True if the module failed, otherwise False.
209+
210+
| **returned**: always
211+
| **type**: bool
212+
213+
214+
207215
jobs
208216
| The output information for a list of jobs matching specified criteria.
209217
210-
| **returned**: success
218+
| **returned**: on zos_job_query module execution
211219
| **type**: list
212220
213221

@@ -298,16 +306,82 @@ Return Values
298306
message
299307
| Message returned on failure.
300308
301-
| **returned**: failure
309+
| **returned**: on zos_job_query module execution
302310
| **type**: str
303311
304312

305313

306314
content
307315
| The resulting text from the command submitted.
308316
309-
| **returned**: on success of PERFORM SHUTDOWN command submission.
317+
| **returned**: on zos_operator module execution
318+
| **type**: list
319+
320+
321+
322+
cmd
323+
| The operator command that has been executed
324+
325+
| **returned**: on zos_operator module execution
326+
| **type**: str
327+
328+
329+
330+
rc
331+
| The return code from the operator command
332+
333+
| **returned**: on zos_operator module execution
334+
| **type**: int
335+
336+
337+
338+
max_rc
339+
| The maximum return code from the tso status command
340+
341+
| **returned**: on zos_tso_command module execution
342+
| **type**: int
343+
344+
345+
346+
output
347+
| The output from the tso command
348+
349+
| **returned**: on zos_tso_command module execution
310350
| **type**: list
351+
352+
353+
354+
command
355+
| The executed TSO command.
356+
357+
| **returned**: always
358+
| **type**: str
359+
360+
361+
362+
rc
363+
| The return code from the executed TSO command.
364+
365+
| **returned**: always
366+
| **type**: int
367+
368+
369+
370+
content
371+
| The response resulting from the execution of the TSO command.
372+
373+
| **returned**: always
374+
| **type**: list
375+
376+
377+
378+
lines
379+
| The line number of the content.
380+
381+
| **returned**: always
382+
| **type**: int
383+
384+
311385

312386

313387

plugins/action/stop_region.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def _get_running_jobs(self):
195195
def _add_status_execution(self, job, result):
196196
self.executions.append({
197197
NAME: CHECK_CICS_STATUS.format(job),
198+
RC: result.get("max_rc"),
198199
RETURN: result,
199200
})
200201

@@ -241,6 +242,7 @@ def execute_zos_job_query(self, job_id):
241242
)
242243
self.executions.append({
243244
NAME: "ZOS Job Query - {0}".format(job_id),
245+
RC: 0 if query_response.get("message", "-") == "" and isinstance(query_response.get("jobs", {}), list) else 1,
244246
RETURN: query_response
245247
})
246248
return query_response
@@ -253,6 +255,7 @@ def execute_zos_operator_cmd(self, command):
253255
)
254256
self.executions.append({
255257
NAME: "ZOS Operator Command - {0}".format(command),
258+
RC: operator_response.get("rc"),
256259
RETURN: operator_response,
257260
})
258261
return operator_response
@@ -276,6 +279,7 @@ def execute_cancel_shell_cmd(self, job_name, job_id):
276279
cancel_response = command_action.run(task_vars=self.task_vars)
277280
self.executions.append({
278281
NAME: "Cancel command - {0}({1})".format(job_name, job_id),
282+
RC: cancel_response.get("rc"),
279283
RETURN: cancel_response,
280284
})
281285
return cancel_response

plugins/modules/stop_region.py

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
rc:
124124
description: The return code for the program execution.
125125
type: int
126-
returned: on shutdown execution
126+
returned: always
127127
return:
128128
description: The standard output returned by the program execution.
129129
type: dict
@@ -133,10 +133,14 @@
133133
description: True if the state was changed, otherwise False.
134134
returned: always
135135
type: bool
136+
failed:
137+
description: True if the module failed, otherwise False.
138+
returned: always
139+
type: bool
136140
jobs:
137141
description: The output information for a list of jobs matching specified criteria.
138142
type: list
139-
returned: success
143+
returned: on zos_job_query module execution
140144
elements: dict
141145
contains:
142146
job_id:
@@ -186,12 +190,47 @@
186190
type: int
187191
message:
188192
description: Message returned on failure.
189-
returned: failure
193+
returned: on zos_job_query module execution
190194
type: str
191195
content:
192196
description: The resulting text from the command submitted.
193-
returned: on success of PERFORM SHUTDOWN command submission.
197+
returned: on zos_operator module execution
198+
type: list
199+
cmd:
200+
description: The operator command that has been executed
201+
returned: on zos_operator module execution
202+
type: str
203+
rc:
204+
description: The return code from the operator command
205+
returned: on zos_operator module execution
206+
type: int
207+
max_rc:
208+
description: The maximum return code from the tso status command
209+
returned: on zos_tso_command module execution
210+
type: int
211+
output:
212+
description: The output from the tso command
213+
returned: on zos_tso_command module execution
194214
type: list
215+
elements: dict
216+
contains:
217+
command:
218+
description: The executed TSO command.
219+
returned: always
220+
type: str
221+
rc:
222+
description: The return code from the executed TSO command.
223+
returned: always
224+
type: int
225+
content:
226+
description: The response resulting from the execution of the TSO command.
227+
returned: always
228+
type: list
229+
lines:
230+
description: The line number of the content.
231+
returned: always
232+
type: int
233+
195234
msg:
196235
description: A string containing an error message if applicable
197236
returned: always

tests/integration/targets/cics_start_stop/playbooks/stop_args.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@
8686
- stop_result.executions[-1].return.output[0].content | length == 2
8787
- "'ON OUTPUT QUEUE' in '{{ stop_result.executions[-1].return.output[0].content | join(' ') }}'"
8888
fail_msg: "CICS Region did not stop successfully"
89+
- name: Assert execution RCs are 0
90+
ansible.builtin.assert:
91+
that:
92+
- item.rc == 0
93+
msg: Job failed with RC != 0
94+
loop: "{{ stop_result.executions }}"
8995

9096
always:
9197
- name: Delete job
@@ -120,6 +126,12 @@
120126
- stop_result.executions[-1].return.output[0].content | length == 2
121127
- "'ON OUTPUT QUEUE' in '{{ stop_result.executions[-1].return.output[0].content | join(' ') }}'"
122128
fail_msg: "CICS Region did not stop successfully"
129+
- name: Assert execution RCs are 0
130+
ansible.builtin.assert:
131+
that:
132+
- item.rc == 0
133+
msg: Job failed with RC != 0
134+
loop: "{{ stop_result.executions }}"
123135

124136
- name: Stop job mismatched name and ID
125137
block:

tests/integration/targets/cics_start_stop/repeatable_tasks/stop_region.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@
7878
- "'ON OUTPUT QUEUE' in '{{ stop_output.executions[-1].return.output[0].content | join(' ') }}'"
7979
fail_msg: "CICS Region did not stop successfully"
8080

81+
- name: Assert execution RCs are 0
82+
when: expect_failure is not defined or expect_failure is false
83+
ansible.builtin.assert:
84+
that:
85+
- item.rc == 0
86+
msg: Job failed with RC != 0
87+
loop: "{{ stop_output.executions }}"
88+
8189
- name: Execute a command to delete job
8290
when: expect_failure is not defined or expect_failure is false
8391
ansible.builtin.command:

tests/unit/modules/test_stop_cics.py renamed to tests/unit/modules/test_stop_region.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,20 @@ def test__validate_sdtran():
3333
stop_module._module.params[SDTRAN] = "CESD"
3434
stop_module.main()
3535
assert stop_module.failed is False
36-
assert stop_module.changed is False
37-
assert stop_module.executions == []
3836

3937

4038
def test__validate_sdtran_3_chars():
4139
stop_module = initialise_module()
4240
stop_module._module.params[SDTRAN] = "C$D"
4341
stop_module.main()
4442
assert stop_module.failed is False
45-
assert stop_module.changed is False
46-
assert stop_module.executions == []
4743

4844

4945
def test__validate_sdtran_numerical():
5046
stop_module = initialise_module()
5147
stop_module._module.params[SDTRAN] = "1234"
5248
stop_module.main()
5349
assert stop_module.failed is False
54-
assert stop_module.changed is False
55-
assert stop_module.executions == []
5650

5751

5852
def test__validate_sdtran_too_long():
@@ -64,4 +58,3 @@ def test__validate_sdtran_too_long():
6458
stop_module.msg
6559
== "Value: CESDS, is invalid. SDTRAN value must be 1-4 characters."
6660
)
67-
assert stop_module.executions == []

0 commit comments

Comments
 (0)