Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/374/module zos mvs raw errors with long multi line quoted string in content field #1057

Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2e58d14
Add function of write content
AndreMarcel99 Nov 8, 2023
f3aecb8
Push easy soultion for two cases
AndreMarcel99 Nov 9, 2023
dc7e2dc
Fix identation and more issues
AndreMarcel99 Nov 9, 2023
b5f20f6
Fix identation and more issues
AndreMarcel99 Nov 9, 2023
6971052
Solve error of null
AndreMarcel99 Nov 9, 2023
62f1fe9
Add validation comments and separete the code
AndreMarcel99 Nov 10, 2023
4055408
Merge branch 'dev' into bugfix/374/Module_zos_mvs_raw_errors_with_lon…
AndreMarcel99 Nov 10, 2023
dbdb85e
Add fragment
AndreMarcel99 Nov 10, 2023
7235df0
Merge branch 'bugfix/374/Module_zos_mvs_raw_errors_with_long_multi-li…
AndreMarcel99 Nov 10, 2023
af84956
Modify logics
AndreMarcel99 Nov 13, 2023
f7fbf01
Return overthink
AndreMarcel99 Nov 13, 2023
b908646
Add explanation for the user and change logic
AndreMarcel99 Nov 13, 2023
282d410
Add explanation for the user and change logic
AndreMarcel99 Nov 13, 2023
821f5bc
Change documentation
AndreMarcel99 Nov 13, 2023
d1ae54e
Change fragment
AndreMarcel99 Nov 14, 2023
ea1036b
Better error message, better documentation and fragment
AndreMarcel99 Nov 14, 2023
aeaaa98
Merge branch 'dev' into bugfix/374/Module_zos_mvs_raw_errors_with_lon…
AndreMarcel99 Nov 14, 2023
7619a91
Get better mesages
AndreMarcel99 Nov 15, 2023
ed7344d
Merge branch 'dev' into bugfix/374/Module_zos_mvs_raw_errors_with_lon…
AndreMarcel99 Nov 15, 2023
093843b
Change the logic
AndreMarcel99 Nov 16, 2023
37f6610
Merge branch 'bugfix/374/Module_zos_mvs_raw_errors_with_long_multi-li…
AndreMarcel99 Nov 16, 2023
7cda962
Change documentation
AndreMarcel99 Nov 27, 2023
8512129
Change logic
AndreMarcel99 Nov 27, 2023
7f1798f
Add scape to #
AndreMarcel99 Nov 27, 2023
fda2e3f
Check failing
AndreMarcel99 Nov 27, 2023
26b51eb
Check failing
AndreMarcel99 Nov 27, 2023
1e738b9
Add valid scapes
AndreMarcel99 Nov 27, 2023
d217b1a
Merge branch 'dev' into bugfix/374/Module_zos_mvs_raw_errors_with_lon…
AndreMarcel99 Nov 28, 2023
5ec03eb
Update zos_mvs_raw fragment and module doc
ddimatos Dec 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fernandofloresg marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
bugfixes:
- zos_mvs_raw - module wasn't able to write a multi-line JCL because it truncated
the first one or two characters, resulting in syntactically incorrect JCL.
Change now validates the length of lines and allow multi-line declaration with | or |1-9 by adding
two spaces to be syntactically correct.
(https://github.com/ansible-collections/ibm_zos_core/pull/1057).
48 changes: 48 additions & 0 deletions plugins/modules/zos_mvs_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,9 @@
proper literal block style indicator "|".
- If a list of strings is provided, newlines will be
added to each of the lines when used as input.
- The maximum length of the line is 80 columns including 2 spaces at the beginning.
ddimatos marked this conversation as resolved.
Show resolved Hide resolved
If the two spaces aren't present, the module will add them to form syntactically
correct JCL (more information in the Notes section).
required: true
type: raw
return_content:
Expand Down Expand Up @@ -1208,6 +1211,10 @@
- 2. L(zos_mvs_raw,./zos_mvs_raw.html) module execution fails when invoking DFSRRC00 with parm
"UPB,PRECOMP", "UPB, POSTCOMP" or "UPB,PRECOMP,POSTCOMP". This issue is
addressed by APAR PH28089.
- 3. For syntactically correct JCL programs see the
ddimatos marked this conversation as resolved.
Show resolved Hide resolved
L(JCL reference,https://www.ibm.com/docs/en/zos-basic-skills?topic=collection-coding-your-own-jcl).
- 4. For continuing a line of C(dd_input) see the reference for symbols (+/-) for extended lines
ddimatos marked this conversation as resolved.
Show resolved Hide resolved
L(in the official documentation,https://www.ibm.com/docs/en/abo/2.1?topic=modules-line-continuation).
seealso:
- module: zos_data_set
"""
Expand Down Expand Up @@ -2166,6 +2173,11 @@ def dd_content(contents, dependencies):
"""
if contents is None:
return None
if contents is not None:
# Empty string can be passed for content but not modify to ensure proper entry
if len(contents) > 0:
contents = modify_contents(contents)
return contents
if isinstance(contents, list):
return "\n".join(contents)
fernandofloresg marked this conversation as resolved.
Show resolved Hide resolved
return contents
Expand Down Expand Up @@ -3090,6 +3102,42 @@ def get_content(formatted_name, binary=False, from_encoding=None, to_encoding=No
return stdout


def modify_contents(contents):
fernandofloresg marked this conversation as resolved.
Show resolved Hide resolved
"""Return the content of dd_input to a valid form for a JCL program.

Args:
contents (str or list): The string or list with the program.

Returns:
contents: The content in a proper multi line str.
"""
if not isinstance(contents, list):
contents = list(contents.split("\n"))
contents = prepend_spaces(contents)
contents = "\n".join(contents)
return contents


def prepend_spaces(lines):
"""Return the array with two spaces at the beggining.

Args:
lines (list): The list with a line of a program.

Returns:
new_lines: The list in a proper two spaces and the code.
"""
module = AnsibleModuleHelper(argument_spec={})
for index, line in enumerate(lines):
if len(line) > 0:
ddimatos marked this conversation as resolved.
Show resolved Hide resolved
if len(line) > 78:
module.fail_json(msg="""Length of line {0} is over 80. The maximum length allowed is 80 columns, including 2 spaces at the beginning.
If the two spaces are not present, the module will add them to form syntactically correct JCL. """.format(line))
if len(line) > 1 and line[0] != " " and line[1] != " ":
lines[index] = " {0}".format(line)
return lines


class ZOSRawError(Exception):
def __init__(self, program="", error=""):
self.msg = "An error occurred during execution of z/OS program {0}. {1}".format(
Expand Down