Skip to content

Commit 4f6d5fa

Browse files
[Bugfix][1377]output_mvs_raw_gds_positive_was_false_positive (#1541)
* Fix quick issue * Fix output of mvs_raw +1 gds * Fix false positive * Add fragment * Fix sanity * Adder disposition new again * Add coments * Fix disposition * Fix sanity * Fix sanity
1 parent e9bcae6 commit 4f6d5fa

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
minor_changes:
2+
- zos_mvs_raw - Added support for GDG and GDS relative positive name notation to use a data set.
3+
(https://github.com/ansible-collections/ibm_zos_core/pull/1541).

plugins/modules/zos_mvs_raw.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,19 +1637,25 @@
16371637
RawInputDefinition,
16381638
RawOutputDefinition,
16391639
)
1640+
from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.import_handler import ZOAUImportError
16401641
from ansible_collections.ibm.ibm_zos_core.plugins.module_utils import data_set
16411642
from ansible.module_utils.basic import AnsibleModule
16421643
from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.ansible_module import (
16431644
AnsibleModuleHelper,
16441645
)
16451646
import re
1647+
import traceback
16461648
from ansible.module_utils.six import PY3
16471649

16481650
if PY3:
16491651
from shlex import quote
16501652
else:
16511653
from pipes import quote
16521654

1655+
try:
1656+
from zoautil_py import datasets
1657+
except Exception:
1658+
datasets = ZOAUImportError(traceback.format_exc())
16531659

16541660
ENCODING_ENVIRONMENT_VARS = {"_BPXK_AUTOCVT": "OFF"}
16551661

@@ -2580,9 +2586,11 @@ def get_dd_name_and_key(dd):
25802586
key = ""
25812587
if dd.get("dd_data_set"):
25822588
dd_name = dd.get("dd_data_set").get("dd_name")
2583-
data_set_name = resolve_data_set_names(dd.get("dd_data_set").get("data_set_name"),
2584-
dd.get("dd_data_set").get("disposition"))
2589+
data_set_name, disposition = resolve_data_set_names(dd.get("dd_data_set").get("data_set_name"),
2590+
dd.get("dd_data_set").get("disposition"),
2591+
dd.get("dd_data_set").get("type"))
25852592
dd.get("dd_data_set")["data_set_name"] = data_set_name
2593+
dd.get("dd_data_set")["disposition"] = disposition
25862594
key = "dd_data_set"
25872595
elif dd.get("dd_unix"):
25882596
dd_name = dd.get("dd_unix").get("dd_name")
@@ -2627,7 +2635,7 @@ def set_extra_attributes_in_dd(dd, tmphlq, key):
26272635
return dd
26282636

26292637

2630-
def resolve_data_set_names(dataset, disposition):
2638+
def resolve_data_set_names(dataset, disposition, type):
26312639
"""Resolve cases for data set names as relative gds or positive
26322640
that could be accepted if disposition is new.
26332641
Parameters
@@ -2636,15 +2644,27 @@ def resolve_data_set_names(dataset, disposition):
26362644
Data set name to determine if is a GDS relative name or regular name.
26372645
disposition : str
26382646
Disposition of data set for it creation.
2647+
type : str
2648+
Type of dataset
26392649
Returns
26402650
-------
26412651
str
26422652
The absolute name of dataset or relative positive if disposition is new.
2653+
str
2654+
The disposition base on the system
26432655
"""
2656+
if disposition:
2657+
disp = disposition
2658+
else:
2659+
disp = "shr"
2660+
26442661
if data_set.DataSet.is_gds_relative_name(dataset):
26452662
if data_set.DataSet.is_gds_positive_relative_name(dataset):
2646-
if disposition and disposition == "new":
2647-
return dataset
2663+
if disp == "new":
2664+
if type:
2665+
return str(datasets.create(dataset, type).name), "shr"
2666+
else:
2667+
return str(datasets.create(dataset, "seq").name), "shr"
26482668
else:
26492669
raise ("To generate a new GDS as {0} disposition 'new' is required.".format(dataset))
26502670
else:
@@ -2653,14 +2673,14 @@ def resolve_data_set_names(dataset, disposition):
26532673
)
26542674
src = data.name
26552675
if data.is_gds_active:
2656-
if disposition and disposition == "new":
2676+
if disposition and disp == "new":
26572677
raise ("GDS {0} already created, incorrect parameters for disposition and data_set_name".format(src))
26582678
else:
2659-
return src
2679+
return src, disposition
26602680
else:
26612681
raise ("{0} does not exist".format(src))
26622682
else:
2663-
return dataset
2683+
return dataset, disp
26642684

26652685

26662686
def build_data_definition(dd):

0 commit comments

Comments
 (0)