Skip to content

Commit 075688b

Browse files
[Enhancement][zos_mvs_raw] Add support for volume definition in zos_mvs_raw module… (#2194)
* [Enhancement] Add support for volume definition in zos_mvs_raw module and corresponding tests * changed from volser to volume * Allow both volume or volume_name, but require at least one * Rename 'volser' to 'volume' in test_full_volume_dump_with_custom_dd_volume function * added fragments * added documentation * fixed doc * fixed * fixed * required set to true * fixed * FIXED * sanity fixed * added choices for unit dd_volume * FIXED * removed return_content * reviewed comment resolve * fixed * changed volume to volume_names * reviewed comments resolved * reviwed comments * fixed * changed fragments * Update dd_statement.py * Update plugins/modules/zos_mvs_raw.py * added dd_output * changed dd_dummy to dd_output in example section * fixed --------- Co-authored-by: Fernando Flores <[email protected]>
1 parent 849d275 commit 075688b

File tree

4 files changed

+165
-6
lines changed

4 files changed

+165
-6
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
minor_changes:
2+
- zos_mvs_raw - Adds support for volume data definition.
3+
(https://github.com/ansible-collections/ibm_zos_core/pull/2194)
4+
5+
trivial:
6+
- test_zos_mvs_raw_func - added test cases to verify volume definition functionality in zos_mvs_raw module.
7+
(https://github.com/ansible-collections/ibm_zos_core/pull/2194).

plugins/module_utils/dd_statement.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,15 +656,21 @@ def _build_arg_string(self):
656656

657657

658658
class VolumeDefinition(DataDefinition):
659-
def __init__(self, volume_name):
660-
"""Volume DD data type to be used in a DDStatement.
661-
659+
def __init__(self, volume_name, unit, disposition):
660+
"""
661+
Volume DD data type to be used in a DDStatement.
662662
Parameters
663663
----------
664664
volume_name : str
665665
The volume name to associate with the DD statement.
666+
unit : str
667+
The unit of measurement to use when defining the volume.
668+
disposition : str
669+
The disposition of the volume.
666670
"""
667671
super().__init__(volume_name)
672+
self.unit = unit
673+
self.disposition = disposition
668674

669675
def _build_arg_string(self):
670676
"""Build a string representing the arguments of this particular data type
@@ -675,7 +681,11 @@ def _build_arg_string(self):
675681
str
676682
',vol'
677683
"""
678-
return ",vol"
684+
mvscmd_string = ",vol"
685+
mvscmd_string = self._append_mvscmd_string(mvscmd_string, "unit", self.unit)
686+
if self.disposition:
687+
mvscmd_string += f",{self.disposition}"
688+
return mvscmd_string
679689

680690

681691
class StdoutDefinition(DataDefinition):

plugins/modules/zos_mvs_raw.py

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,37 @@
690690
- The DD name.
691691
required: true
692692
type: str
693+
dd_volume:
694+
description:
695+
- Use I(dd_volume) to specify the volume to use in the DD statement.
696+
required: false
697+
type: dict
698+
suboptions:
699+
dd_name:
700+
description: The DD name.
701+
required: true
702+
type: str
703+
volume_name:
704+
description:
705+
- The volume serial number.
706+
type: str
707+
required: true
708+
unit:
709+
description:
710+
- Device type for the volume.
711+
- This option is case sensitive.
712+
type: str
713+
required: true
714+
disposition:
715+
description:
716+
- I(disposition) indicates the status of a data set.
717+
type: str
718+
required: true
719+
choices:
720+
- new
721+
- shr
722+
- mod
723+
- old
693724
dd_concat:
694725
description:
695726
- I(dd_concat) is used to specify a data set concatenation.
@@ -1351,6 +1382,37 @@
13511382
dd_name: sysin
13521383
content: " LISTCAT ENTRIES('SOME.DATASET.*')"
13531384
1385+
- name: Full volume dump using ADDRDSU.
1386+
zos_mvs_raw:
1387+
program_name: adrdssu
1388+
auth: true
1389+
dds:
1390+
- dd_data_set:
1391+
dd_name: dumpdd
1392+
data_set_name: mypgm.output.ds
1393+
disposition: new
1394+
disposition_normal: catalog
1395+
disposition_abnormal: delete
1396+
space_type: cyl
1397+
space_primary: 10
1398+
space_secondary: 10
1399+
record_format: u
1400+
record_length: 0
1401+
block_size: 32760
1402+
type: seq
1403+
- dd_volume:
1404+
dd_name: voldd
1405+
volume_name: "000000"
1406+
unit: "3390"
1407+
disposition: old
1408+
- dd_input:
1409+
dd_name: sysin
1410+
content: " VOLDUMP VOL(voldd) DSNAME(dumpdd) FULL"
1411+
- dd_output:
1412+
dd_name: sysprint
1413+
return_content:
1414+
type: text
1415+
13541416
- name: List data sets matching patterns in catalog,
13551417
save output to a new sequential data set and return output as text.
13561418
zos_mvs_raw:
@@ -1698,6 +1760,7 @@
16981760
DDStatement,
16991761
DummyDefinition,
17001762
VIODefinition,
1763+
VolumeDefinition,
17011764
)
17021765

17031766
from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.zos_mvs_raw import (
@@ -1907,14 +1970,19 @@ def run_module():
19071970
),
19081971
)
19091972
)
1910-
1973+
dd_volume_base = dict(
1974+
volume_name=dict(type="str", required=True),
1975+
unit=dict(type="str", required=True),
1976+
disposition=dict(type="str", choices=["new", "shr", "mod", "old"], required=True),
1977+
)
19111978
dd_data_set = dict(type="dict", options=combine_dicts(dd_name_base, dd_data_set_base))
19121979
dd_unix = dict(type="dict", options=combine_dicts(dd_name_base, dd_unix_base))
19131980
dd_input = dict(type="dict", options=combine_dicts(dd_name_base, dd_input_base))
19141981
dd_output = dict(type="dict", options=combine_dicts(dd_name_base, dd_output_base))
19151982
dd_dummy = dict(type="dict", options=combine_dicts(dd_name_base, dd_dummy_base))
19161983
dd_vio = dict(type="dict", options=combine_dicts(dd_name_base, dd_vio_base))
19171984
dd_concat = dict(type="dict", options=combine_dicts(dd_name_base, dd_concat_base))
1985+
dd_volume = dict(type="dict", options=combine_dicts(dd_name_base, dd_volume_base))
19181986

19191987
module_args = dict(
19201988
program_name=dict(type="str", aliases=["program", "pgm"], required=True),
@@ -1934,6 +2002,7 @@ def run_module():
19342002
dd_vio=dd_vio,
19352003
dd_concat=dd_concat,
19362004
dd_dummy=dd_dummy,
2005+
dd_volume=dd_volume,
19372006
),
19382007
),
19392008
)
@@ -2148,14 +2217,19 @@ def parse_and_validate_args(params):
21482217
),
21492218
)
21502219
)
2151-
2220+
dd_volume_base = dict(
2221+
volume_name=dict(type="str", required=True),
2222+
unit=dict(type="str", required=True),
2223+
disposition=dict(type="str", choices=["new", "shr", "mod", "old"], required=True),
2224+
)
21522225
dd_data_set = dict(type="dict", options=combine_dicts(dd_name_base, dd_data_set_base))
21532226
dd_unix = dict(type="dict", options=combine_dicts(dd_name_base, dd_unix_base))
21542227
dd_input = dict(type="dict", options=combine_dicts(dd_name_base, dd_input_base))
21552228
dd_output = dict(type="dict", options=combine_dicts(dd_name_base, dd_output_base))
21562229
dd_dummy = dict(type="dict", options=combine_dicts(dd_name_base, dd_dummy_base))
21572230
dd_vio = dict(type="dict", options=combine_dicts(dd_name_base, dd_vio_base))
21582231
dd_concat = dict(type="dict", options=combine_dicts(dd_name_base, dd_concat_base))
2232+
dd_volume = dict(type="dict", options=combine_dicts(dd_name_base, dd_volume_base))
21592233

21602234
module_args = dict(
21612235
program_name=dict(type="str", aliases=["program", "pgm"], required=True),
@@ -2176,6 +2250,7 @@ def parse_and_validate_args(params):
21762250
dd_vio=dd_vio,
21772251
dd_concat=dd_concat,
21782252
dd_dummy=dd_dummy,
2253+
dd_volume=dd_volume,
21792254
),
21802255
),
21812256
# verbose=dict(type="bool", required=False),
@@ -2690,6 +2765,9 @@ def get_dd_name_and_key(dd):
26902765
elif dd.get("dd_concat"):
26912766
dd_name = dd.get("dd_concat").get("dd_name")
26922767
key = "dd_concat"
2768+
elif dd.get("dd_volume"):
2769+
dd_name = dd.get("dd_volume").get("dd_name")
2770+
key = "dd_volume"
26932771
return dd_name, key
26942772

26952773

@@ -2797,6 +2875,14 @@ def build_data_definition(dd):
27972875
dd.get("dd_vio").get("tmphlq"))
27982876
elif dd.get("dd_dummy"):
27992877
data_definition = DummyDefinition()
2878+
elif dd.get("dd_volume"):
2879+
volume_args = dd["dd_volume"]
2880+
data_definition = VolumeDefinition(
2881+
volume_name=volume_args.get("volume_name"),
2882+
unit=volume_args.get("unit"),
2883+
disposition=volume_args.get("disposition"),
2884+
)
2885+
28002886
elif dd.get("dd_concat"):
28012887
data_definition = []
28022888
for single_dd in dd.get("dd_concat").get("dds", []):

tests/functional/modules/test_zos_mvs_raw_func.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,62 @@ def get_temp_idcams_dataset(hosts):
4545
# Data set DD tests #
4646
# ---------------------------------------------------------------------------- #
4747

48+
def test_full_volume_dump_with_custom_dd_volume(ansible_zos_module, volumes_on_systems):
49+
hosts = ansible_zos_module
50+
dump_dataset = get_tmp_ds_name()
51+
volume_handler = Volume_Handler(volumes_on_systems)
52+
test_volume = volume_handler.get_available_vol()
53+
try:
54+
results = hosts.all.zos_mvs_raw(
55+
program_name="ADRDSSU",
56+
auth=True,
57+
verbose=True,
58+
dds=[
59+
{
60+
"dd_data_set": {
61+
"dd_name": "DUMPDD",
62+
"data_set_name": dump_dataset,
63+
"disposition": "new",
64+
"disposition_normal": "catalog",
65+
"disposition_abnormal": "delete",
66+
"space_type": "cyl",
67+
"space_primary": 10,
68+
"space_secondary": 2,
69+
"record_format": "u",
70+
"record_length": 0,
71+
"block_size": 32760,
72+
"type": "seq",
73+
}
74+
},
75+
{
76+
"dd_volume": {
77+
"dd_name": "VOLDD",
78+
"volume_name": test_volume,
79+
"unit": "3390",
80+
"disposition": "old",
81+
}
82+
},
83+
{
84+
"dd_input": {
85+
"dd_name": "SYSIN",
86+
"content": " DUMP FULL INDDNAME(VOLDD) OUTDDNAME(DUMPDD)"
87+
}
88+
},
89+
{
90+
"dd_output":{
91+
"dd_name":"SYSPRINT",
92+
"return_content":{
93+
"type":"text"
94+
}
95+
}
96+
},
97+
],
98+
)
99+
for result in results.contacted.values():
100+
assert result.get("ret_code", {}).get("code", -1) == 0
101+
assert result.get("changed", False) is True
102+
finally:
103+
hosts.all.zos_data_set(name=dump_dataset, state="absent")
48104

49105
def test_failing_name_format(ansible_zos_module):
50106
hosts = ansible_zos_module

0 commit comments

Comments
 (0)