From eab8a054bcaddae15b28ebc8d788735610865520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Tue, 7 Jan 2025 12:21:50 -0600 Subject: [PATCH 01/43] First iteration --- plugins/module_utils/data_set.py | 20 +++++++ plugins/modules/zos_copy.py | 54 ++----------------- .../functional/modules/test_zos_copy_func.py | 1 - 3 files changed, 23 insertions(+), 52 deletions(-) diff --git a/plugins/module_utils/data_set.py b/plugins/module_utils/data_set.py index c1740b5a4..6c84e803b 100644 --- a/plugins/module_utils/data_set.py +++ b/plugins/module_utils/data_set.py @@ -1990,6 +1990,26 @@ def _process_listcat_output(self, output): ).replace("-", "") return result + @staticmethod + def gather_data_set_info_in_use(data_set_name): + """Retrieves information about the input data set using LISTDS and + LISTCAT commands. + + Returns: + bool -- Boolean value if the dataset is in use + """ + result = dict() + listds_rc, listds_out, listds_err = mvs_cmd.ikjeft01( + " LISTDS '{0}'".format(data_set_name), + authorized=True + ) + + if listds_rc == 0: + return False + else: + if re.findall(r"ALREADY IN USE", listds_out): + return True + class MVSDataSet(): """ diff --git a/plugins/modules/zos_copy.py b/plugins/modules/zos_copy.py index 1fc28e3d3..e96501ae7 100644 --- a/plugins/modules/zos_copy.py +++ b/plugins/modules/zos_copy.py @@ -931,7 +931,8 @@ AnsibleModuleHelper from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.data_set import ( is_member, - is_data_set + is_data_set, + DataSetUtils ) from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.import_handler import \ ZOAUImportError @@ -3157,55 +3158,6 @@ def normalize_line_endings(src, encoding=None): return src -def data_set_locked(dataset_name): - """ - Checks if a data set is in use and therefore locked (DISP=SHR), which - is often caused by a long running task. Returns a boolean value to indicate the data set status. - - Parameters - ---------- - dataset_name (str): - The data set name used to check if there is a lock. - - Returns - ------- - bool - True if the data set is locked, or False if the data set is not locked. - - Raises - ------ - CopyOperationError - When the user does not have Universal Access Authority to - ZOAU SAF Profile 'MVS.MCSOPER.ZOAU' and SAF Class OPERCMDS. - """ - # Using operator command "D GRS,RES=(*,{dataset_name})" to detect if a data set - # is in use, when a data set is in use it will have "EXC/SHR and SHARE" - # in the result with a length greater than 4. - result = dict() - result["stdout"] = [] - command_dgrs = "D GRS,RES=(*,{0})".format(dataset_name) - - try: - response = opercmd.execute(command=command_dgrs) - stdout = response.stdout_response - - if stdout is not None: - for out in stdout.split("\n"): - if out: - result["stdout"].append(out) - if len(result["stdout"]) <= 4 and "NO REQUESTORS FOR RESOURCE" in stdout: - return False - - return True - except zoau_exceptions.ZOAUException as copy_exception: - raise CopyOperationError( - msg="Unable to determine if the dest {0} is in use.".format(dataset_name), - rc=copy_exception.response.rc, - stdout=copy_exception.response.stdout_response, - stderr=copy_exception.response.stderr_response - ) - - def run_module(module, arg_def): """Initialize module @@ -3546,7 +3498,7 @@ def run_module(module, arg_def): # ******************************************************************** if dest_exists and dest_ds_type != "USS": if not force_lock: - is_dest_lock = data_set_locked(dest_name) + is_dest_lock = DataSetUtils.gather_data_set_info_in_use(data_set_name=dest_name) if is_dest_lock: module.fail_json( msg="Unable to write to dest '{0}' because a task is accessing the data set.".format( diff --git a/tests/functional/modules/test_zos_copy_func.py b/tests/functional/modules/test_zos_copy_func.py index cab2a7742..38b5a6156 100644 --- a/tests/functional/modules/test_zos_copy_func.py +++ b/tests/functional/modules/test_zos_copy_func.py @@ -2010,7 +2010,6 @@ def test_copy_dest_lock(ansible_zos_module, ds_type, f_lock ): force_lock=f_lock, ) for result in results.contacted.values(): - print(result) if f_lock: #and apf_auth_user: assert result.get("changed") == True assert result.get("msg") is None From a99f8837a813c9fda9cbcef0580dad2f34f5a6f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Tue, 7 Jan 2025 12:21:50 -0600 Subject: [PATCH 02/43] First iteration --- plugins/module_utils/data_set.py | 20 +++++++ plugins/modules/zos_copy.py | 54 ++----------------- .../functional/modules/test_zos_copy_func.py | 1 - 3 files changed, 23 insertions(+), 52 deletions(-) diff --git a/plugins/module_utils/data_set.py b/plugins/module_utils/data_set.py index c1740b5a4..6c84e803b 100644 --- a/plugins/module_utils/data_set.py +++ b/plugins/module_utils/data_set.py @@ -1990,6 +1990,26 @@ def _process_listcat_output(self, output): ).replace("-", "") return result + @staticmethod + def gather_data_set_info_in_use(data_set_name): + """Retrieves information about the input data set using LISTDS and + LISTCAT commands. + + Returns: + bool -- Boolean value if the dataset is in use + """ + result = dict() + listds_rc, listds_out, listds_err = mvs_cmd.ikjeft01( + " LISTDS '{0}'".format(data_set_name), + authorized=True + ) + + if listds_rc == 0: + return False + else: + if re.findall(r"ALREADY IN USE", listds_out): + return True + class MVSDataSet(): """ diff --git a/plugins/modules/zos_copy.py b/plugins/modules/zos_copy.py index 99aa831b3..7489711c6 100644 --- a/plugins/modules/zos_copy.py +++ b/plugins/modules/zos_copy.py @@ -931,7 +931,8 @@ AnsibleModuleHelper from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.data_set import ( is_member, - is_data_set + is_data_set, + DataSetUtils ) from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.import_handler import \ ZOAUImportError @@ -3157,55 +3158,6 @@ def normalize_line_endings(src, encoding=None): return src -def data_set_locked(dataset_name): - """ - Checks if a data set is in use and therefore locked (DISP=SHR), which - is often caused by a long running task. Returns a boolean value to indicate the data set status. - - Parameters - ---------- - dataset_name (str): - The data set name used to check if there is a lock. - - Returns - ------- - bool - True if the data set is locked, or False if the data set is not locked. - - Raises - ------ - CopyOperationError - When the user does not have Universal Access Authority to - ZOAU SAF Profile 'MVS.MCSOPER.ZOAU' and SAF Class OPERCMDS. - """ - # Using operator command "D GRS,RES=(*,{dataset_name})" to detect if a data set - # is in use, when a data set is in use it will have "EXC/SHR and SHARE" - # in the result with a length greater than 4. - result = dict() - result["stdout"] = [] - command_dgrs = "D GRS,RES=(*,{0})".format(dataset_name) - - try: - response = opercmd.execute(command=command_dgrs) - stdout = response.stdout_response - - if stdout is not None: - for out in stdout.split("\n"): - if out: - result["stdout"].append(out) - if len(result["stdout"]) <= 4 and "NO REQUESTORS FOR RESOURCE" in stdout: - return False - - return True - except zoau_exceptions.ZOAUException as copy_exception: - raise CopyOperationError( - msg="Unable to determine if the dest {0} is in use.".format(dataset_name), - rc=copy_exception.response.rc, - stdout=copy_exception.response.stdout_response, - stderr=copy_exception.response.stderr_response - ) - - def run_module(module, arg_def): """Initialize module @@ -3546,7 +3498,7 @@ def run_module(module, arg_def): # ******************************************************************** if dest_exists and dest_ds_type != "USS": if not force_lock: - is_dest_lock = data_set_locked(dest_name) + is_dest_lock = DataSetUtils.gather_data_set_info_in_use(data_set_name=dest_name) if is_dest_lock: module.fail_json( msg="Unable to write to dest '{0}' because a task is accessing the data set.".format( diff --git a/tests/functional/modules/test_zos_copy_func.py b/tests/functional/modules/test_zos_copy_func.py index 0bc9d884f..8bfee41dc 100644 --- a/tests/functional/modules/test_zos_copy_func.py +++ b/tests/functional/modules/test_zos_copy_func.py @@ -2015,7 +2015,6 @@ def test_copy_dest_lock(ansible_zos_module, ds_type, f_lock ): force_lock=f_lock, ) for result in results.contacted.values(): - print(result) if f_lock: #and apf_auth_user: assert result.get("changed") == True assert result.get("msg") is None From 9174060ea7f0453aa3f3ab863d79cea292ae25c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 15 Jan 2025 09:52:46 -0600 Subject: [PATCH 03/43] Replace calls for blockinfile --- plugins/modules/zos_mount.py | 137 +++++------------------------------ 1 file changed, 19 insertions(+), 118 deletions(-) diff --git a/plugins/modules/zos_mount.py b/plugins/modules/zos_mount.py index 962a137d8..527c8a3c2 100644 --- a/plugins/modules/zos_mount.py +++ b/plugins/modules/zos_mount.py @@ -538,6 +538,7 @@ import os import re import tempfile +import traceback from datetime import datetime from ansible.module_utils.basic import AnsibleModule @@ -550,6 +551,14 @@ from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.copy import ( copy_uss_mvs ) +from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.import_handler import ( + ZOAUImportError, +) + +try: + from zoautil_py import datasets +except Exception: + datasets = ZOAUImportError(traceback.format_exc()) # This is a duplicate of backupOper found in zos_apf.py of this collection @@ -610,82 +619,6 @@ def mt_backupOper(module, src, backup, tmphlq=None): return backup_name -def swap_text(original, adding, removing): - """swap_text returns original after removing blocks matching removing, - and adding the adding param. - original now should be a list of lines without newlines. - return is the consolidated file value. - - Parameters - ---------- - original : str - Text to modify. - adding : str - Lines to add. - removing : str - Lines to delete if matched. - - Returns - ------- - str - The consolidated file value. - """ - content_lines = original - - remove_starting_at_index = None - remove_ending_at_index = None - - ms = re.compile(r"^\s*MOUNT\s+FILESYSTEM\(\s*'" + removing.upper() + r"'\s*\)") - removable = dict() - - for index, line in enumerate(content_lines): - if remove_starting_at_index is None: - if ms.match(line) is not None: - remove_starting_at_index = index - # Check for comments above the match line - if index > 0: - for tmpindex in range(index - 1, 0, -1): - tmpline = content_lines[tmpindex] - if len(tmpline) > 0: - # Added the second test to handle adjacent entries - if tmpline[0:2] != "/*" or tmpline[0:6] == "/* BEG": - remove_starting_at_index = tmpindex - break - else: - remove_starting_at_index = tmpindex - break - remove_ending_at_index = index - continue - if remove_starting_at_index is not None: - remove_ending_at_index = index - doit = False - if len(line) > 0: - if line[0] != " " and line[0] != "\t" and line[0:2] != "/*": - doit = True - elif line[0:6] == "/* END": - doit = True - else: - doit = True - if doit: - removable[remove_starting_at_index] = remove_ending_at_index - remove_starting_at_index = None - remove_ending_at_index = None - - if remove_starting_at_index is not None: - if remove_ending_at_index is not None: - if remove_starting_at_index != remove_ending_at_index: - removable[remove_starting_at_index] = remove_ending_at_index - - for startidx in reversed(removable.keys()): - endidx = removable[startidx] - del content_lines[startidx: endidx + 1] - - if len(adding) > 0: - content_lines.extend(adding.split("\n")) - - return "\n".join(content_lines) - - # ############################################################################# # ############## run_module: code for zos_mount module ######################## # ############################################################################# @@ -863,10 +796,7 @@ def run_module(module, arg_def): # ########################################## # Assemble the mount command - d = datetime.today() - dtstr = d.strftime("%Y%m%d-%H%M%S") - parmtext = "/* BEGIN ANSIBLE MANAGED BLOCK " + dtstr + " */\n" - parmtail = "\n" + parmtext.replace("BEGIN", "END") + parmtext = "" if comment is not None: extra = "" @@ -975,7 +905,7 @@ def run_module(module, arg_def): if len(automove_list) > 1: fullcmd = fullcmd + "(" + automove_list + ")" parmtext = parmtext + "(" + automove_list + ")" - parmtext = parmtext + parmtail + else: parmtext = "" @@ -1040,45 +970,16 @@ def run_module(module, arg_def): stderr=str(res_args), ) - tmp_file = tempfile.NamedTemporaryFile(delete=True) - tmp_file_filename = tmp_file.name - tmp_file.close() - - copy_uss_mvs(data_store, tmp_file_filename, is_binary=False) + marker = '/* {mark} ANSIBLE MANAGED BLOCK' + marker = "{0}\\n{1}\\n{2}".format("BEGIN", "END", marker) + datasets.blockinfile(dataset=data_store, state=False, marker=marker) - module.run_command( - "chtag -tc ISO8859-1 " + tmp_file_filename, use_unsafe_shell=False, errors='replace' - ) - - with open(tmp_file_filename, "r") as fh: - content = fh.read().splitlines() - - cont = list() - - if stdout is None: - stdout = " " - - # removing null entries - for line in content: - if line is not None: - if len(line) > 0: - if (line[0:1] is not None) and (line[0:1] != "\u0000"): - cont.append(line) - - stdout += "\n" - newtext = swap_text(cont, parmtext, src) - if newtext != cont or cont != content: - fh = open(tmp_file_filename, "w") - fh.write(newtext) - fh.close() - # pre-clear to prevent caching behavior on the copy-back - module.run_command( - "mrm " + data_store, use_unsafe_shell=False, errors='replace' - ) - copy_uss_mvs(tmp_file_filename, data_store, is_binary=True) + d = datetime.today() + dtstr = d.strftime("%Y%m%d-%H%M%S") + marker = '/* {mark} ANSIBLE MANAGED BLOCK' + dtstr + "*/" + marker = "{0}\\n{1}\\n{2}".format("BEGIN", "END", marker) - if os.path.isfile(tmp_file_filename): - os.unlink(tmp_file_filename) + datasets.blockinfile(dataset=data_store, state=True, block=parmtext, marker=marker, insert_after="EOF") if rc == 0: if stdout is None: From 6566eb0cc22196998e6c41f1668b55c5aaaae1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Thu, 16 Jan 2025 11:30:15 -0600 Subject: [PATCH 04/43] Solution on propose --- plugins/modules/zos_mount.py | 66 +++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/plugins/modules/zos_mount.py b/plugins/modules/zos_mount.py index 527c8a3c2..5a5b62528 100644 --- a/plugins/modules/zos_mount.py +++ b/plugins/modules/zos_mount.py @@ -619,6 +619,53 @@ def mt_backupOper(module, src, backup, tmphlq=None): return backup_name +def get_str_to_keep(dataset, src): + """Get the content of previous statements by the module to remove it. + + Parameters + ---------- + dataset : str + Dataset for persistant. + src : str + Name of zfs dataset. + + Returns + ------- + list + head_content. + list + tail_content. + """ + content = datasets.read(dataset=dataset).split("\n") + line_counter = 0 + pattern = re.compile(r"^\s*MOUNT\s+FILESYSTEM\(\s*'" + src.upper() + r"'\s*\)") + + for line in content: + if pattern.match(line) is not None: + line_counter+=1 + break + line_counter+=1 + + begin_block_code=line_counter + for index, line in enumerate(reversed(content[:line_counter])): + if "/* BEGIN ANSIBLE MANAGED" in line: + begin_block_code-=1 + break + begin_block_code-=1 + + end_block_code=line_counter + for line in content[line_counter:]: + if "/* END ANSIBLE MANAGED" in line: + end_block_code+=1 + break + end_block_code+=1 + + head_content = content[:begin_block_code] + tail_content = content[end_block_code+1:] + + return head_content, tail_content + + # ############################################################################# # ############## run_module: code for zos_mount module ######################## # ############################################################################# @@ -970,13 +1017,24 @@ def run_module(module, arg_def): stderr=str(res_args), ) - marker = '/* {mark} ANSIBLE MANAGED BLOCK' - marker = "{0}\\n{1}\\n{2}".format("BEGIN", "END", marker) - datasets.blockinfile(dataset=data_store, state=False, marker=marker) + bk_ds = datasets.tmp_name(high_level_qualifier=tmphlq) + datasets.create(name=bk_ds, dataset_type="SEQ") + + new_str_pt1, new_str_pt2 = get_str_to_keep(dataset=data_store, src=src) + + for line in new_str_pt1: + datasets.write(dataset_name=bk_ds, content=line.rstrip(), append=True) + + for line in new_str_pt2: + datasets.write(dataset_name=bk_ds, content=line.rstrip(), append=True) + + datasets.delete(dataset=data_store) + datasets.copy(source=bk_ds, target=data_store) + datasets.delete(dataset=bk_ds) d = datetime.today() dtstr = d.strftime("%Y%m%d-%H%M%S") - marker = '/* {mark} ANSIBLE MANAGED BLOCK' + dtstr + "*/" + marker = '/* {mark} ANSIBLE MANAGED BLOCK ' + dtstr + " */" marker = "{0}\\n{1}\\n{2}".format("BEGIN", "END", marker) datasets.blockinfile(dataset=data_store, state=True, block=parmtext, marker=marker, insert_after="EOF") From 829d84b61d8f1a7a231ab306d3b6a36469b044a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Thu, 16 Jan 2025 12:25:03 -0600 Subject: [PATCH 05/43] Fix bad code --- plugins/modules/zos_mount.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/modules/zos_mount.py b/plugins/modules/zos_mount.py index 5a5b62528..326485194 100644 --- a/plugins/modules/zos_mount.py +++ b/plugins/modules/zos_mount.py @@ -647,7 +647,7 @@ def get_str_to_keep(dataset, src): line_counter+=1 begin_block_code=line_counter - for index, line in enumerate(reversed(content[:line_counter])): + for line in reversed(content[:line_counter]): if "/* BEGIN ANSIBLE MANAGED" in line: begin_block_code-=1 break @@ -663,7 +663,9 @@ def get_str_to_keep(dataset, src): head_content = content[:begin_block_code] tail_content = content[end_block_code+1:] - return head_content, tail_content + head_content.extend(tail_content) + + return head_content # ############################################################################# @@ -1020,12 +1022,9 @@ def run_module(module, arg_def): bk_ds = datasets.tmp_name(high_level_qualifier=tmphlq) datasets.create(name=bk_ds, dataset_type="SEQ") - new_str_pt1, new_str_pt2 = get_str_to_keep(dataset=data_store, src=src) - - for line in new_str_pt1: - datasets.write(dataset_name=bk_ds, content=line.rstrip(), append=True) + new_str = get_str_to_keep(dataset=data_store, src=src) - for line in new_str_pt2: + for line in new_str: datasets.write(dataset_name=bk_ds, content=line.rstrip(), append=True) datasets.delete(dataset=data_store) From 0ff76102b4504cfa9d72aefe81f04c07ca96e7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Thu, 16 Jan 2025 12:25:48 -0600 Subject: [PATCH 06/43] Revert issues on copy --- plugins/module_utils/data_set.py | 20 -------- plugins/modules/zos_copy.py | 51 +++++++++++++++++-- .../functional/modules/test_zos_copy_func.py | 1 + 3 files changed, 49 insertions(+), 23 deletions(-) diff --git a/plugins/module_utils/data_set.py b/plugins/module_utils/data_set.py index 6c84e803b..c1740b5a4 100644 --- a/plugins/module_utils/data_set.py +++ b/plugins/module_utils/data_set.py @@ -1990,26 +1990,6 @@ def _process_listcat_output(self, output): ).replace("-", "") return result - @staticmethod - def gather_data_set_info_in_use(data_set_name): - """Retrieves information about the input data set using LISTDS and - LISTCAT commands. - - Returns: - bool -- Boolean value if the dataset is in use - """ - result = dict() - listds_rc, listds_out, listds_err = mvs_cmd.ikjeft01( - " LISTDS '{0}'".format(data_set_name), - authorized=True - ) - - if listds_rc == 0: - return False - else: - if re.findall(r"ALREADY IN USE", listds_out): - return True - class MVSDataSet(): """ diff --git a/plugins/modules/zos_copy.py b/plugins/modules/zos_copy.py index 7489711c6..5572e773c 100644 --- a/plugins/modules/zos_copy.py +++ b/plugins/modules/zos_copy.py @@ -931,8 +931,7 @@ AnsibleModuleHelper from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.data_set import ( is_member, - is_data_set, - DataSetUtils + is_data_set ) from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.import_handler import \ ZOAUImportError @@ -3158,6 +3157,52 @@ def normalize_line_endings(src, encoding=None): return src +def data_set_locked(dataset_name): + """ + Checks if a data set is in use and therefore locked (DISP=SHR), which + is often caused by a long running task. Returns a boolean value to indicate the data set status. + Parameters + ---------- + dataset_name (str): + The data set name used to check if there is a lock. + Returns + ------- + bool + True if the data set is locked, or False if the data set is not locked. + Raises + ------ + CopyOperationError + When the user does not have Universal Access Authority to + ZOAU SAF Profile 'MVS.MCSOPER.ZOAU' and SAF Class OPERCMDS. + """ + # Using operator command "D GRS,RES=(*,{dataset_name})" to detect if a data set + # is in use, when a data set is in use it will have "EXC/SHR and SHARE" + # in the result with a length greater than 4. + result = dict() + result["stdout"] = [] + command_dgrs = "D GRS,RES=(*,{0})".format(dataset_name) + + try: + response = opercmd.execute(command=command_dgrs) + stdout = response.stdout_response + + if stdout is not None: + for out in stdout.split("\n"): + if out: + result["stdout"].append(out) + if len(result["stdout"]) <= 4 and "NO REQUESTORS FOR RESOURCE" in stdout: + return False + + return True + except zoau_exceptions.ZOAUException as copy_exception: + raise CopyOperationError( + msg="Unable to determine if the dest {0} is in use.".format(dataset_name), + rc=copy_exception.response.rc, + stdout=copy_exception.response.stdout_response, + stderr=copy_exception.response.stderr_response + ) + + def run_module(module, arg_def): """Initialize module @@ -3498,7 +3543,7 @@ def run_module(module, arg_def): # ******************************************************************** if dest_exists and dest_ds_type != "USS": if not force_lock: - is_dest_lock = DataSetUtils.gather_data_set_info_in_use(data_set_name=dest_name) + is_dest_lock = data_set_locked(dest_name) if is_dest_lock: module.fail_json( msg="Unable to write to dest '{0}' because a task is accessing the data set.".format( diff --git a/tests/functional/modules/test_zos_copy_func.py b/tests/functional/modules/test_zos_copy_func.py index 8bfee41dc..0bc9d884f 100644 --- a/tests/functional/modules/test_zos_copy_func.py +++ b/tests/functional/modules/test_zos_copy_func.py @@ -2015,6 +2015,7 @@ def test_copy_dest_lock(ansible_zos_module, ds_type, f_lock ): force_lock=f_lock, ) for result in results.contacted.values(): + print(result) if f_lock: #and apf_auth_user: assert result.get("changed") == True assert result.get("msg") is None From 6b9450a0297b073273dee1fcc627a51792cca28b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Thu, 16 Jan 2025 12:27:03 -0600 Subject: [PATCH 07/43] Full return of zos copy --- plugins/modules/zos_copy.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/modules/zos_copy.py b/plugins/modules/zos_copy.py index 5572e773c..99aa831b3 100644 --- a/plugins/modules/zos_copy.py +++ b/plugins/modules/zos_copy.py @@ -3161,14 +3161,17 @@ def data_set_locked(dataset_name): """ Checks if a data set is in use and therefore locked (DISP=SHR), which is often caused by a long running task. Returns a boolean value to indicate the data set status. + Parameters ---------- dataset_name (str): The data set name used to check if there is a lock. + Returns ------- bool True if the data set is locked, or False if the data set is not locked. + Raises ------ CopyOperationError From 7a724b1bfbbfdf8c518b01d159c59c881cc86bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Thu, 16 Jan 2025 12:39:42 -0600 Subject: [PATCH 08/43] Add fragment --- changelogs/fragments/1871-Failing_using_persistent_option.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/1871-Failing_using_persistent_option.yml diff --git a/changelogs/fragments/1871-Failing_using_persistent_option.yml b/changelogs/fragments/1871-Failing_using_persistent_option.yml new file mode 100644 index 000000000..5f3d51102 --- /dev/null +++ b/changelogs/fragments/1871-Failing_using_persistent_option.yml @@ -0,0 +1,3 @@ +bugfixes: + - zos_mount - Module fail when using persistent option. Fix now uses allow use of persistent option. + (https://github.com/ansible-collections/ibm_zos_core/pull/1871). \ No newline at end of file From 4a2897322e0819cedcbbd2576521b5492f051c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Thu, 16 Jan 2025 14:19:53 -0600 Subject: [PATCH 09/43] Debug --- tests/functional/modules/test_zos_mount_func.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 7adb888a8..175dade65 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -98,6 +98,7 @@ def test_basic_mount(ansible_zos_module, volumes_on_systems): src=srcfn, path="/pythonx", fs_type="zfs", state="mounted" ) for result in mount_result.values(): + print(result) assert result.get("rc") == 0 assert result.get("stdout") != "" assert result.get("changed") is True From b4dacc643740051708257c84c229a3209f29524f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Thu, 16 Jan 2025 14:36:54 -0600 Subject: [PATCH 10/43] Debug --- tests/functional/modules/test_zos_mount_func.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 175dade65..5a3290899 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -63,15 +63,15 @@ def create_sourcefile(hosts, volume): starter = get_sysname(hosts).split(".")[0].upper() if len(starter) < 2: starter = "IMSTESTU" - basefile = starter + ".A@$#TO.MNT.ZFS" - thisfile = DataSet.escape_data_set_name(basefile) + basefile = starter + ".TTT.MNT.ZFS" + thisfile = starter + ".TTT.MNT.ZFS" print( "\ncsf: starter={0} thisfile={1} is type {2}".format( starter, thisfile, str(type(thisfile)) ) ) - mount_result = hosts.all.shell( + hosts.all.shell( cmd="zfsadm define -aggregate " + thisfile + " -volumes {0} -cylinders 200 1".format(volume), @@ -79,7 +79,7 @@ def create_sourcefile(hosts, volume): stdin="", ) - mount_result = hosts.all.shell( + hosts.all.shell( cmd="zfsadm format -aggregate " + thisfile, executable=SHELL_EXECUTABLE, stdin="", From 5b444cc1e3b78e73cbdc1136f5519304e5c49af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Thu, 16 Jan 2025 14:55:27 -0600 Subject: [PATCH 11/43] Debug --- tests/functional/modules/test_zos_mount_func.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 5a3290899..7adb888a8 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -63,15 +63,15 @@ def create_sourcefile(hosts, volume): starter = get_sysname(hosts).split(".")[0].upper() if len(starter) < 2: starter = "IMSTESTU" - basefile = starter + ".TTT.MNT.ZFS" - thisfile = starter + ".TTT.MNT.ZFS" + basefile = starter + ".A@$#TO.MNT.ZFS" + thisfile = DataSet.escape_data_set_name(basefile) print( "\ncsf: starter={0} thisfile={1} is type {2}".format( starter, thisfile, str(type(thisfile)) ) ) - hosts.all.shell( + mount_result = hosts.all.shell( cmd="zfsadm define -aggregate " + thisfile + " -volumes {0} -cylinders 200 1".format(volume), @@ -79,7 +79,7 @@ def create_sourcefile(hosts, volume): stdin="", ) - hosts.all.shell( + mount_result = hosts.all.shell( cmd="zfsadm format -aggregate " + thisfile, executable=SHELL_EXECUTABLE, stdin="", @@ -98,7 +98,6 @@ def test_basic_mount(ansible_zos_module, volumes_on_systems): src=srcfn, path="/pythonx", fs_type="zfs", state="mounted" ) for result in mount_result.values(): - print(result) assert result.get("rc") == 0 assert result.get("stdout") != "" assert result.get("changed") is True From 4de599fbc5dd8f94b48317a38970bacceac3f7f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Tue, 21 Jan 2025 10:39:34 -0600 Subject: [PATCH 12/43] Fix bassic mount --- tests/functional/modules/test_zos_mount_func.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 7adb888a8..e4d26e49e 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -332,11 +332,11 @@ def test_basic_mount_with_bpx_comment_backup(ansible_zos_module, volumes_on_syst is_binary=True, remote_src=True, ) - hosts.all.shell( - cmd="chtag -t -c ISO8859-1 " + test_tmp_file_filename, - executable=SHELL_EXECUTABLE, - stdin="", - ) + #hosts.all.shell( + # cmd="chtag -t -c ISO8859-1 " + test_tmp_file_filename, + # executable=SHELL_EXECUTABLE, + # stdin="", + #) results = hosts.all.shell( cmd="cat " + test_tmp_file_filename, executable=SHELL_EXECUTABLE, stdin="" ) From 3e5a19288a3b2bb4015c93aa3e45e1bc142d6a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Tue, 21 Jan 2025 10:55:29 -0600 Subject: [PATCH 13/43] Remove for test and validate write option --- plugins/modules/zos_mount.py | 9 +++++---- tests/functional/modules/test_zos_mount_func.py | 5 ----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/plugins/modules/zos_mount.py b/plugins/modules/zos_mount.py index 326485194..da720f885 100644 --- a/plugins/modules/zos_mount.py +++ b/plugins/modules/zos_mount.py @@ -1031,10 +1031,11 @@ def run_module(module, arg_def): datasets.copy(source=bk_ds, target=data_store) datasets.delete(dataset=bk_ds) - d = datetime.today() - dtstr = d.strftime("%Y%m%d-%H%M%S") - marker = '/* {mark} ANSIBLE MANAGED BLOCK ' + dtstr + " */" - marker = "{0}\\n{1}\\n{2}".format("BEGIN", "END", marker) + if will_mount: + d = datetime.today() + dtstr = d.strftime("%Y%m%d-%H%M%S") + marker = '/* {mark} ANSIBLE MANAGED BLOCK ' + dtstr + " */" + marker = "{0}\\n{1}\\n{2}".format("BEGIN", "END", marker) datasets.blockinfile(dataset=data_store, state=True, block=parmtext, marker=marker, insert_after="EOF") diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index e4d26e49e..ec54ab8b4 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -332,11 +332,6 @@ def test_basic_mount_with_bpx_comment_backup(ansible_zos_module, volumes_on_syst is_binary=True, remote_src=True, ) - #hosts.all.shell( - # cmd="chtag -t -c ISO8859-1 " + test_tmp_file_filename, - # executable=SHELL_EXECUTABLE, - # stdin="", - #) results = hosts.all.shell( cmd="cat " + test_tmp_file_filename, executable=SHELL_EXECUTABLE, stdin="" ) From ad4b26e96a963b74ea59d73d15b3e94897f2257c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Tue, 21 Jan 2025 11:01:49 -0600 Subject: [PATCH 14/43] Space --- plugins/modules/zos_mount.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/zos_mount.py b/plugins/modules/zos_mount.py index da720f885..99ce33af4 100644 --- a/plugins/modules/zos_mount.py +++ b/plugins/modules/zos_mount.py @@ -1037,7 +1037,7 @@ def run_module(module, arg_def): marker = '/* {mark} ANSIBLE MANAGED BLOCK ' + dtstr + " */" marker = "{0}\\n{1}\\n{2}".format("BEGIN", "END", marker) - datasets.blockinfile(dataset=data_store, state=True, block=parmtext, marker=marker, insert_after="EOF") + datasets.blockinfile(dataset=data_store, state=True, block=parmtext, marker=marker, insert_after="EOF") if rc == 0: if stdout is None: From 18f5c5c97c74b6ed8371c6b98dc8c4af940bfa1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Tue, 21 Jan 2025 11:14:09 -0600 Subject: [PATCH 15/43] Fix ansible lint --- plugins/modules/zos_mount.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/plugins/modules/zos_mount.py b/plugins/modules/zos_mount.py index 99ce33af4..c6795dec1 100644 --- a/plugins/modules/zos_mount.py +++ b/plugins/modules/zos_mount.py @@ -537,7 +537,6 @@ import os import re -import tempfile import traceback from datetime import datetime @@ -548,9 +547,6 @@ data_set, backup as Backup, ) -from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.copy import ( - copy_uss_mvs -) from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.import_handler import ( ZOAUImportError, ) @@ -642,26 +638,26 @@ def get_str_to_keep(dataset, src): for line in content: if pattern.match(line) is not None: - line_counter+=1 + line_counter += 1 break - line_counter+=1 + line_counter += 1 - begin_block_code=line_counter + begin_block_code = line_counter for line in reversed(content[:line_counter]): if "/* BEGIN ANSIBLE MANAGED" in line: - begin_block_code-=1 + begin_block_code -= 1 break - begin_block_code-=1 + begin_block_code -= 1 - end_block_code=line_counter + end_block_code = line_counter for line in content[line_counter:]: if "/* END ANSIBLE MANAGED" in line: - end_block_code+=1 + end_block_code += 1 break - end_block_code+=1 + end_block_code += 1 head_content = content[:begin_block_code] - tail_content = content[end_block_code+1:] + tail_content = content[end_block_code + 1:] head_content.extend(tail_content) From 8fab611b71797a7a162c3ee2ef267e81f7804f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= <68956970+AndreMarcel99@users.noreply.github.com> Date: Tue, 21 Jan 2025 12:06:00 -0600 Subject: [PATCH 16/43] Update changelogs/fragments/1871-Failing_using_persistent_option.yml Co-authored-by: Fernando Flores --- changelogs/fragments/1871-Failing_using_persistent_option.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/1871-Failing_using_persistent_option.yml b/changelogs/fragments/1871-Failing_using_persistent_option.yml index 5f3d51102..61d921099 100644 --- a/changelogs/fragments/1871-Failing_using_persistent_option.yml +++ b/changelogs/fragments/1871-Failing_using_persistent_option.yml @@ -1,3 +1,3 @@ bugfixes: - - zos_mount - Module fail when using persistent option. Fix now uses allow use of persistent option. + - zos_mount - Module failed when using persistent option with a data set that contains non UTF-8 characters. Fix now can use a data set with non UTF-8 characters as data_store. (https://github.com/ansible-collections/ibm_zos_core/pull/1871). \ No newline at end of file From 6d66ac647b51afc4117ebc40f32fd4b303782ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Tue, 21 Jan 2025 12:13:51 -0600 Subject: [PATCH 17/43] Fix check if work properly --- plugins/modules/zos_mount.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/modules/zos_mount.py b/plugins/modules/zos_mount.py index c6795dec1..8d2fc874b 100644 --- a/plugins/modules/zos_mount.py +++ b/plugins/modules/zos_mount.py @@ -1021,11 +1021,15 @@ def run_module(module, arg_def): new_str = get_str_to_keep(dataset=data_store, src=src) for line in new_str: - datasets.write(dataset_name=bk_ds, content=line.rstrip(), append=True) - - datasets.delete(dataset=data_store) - datasets.copy(source=bk_ds, target=data_store) - datasets.delete(dataset=bk_ds) + rc_write = datasets.write(dataset_name=bk_ds, content=line.rstrip(), append=True) + if rc_write != 0: + datasets.delete(dataset=bk_ds) + break + + if rc_write == 0: + datasets.delete(dataset=data_store) + datasets.copy(source=bk_ds, target=data_store) + datasets.delete(dataset=bk_ds) if will_mount: d = datetime.today() From 7ff2de728f621f3517b9560191ffe75c1855809c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Tue, 21 Jan 2025 12:22:32 -0600 Subject: [PATCH 18/43] Fix check if work properly --- plugins/modules/zos_mount.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/modules/zos_mount.py b/plugins/modules/zos_mount.py index 8d2fc874b..c5af2a7ba 100644 --- a/plugins/modules/zos_mount.py +++ b/plugins/modules/zos_mount.py @@ -1020,6 +1020,8 @@ def run_module(module, arg_def): new_str = get_str_to_keep(dataset=data_store, src=src) + rc_write = 0 + for line in new_str: rc_write = datasets.write(dataset_name=bk_ds, content=line.rstrip(), append=True) if rc_write != 0: From 5ef03163ef6320b8f58554149df4833a1fd684bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Tue, 21 Jan 2025 13:36:09 -0600 Subject: [PATCH 19/43] Enhance validation --- plugins/modules/zos_mount.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/modules/zos_mount.py b/plugins/modules/zos_mount.py index c5af2a7ba..b4becda35 100644 --- a/plugins/modules/zos_mount.py +++ b/plugins/modules/zos_mount.py @@ -1020,18 +1020,19 @@ def run_module(module, arg_def): new_str = get_str_to_keep(dataset=data_store, src=src) - rc_write = 0 - - for line in new_str: - rc_write = datasets.write(dataset_name=bk_ds, content=line.rstrip(), append=True) - if rc_write != 0: - datasets.delete(dataset=bk_ds) - break - - if rc_write == 0: - datasets.delete(dataset=data_store) - datasets.copy(source=bk_ds, target=data_store) + try: + for line in new_str: + datasets.write(dataset_name=bk_ds, content=line.rstrip(), append=True) + except: datasets.delete(dataset=bk_ds) + module.fail_json( + msg="Unable to write on persistent data set {0}.".format(data_store), + stderr=str(res_args), + ) + + datasets.delete(dataset=data_store) + datasets.copy(source=bk_ds, target=data_store) + datasets.delete(dataset=bk_ds) if will_mount: d = datetime.today() From f5b1fc4fb3321053d1e5b1457ac2cd6ee42243f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Tue, 21 Jan 2025 13:44:59 -0600 Subject: [PATCH 20/43] Fix lint --- plugins/modules/zos_mount.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/zos_mount.py b/plugins/modules/zos_mount.py index b4becda35..8cad6920e 100644 --- a/plugins/modules/zos_mount.py +++ b/plugins/modules/zos_mount.py @@ -1023,7 +1023,7 @@ def run_module(module, arg_def): try: for line in new_str: datasets.write(dataset_name=bk_ds, content=line.rstrip(), append=True) - except: + except Exception: datasets.delete(dataset=bk_ds) module.fail_json( msg="Unable to write on persistent data set {0}.".format(data_store), From ba40d89e7afbe87473933df2fd59427e28d50179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Tue, 21 Jan 2025 14:13:07 -0600 Subject: [PATCH 21/43] Fix try catch --- plugins/modules/zos_mount.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/modules/zos_mount.py b/plugins/modules/zos_mount.py index 8cad6920e..205632d49 100644 --- a/plugins/modules/zos_mount.py +++ b/plugins/modules/zos_mount.py @@ -1020,16 +1020,21 @@ def run_module(module, arg_def): new_str = get_str_to_keep(dataset=data_store, src=src) + rc_write = 0 + try: for line in new_str: - datasets.write(dataset_name=bk_ds, content=line.rstrip(), append=True) - except Exception: + rc_write = datasets.write(dataset_name=bk_ds, content=line.rstrip(), append=True) + if rc_write != 0: + raise Exception("Non zero return code from datasets.write.") + except Exception as e: datasets.delete(dataset=bk_ds) module.fail_json( - msg="Unable to write on persistent data set {0}.".format(data_store), + msg="Unable to write on persistent data set {0}. {1}".format(data_store, e), stderr=str(res_args), ) + datasets.delete(dataset=data_store) datasets.copy(source=bk_ds, target=data_store) datasets.delete(dataset=bk_ds) From 69887aecae4db6229698b1d2a16e6577fc372976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Tue, 21 Jan 2025 14:20:20 -0600 Subject: [PATCH 22/43] Fix ansible lint --- plugins/modules/zos_mount.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/modules/zos_mount.py b/plugins/modules/zos_mount.py index 205632d49..2ae313c59 100644 --- a/plugins/modules/zos_mount.py +++ b/plugins/modules/zos_mount.py @@ -1034,7 +1034,6 @@ def run_module(module, arg_def): stderr=str(res_args), ) - datasets.delete(dataset=data_store) datasets.copy(source=bk_ds, target=data_store) datasets.delete(dataset=bk_ds) From 1366201ae42b900ff96c536093a7567285d972ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 10:43:29 -0600 Subject: [PATCH 23/43] Add test case to validate change --- .../functional/modules/test_zos_mount_func.py | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index ec54ab8b4..491bfbcee 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -31,6 +31,15 @@ AUTOMOVE """ +SRC_INVALID_UTF8 = """MOUNT FILESYSTEM('TEST.ZFS.DATA.USER') + MOUNTPOINT('/tmp/zfs_aggr1') + TYPE('ZFS') + SECURITY + æ + automove + 'AB\xfc' +""" + SHELL_EXECUTABLE = "/bin/sh" @@ -255,6 +264,75 @@ def test_basic_mount_with_bpx_nocomment_nobackup(ansible_zos_module, volumes_on_ record_length=80, ) +def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_on_systems): + hosts = ansible_zos_module + volumes = Volume_Handler(volumes_on_systems) + volume_1 = volumes.get_available_vol() + srcfn = create_sourcefile(hosts, volume_1) + + tmp_file_filename = "/tmp/testfile.txt" + + hosts.all.zos_copy( + content=SRC_INVALID_UTF8.encode('cp1252'), + dest=tmp_file_filename, + is_binary=True, + ) + + dest = get_tmp_ds_name() + dest_path = dest + "(AUTO1)" + + hosts.all.zos_data_set( + name=dest, + type="pdse", + space_primary=5, + space_type="m", + record_format="fba", + record_length=80, + ) + + hosts.all.zos_copy( + src=tmp_file_filename, + dest=dest_path, + is_binary=True, + remote_src=True, + ) + + try: + mount_result = hosts.all.zos_mount( + src=srcfn, + path="/pythonx", + fs_type="zfs", + state="mounted", + persistent=dict(data_store=dest_path), + ) + + for result in mount_result.values(): + assert result.get("rc") == 0 + assert result.get("changed") is True + + finally: + hosts.all.zos_mount( + src=srcfn, + path="/pythonx", + fs_type="zfs", + state="absent", + ) + hosts.all.shell( + cmd="drm " + DataSet.escape_data_set_name(srcfn), + executable=SHELL_EXECUTABLE, + stdin="", + ) + hosts.all.file(path=tmp_file_filename, state="absent") + hosts.all.file(path="/pythonx/", state="absent") + hosts.all.zos_data_set( + name=dest, + state="absent", + type="pdse", + space_primary=5, + space_type="m", + record_format="fba", + record_length=80, + ) def test_basic_mount_with_bpx_comment_backup(ansible_zos_module, volumes_on_systems): hosts = ansible_zos_module From 871bc799d319821f7f649eb464028389fd1e62a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 10:56:52 -0600 Subject: [PATCH 24/43] Add test case to validate change --- tests/functional/modules/test_zos_mount_func.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 491bfbcee..490f9f9eb 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -273,7 +273,7 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o tmp_file_filename = "/tmp/testfile.txt" hosts.all.zos_copy( - content=SRC_INVALID_UTF8.encode('cp1252'), + content=SRC_INVALID_UTF8, dest=tmp_file_filename, is_binary=True, ) From fe8278046ab2c1c6703883afe932224dd64a0719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 11:17:51 -0600 Subject: [PATCH 25/43] Add test case to validate change --- tests/functional/modules/test_zos_mount_func.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 490f9f9eb..a8561d12c 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -273,11 +273,17 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o tmp_file_filename = "/tmp/testfile.txt" hosts.all.zos_copy( - content=SRC_INVALID_UTF8, + content=SRC_INVALID_UTF8.encode('cp1252'), dest=tmp_file_filename, is_binary=True, ) + hosts.all.shell( + cmd="chtag -t -c ISO8859-1 " + tmp_file_filename, + executable=SHELL_EXECUTABLE, + stdin="", + ) + dest = get_tmp_ds_name() dest_path = dest + "(AUTO1)" From 2e3833d3d5c869530cf3cd8d5813e0b99244192f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 11:24:48 -0600 Subject: [PATCH 26/43] Add test case to validate change --- tests/functional/modules/test_zos_mount_func.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index a8561d12c..57264e9aa 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -279,7 +279,7 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o ) hosts.all.shell( - cmd="chtag -t -c ISO8859-1 " + tmp_file_filename, + cmd="chtag -t -c Cp1252 " + tmp_file_filename, executable=SHELL_EXECUTABLE, stdin="", ) From d6754e3e06522d4904654423b2f898a65f2e7d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 11:32:26 -0600 Subject: [PATCH 27/43] Add test case to validate change --- tests/functional/modules/test_zos_mount_func.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 57264e9aa..be46aeffa 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -273,13 +273,13 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o tmp_file_filename = "/tmp/testfile.txt" hosts.all.zos_copy( - content=SRC_INVALID_UTF8.encode('cp1252'), + content=SRC_INVALID_UTF8, dest=tmp_file_filename, is_binary=True, ) hosts.all.shell( - cmd="chtag -t -c Cp1252 " + tmp_file_filename, + cmd="chtag -t -c ISO8859-1 " + tmp_file_filename, executable=SHELL_EXECUTABLE, stdin="", ) From 0b5ba82de6f1a0be08d1fe2b9c21b9e8f6cbc12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 12:07:08 -0600 Subject: [PATCH 28/43] Add test case to validate change --- tests/functional/modules/test_zos_mount_func.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index be46aeffa..c1ff1bc7d 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -273,17 +273,11 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o tmp_file_filename = "/tmp/testfile.txt" hosts.all.zos_copy( - content=SRC_INVALID_UTF8, + content=u'æ'.encode('cp1252'), dest=tmp_file_filename, is_binary=True, ) - hosts.all.shell( - cmd="chtag -t -c ISO8859-1 " + tmp_file_filename, - executable=SHELL_EXECUTABLE, - stdin="", - ) - dest = get_tmp_ds_name() dest_path = dest + "(AUTO1)" From 6f03eedbceaded8143188f6d98efee1922ad96d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 12:18:18 -0600 Subject: [PATCH 29/43] Add test case to validate change --- tests/functional/modules/test_zos_mount_func.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index c1ff1bc7d..59c6537cb 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -273,11 +273,17 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o tmp_file_filename = "/tmp/testfile.txt" hosts.all.zos_copy( - content=u'æ'.encode('cp1252'), + content=SRC_INVALID_UTF8, dest=tmp_file_filename, is_binary=True, ) + hosts.all.shell( + cmd="iconv -f utf-8 -t cp1252 " + tmp_file_filename, + executable=SHELL_EXECUTABLE, + stdin="", + ) + dest = get_tmp_ds_name() dest_path = dest + "(AUTO1)" From 0c9028b9f5bb54837e341b88c202fbad4f57059c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 12:23:28 -0600 Subject: [PATCH 30/43] Add test case to validate change --- tests/functional/modules/test_zos_mount_func.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 59c6537cb..acc1f5bd0 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -313,6 +313,7 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o ) for result in mount_result.values(): + print(result) assert result.get("rc") == 0 assert result.get("changed") is True From 893e0b6df0481ff142cff965627cfa5a2d40a359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 13:16:20 -0600 Subject: [PATCH 31/43] Fix removal and check --- .../functional/modules/test_zos_mount_func.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index acc1f5bd0..c25c7b8b5 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -287,13 +287,8 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o dest = get_tmp_ds_name() dest_path = dest + "(AUTO1)" - hosts.all.zos_data_set( - name=dest, - type="pdse", - space_primary=5, - space_type="m", - record_format="fba", - record_length=80, + hosts.all.shell( + cmd="dtouch -tpdse {0}".format(dest) ) hosts.all.zos_copy( @@ -317,6 +312,15 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o assert result.get("rc") == 0 assert result.get("changed") is True + result_cat = hosts.all.shell( + cmd="dcat '{0}'".format(dest), + executable=SHELL_EXECUTABLE, + stdin="", + ) + + for result in result_cat.values(): + print(result) + assert srcfn in result.get("stdout") finally: hosts.all.zos_mount( src=srcfn, @@ -331,14 +335,10 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o ) hosts.all.file(path=tmp_file_filename, state="absent") hosts.all.file(path="/pythonx/", state="absent") - hosts.all.zos_data_set( - name=dest, - state="absent", - type="pdse", - space_primary=5, - space_type="m", - record_format="fba", - record_length=80, + hosts.all.shell( + cmd="drm " + dest, + executable=SHELL_EXECUTABLE, + stdin="", ) def test_basic_mount_with_bpx_comment_backup(ansible_zos_module, volumes_on_systems): From 4f8fa176266cc7063d4a52d105fffdf61152381d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 13:27:11 -0600 Subject: [PATCH 32/43] Fix removal and check --- tests/functional/modules/test_zos_mount_func.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index c25c7b8b5..397539776 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -319,8 +319,7 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o ) for result in result_cat.values(): - print(result) - assert srcfn in result.get("stdout") + assert DataSet.escape_data_set_name(srcfn) in result.get("stdout") finally: hosts.all.zos_mount( src=srcfn, From f4ac77bf0b6bef6d26762b6e1184091705ce6faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 13:35:29 -0600 Subject: [PATCH 33/43] Fix removal and check --- tests/functional/modules/test_zos_mount_func.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 397539776..f36e52354 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -318,7 +318,7 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o stdin="", ) - for result in result_cat.values(): + for result in result_cat.contacted.values(): assert DataSet.escape_data_set_name(srcfn) in result.get("stdout") finally: hosts.all.zos_mount( From d884f03dd320bb6e0be3bcbef111e6b7e257b551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 13:42:41 -0600 Subject: [PATCH 34/43] Fix removal and check --- tests/functional/modules/test_zos_mount_func.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index f36e52354..9ea8d1872 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -314,8 +314,6 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o result_cat = hosts.all.shell( cmd="dcat '{0}'".format(dest), - executable=SHELL_EXECUTABLE, - stdin="", ) for result in result_cat.contacted.values(): From 0ab6e387c8145ce3f7a568f1e28deff2139e1c62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 13:48:49 -0600 Subject: [PATCH 35/43] Fix removal and check --- tests/functional/modules/test_zos_mount_func.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 9ea8d1872..639964869 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -317,7 +317,7 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o ) for result in result_cat.contacted.values(): - assert DataSet.escape_data_set_name(srcfn) in result.get("stdout") + assert srcfn in result.get("cmd") finally: hosts.all.zos_mount( src=srcfn, From 8bc90da3451fb3648faeaa6febd3617c58442299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 13:54:54 -0600 Subject: [PATCH 36/43] Fix removal and check --- tests/functional/modules/test_zos_mount_func.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 639964869..21325e138 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -308,7 +308,6 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o ) for result in mount_result.values(): - print(result) assert result.get("rc") == 0 assert result.get("changed") is True @@ -317,6 +316,7 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o ) for result in result_cat.contacted.values(): + print(result) assert srcfn in result.get("cmd") finally: hosts.all.zos_mount( From 622cbee916b4ec45d7d5d7c0a30109ae7860c079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 14:03:49 -0600 Subject: [PATCH 37/43] Fix removal and check --- tests/functional/modules/test_zos_mount_func.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 21325e138..c2a7114a3 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -312,7 +312,7 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o assert result.get("changed") is True result_cat = hosts.all.shell( - cmd="dcat '{0}'".format(dest), + cmd="dcat '{0}'".format(dest_path), ) for result in result_cat.contacted.values(): From 7012fa8da4f9a32f318898110b085e53dd10bd58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Wed, 22 Jan 2025 14:20:20 -0600 Subject: [PATCH 38/43] Fix removal and check --- tests/functional/modules/test_zos_mount_func.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index c2a7114a3..eb7586f91 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -316,8 +316,7 @@ def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_o ) for result in result_cat.contacted.values(): - print(result) - assert srcfn in result.get("cmd") + assert srcfn in result.get("stdout") finally: hosts.all.zos_mount( src=srcfn, From 4be249e3ab87ddbe5204390b51e94cb2694849c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Fri, 24 Jan 2025 18:13:39 -0600 Subject: [PATCH 39/43] Delete line --- tests/functional/modules/test_zos_mount_func.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index eb7586f91..fbe90d589 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -264,7 +264,7 @@ def test_basic_mount_with_bpx_nocomment_nobackup(ansible_zos_module, volumes_on_ record_length=80, ) -def test_basic_mount_with_bpx_no_utf_8_characters_(ansible_zos_module, volumes_on_systems): +def test_basic_mount_with_bpx_no_utf_8_characters(ansible_zos_module, volumes_on_systems): hosts = ansible_zos_module volumes = Volume_Handler(volumes_on_systems) volume_1 = volumes.get_available_vol() From c7c77f490d4f9832d1719f0e198fa1e2f160aecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Fri, 24 Jan 2025 19:45:23 -0600 Subject: [PATCH 40/43] Write no utf-8 characters --- tests/functional/modules/test_zos_mount_func.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index fbe90d589..771f282d5 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -278,11 +278,9 @@ def test_basic_mount_with_bpx_no_utf_8_characters(ansible_zos_module, volumes_on is_binary=True, ) - hosts.all.shell( - cmd="iconv -f utf-8 -t cp1252 " + tmp_file_filename, - executable=SHELL_EXECUTABLE, - stdin="", - ) + f = open(tmp_file_filename, "w", encoding='utf8') + f.write("çıkardınız") + f.close() dest = get_tmp_ds_name() dest_path = dest + "(AUTO1)" @@ -308,6 +306,7 @@ def test_basic_mount_with_bpx_no_utf_8_characters(ansible_zos_module, volumes_on ) for result in mount_result.values(): + print(result) assert result.get("rc") == 0 assert result.get("changed") is True From 674cc3b8ac914e4412f157cb850994f7ce316dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Fri, 24 Jan 2025 20:12:14 -0600 Subject: [PATCH 41/43] Use blockinfile --- tests/functional/modules/test_zos_mount_func.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 771f282d5..3bfb2b8b1 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -32,12 +32,11 @@ """ SRC_INVALID_UTF8 = """MOUNT FILESYSTEM('TEST.ZFS.DATA.USER') + MOUNTPOINT('/tmp/src/somedirectory') 0xC1 MOUNTPOINT('/tmp/zfs_aggr1') TYPE('ZFS') SECURITY - æ - automove - 'AB\xfc' + 0x15 0x0D 0x25 0x0E 0x0F 0xF8 0xC1 """ SHELL_EXECUTABLE = "/bin/sh" @@ -272,15 +271,11 @@ def test_basic_mount_with_bpx_no_utf_8_characters(ansible_zos_module, volumes_on tmp_file_filename = "/tmp/testfile.txt" - hosts.all.zos_copy( - content=SRC_INVALID_UTF8, - dest=tmp_file_filename, - is_binary=True, + hosts.all.shell( + cmd="touch {0}".format(tmp_file_filename) ) - f = open(tmp_file_filename, "w", encoding='utf8') - f.write("çıkardınız") - f.close() + hosts.all.zos_blockinfile(path=tmp_file_filename, insertafter="EOF", block=SRC_INVALID_UTF8) dest = get_tmp_ds_name() dest_path = dest + "(AUTO1)" From ac06ee372c1ed7bef396e40a53b89ff9d763bbec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Fri, 24 Jan 2025 20:20:36 -0600 Subject: [PATCH 42/43] Use blockinfile --- tests/functional/modules/test_zos_mount_func.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 3bfb2b8b1..309d64f4f 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -35,8 +35,8 @@ MOUNTPOINT('/tmp/src/somedirectory') 0xC1 MOUNTPOINT('/tmp/zfs_aggr1') TYPE('ZFS') + 0x0D 0x25 SECURITY - 0x15 0x0D 0x25 0x0E 0x0F 0xF8 0xC1 """ SHELL_EXECUTABLE = "/bin/sh" From 5fb4423daa12dcb116256eb1e72ceba5fef8752f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marcel=20Guti=C3=A9rrez=20Ben=C3=ADtez?= Date: Sat, 25 Jan 2025 09:45:28 -0600 Subject: [PATCH 43/43] Use blockinfile --- tests/functional/modules/test_zos_mount_func.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/functional/modules/test_zos_mount_func.py b/tests/functional/modules/test_zos_mount_func.py index 309d64f4f..b0efe68a7 100644 --- a/tests/functional/modules/test_zos_mount_func.py +++ b/tests/functional/modules/test_zos_mount_func.py @@ -35,7 +35,6 @@ MOUNTPOINT('/tmp/src/somedirectory') 0xC1 MOUNTPOINT('/tmp/zfs_aggr1') TYPE('ZFS') - 0x0D 0x25 SECURITY """