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 9 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,5 @@
bugfixes:
zos_mvs_raw:
- module wasn't able to wrote properly a JCL with multi-line | or |1-9.
Change now validate the length of lines and allow multi-line declaration with | or |1-9.
fernandofloresg marked this conversation as resolved.
Show resolved Hide resolved
(https://github.com/ansible-collections/ibm_zos_core/pull/1057).
54 changes: 52 additions & 2 deletions plugins/modules/zos_mvs_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -2166,8 +2166,15 @@ 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:
return contents
contents = modify_contents(contents)
return contents
if isinstance(contents, list):
return "\n".join(contents)
fernandofloresg marked this conversation as resolved.
Show resolved Hide resolved
contents = "\n".join(contents)
return contents
return contents


Expand Down Expand Up @@ -2454,7 +2461,7 @@ def __init__(
disposition_abnormal=None,
block_size=None,
directory_blocks=None,
record_format=None,
record_format='FB',
fernandofloresg marked this conversation as resolved.
Show resolved Hide resolved
record_length=None,
sms_storage_class=None,
sms_data_class=None,
Expand Down Expand Up @@ -3090,6 +3097,49 @@ 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 isinstance(contents, list):
contents = "\n".join(contents)
contents = add_space(contents)
else:
if contents[0] != " " or contents[0] != "-":
contents = " {0}".format(contents)
richp405 marked this conversation as resolved.
Show resolved Hide resolved
contents = list(contents.split("\n"))
contents = add_space(contents)
contents = "\n".join(contents)
return contents


def add_space(lines):
fernandofloresg marked this conversation as resolved.
Show resolved Hide resolved
"""Return the array with two spaces at the beggining.

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

Returns:
lines: The list in a proper two spaces and the code.
"""
module = AnsibleModule
fernandofloresg marked this conversation as resolved.
Show resolved Hide resolved
for line in lines:
if len(line) == 0:
pass
fernandofloresg marked this conversation as resolved.
Show resolved Hide resolved
else:
if line[0] != " " or line[0] != "-":
fernandofloresg marked this conversation as resolved.
Show resolved Hide resolved
if len(line) > 78:
module.fail_json(msg="Length of the line {0} over 80, dataset can not be written".format(line))
fernandofloresg marked this conversation as resolved.
Show resolved Hide resolved
else:
line = " {0}".format(line)
fernandofloresg marked this conversation as resolved.
Show resolved Hide resolved
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