Skip to content

Commit

Permalink
Bugfix/393/tmp hlq ddstatements: Adds tmphlq to create_temp datasets …
Browse files Browse the repository at this point in the history
…in DDStatements. (#414)

* Added tmphlq variable for StdinDefinition and OutputDefinition init

* Added tmphlq variable to inpud_dd and output_dd statements

* # This is a combination of 2 commits.
# This is the 1st commit message:

Added the tmphlq in a different funtion in case we need to set extra attributes in the future

# This is the commit message #2:

Fixing pep8 issues

* Added the tmphlq in a different funtion in case we need to set extra attributes in the future

Fixing pep8 issues

Updated dependency finder

resolved pep8 issue

* fixed wrong key

* Modified VIODefinition call

Added removed comma

Pulled dependency finder

Got latest dependency finder

* Added changelog for tmp_hlq dd_statements change

Added new line at the end of file

Added new line at the end of file
  • Loading branch information
fernandofloresg authored Sep 14, 2022
1 parent c745d0a commit fd359d6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
7 changes: 7 additions & 0 deletions changelogs/fragments/393-tmphlq-dd-statements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
minor_changes:
- >
zos_mvs_raw - Ensures that temporary datasets created by DD Statements use the tmp_hlq specified.
This allows for a user to specify the data set high level qualifier (HLQ)
used in any temporary data set created by the module. Often, the
defaults are not permitted on systems, this provies a way to override
the defaults. (https://github.com/ansible-collections/ibm_zos_core/pull/414).
4 changes: 4 additions & 0 deletions plugins/module_utils/dd_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ class StdinDefinition(DataDefinition):
def __init__(
self,
content,
tmphlq="",
record_format="FB",
space_primary=5,
space_secondary=5,
Expand Down Expand Up @@ -539,6 +540,7 @@ def __init__(
"""
self.name = None
name = DataSet.create_temp(
hlq=tmphlq,
record_format=record_format,
space_primary=space_primary,
space_secondary=space_secondary,
Expand Down Expand Up @@ -588,6 +590,7 @@ class InputDefinition(StdinDefinition):
class OutputDefinition(DataDefinition):
def __init__(
self,
tmphlq="",
record_format="FBA",
space_primary=100,
space_secondary=50,
Expand All @@ -614,6 +617,7 @@ def __init__(
"""
self.name = None
name = DataSet.create_temp(
hlq=tmphlq,
record_format=record_format,
space_primary=space_primary,
space_secondary=space_secondary,
Expand Down
29 changes: 26 additions & 3 deletions plugins/modules/zos_mvs_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -2313,6 +2313,7 @@ def build_dd_statements(parms):
dd_statements = []
for dd in parms.get("dds"):
dd_name = get_dd_name(dd)
dd = set_extra_attributes_in_dd(dd)
data_definition = build_data_definition(dd)
if data_definition is None:
raise ValueError("No valid data definition found.")
Expand Down Expand Up @@ -2348,6 +2349,30 @@ def get_dd_name(dd):
return dd_name


def set_extra_attributes_in_dd(dd):
"""
Set any extra attributes in dds like global tmphlq.
Args:
dd (dict): A single DD parm as specified in module parms.
Returns:
dd (dict): A single DD parm as specified in module parms.
"""
global g_tmphlq
if dd.get("dd_data_set"):
dd.get("dd_data_set")["tmphlq"] = g_tmphlq
elif dd.get("dd_input"):
dd.get("dd_input")["tmphlq"] = g_tmphlq
elif dd.get("dd_output"):
dd.get("dd_output")["tmphlq"] = g_tmphlq
elif dd.get("dd_vio"):
dd.get("dd_vio")["tmphlq"] = g_tmphlq
elif dd.get("dd_concat"):
for single_dd in dd.get("dd_concat").get("dds", []):
set_extra_attributes_in_dd(single_dd)
return dd


def build_data_definition(dd):
"""Build a DataDefinition object for a particular DD parameter.
Expand All @@ -2361,9 +2386,7 @@ def build_data_definition(dd):
RawInputDefinition, DummyDefinition]: The DataDefinition object or a list of DataDefinition objects.
"""
data_definition = None
global g_tmphlq
if dd.get("dd_data_set"):
dd.get("dd_data_set")["tmphlq"] = g_tmphlq
data_definition = RawDatasetDefinition(**(dd.get("dd_data_set")))
elif dd.get("dd_unix"):
data_definition = RawFileDefinition(**(dd.get("dd_unix")))
Expand All @@ -2372,7 +2395,7 @@ def build_data_definition(dd):
elif dd.get("dd_output"):
data_definition = RawOutputDefinition(**(dd.get("dd_output")))
elif dd.get("dd_vio"):
data_definition = VIODefinition(tmphlq=g_tmphlq)
data_definition = VIODefinition(dd.get("dd_vio").get("tmphlq"))
elif dd.get("dd_dummy"):
data_definition = DummyDefinition()
elif dd.get("dd_concat"):
Expand Down

0 comments on commit fd359d6

Please sign in to comment.