Skip to content

Commit 9740f9e

Browse files
[Bugfix][zos_data_set] Added support for batch mode when creating gdg (#1515)
* Added support for batch mode * changed style * Added changelog * Corrected pyflakes
1 parent 811082d commit 9740f9e

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
trivial:
2+
- zos_data_set - Batch mode when type=gdg failed asking for limit option.
3+
Fix now accepts limit as part of batch option.
4+
(https://github.com/ansible-collections/ibm_zos_core/pull/1515).

plugins/module_utils/data_set.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ def create(
10321032
create_exception.response.rc,
10331033
create_exception.response.stdout_response + "\n" + create_exception.response.stderr_response
10341034
)
1035-
except exceptions.DatasetVerificationError as e:
1035+
except exceptions.DatasetVerificationError:
10361036
# verification of a data set spanning multiple volumes is currently broken in ZOAU v.1.3.0
10371037
if volumes and len(volumes) > 1:
10381038
if DataSet.data_set_cataloged(name, volumes):

plugins/modules/zos_data_set.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ def parse_and_validate_args(params):
14541454
type=dict(
14551455
type=data_set_type,
14561456
required=False,
1457-
dependencies=["state"],
1457+
dependencies=["state", "limit"],
14581458
choices=DATA_SET_TYPES,
14591459
),
14601460
space_type=dict(
@@ -1526,6 +1526,30 @@ def parse_and_validate_args(params):
15261526
aliases=["volume"],
15271527
dependencies=["state"],
15281528
),
1529+
limit=dict(
1530+
type="int",
1531+
required=False
1532+
),
1533+
empty=dict(
1534+
type="bool",
1535+
required=False
1536+
),
1537+
purge=dict(
1538+
type="bool",
1539+
required=False
1540+
),
1541+
scratch=dict(
1542+
type="bool",
1543+
required=False
1544+
),
1545+
extended=dict(
1546+
type="bool",
1547+
required=False
1548+
),
1549+
fifo=dict(
1550+
type="bool",
1551+
required=False
1552+
),
15291553
force=dict(
15301554
type="bool",
15311555
required=False,
@@ -1598,7 +1622,7 @@ def parse_and_validate_args(params):
15981622
default=False,
15991623
),
16001624
# GDG options
1601-
limit=dict(type=limit_type, required=False),
1625+
limit=dict(type="int", required=False),
16021626
empty=dict(type="bool", required=False),
16031627
purge=dict(type="bool", required=False),
16041628
scratch=dict(type="bool", required=False),
@@ -1721,7 +1745,7 @@ def run_module():
17211745
default=False,
17221746
),
17231747
# GDG options
1724-
limit=dict(type="int", required=False, no_log=False),
1748+
limit=dict(type="int", required=False),
17251749
empty=dict(type="bool", required=False),
17261750
purge=dict(type="bool", required=False),
17271751
scratch=dict(type="bool", required=False),

tests/functional/modules/test_zos_data_set_func.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,29 @@ def test_gdg_create_and_delete_force(ansible_zos_module):
10291029
hosts.all.zos_data_set(name=data_set_name, state="absent", force=True, type="gdg")
10301030

10311031

1032+
def test_gdg_create_and_delete_force(ansible_zos_module):
1033+
try:
1034+
hosts = ansible_zos_module
1035+
data_set_name = get_tmp_ds_name(2,2, symbols=True)
1036+
data_set_list = [f"{data_set_name}A", f"{data_set_name}B", f"{data_set_name}C"]
1037+
results = hosts.all.zos_data_set(
1038+
batch=[
1039+
{"name":data_set_list[0], "state":"present", "type":"gdg", "limit":3},
1040+
{"name":data_set_list[1], "state":"present", "type":"gdg", "limit":3},
1041+
{"name":data_set_list[2], "state":"present", "type":"gdg", "limit":3},
1042+
]
1043+
)
1044+
for result in results.contacted.values():
1045+
assert result.get("changed") is True
1046+
assert result.get("module_stderr") is None
1047+
results = hosts.all.shell(cmd=f"dls -tGDG ANSIBLE.*")
1048+
for result in results.contacted.values():
1049+
for ds_name in data_set_list:
1050+
assert ds_name in result.get("stdout")
1051+
finally:
1052+
results = hosts.all.shell(cmd=f"drm ANSIBLE.*")
1053+
1054+
10321055
def test_create_special_chars(ansible_zos_module):
10331056
try:
10341057
hosts = ansible_zos_module

0 commit comments

Comments
 (0)