Skip to content

Commit fcc27d5

Browse files
committed
added warm state for TEMP and LRQ
Signed-off-by: Kye Maloy <[email protected]>
1 parent 412c1fa commit fcc27d5

File tree

16 files changed

+706
-97
lines changed

16 files changed

+706
-97
lines changed

plugins/module_utils/auxiliary_temp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _get_idcams_cmd_temp(dataset): # type: (Dict) -> Dict
3535
"PRIMARY_SPACE_VALUE_DEFAULT": 200,
3636
"SECONDARY_SPACE_VALUE_DEFAULT": 10,
3737
"SPACE_UNIT_DEFAULT": "REC",
38-
"TARGET_STATE_OPTIONS": ["absent", "initial"],
38+
"TARGET_STATE_OPTIONS": ["absent", "initial", "warm"],
3939
"RECORD_COUNT_DEFAULT": 4089,
4040
"RECORD_SIZE_DEFAULT": 4089,
4141
"CONTROL_INTERVAL_SIZE_DEFAULT": 4096,

plugins/module_utils/data_set.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from ansible_collections.ibm.ibm_zos_cics.plugins.module_utils.response import _response, _state
1212
from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.better_arg_parser import BetterArgParser
1313
from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.dd_statement import DatasetDefinition
14+
from ansible_collections.ibm.ibm_zos_cics.plugins.module_utils.icetool import _run_icetool
1415

1516

1617
class DataSet(object):
@@ -143,7 +144,22 @@ def init_data_set(self): # type: () -> None
143144
self.create_data_set()
144145

145146
def warm_data_set(self): # type: () -> None
146-
if not self.data_set["exists"]:
147+
if self.data_set["exists"]:
148+
try:
149+
icetool_executions, record_count = _run_icetool(self.data_set["name"])
150+
self.result["executions"] = self.result["executions"] + icetool_executions
151+
if record_count["record_count"] <= 0:
152+
self.result["end_state"] = _state(
153+
exists=self.data_set["exists"]
154+
)
155+
self._fail("Data set {0} is empty.".format(self.data_set["name"]))
156+
except Exception as e:
157+
self.result["executions"] = self.result["executions"] + e.args[1]
158+
self._fail(e.args[0])
159+
else:
160+
self.result["end_state"] = _state(
161+
exists=self.data_set["exists"]
162+
)
147163
self._fail(
148164
"Data set {0} does not exist.".format(
149165
self.data_set["name"]))

plugins/module_utils/local_request_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _get_idcams_cmd_lrq(dataset): # type: (Dict) -> Dict
3434
"PRIMARY_SPACE_VALUE_DEFAULT": 4,
3535
"SECONDARY_SPACE_VALUE_DEFAULT": 1,
3636
"SPACE_UNIT_DEFAULT": "M",
37-
"TARGET_STATE_OPTIONS": ["absent", "initial"],
37+
"TARGET_STATE_OPTIONS": ["absent", "initial", "warm"],
3838
"RECORD_COUNT_DEFAULT": 2232,
3939
"RECORD_SIZE_DEFAULT": 2400,
4040
"CONTROL_INTERVAL_SIZE_DEFAULT": 2560,

plugins/modules/auxiliary_temp.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,11 @@
9797
already exists.
9898
- V(initial) will create the auxiliary temporary storage data set if it does not
9999
already exist.
100+
- V(warm) will retain an existing auxiliary temporary storage data set in its current state.
100101
choices:
101102
- "initial"
102103
- "absent"
104+
- "warm"
103105
required: true
104106
type: str
105107
"""

plugins/modules/local_catalog.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@
209209
from ansible_collections.ibm.ibm_zos_cics.plugins.module_utils.data_set import DataSet
210210
from ansible_collections.ibm.ibm_zos_cics.plugins.module_utils.local_catalog import (
211211
_run_dfhccutl, _get_idcams_cmd_lcd)
212-
from ansible_collections.ibm.ibm_zos_cics.plugins.module_utils.icetool import (_run_icetool)
213212
from ansible_collections.ibm.ibm_zos_cics.plugins.module_utils.local_catalog import _local_catalog_constants as lc_constants
214213
from ansible_collections.ibm.ibm_zos_cics.plugins.module_utils.data_set import _dataset_constants as ds_constants
215214

@@ -363,20 +362,6 @@ def delete_data_set(self): # type: () -> None
363362

364363
super().delete_data_set("Removing local catalog data set")
365364

366-
def warm_data_set(self): # type: () -> None
367-
super().warm_data_set()
368-
369-
try:
370-
icetool_executions, record_count = _run_icetool(self.data_set["name"])
371-
if record_count["record_count"] <= 0:
372-
self._fail("Unused catalog. The catalog must be used by CICS before doing a warm start.")
373-
374-
self.result["executions"] = self.result["executions"] + icetool_executions
375-
self.result["changed"] = False
376-
except Exception as e:
377-
self.result["executions"] = self.result["executions"] + e.args[1]
378-
self._fail(e.args[0])
379-
380365
def init_data_set(self): # type: () -> None
381366
if self.data_set["exists"]:
382367
self.result["end_state"] = {

plugins/modules/local_request_queue.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,11 @@
9797
already exists.
9898
- V(initial) will create the local request queue data set if it does not
9999
already exist, and empty it of all existing records.
100+
- V(warm) will retain an existing LRQ data set in its current state.
100101
choices:
101102
- "initial"
102103
- "absent"
104+
- "warm"
103105
required: true
104106
type: str
105107
'''

plugins/modules/trace.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@
113113
already exists.
114114
- V(initial) will create the auxillary trace data set if it does not
115115
already exist.
116-
- V(warm) will error if the data set is absent, or if it is present and has no records. It will
117-
will no-op if the data set is present and contains at least 1 record.
116+
- V(warm) will retain an existing auxiliary trace data set in its current state.
118117
choices:
119118
- "initial"
120119
- "absent"
@@ -183,7 +182,6 @@
183182
returned: always
184183
"""
185184

186-
from ansible_collections.ibm.ibm_zos_cics.plugins.module_utils.icetool import _run_icetool
187185
from ansible_collections.ibm.ibm_zos_cics.plugins.module_utils.response import _state
188186
from ansible_collections.ibm.ibm_zos_cics.plugins.module_utils.trace import _build_seq_data_set_definition_trace
189187
from ansible_collections.ibm.ibm_zos_cics.plugins.module_utils.trace import _trace_data_set_constants as trace_constants
@@ -419,24 +417,6 @@ def init_trace(self):
419417
if not (self.data_set["exists"]):
420418
self.create_data_set()
421419

422-
def warm_trace(self):
423-
if not self.data_set["exists"]:
424-
self.result["end_state"] = _state(
425-
exists=self.data_set["exists"]
426-
)
427-
self._fail("Warm is not compatible with absent data set.")
428-
icetool_executions, record_count = _run_icetool(self.data_set["name"])
429-
if record_count["record_count"] <= 0:
430-
self.result["end_state"] = _state(
431-
exists=self.data_set["exists"]
432-
)
433-
self._fail("Warm is not compatible with empty data set.")
434-
if record_count["record_count"] > 0:
435-
self.result["end_state"] = _state(
436-
exists=self.data_set["exists"]
437-
)
438-
self._exit()
439-
440420
def invalid_state(self): # type: () -> None
441421
self._fail("{0} is not a valid target state.".format(
442422
self.data_set["state"]))
@@ -445,7 +425,7 @@ def get_target_method(self, target):
445425
return {
446426
ds_constants["TARGET_STATE_ABSENT"]: self.delete_aux_trace_datasets,
447427
ds_constants["TARGET_STATE_INITIAL"]: self.init_trace,
448-
ds_constants["TARGET_STATE_WARM"]: self.warm_trace
428+
ds_constants["TARGET_STATE_WARM"]: super().warm_data_set
449429
}.get(target, self.invalid_state)
450430

451431
def main(self):

tests/integration/targets/cics_trace/runme.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ ansible-playbook -i "$INV_PATH" -e "@$VAR_PATH" -e "@$ZOS_ENV" playbooks/initial
1414
ansible-playbook -i "$INV_PATH" -e "@$VAR_PATH" -e "@$ZOS_ENV" playbooks/check_bad_trace_location.yml
1515
ansible-playbook -i "$INV_PATH" -e "@$VAR_PATH" -e "@$ZOS_ENV" playbooks/check_uppercase_location.yml
1616
ansible-playbook -i "$INV_PATH" -e "@$VAR_PATH" -e "@$ZOS_ENV" playbooks/incompatible_destination.yml
17-
ansible-playbook -i "$INV_PATH" -e "@$VAR_PATH" -e "@$ZOS_ENV" playbooks/template_lowest_precedence.yml
17+
ansible-playbook -i "$INV_PATH" -e "@$VAR_PATH" -e "@$ZOS_ENV" playbooks/template_lowest_precedence.yml
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# (c) Copyright IBM Corp. 2024
2+
# Apache License, Version 2.0 (see https://opensource.org/licenses/Apache-2.0)
3+
---
4+
- name: Warm auxillary trace data set
5+
6+
hosts: "all"
7+
gather_facts: false
8+
vars:
9+
region_dataset_path: "ANSIBIT.CICS.TESTS.{{ cics_test_area_absent }}"
10+
auxt_name: "DFHAUXT"
11+
buxt_name: "DFHBUXT"
12+
auxt_path: "{{ region_dataset_path }}.{{ auxt_name }}"
13+
buxt_path: "{{ region_dataset_path }}.{{ buxt_name }}"
14+
15+
module_defaults:
16+
ibm.ibm_zos_cics.trace:
17+
region_data_sets:
18+
template: "{{ region_dataset_path }}.<< data_set_name >>"
19+
20+
tasks:
21+
# #############################################################################
22+
# ############################## Initial cleanup ##############################
23+
# #############################################################################
24+
25+
- name: Delete DFHAUXT Data Set if it exists
26+
environment: "{{ environment_vars }}"
27+
ibm.ibm_zos_core.zos_data_set:
28+
name: "{{ auxt_path }}"
29+
state: absent
30+
register: delete_result
31+
retries: 3
32+
until: delete_result is not failed
33+
34+
- name: Assert Delete Passed
35+
ansible.builtin.assert:
36+
that:
37+
- delete_result.failed == false
38+
39+
- name: Delete DFHBUXT Data Set if it exists
40+
environment: "{{ environment_vars }}"
41+
ibm.ibm_zos_core.zos_data_set:
42+
name: "{{ buxt_path }}"
43+
state: absent
44+
register: delete_result
45+
retries: 3
46+
until: delete_result is not failed
47+
48+
- name: Assert Delete Passed
49+
ansible.builtin.assert:
50+
that:
51+
- delete_result.failed == false
52+
53+
54+
# #############################################################################
55+
# ############################## Module Testing ###############################
56+
# #############################################################################
57+
58+
- name: Create DFHAUXT data set with warm (should fail)
59+
environment: "{{ environment_vars }}"
60+
ibm.ibm_zos_cics.trace:
61+
state: "warm"
62+
register: result
63+
ignore_errors: true
64+
65+
- name: Debug
66+
ansible.builtin.debug:
67+
msg: "{{ result }}"
68+
69+
- name: Assert DFHAUXT failed to create
70+
ansible.builtin.assert:
71+
that:
72+
- result.failed is true
73+
- result.changed is false
74+
- result.start_state.exists == false
75+
- result.end_state.exists == false
76+
- "'msg' in result"
77+
- "'Data set {{ auxt_path }} does not exist.' in result.msg"
78+
79+
- name: Create DFHAUXT data set
80+
environment: "{{ environment_vars }}"
81+
ibm.ibm_zos_cics.trace:
82+
state: "initial"
83+
register: result
84+
85+
- name: Debug
86+
ansible.builtin.debug:
87+
msg: "{{ result }}"
88+
89+
- name: Assert DFHAUXT Created
90+
ansible.builtin.assert:
91+
that:
92+
- result.failed is false
93+
- result.changed is true
94+
95+
- result.start_state.exists == false
96+
97+
- result.end_state.exists == true
98+
99+
- name: Create DFHAUXT data set with warm (should fail, empty)
100+
environment: "{{ environment_vars }}"
101+
ibm.ibm_zos_cics.trace:
102+
state: "warm"
103+
register: result
104+
ignore_errors: true
105+
106+
- name: Debug
107+
ansible.builtin.debug:
108+
msg: "{{ result }}"
109+
110+
- name: Assert DFHAUXT failed to create
111+
ansible.builtin.assert:
112+
that:
113+
- result.failed is true
114+
- result.changed is false
115+
- result.start_state.exists == true
116+
- result.end_state.exists == true
117+
- "'msg' in result"
118+
- "'Data set {{ auxt_path }} is empty.' in result.msg"
119+
120+
- name: Copy a local file to a sequential data set
121+
environment: "{{ environment_vars }}"
122+
ibm.ibm_zos_core.zos_copy:
123+
src: "{{ playbook_dir }}/sample_trace.txt"
124+
dest: "{{ auxt_path }}"
125+
encoding:
126+
from: UTF-8
127+
to: IBM-1047
128+
register: result
129+
retries: 3
130+
until: result is not failed
131+
delay: 5
132+
133+
- name: Create DFHAUXT data set with warm
134+
environment: "{{ environment_vars }}"
135+
ibm.ibm_zos_cics.trace:
136+
state: "warm"
137+
register: result
138+
139+
- name: Debug
140+
ansible.builtin.debug:
141+
msg: "{{ result }}"
142+
143+
- name: Assert DFHAUXT succeeded
144+
ansible.builtin.assert:
145+
that:
146+
- result.failed is false
147+
- result.changed is false
148+
- result.start_state.exists == true
149+
- result.end_state.exists == true
150+
151+
# #############################################################################
152+
# ################################## Cleanup ##################################
153+
# #############################################################################
154+
155+
- name: Delete DFHAUXT Data Set
156+
environment: "{{ environment_vars }}"
157+
ibm.ibm_zos_core.zos_data_set:
158+
name: "{{ auxt_path }}"
159+
state: absent
160+
register: delete_result
161+
retries: 3
162+
until: delete_result is not failed
163+
164+
- name: Assert Delete Passed
165+
ansible.builtin.assert:
166+
that:
167+
- delete_result.failed == false
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CICS - AUXILIARY TRACE FROM 01/01/01 - APPLID IYCXXXX PAGE 00001
2+
3+
SELECTIVE TRACE PRINT PARAMETERS:
4+
5+
ENTRY_NUM=1-10
6+
7+
8+
DS 0012 DSKE ENTRY - FUNCTION(TASK_REPLY) TASK_TOKEN(225B3100) ATTACH_TOKEN(3F4B7980)
9+
10+
TASK-TI KE_NUM-002C TCB-C/QR /009D6398 RET-9FD0351E TIME-22:46:50.4980264062 INTERVAL-**.*********** =0000001
11+
1-0000 00B00000 00000001 00000000 00000000 B8800000 00000000 02000100 225B3100 *.............................$..*
12+
0020 00000000 00000000 00000000 3F4B7980 00000000 00000000 00000000 00000000 *................................*
13+
0040 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 *................................*
14+
0060 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 *................................*
15+
0080 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 *................................*
16+
00A0 00000000 00000000 00000000 00000000 *................

0 commit comments

Comments
 (0)