Skip to content

Commit 27f8d35

Browse files
authored
Corrects zos_data_set default record format FB breaking VSAM (#647)
* Change zos_data_set record format default to FB Signed-off-by: ddimatos <[email protected]> * Update zos_data_set module to not have defaults values when it should not Signed-off-by: ddimatos <[email protected]> * Linting too many blank lines Signed-off-by: ddimatos <[email protected]> * changelog fragment for zos_data_set record format issue Signed-off-by: ddimatos <[email protected]> * Update zos_data_set module doc with added context for record_format Signed-off-by: ddimatos <[email protected]> * Add back job clean up for JES Signed-off-by: ddimatos <[email protected]> --------- Signed-off-by: ddimatos <[email protected]>
1 parent 84f7118 commit 27f8d35

File tree

4 files changed

+55
-3
lines changed

4 files changed

+55
-3
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bugfixes:
2+
- zos_data_set - fixes a bug where the default record format FB was actually
3+
never enforced and when enforced it would cause VSAM creation to fail with a
4+
Dynalloc failure. This also cleans up some of the options that are set by
5+
default when they have no bearing for batch.
6+
(https://github.com/ansible-collections/ibm_zos_core/pull/647)

docs/source/modules/zos_data_set.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ record_format
132132

133133
Choices are case-insensitive.
134134

135+
When *type=KSDS*, *type=ESDS*, *type=RRDS*, *type=LDS* or *type=ZFS* then *record_format=None*, these types do not have a default *record_format*.
136+
135137
| **required**: False
136138
| **type**: str
137139
| **default**: FB
@@ -379,6 +381,8 @@ batch
379381

380382
Choices are case-insensitive.
381383

384+
When *type=KSDS*, *type=ESDS*, *type=RRDS*, *type=LDS* or *type=ZFS* then *record_format=None*, these types do not have a default *record_format*.
385+
382386
| **required**: False
383387
| **type**: str
384388
| **default**: FB

plugins/modules/zos_data_set.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@
141141
description:
142142
- The format of the data set. (e.g C(FB))
143143
- Choices are case-insensitive.
144+
- When I(type=KSDS), I(type=ESDS), I(type=RRDS), I(type=LDS) or I(type=ZFS)
145+
then I(record_format=None), these types do not have a default
146+
I(record_format).
144147
required: false
145148
choices:
146149
- FB
@@ -149,6 +152,7 @@
149152
- VBA
150153
- U
151154
type: str
155+
default: FB
152156
sms_storage_class:
153157
description:
154158
- The storage class for an SMS-managed dataset.
@@ -365,6 +369,9 @@
365369
description:
366370
- The format of the data set. (e.g C(FB))
367371
- Choices are case-insensitive.
372+
- When I(type=KSDS), I(type=ESDS), I(type=RRDS), I(type=LDS) or
373+
I(type=ZFS) then I(record_format=None), these types do not have a
374+
default I(record_format).
368375
required: false
369376
choices:
370377
- FB
@@ -373,6 +380,7 @@
373380
- VBA
374381
- U
375382
type: str
383+
default: FB
376384
sms_storage_class:
377385
description:
378386
- The storage class for an SMS-managed dataset.
@@ -629,6 +637,14 @@
629637
"U": 0,
630638
}
631639

640+
DATA_SET_TYPES_VSAM = [
641+
"KSDS",
642+
"ESDS",
643+
"RRDS",
644+
"LDS",
645+
"ZFS",
646+
]
647+
632648
# ------------- Functions to validate arguments ------------- #
633649

634650

@@ -1118,7 +1134,7 @@ def run_module():
11181134
space_type=dict(type="str", required=False, default="M"),
11191135
space_primary=dict(type="int", required=False, aliases=["size"], default=5),
11201136
space_secondary=dict(type="int", required=False, default=3),
1121-
record_format=dict(type="str", required=False, aliases=["format"]),
1137+
record_format=dict(type="str", required=False, aliases=["format"], default="FB"),
11221138
sms_management_class=dict(type="str", required=False),
11231139
# I know this alias is odd, ZOAU used to document they supported
11241140
# SMS data class when they were actually passing as storage class
@@ -1162,7 +1178,7 @@ def run_module():
11621178
space_type=dict(type="str", required=False, default="M"),
11631179
space_primary=dict(type="raw", required=False, aliases=["size"], default=5),
11641180
space_secondary=dict(type="int", required=False, default=3),
1165-
record_format=dict(type="str", required=False, aliases=["format"]),
1181+
record_format=dict(type="str", required=False, aliases=["format"], default="FB"),
11661182
sms_management_class=dict(type="str", required=False),
11671183
# I know this alias is odd, ZOAU used to document they supported
11681184
# SMS data class when they were actually passing as storage class
@@ -1202,6 +1218,32 @@ def run_module():
12021218

12031219
module = AnsibleModule(argument_spec=module_args, supports_check_mode=True)
12041220

1221+
# This evaluation will always occur as a result of the limitation on the
1222+
# better arg parser, this will serve as a solution for now and ensure
1223+
# the non-batch and batch arguments are correctly set
1224+
if module.params.get("batch") is not None:
1225+
for entry in module.params.get("batch"):
1226+
if entry.get('type') is not None and entry.get("type").upper() in DATA_SET_TYPES_VSAM:
1227+
entry["record_format"] = None
1228+
if module.params.get("type") is not None:
1229+
module.params["type"] = None
1230+
if module.params.get("state") is not None:
1231+
module.params["state"] = None
1232+
if module.params.get("space_type") is not None:
1233+
module.params["space_type"] = None
1234+
if module.params.get("space_primary") is not None:
1235+
module.params["space_primary"] = None
1236+
if module.params.get("space_secondary") is not None:
1237+
module.params["space_secondary"] = None
1238+
if module.params.get("replace") is not None:
1239+
module.params["replace"] = None
1240+
if module.params.get("record_format") is not None:
1241+
module.params["record_format"] = None
1242+
elif module.params.get("type") is not None:
1243+
if module.params.get("type").upper() in DATA_SET_TYPES_VSAM:
1244+
# For VSAM types set the value to nothing and let the code manage it
1245+
module.params["record_format"] = None
1246+
12051247
if not module.check_mode:
12061248
try:
12071249
# Update the dictionary for use by better arg parser by adding the

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def z_python_interpreter(request):
4444
def clean_logs(adhoc):
4545
"""Attempt to clean up logs and messages on the system."""
4646
# purge logs
47-
# adhoc.all.command(cmd="opercmd '$PJ(*)'")
47+
adhoc.all.command(cmd="opercmd '$PJ(*)'")
4848
# clean up wtor messages
4949
results = adhoc.all.command(cmd="uname -n")
5050
system_name = ""

0 commit comments

Comments
 (0)