From dce697b8af333483a4837b4335952915cc6e87a7 Mon Sep 17 00:00:00 2001 From: Dipti Date: Mon, 6 Jul 2020 12:16:13 -0700 Subject: [PATCH 01/21] acbgen using raw module --- playbooks/group_vars/all.yml | 60 +++++- plugins/action/ims_acb_gen.py | 361 --------------------------------- plugins/modules/ims_acb_gen.py | 279 ++++++++++++++++++++++++- 3 files changed, 322 insertions(+), 378 deletions(-) delete mode 100644 plugins/action/ims_acb_gen.py diff --git a/playbooks/group_vars/all.yml b/playbooks/group_vars/all.yml index c55be8cd..76df5afd 100755 --- a/playbooks/group_vars/all.yml +++ b/playbooks/group_vars/all.yml @@ -1,9 +1,46 @@ +# ZOAU_ROOT: /u/omvsadm/mvsbuilds/103/mvsutil +# PYTHON_ROOT: /usr/lpp/izoda/v110/anaconda +# JAVA_ROOT: /usr/lpp/java + +# environment_vars: +# LIBPATH: '{{ ZOAU_ROOT}}/lib:{{ PYTHON_ROOT }}/lib:/lib:/usr/lib:.' +# # ZOAU_ROOT: '/u/omvsadm/mvsbuilds/103/mvsutil' #'zoautil/v100' +# ZOAUTIL_DIR: '{{ ZOAU_ROOT }}' +# ZOAU_ROOT: '{{ ZOAU_ROOT }}' +# ZOAU_HOME: '{{ ZOAU_ROOT }}' +# #ZOAUTIL_DIR: '/u/omvsadm/mvsbuilds/103/mvsutil' #'/usr/lpp/zoautil/v100' +# #ZOAU_HOME: '/u/omvsadm/mvsbuilds/103/mvsutil' +# PYTHONPATH: '{{ ZOAU_ROOT }}/lib:/lib:/usr/lib' +# PYTHON_HOME: '/usr/lpp/izoda/v110/anaconda' +# _BPXK_JOBLOG: STDERR +# # environment variables for mvsutils/mvscmd +# _BPXK_AUTOCVT: ON +# #_CEE_RUNOPTS: '"FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"' +# _TAG_REDIR_ERR: txt +# _TAG_REDIR_IN: txtbc +# _TAG_REDIR_OUT: txt +# TOOLS_ROOT: '/usr/lpp/rsusr/ported' +# PATH: '{{ ZOAU_ROOT }}/bin:/usr/lpp/rsusr/ported/bin:{{ JAVA_ROOT }}/java180/J8.0_64/bin:/bin:/var/bin:{{ JAVA_ROOT }}/J8.0/bin:{{ PYTHON_ROOT }}/bin' +# #PATH: '/u/omvsadm/mvsutil/bin:/usr/lpp/rsusr/ported/bin:/usr/lpp/java/java180/J8.0_64/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin:/usr/lpp/izoda/v110/anaconda/bin' +# JAVA_HOME: /usr/lpp/java/java180/J8.0_64 +# STEPLIB: IMSBLD.I15RTSMM.COMRESL1 # IMSNEW.DIPTI.IM00.SDFSRESL +# LANG: C + +# JOB_CARD: |- +# //ANSIBLE JOB 'testing', +# // CLASS=H,MSGLEVEL=(1,1),REGION=0M, +# // MSGCLASS=H,NOTIFY=&SYSUID + +ZOAU_ROOT: /u/omvsadm/mvsbuilds/103/mvsutil +PYTHON_ROOT: /u/oeusr01/usr/lpp/IBM/cyp/v3r8/pyz/usr/lpp/IBM/cyp/v3r8/pyz #/usr/lpp/izoda/v110/anaconda +JAVA_ROOT: /usr/lpp/java + environment_vars: - LIBPATH: '/usr/lpp/izoda/v110/anaconda/lib:/u/omvsadm/mvsutil/lib:/lib:/usr/lib:.' - ZOAU_ROOT: '/usr/lpp/zoautil/v100' - ZOAUTIL_DIR: '/usr/lpp/zoautil/v100' - PYTHONPATH: '/usr/lpp/izoda/v110/anaconda/lib:/u/omvsadm/mvsutil/lib:/lib:/usr/lib' - PYTHON_HOME: '/usr/lpp/izoda/v110/anaconda' + LIBPATH: '{{ ZOAU_ROOT}}/lib:{{ PYTHON_ROOT }}/lib:/lib:/usr/lib:.' + ZOAUTIL_DIR: '{{ ZOAU_ROOT }}' + ZOAU_ROOT: '{{ ZOAU_ROOT }}' + ZOAU_HOME: '{{ ZOAU_ROOT }}' + PYTHONPATH: '{{ ZOAU_ROOT }}/lib:/lib:/usr/lib' _BPXK_JOBLOG: STDERR # environment variables for mvsutils/mvscmd _BPXK_AUTOCVT: ON @@ -12,11 +49,12 @@ environment_vars: _TAG_REDIR_IN: txt _TAG_REDIR_OUT: txt TOOLS_ROOT: '/usr/lpp/rsusr/ported' - PATH: '/u/omvsadm/mvsutil/bin:/usr/lpp/rsusr/ported/bin:/usr/lpp/java/java180/J8.0_64/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin:/usr/lpp/izoda/v110/anaconda/bin' - JAVA_HOME: /usr/lpp/java/java180/J8.0_64 - STEPLIB: IMSBLD.I15RTSMM.COMRESL1 # IMSNEW.DIPTI.IM00.SDFSRESL + PATH: '{{ ZOAU_ROOT }}/bin:/usr/lpp/rsusr/ported/bin:{{ JAVA_ROOT }}/java180/J8.0_64/bin:/bin:/var/bin:{{ JAVA_ROOT }}/J8.0/bin:{{ PYTHON_ROOT }}/bin' + JAVA_HOME: '{{ JAVA_ROOT }}/java180/J8.0_64' + STEPLIB: IMSBLD.I15RTSMM.COMRESL1 + LANG: C JOB_CARD: |- - //ANSIBLE JOB 'testing', - // CLASS=H,MSGLEVEL=(1,1),REGION=0M, - // MSGCLASS=H,NOTIFY=&SYSUID \ No newline at end of file + //ANSIBLE JOB 'testing', + // CLASS=H,MSGLEVEL=(1,1),REGION=0M, + // MSGCLASS=H,NOTIFY=&SYSUID \ No newline at end of file diff --git a/plugins/action/ims_acb_gen.py b/plugins/action/ims_acb_gen.py deleted file mode 100644 index c30c0084..00000000 --- a/plugins/action/ims_acb_gen.py +++ /dev/null @@ -1,361 +0,0 @@ -# Copyright (c) IBM Corporation 2019, 2020 -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function - -__metaclass__ = type - -# Important constants -from ansible.plugins.action import ActionBase -from ansible.errors import AnsibleError, AnsibleFileNotFound -from tempfile import NamedTemporaryFile -from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.better_arg_parser import ( - BetterArgParser, -) -import os -import time -import re - - -def build_dd(ddname, ddlist): - singleddstr = "DD DSN={0}," +"\n// " + "DISP=SHR" - ddstring = "//{0} {1}\n".format(ddname, singleddstr.format(ddlist[0])) - for dd in ddlist[1:]: - ddstring += "// {0}\n".format(" " + singleddstr.format(dd)) - return ddstring - - -def build_dd_steplib(ddname, ddlist, steplib): - singleddstr = "DD DSN={0}," +"\n// " + "DISP=SHR" - if ddlist: - ddstring = "//{0} {1}\n".format(ddname, singleddstr.format(ddlist[0])) - for dd in ddlist[1:]: - ddstring += "// {0}\n".format(" " + singleddstr.format(dd)) - else: - ddstring = "//{0} {1}\n".format(ddname, singleddstr.format(steplib)) - return ddstring - - -def build_psb_name_string(command_input, psbnames): - psb_str = "" - if psbnames: - for psb in psbnames: - #if a match is not found - if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', psb, re.IGNORECASE): - return False, psb - else: - # if a match is found - if psb == "ALL": - psb_str = command_input + " PSB=ALL" - break - else: - psb_str = command_input + " PSB=(" + ",".join(psbnames) + ")" - return True, psb_str - - -def split_lines_dbd(command_input, dbdnames, bldpsb): - return_arr = [] - return_bool = False - if len(dbdnames) < 6: - return_bool, return_str = build_dbd_name_string(command_input, dbdnames, bldpsb) - return return_bool, return_str - else: - for i in range(0, len(dbdnames), 5): - new_db_names_five = dbdnames[i: i + 5] - return_bool, dbd_line = build_dbd_name_string(command_input, new_db_names_five, bldpsb) - return_arr.append(dbd_line) - return return_bool, "\n ".join(return_arr) - return return_bool, return_arr - - -def split_lines_psb(command_input, psbnames): - return_arr = [] - return_bool = False - if len(psbnames) < 6: - return_bool, return_str = build_psb_name_string(command_input, psbnames) - return return_bool, return_str - else: - for i in range(0, len(psbnames), 5): - new_db_names_five = psbnames[i: i + 5] - return_bool, psb_line = build_psb_name_string(command_input, new_db_names_five) - return_arr.append(psb_line) - return return_bool, "\n ".join(return_arr) - return return_bool, return_arr - - -def build_dbd_name_string(command_input, dbdnames, bldpsb): - dbd_str = "" - bldpsb_value = "" - if bldpsb: - bldpsb_value = "YES" - else: - bldpsb_value = "NO" - - if dbdnames: - for dbd in dbdnames: - #if a match is not found - if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', dbd, re.IGNORECASE): - return False, dbd - else: - # if a match is found - if dbdnames and bldpsb: - dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" - elif dbdnames and command_input == "BUILD": - dbd_str = ( - command_input - + " DBD=(" - + ",".join(dbdnames) - + ")" - + ",BLDPSB=" - + bldpsb_value - ) - elif dbdnames: - dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" - return True, dbd_str - - -def str_or_list_of_str(contents, dependencies): - if isinstance(contents, list): - for item in contents: - if not isinstance(item, str): - raise ValueError( - "Items provided in list do not match the string type expected." - ) - elif isinstance(contents, str): - contents = [contents] # make this a list of strings to consistent format - else: - raise ValueError( - "Incorrect type provided. A string or list of strings is expected" - ) - return contents - -ZOAU_TEMP_USS = "/tmp/test.jcl" - - -class ActionModule(ActionBase): - def run(self, tmp=None, task_vars=None): - """handler for file transfer operations.""" - if task_vars is None: - task_vars = dict() - - result = super(ActionModule, self).run(tmp, task_vars) - - if result.get("skipped"): - return result - - module_args = self._task.args.copy() - - # Retrieve properties set by the user - module_defs = dict( - command_input=dict(arg_type="str", required=True), - compression=dict(arg_type="str", required=False, default=""), - psb_name=dict(arg_type=str_or_list_of_str, required=False), - dbd_name=dict(arg_type=str_or_list_of_str, elements="str", required=False), - acb_lib=dict(arg_type="str", required=True), - psb_lib=dict(arg_type="list", elements="str", required=True), - dbd_lib=dict(arg_type="list", elements="str", required=True), - reslib=dict(arg_type="list", elements="str", required=False), - steplib=dict(arg_type="list", elements="str", required=False), - build_psb=dict(arg_type="bool", required=False, default=True), - ) - - # Parse the properties - parser = BetterArgParser(module_defs) - parsed_args = parser.parse_args(module_args) - - command_input = parsed_args.get("command_input") - compression = parsed_args.get("compression") - psb_name = parsed_args.get("psb_name") - dbd_name = parsed_args.get("dbd_name") - acb_lib = parsed_args.get("acb_lib") - psb_lib = parsed_args.get("psb_lib") - dbd_lib = parsed_args.get("dbd_lib") - reslib = parsed_args.get("reslib") - steplib = parsed_args.get("steplib") - build_psb = parsed_args.get("build_psb") - - psb_name_str = "" - if psb_name: - psb_name_str, psb = split_lines_psb(command_input, psb_name) - if psb_name_str: - if psb: - psb_name_str = '\n ' + psb - else: - psb_name_str = psb - elif psb: - msg = 'A PSB named ' + str(psb) + ' provided in the module input was not found.' - result['rc'] = -1 - result['msg'] = msg - return result - - dbd_name_str = "" - if dbd_name: - dbd_name_str, dbd = split_lines_dbd(command_input, dbd_name, build_psb) - if dbd_name_str: - dbd_name_str = '\n ' + dbd - else: - msg = 'A DBD named ' + str(dbd) + ' provided in the module input was not found.' - result['rc'] = -1 - result['msg'] = msg - return result - - env = task_vars.get("environment_vars") - if env is not None: - env_steplib = env.get("STEPLIB") - else: - env_steplib = task_vars.get("STEPLIB") - job_card = task_vars.get("JOB_CARD") - - dd_steplib = build_dd_steplib("STEPLIB", steplib, env_steplib) - - dd_reslib = "" - if reslib: - dd_reslib = build_dd("DFSRESLB", reslib) - # Create string for the JCL contents and fill in the values - acbgen_jcl = """{8} -//* -//ACBGEN PROC SOUT=A,COMP='{0}' -//G EXEC PGM=DFSRRC00,PARM='UPB,&COMP' -//SYSPRINT DD SYSOUT=&SOUT -{1}{2}{3}{4}//IMSACB DD DSN={5},DISP=OLD -//COMPCTL DD * - COPY INDD=IMSACB,OUTDD=IMSACB -// PEND -//* -//STEPA EXEC ACBGEN -//SYSIN DD *{6}{7} -/* -""".format( - compression, - dd_steplib, - dd_reslib, - build_dd("IMS", psb_lib), - build_dd("", dbd_lib), - acb_lib, - psb_name_str, - dbd_name_str, - job_card, - ) - - # Get a temporary file on the controller and write to a it - # Initialize JCL temp file - delete_on_close = True - tmp_file = NamedTemporaryFile(delete=delete_on_close) - with open(tmp_file.name, "w") as f: - f.write(acbgen_jcl) - - result = {} - module_args = self._task.args.copy() - - # Define file paths of the local controller file and the remote destination file - dest = ZOAU_TEMP_USS - source = tmp_file.name - - # Make sure the source file is able to be found - try: - source = self._find_needle("files", source) - except AnsibleError as e: - result["failed"] = True - result["msg"] = to_text(e) - return result - - if tmp is None or "-tmp-" not in tmp: - tmp = self._make_tmp_path() - - # Locate the actual location of the file in the Ansible controller - try: - source_full = self._loader.get_real_file(source) - source_rel = os.path.basename(source) - except AnsibleFileNotFound as e: - result["failed"] = True - result["msg"] = "could not find src=%s, %s" % (source_full, e) - self._remove_tmp_path(tmp) - return result - - if self._connection._shell.path_has_trailing_slash(dest): - dest_file = self._connection._shell.join_path(dest, source_rel) - else: - dest_file = self._connection._shell.join_path(dest) - - dest_status = self._execute_remote_stat( - dest_file, all_vars=task_vars, follow=False - ) - - if dest_status["exists"] and dest_status["isdir"]: - self._remove_tmp_path(tmp) - result["failed"] = True - result["msg"] = "can not use content with a dir as dest" - return result - - tmp_src = self._connection._shell.join_path(tmp, "source") - - remote_path = None - remote_path = self._transfer_file(source_full, tmp_src) - - if remote_path: - self._fixup_perms2((tmp, remote_path)) - - # Generate arguments to call the copy module - copy_args = dict( - src=tmp_src, dest=dest, mode="0755", _original_basename=source_rel, - ) - - # Run the copy module to copy JCL temp file with proper input values from user to z/OS USS - result.update( - self._execute_module( - module_name="copy", module_args=copy_args, task_vars=task_vars, - ) - ) - # After successfully copying the module to the remote host, return to the ims_acb_gen to submit the JCL - result.update( - self._execute_module( - module_name="ims_acb_gen", module_args=module_args, task_vars=task_vars, - ) - ) - - time.sleep(5) - - jobId = result["jobId"] - - # Generate arguments to call the zos_job_output module - job_query_args = dict(job_id=jobId) - - # Run the zos_job_output module to get the results of the jcl being submitted - result.update( - self._execute_module( - module_name="zos_job_output", - module_args=job_query_args, - task_vars=task_vars, - ) - ) - - return_code = "" - job_content = "" - ddnames = "" - module_changed = False - - listJobs = result["jobs"] - for i in listJobs: - for k in i.keys(): - if k == "ret_code": - return_code = i.get("ret_code") - if k == "ddnames": - ddnames = i.get("ddnames") - for x in ddnames: - for y in x.keys(): - if y == "content": - job_content = x.get("content") - - if return_code["msg_code"] == "0000" or return_code["msg_code"] == "0004": - module_changed = True - rc = "0" - return_code["msg_txt"] = 'ACBGEN execution is successful' - else: - rc = return_code["msg_code"] - return_code["msg_txt"] = 'ACBGEN execution unsuccessful.' - - newResult = dict( - content=job_content, changed=module_changed, rc=rc, msg=return_code["msg_txt"] - ) - - return newResult diff --git a/plugins/modules/ims_acb_gen.py b/plugins/modules/ims_acb_gen.py index 26c96b0c..6677f3aa 100644 --- a/plugins/modules/ims_acb_gen.py +++ b/plugins/modules/ims_acb_gen.py @@ -189,10 +189,125 @@ type: bool ''' -from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.basic import AnsibleModule, env_fallback, AnsibleFallbackNotFound from ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.ims_gen_utils import ( submit_uss_jcl, ) +from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.dd_statement import ( # pylint: disable=import-error + DDStatement, + FileDefinition, + DatasetDefinition, + StdoutDefinition, + StdinDefinition, +) +from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.better_arg_parser import BetterArgParser # pylint: disable=import-error +from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.zos_raw import MVSCmd # pylint: disable=import-error +# import ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.dataset_utils +import tempfile +import re +from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.import_handler import ( # pylint: disable=import-error + MissingZOAUImport, +) +import tempfile +import pprint + +try: + from zoautil_py import Datasets, types # pylint: disable=import-error +except Exception: + Datasets = MissingZOAUImport() + types = MissingZOAUImport() + +module = None + +def str_or_list_of_str(contents, dependencies): + print("contents: ", contents) + if isinstance(contents, list): + for item in contents: + if not isinstance(item, str): + raise ValueError( + "Items provided in list do not match the string type expected." + ) + elif isinstance(contents, str): + contents = [contents] # make this a list of strings to consistent format + else: + raise ValueError( + "Incorrect type provided. A string or list of strings is expected" + ) + return contents + +def split_lines_psb(command_input, psbnames): + return_arr = [] + return_bool = False + if len(psbnames) < 6: + return_bool, return_str = build_psb_name_string(command_input, psbnames) + return return_bool, return_str + else: + for i in range(0, len(psbnames), 5): + new_db_names_five = psbnames[i: i + 5] + return_bool, psb_line = build_psb_name_string(command_input, new_db_names_five) + return_arr.append(psb_line) + return return_bool, "\n ".join(return_arr) + return return_bool, return_arr + +def build_psb_name_string(command_input, psbnames): + psb_str = "" + if psbnames: + for psb in psbnames: + #if a match is not found + if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', psb, re.IGNORECASE): + return False, psb + else: + # if a match is found + if psb == "ALL": + psb_str = command_input + " PSB=ALL" + break + else: + psb_str = command_input + " PSB=(" + ",".join(psbnames) + ")" + return True, psb_str + +def split_lines_dbd(command_input, dbdnames, bldpsb): + return_arr = [] + return_bool = False + if len(dbdnames) < 6: + return_bool, return_str = build_dbd_name_string(command_input, dbdnames, bldpsb) + return return_bool, return_str + else: + for i in range(0, len(dbdnames), 5): + new_db_names_five = dbdnames[i: i + 5] + return_bool, dbd_line = build_dbd_name_string(command_input, new_db_names_five, bldpsb) + return_arr.append(dbd_line) + return return_bool, "\n ".join(return_arr) + return return_bool, return_arr + +def build_dbd_name_string(command_input, dbdnames, bldpsb): + dbd_str = "" + bldpsb_value = "" + if bldpsb: + bldpsb_value = "YES" + else: + bldpsb_value = "NO" + + if dbdnames: + for dbd in dbdnames: + #if a match is not found + if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', dbd, re.IGNORECASE): + return False, dbd + else: + # if a match is found + if dbdnames and bldpsb: + dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" + elif dbdnames and command_input == "BUILD": + dbd_str = ( + command_input + + " DBD=(" + + ",".join(dbdnames) + + ")" + + ",BLDPSB=" + + bldpsb_value + ) + elif dbdnames: + dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" + return True, dbd_str def run_module(): @@ -208,11 +323,163 @@ def run_module(): steplib=dict(type="list", required=False), build_psb=dict(type="bool", required=False, default=True), ) - module = AnsibleModule(argument_spec=module_args, supports_check_mode=True) - result = dict(rc="0", jobId="") - jobId = submit_uss_jcl(module) - result["jobId"] = jobId - module.exit_json(**result) + + global module + module = AnsibleModule( + argument_spec=module_args, + supports_check_mode=True) + + result = {} + result["changed"] = False + + + # Retrieve properties set by the user + module_defs = dict( + command_input=dict(arg_type="str", required=True), + compression=dict(arg_type="str", required=False, default=""), + psb_name=dict(arg_type=str_or_list_of_str, required=False), + dbd_name=dict(arg_type=str_or_list_of_str, required=False), #elements="str", + acb_lib=dict(arg_type="str", required=True), + psb_lib=dict(arg_type="list", elements="str", required=True), + dbd_lib=dict(arg_type="list", elements="str", required=True), + reslib=dict(arg_type="list", elements="str", required=False), + steplib=dict(arg_type="list", elements="str", required=False), + build_psb=dict(arg_type="bool", required=False, default=True), + ) + + # Parse the properties + parser = BetterArgParser(module_defs) + parsed_args = parser.parse_args(module.params) + + command_input = parsed_args.get("command_input") + compression = parsed_args.get("compression") + psb_name = parsed_args.get("psb_name") + dbd_name = parsed_args.get("dbd_name") + acb_lib = parsed_args.get("acb_lib") + psb_lib = parsed_args.get("psb_lib") + dbd_lib = parsed_args.get("dbd_lib") + reslib = parsed_args.get("reslib") + steplib = parsed_args.get("steplib") + build_psb = parsed_args.get("build_psb") + + + #DD statement Generation + dDStatementList = [] + imsDatasetList = [] + commandList = [] + + # #Generate DD statement for SYSPRINT + sysDefinition = StdoutDefinition() + sysprintDDStatement = DDStatement("SYSPRINT", sysDefinition) + dDStatementList.append(sysprintDDStatement) + + + #Generate DD statement for STEPLIB + if steplib: + steplibDatasets = [DatasetDefinition(step) for step in steplib] + steplibDDStatement = DDStatement("STEPLIB", steplibDatasets) + # dDStatementList.append(steplibDDStatement) DatasetDefinition(steplib) + else: + try: + steplib = env_fallback('STEPLIB') #task_vars.get("environment_vars") + print("STEPLIB: ", steplib) + except AnsibleFallbackNotFound as e: + module.fail_json(msg="The input option 'steplib' is not provided. Please provide it in the environment " + "variables 'STEPLIB', or in the module input option 'steplib'. ", **result) + + # if env is not None: + # env_steplib = env.get("STEPLIB") + # else: + # env_steplib = task_vars.get("STEPLIB") + steplibDDStatement = DDStatement("STEPLIB", DatasetDefinition(steplib)) + dDStatementList.append(steplibDDStatement) + + #Generate DD statement for RESLIB + if reslib: + reslibDatasets = [DatasetDefinition(dfsres) for dfsres in reslib] + dfsreslbDDStatement = DDStatement("DFSRESLB", reslibDatasets) # DatasetDefinition(reslib) + dDStatementList.append(dfsreslbDDStatement) + + #Generate DD statements for DBDLIB and PSBLIB + if psb_lib: + psbDatasets = [DatasetDefinition(psb) for psb in psb_lib] + imsDatasetList += psbDatasets + if dbd_lib: + dbdDatasets = [DatasetDefinition(dbd) for dbd in dbd_lib] + imsDatasetList += dbdDatasets + if imsDatasetList: + imsDDStatement = DDStatement("IMS", imsDatasetList) + dDStatementList.append(imsDDStatement) + + # if psb_lib: + # psbDataset = DatasetDefinition(psb_lib) + # imsDatasetList.append(psbDataset) + # if dbd_lib: + # dbdDataset = DatasetDefinition(dbd_lib) + # imsDatasetList.append(dbdDataset) + # if imsDatasetList: + # imsDDStatement = DDStatement("IMS", imsDatasetList) + # dDStatementList.append(imsDDStatement) + + #Generate DD statement for ACBLIB + if acb_lib: + acbDataset = DDStatement("IMSACB", DatasetDefinition(acb_lib)) + dDStatementList.append(acbDataset) + + #Generate DD statement for COMPCTL + compctlDDStatement = DDStatement("COMPCTL", StdinDefinition(" COPY INDD=IMSACB,OUTDD=IMSACB")) + dDStatementList.append(compctlDDStatement) + + + #Generate DD statements for commands + psb_name_str = "" + if command_input: + if psb_name: + psb_name_str, psb = split_lines_psb(command_input, psb_name) + + if psb_name_str: + if psb: + psb_name_str = ' ' + psb + else: + psb_name_str = psb + commandList.append(psb_name_str) + elif psb: + msg = 'A PSB named ' + str(psb) + ' provided in the module input was not found.' + result['rc'] = -1 + result['msg'] = msg + return result + + dbd_name_str = "" + if dbd_name: + dbd_name_str, dbd = split_lines_dbd(command_input, dbd_name, build_psb) + if dbd_name_str: + dbd_name_str = ' ' + dbd + commandList.append(dbd_name_str) + else: + msg = 'A DBD named ' + str(dbd) + ' provided in the module input was not found.' + result['rc'] = -1 + result['msg'] = msg + return result + + #raise ValueError("/n".join(commandList)) + + commandDDStatement = DDStatement("SYSIN",StdinDefinition("\n".join(commandList))) ) + + dDStatementList.append(commandDDStatement) + + paramString = 'UPB,{0}'.format(compression) + + try: + response = MVSCmd.execute("DFSRRC00", dDStatementList, paramString, verbose=True) + result["response"] = { + "rc": response.rc, + "stdout": response.stdout, + "stderr": response.stderr, + } + except Exception as e: + module.fail_json(msg=repr(e), **result) + finally: + module.exit_json(**result) def main(): From adea6ca545d6744d0a720b9c09ba826e333e5764 Mon Sep 17 00:00:00 2001 From: Dipti Date: Tue, 7 Jul 2020 16:43:03 -0700 Subject: [PATCH 02/21] acbgen with raw --- plugins/module_utils/acbgen.py | 276 ++++++++++++ .../module_utils/ims_module_error_messages.py | 21 +- plugins/modules/ims_acb_gen.py | 411 ++++++++---------- tests/run.sh | 3 + 4 files changed, 487 insertions(+), 224 deletions(-) create mode 100644 plugins/module_utils/acbgen.py diff --git a/plugins/module_utils/acbgen.py b/plugins/module_utils/acbgen.py new file mode 100644 index 00000000..186c3771 --- /dev/null +++ b/plugins/module_utils/acbgen.py @@ -0,0 +1,276 @@ +from ansible.module_utils.basic import AnsibleModule, env_fallback, AnsibleFallbackNotFound +from ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.ims_gen_utils import ( + submit_uss_jcl, +) +from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.dd_statement import ( # pylint: disable=import-error + DDStatement, + FileDefinition, + DatasetDefinition, + StdoutDefinition, + StdinDefinition, +) +from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.zos_raw import MVSCmd # pylint: disable=import-error +import tempfile +import re +from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.import_handler import ( # pylint: disable=import-error + MissingZOAUImport, +) +from ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.ims_module_error_messages import ACBGENErrorMessages as em # pylint: disable=import-error +try: + from zoautil_py import Datasets, types # pylint: disable=import-error +except Exception: + Datasets = MissingZOAUImport() + types = MissingZOAUImport() + +class acbgen(): + ACBGEN_UTILITY = "DFSRRC00" + # REPLACEMENT_VALUES = { + # "YES": True + # "NO": False + # } + + #def __init__(self, command_input, compression, psb_name=None, dbd_name=None, acb_lib, psb_lib, dbd_lib, reslib=None, steplib=None, build_psb): + def __init__(self, command_input, compression, psb_name, dbd_name, acb_lib, psb_lib, dbd_lib, reslib, steplib, build_psb): + """IMSAcbgen constructor for generating IMS ACB using zos_mvs_raw + Args: + + """ + print("Within contructor: ") + self.command_input = command_input + self.compression = compression + self.psb_name = psb_name + self.dbd_name = dbd_name + self.acb_lib = acb_lib + self.psb_lib = psb_lib + self.dbd_lib = dbd_lib + self.reslib = reslib + self.steplib = steplib + self.build_psb = build_psb + self._assert_valid_input_types() + + def _assert_valid_input_types(self): + """This assertion function validates that all parameters are the correct data type. + Raises: + TypeError: Raised if parameter is the wrong data type. + """ + if self.command_input and not isinstance(self.command_input, str): + raise TypeError(em.INCORRECT_COMMAND_INPUT_TYPE) + if self.build_psb and not isinstance(self.build_psb, bool): + raise TypeError(em.INCORRECT_BUILD_PSB_TYPE) + + def _build_utility_statements(self): + """Builds the list of DDStatements that will be provided zos_mvs_raw's execute function + based on the user input. + + Returns: + (list[DDStatement]): List of DDStatements + """ + acbgen_utility_fields = [] + ims_dataset_list = [] + sysprint = DDStatement("SYSPRINT", StdoutDefinition()) + acbgen_utility_fields.append(sysprint) + + print("Build DD statement: ") + print("steplib: ", self.steplib) + if self.steplib: + steplib_data_set_definitions = [DatasetDefinition(steplib) for steplib in self.steplib] + steplib = DDStatement("STEPLIB", steplib_data_set_definitions) + acbgen_utility_fields.append(steplib) + # else: + # try: + # steplib = env_fallback('STEPLIB') + # except AnsibleFallbackNotFound as e: + # # TODO + + if self.reslib: + reslib_data_set_definitions = [DatasetDefinition(reslib) for reslib in self.reslib] + reslib = DDStatement("DFSRESLB", reslib_data_set_definitions) + acbgen_utility_fields.append(reslib) + + if self.psb_lib: + psblib_data_set_definitions = [DatasetDefinition(psblib) for psblib in self.psb_lib] + ims_dataset_list.append(psblib_data_set_definitions) + print("print psblib2: ", self.psb_lib) + + if self.dbd_lib: + dbdlib_data_set_definitions = [DatasetDefinition(dbdlib) for dbdlib in self.dbd_lib] + ims_dataset_list.append(dbdlib_data_set_definitions) + print("print dbdlib: ", self.dbd_lib) + + print("Within the list: ") + for i in ims_dataset_list: + print("List : ", i) + #print(" ".join(ims_dataset_list)) + ims_data_set_definitions = DDStatement("IMS", ims_dataset_list) + print(" After the list: ") + acbgen_utility_fields.append(ims_data_set_definitions) + print(" IMS Dataset list: ") + + if self.acb_lib: + acblib_data_set_definitions = DDStatement("IMSACB", DatasetDefinition(self.acb_lib)) + acbgen_utility_fields.append(acblib_data_set_definitions) + print("print acblib: ", self.acb_lib) + + compctl_stdin_definitions = DDStatement("COMPCTL", StdinDefinition(" COPY INDD=IMSACB,OUTDD=IMSACB")) + acbgen_utility_fields.append(compctl_stdin_definitions) + + print("Build DD statement 2: ") + #Generate DD statements for commands + psb_name_str = "" + if command_input: + if psb_name: + psb_name_str, psb = split_lines_psb(command_input, psb_name) + + if psb_name_str: + if psb: + psb_name_str = ' ' + psb + else: + psb_name_str = psb + print("psb command: ", psb_name_str) + commandList.append(psb_name_str) + elif psb: + msg = 'A PSB named ' + str(psb) + ' provided in the module input was not found.' + result['rc'] = -1 + result['msg'] = msg + return result + + dbd_name_str = "" + if dbd_name: + dbd_name_str, dbd = split_lines_dbd(command_input, dbd_name, build_psb) + if dbd_name_str: + dbd_name_str = ' ' + dbd + commandList.append(dbd_name_str) + else: + msg = 'A DBD named ' + str(dbd) + ' provided in the module input was not found.' + result['rc'] = -1 + result['msg'] = msg + return result + + command_stdin_definitions = DDStatement("SYSIN",StdinDefinition("\n".join(commandList))) + acbgen_utility_fields.append(command_stdin_definitions) + return acbgen_utility_fields + + # def str_or_list_of_str(contents, dependencies): + # print("contents: ", contents) + # if isinstance(contents, list): + # for item in contents: + # if not isinstance(item, str): + # raise ValueError( + # "Items provided in list do not match the string type expected." + # ) + # elif isinstance(contents, str): + # contents = [contents] # make this a list of strings to consistent format + # else: + # raise ValueError( + # "Incorrect type provided. A string or list of strings is expected" + # ) + # return contents + + def split_lines_psb(command_input, psbnames): + return_arr = [] + return_bool = False + if len(psbnames) < 6: + return_bool, return_str = build_psb_name_string(command_input, psbnames) + return return_bool, return_str + else: + for i in range(0, len(psbnames), 5): + new_db_names_five = psbnames[i: i + 5] + return_bool, psb_line = build_psb_name_string(command_input, new_db_names_five) + return_arr.append(psb_line) + return return_bool, "\n ".join(return_arr) + return return_bool, return_arr + + def build_psb_name_string(command_input, psbnames): + psb_str = "" + if psbnames: + for psb in psbnames: + #if a match is not found + if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', psb, re.IGNORECASE): + return False, psb + else: + # if a match is found + if psb == "ALL": + psb_str = command_input + " PSB=ALL" + break + else: + psb_str = command_input + " PSB=(" + ",".join(psbnames) + ")" + return True, psb_str + + def split_lines_dbd(command_input, dbdnames, bldpsb): + return_arr = [] + return_bool = False + if len(dbdnames) < 6: + return_bool, return_str = build_dbd_name_string(command_input, dbdnames, bldpsb) + return return_bool, return_str + else: + for i in range(0, len(dbdnames), 5): + new_db_names_five = dbdnames[i: i + 5] + return_bool, dbd_line = build_dbd_name_string(command_input, new_db_names_five, bldpsb) + return_arr.append(dbd_line) + return return_bool, "\n ".join(return_arr) + return return_bool, return_arr + + def build_dbd_name_string(command_input, dbdnames, bldpsb): + dbd_str = "" + bldpsb_value = "" + if bldpsb: + bldpsb_value = "YES" + else: + bldpsb_value = "NO" + + if dbdnames: + for dbd in dbdnames: + #if a match is not found + if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', dbd, re.IGNORECASE): + return False, dbd + else: + # if a match is found + if dbdnames and bldpsb: + dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" + elif dbdnames and command_input == "BUILD": + dbd_str = ( + command_input + + " DBD=(" + + ",".join(dbdnames) + + ")" + + ",BLDPSB=" + + bldpsb_value + ) + elif dbdnames: + dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" + return True, dbd_str + + + def execute(self): + """ + """ + print("Within Interface: ") + param_string = 'UPB,{0}'.format(self.compression) + + try: + #print("Within Interface: ") + acbgen_utility_fields = self._build_utility_statements() + + response = MVSCmd.execute(acbgen.ACBGEN_UTILITY, acbgen_utility_fields, param_string, verbose=True) + result = { + "rc": response.rc, + "output": response.stdout, + "error": response.stderr, + # "changed": True + } + #changed + #msg + #content + except Exception as e: + result = { + "changed": False, + "rc": None, + "error": repr(e), + } + + finally: + return result + + + + \ No newline at end of file diff --git a/plugins/module_utils/ims_module_error_messages.py b/plugins/module_utils/ims_module_error_messages.py index 604a9df6..5ecc232a 100755 --- a/plugins/module_utils/ims_module_error_messages.py +++ b/plugins/module_utils/ims_module_error_messages.py @@ -12,4 +12,23 @@ class ErrorMessages(): NON_ZERO_ERR_MSG = "Refer to IMS return codes." REXX_RETURN_CODE_MSG = "The following REXX error code was returned: " SUBMISSION_ERROR_MSG = "Error submitting IMS Command." - SUCCESS_MSG = "Success" \ No newline at end of file + SUCCESS_MSG = "Success" + +class ACBGENErrorMessages(): + INCORRECT_COMMAND_INPUT_TYPE = "'command_input' must be a string." + INCORRECT_COMPRESSION_TYPE = "'compression' must be a string - PRECOMP,POSTCOMP, in any combination. The default is none." + INCORRECT_PSB_NAME_TYPE = "'psb_name' must be string(ALL) or list of strings." + INCORRECT_DBD_NAME_TYPE = "'dbd_name' must be a string or list of strings." + INCORRECT_ACBLIB_TYPE = "'acb_lib' must be a string." + INCORRECT_PSBLIB_TYPE = "'psb_lib' must be string or list of strings." + INCORRECT_DBDLIB_TYPE = "'dbd_lib' must be string or list of strings." + INCORRECT_RESLIB_TYPE = "step_lib' must be string or list of strings." + INCORRECT_STEPLIB_TYPE = "res_lib' must be string or list of strings." + INCORRECT_BUILD_PSB_TYPE = "'build_psb' must be boolean value - yes, no or true, false" + COMMAND_INPUT_REQUIREMENT_MSG = "'command_input' must be specified" + ACBLIB_REQUIREMENT_MSG = "'acb_lib' must be specified " + PSBLIB_REQUIREMENT_MSG = "'psb_lib' must be specified" + DBDLIB_REQUIREMENT_MSG = "'dbd_lib' must be specified" + SUCCESS_MSG = "ACBGEN execution is successful." + FAILURE_MSG = "Failure. See output for details." + EMPTY_OUTPUT_MSG = "ACBGEN could not be processed. Please check input parameters." \ No newline at end of file diff --git a/plugins/modules/ims_acb_gen.py b/plugins/modules/ims_acb_gen.py index 6677f3aa..f33400b9 100644 --- a/plugins/modules/ims_acb_gen.py +++ b/plugins/modules/ims_acb_gen.py @@ -190,9 +190,7 @@ ''' from ansible.module_utils.basic import AnsibleModule, env_fallback, AnsibleFallbackNotFound -from ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.ims_gen_utils import ( - submit_uss_jcl, -) +from ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.acbgen.acbgen import acbgen # pylint: disable=import-error from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.dd_statement import ( # pylint: disable=import-error DDStatement, FileDefinition, @@ -202,7 +200,6 @@ ) from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.better_arg_parser import BetterArgParser # pylint: disable=import-error from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.zos_raw import MVSCmd # pylint: disable=import-error -# import ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.dataset_utils import tempfile import re from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.import_handler import ( # pylint: disable=import-error @@ -235,181 +232,155 @@ def str_or_list_of_str(contents, dependencies): ) return contents -def split_lines_psb(command_input, psbnames): - return_arr = [] - return_bool = False - if len(psbnames) < 6: - return_bool, return_str = build_psb_name_string(command_input, psbnames) - return return_bool, return_str - else: - for i in range(0, len(psbnames), 5): - new_db_names_five = psbnames[i: i + 5] - return_bool, psb_line = build_psb_name_string(command_input, new_db_names_five) - return_arr.append(psb_line) - return return_bool, "\n ".join(return_arr) - return return_bool, return_arr - -def build_psb_name_string(command_input, psbnames): - psb_str = "" - if psbnames: - for psb in psbnames: - #if a match is not found - if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', psb, re.IGNORECASE): - return False, psb - else: - # if a match is found - if psb == "ALL": - psb_str = command_input + " PSB=ALL" - break - else: - psb_str = command_input + " PSB=(" + ",".join(psbnames) + ")" - return True, psb_str - -def split_lines_dbd(command_input, dbdnames, bldpsb): - return_arr = [] - return_bool = False - if len(dbdnames) < 6: - return_bool, return_str = build_dbd_name_string(command_input, dbdnames, bldpsb) - return return_bool, return_str - else: - for i in range(0, len(dbdnames), 5): - new_db_names_five = dbdnames[i: i + 5] - return_bool, dbd_line = build_dbd_name_string(command_input, new_db_names_five, bldpsb) - return_arr.append(dbd_line) - return return_bool, "\n ".join(return_arr) - return return_bool, return_arr - -def build_dbd_name_string(command_input, dbdnames, bldpsb): - dbd_str = "" - bldpsb_value = "" - if bldpsb: - bldpsb_value = "YES" - else: - bldpsb_value = "NO" - - if dbdnames: - for dbd in dbdnames: - #if a match is not found - if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', dbd, re.IGNORECASE): - return False, dbd - else: - # if a match is found - if dbdnames and bldpsb: - dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" - elif dbdnames and command_input == "BUILD": - dbd_str = ( - command_input - + " DBD=(" - + ",".join(dbdnames) - + ")" - + ",BLDPSB=" - + bldpsb_value - ) - elif dbdnames: - dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" - return True, dbd_str - - def run_module(): - module_args = dict( - command_input=dict(type="str", required=True), - compression=dict(type="str", required=False, default=""), - psb_name=dict(type="list", elements="str", required=False), - dbd_name=dict(type="list", elements="str", required=False), - acb_lib=dict(type="str", required=True), - psb_lib=dict(type="list", required=True), - dbd_lib=dict(type="list", required=True), - reslib=dict(type="list", required=False), - steplib=dict(type="list", required=False), - build_psb=dict(type="bool", required=False, default=True), + global module + + module_args = dict( + command_input=dict(type="str", required=True), + compression=dict(type="str", required=False, default=""), + psb_name=dict(type="list", elements="str", required=False), + dbd_name=dict(type="list", elements="str", required=False), + acb_lib=dict(type="str", required=True), + psb_lib=dict(type="list", required=True), + dbd_lib=dict(type="list", required=True), + reslib=dict(type="list", required=False), + steplib=dict(type="list", required=False), + build_psb=dict(type="bool", required=False, default=True), + ) + + result = dict( + changed=False, + msg='', ) - global module - module = AnsibleModule( - argument_spec=module_args, - supports_check_mode=True) + module = AnsibleModule( + argument_spec=module_args, + supports_check_mode=True) + + # Retrieve properties set by the user + module_defs = dict( + command_input=dict(arg_type="str", required=True), + compression=dict(arg_type="str", required=False, default=""), + psb_name=dict(arg_type=str_or_list_of_str, required=False), + dbd_name=dict(arg_type=str_or_list_of_str, required=False), #elements="str", + acb_lib=dict(arg_type="str", required=True), + psb_lib=dict(arg_type="list", elements="str", required=True), + dbd_lib=dict(arg_type="list", elements="str", required=True), + reslib=dict(arg_type="list", elements="str", required=False), + steplib=dict(arg_type="list", elements="str", required=False), + build_psb=dict(arg_type="bool", required=False, default=True), + ) + + # Parse the properties + parser = BetterArgParser(module_defs) + parsed_args = parser.parse_args(module.params) + + print("Before calling the interface:") + + command_input = parsed_args.get("command_input") + compression = parsed_args.get("compression") + psb_name = parsed_args.get("psb_name") + dbd_name = parsed_args.get("dbd_name") + acb_lib = parsed_args.get("acb_lib") + psb_lib = parsed_args.get("psb_lib") + dbd_lib = parsed_args.get("dbd_lib") + reslib = parsed_args.get("reslib") + steplib = parsed_args.get("steplib") + build_psb = parsed_args.get("build_psb") + + try: + response = acbgen( + command_input, + compression, + psb_name, + dbd_name, + acb_lib, + psb_lib, + dbd_lib, + reslib, + steplib, + build_psb).execute() + + result['changed'] = True + + # # if not result['acbgen_output']: + # if response['rc'] and response['rc']) > 4: + # result['msg'] = response['error'] + # else: + # result['msg'] = em.EMPTY_OUTPUT_MSG + + # if response['error']: + # print("An error occurred:", response['error']) + # result['changed'] = False + # module.fail_json(**result) + # else: + # result['msg'] = em.SUCCESS_MSG + except Exception as e: + result['msg'] = e + module.fail_json(**result) - result = {} - result["changed"] = False - - - # Retrieve properties set by the user - module_defs = dict( - command_input=dict(arg_type="str", required=True), - compression=dict(arg_type="str", required=False, default=""), - psb_name=dict(arg_type=str_or_list_of_str, required=False), - dbd_name=dict(arg_type=str_or_list_of_str, required=False), #elements="str", - acb_lib=dict(arg_type="str", required=True), - psb_lib=dict(arg_type="list", elements="str", required=True), - dbd_lib=dict(arg_type="list", elements="str", required=True), - reslib=dict(arg_type="list", elements="str", required=False), - steplib=dict(arg_type="list", elements="str", required=False), - build_psb=dict(arg_type="bool", required=False, default=True), - ) + finally: + pass - # Parse the properties - parser = BetterArgParser(module_defs) - parsed_args = parser.parse_args(module.params) + module.exit_json(**result) - command_input = parsed_args.get("command_input") - compression = parsed_args.get("compression") - psb_name = parsed_args.get("psb_name") - dbd_name = parsed_args.get("dbd_name") - acb_lib = parsed_args.get("acb_lib") - psb_lib = parsed_args.get("psb_lib") - dbd_lib = parsed_args.get("dbd_lib") - reslib = parsed_args.get("reslib") - steplib = parsed_args.get("steplib") - build_psb = parsed_args.get("build_psb") +def main(): + run_module() +if __name__ == "__main__": + main() + #DD statement Generation - dDStatementList = [] - imsDatasetList = [] - commandList = [] + # dDStatementList = [] + # imsDatasetList = [] + # commandList = [] - # #Generate DD statement for SYSPRINT - sysDefinition = StdoutDefinition() - sysprintDDStatement = DDStatement("SYSPRINT", sysDefinition) - dDStatementList.append(sysprintDDStatement) + #Generate DD statement for SYSPRINT + # sysDefinition = StdoutDefinition() + # sysprintDDStatement = DDStatement("SYSPRINT", sysDefinition) + # dDStatementList.append(sysprintDDStatement) #Generate DD statement for STEPLIB - if steplib: - steplibDatasets = [DatasetDefinition(step) for step in steplib] - steplibDDStatement = DDStatement("STEPLIB", steplibDatasets) - # dDStatementList.append(steplibDDStatement) DatasetDefinition(steplib) - else: - try: - steplib = env_fallback('STEPLIB') #task_vars.get("environment_vars") - print("STEPLIB: ", steplib) - except AnsibleFallbackNotFound as e: - module.fail_json(msg="The input option 'steplib' is not provided. Please provide it in the environment " - "variables 'STEPLIB', or in the module input option 'steplib'. ", **result) + # if steplib: + # steplibDatasets = [DatasetDefinition(step) for step in steplib] + # steplibDDStatement = DDStatement("STEPLIB", steplibDatasets) + # # dDStatementList.append(steplibDDStatement) DatasetDefinition(steplib) + # else: + # try: + # steplib = env_fallback('STEPLIB') #task_vars.get("environment_vars") + # print("STEPLIB: ", steplib) + # except AnsibleFallbackNotFound as e: + # module.fail_json(msg="The input option 'steplib' is not provided. Please provide it in the environment " + # "variables 'STEPLIB', or in the module input option 'steplib'. ", **result) - # if env is not None: - # env_steplib = env.get("STEPLIB") - # else: - # env_steplib = task_vars.get("STEPLIB") - steplibDDStatement = DDStatement("STEPLIB", DatasetDefinition(steplib)) - dDStatementList.append(steplibDDStatement) + # if not steplib: + # try: + # steplib = env_fallback('STEPLIB') + # except AnsibleFallbackNotFound as e: + # module.fail_json(msg="The input option 'steplib' is not provided. Please provide it in the environment " + # "variables 'STEPLIB', or in the module input option 'steplib'. ", **result) + + # steplibDDStatement = DDStatement("STEPLIB", DatasetDefinition(steplib)) + # dDStatementList.append(steplibDDStatement) #Generate DD statement for RESLIB - if reslib: - reslibDatasets = [DatasetDefinition(dfsres) for dfsres in reslib] - dfsreslbDDStatement = DDStatement("DFSRESLB", reslibDatasets) # DatasetDefinition(reslib) - dDStatementList.append(dfsreslbDDStatement) + # if reslib: + # reslibDatasets = [DatasetDefinition(dfsres) for dfsres in reslib] + # dfsreslbDDStatement = DDStatement("DFSRESLB", reslibDatasets) # DatasetDefinition(reslib) + # dDStatementList.append(dfsreslbDDStatement) #Generate DD statements for DBDLIB and PSBLIB - if psb_lib: - psbDatasets = [DatasetDefinition(psb) for psb in psb_lib] - imsDatasetList += psbDatasets - if dbd_lib: - dbdDatasets = [DatasetDefinition(dbd) for dbd in dbd_lib] - imsDatasetList += dbdDatasets - if imsDatasetList: - imsDDStatement = DDStatement("IMS", imsDatasetList) - dDStatementList.append(imsDDStatement) + # if psb_lib: + # psbDatasets = [DatasetDefinition(psb) for psb in psb_lib] + # imsDatasetList += psbDatasets + # if dbd_lib: + # dbdDatasets = [DatasetDefinition(dbd) for dbd in dbd_lib] + # imsDatasetList += dbdDatasets + # if imsDatasetList: + # imsDDStatement = DDStatement("IMS", imsDatasetList) + # dDStatementList.append(imsDDStatement) # if psb_lib: # psbDataset = DatasetDefinition(psb_lib) @@ -421,70 +392,64 @@ def run_module(): # imsDDStatement = DDStatement("IMS", imsDatasetList) # dDStatementList.append(imsDDStatement) - #Generate DD statement for ACBLIB - if acb_lib: - acbDataset = DDStatement("IMSACB", DatasetDefinition(acb_lib)) - dDStatementList.append(acbDataset) - - #Generate DD statement for COMPCTL - compctlDDStatement = DDStatement("COMPCTL", StdinDefinition(" COPY INDD=IMSACB,OUTDD=IMSACB")) - dDStatementList.append(compctlDDStatement) - - - #Generate DD statements for commands - psb_name_str = "" - if command_input: - if psb_name: - psb_name_str, psb = split_lines_psb(command_input, psb_name) - - if psb_name_str: - if psb: - psb_name_str = ' ' + psb - else: - psb_name_str = psb - commandList.append(psb_name_str) - elif psb: - msg = 'A PSB named ' + str(psb) + ' provided in the module input was not found.' - result['rc'] = -1 - result['msg'] = msg - return result - - dbd_name_str = "" - if dbd_name: - dbd_name_str, dbd = split_lines_dbd(command_input, dbd_name, build_psb) - if dbd_name_str: - dbd_name_str = ' ' + dbd - commandList.append(dbd_name_str) - else: - msg = 'A DBD named ' + str(dbd) + ' provided in the module input was not found.' - result['rc'] = -1 - result['msg'] = msg - return result + # #Generate DD statement for ACBLIB + # if acb_lib: + # acbDataset = DDStatement("IMSACB", DatasetDefinition(acb_lib)) + # dDStatementList.append(acbDataset) + + # #Generate DD statement for COMPCTL + # compctlDDStatement = DDStatement("COMPCTL", StdinDefinition(" COPY INDD=IMSACB,OUTDD=IMSACB")) + # dDStatementList.append(compctlDDStatement) + + + # #Generate DD statements for commands + # psb_name_str = "" + # if command_input: + # if psb_name: + # psb_name_str, psb = split_lines_psb(command_input, psb_name) + + # if psb_name_str: + # if psb: + # psb_name_str = ' ' + psb + # else: + # psb_name_str = psb + # commandList.append(psb_name_str) + # elif psb: + # msg = 'A PSB named ' + str(psb) + ' provided in the module input was not found.' + # result['rc'] = -1 + # result['msg'] = msg + # return result + + # dbd_name_str = "" + # if dbd_name: + # dbd_name_str, dbd = split_lines_dbd(command_input, dbd_name, build_psb) + # if dbd_name_str: + # dbd_name_str = ' ' + dbd + # commandList.append(dbd_name_str) + # else: + # msg = 'A DBD named ' + str(dbd) + ' provided in the module input was not found.' + # result['rc'] = -1 + # result['msg'] = msg + # return result #raise ValueError("/n".join(commandList)) - commandDDStatement = DDStatement("SYSIN",StdinDefinition("\n".join(commandList))) ) + # commandDDStatement = DDStatement("SYSIN",StdinDefinition("\n".join(commandList))) - dDStatementList.append(commandDDStatement) - - paramString = 'UPB,{0}'.format(compression) - - try: - response = MVSCmd.execute("DFSRRC00", dDStatementList, paramString, verbose=True) - result["response"] = { - "rc": response.rc, - "stdout": response.stdout, - "stderr": response.stderr, - } - except Exception as e: - module.fail_json(msg=repr(e), **result) - finally: - module.exit_json(**result) + # dDStatementList.append(commandDDStatement) + + # paramString = 'UPB,{0}'.format(compression) + + # try: + # response = MVSCmd.execute("DFSRRC00", dDStatementList, paramString, verbose=True) + # result["response"] = { + # "rc": response.rc, + # "stdout": response.stdout, + # "stderr": response.stderr, + # "changed": True + # } + # except Exception as e: + # module.fail_json(msg=repr(e), **result) + # finally: + # module.exit_json(**result) - -def main(): - run_module() - - -if __name__ == "__main__": - main() diff --git a/tests/run.sh b/tests/run.sh index a209865d..95b25018 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -12,3 +12,6 @@ export ANSIBLE_CONNECTION_PLUGINS=${plugins_dir}/connection export ANSIBLE_CONFIG=$(pwd)/ansible.cfg python3 -m pytest --host-pattern=all --zinventory=${1:-test_config.yml} $2 -vvv + + +# ./run.sh test_config.yml functional/modules/ims_acb_gen/test_ims_acb_gen_sample.py \ No newline at end of file From e37ca583ba960af3cdb351a19aa9e6dec8400017 Mon Sep 17 00:00:00 2001 From: Dipti Date: Thu, 9 Jul 2020 14:18:47 -0700 Subject: [PATCH 03/21] checked-in python interface - ACBGEN --- plugins/module_utils/acbgen.py | 259 +++++++----------- plugins/modules/ims_acb_gen.py | 167 +++-------- .../module_utils/ims_test_gen_utils.py | 2 +- 3 files changed, 136 insertions(+), 292 deletions(-) diff --git a/plugins/module_utils/acbgen.py b/plugins/module_utils/acbgen.py index 186c3771..f2d4365a 100644 --- a/plugins/module_utils/acbgen.py +++ b/plugins/module_utils/acbgen.py @@ -35,7 +35,6 @@ def __init__(self, command_input, compression, psb_name, dbd_name, acb_lib, psb_ Args: """ - print("Within contructor: ") self.command_input = command_input self.compression = compression self.psb_name = psb_name @@ -47,6 +46,7 @@ def __init__(self, command_input, compression, psb_name, dbd_name, acb_lib, psb_ self.steplib = steplib self.build_psb = build_psb self._assert_valid_input_types() + self.result = {} def _assert_valid_input_types(self): """This assertion function validates that all parameters are the correct data type. @@ -70,17 +70,10 @@ def _build_utility_statements(self): sysprint = DDStatement("SYSPRINT", StdoutDefinition()) acbgen_utility_fields.append(sysprint) - print("Build DD statement: ") - print("steplib: ", self.steplib) if self.steplib: steplib_data_set_definitions = [DatasetDefinition(steplib) for steplib in self.steplib] steplib = DDStatement("STEPLIB", steplib_data_set_definitions) acbgen_utility_fields.append(steplib) - # else: - # try: - # steplib = env_fallback('STEPLIB') - # except AnsibleFallbackNotFound as e: - # # TODO if self.reslib: reslib_data_set_definitions = [DatasetDefinition(reslib) for reslib in self.reslib] @@ -88,188 +81,140 @@ def _build_utility_statements(self): acbgen_utility_fields.append(reslib) if self.psb_lib: - psblib_data_set_definitions = [DatasetDefinition(psblib) for psblib in self.psb_lib] - ims_dataset_list.append(psblib_data_set_definitions) - print("print psblib2: ", self.psb_lib) - + for psblib in self.psb_lib: + ims_dataset_list.append(DatasetDefinition(psblib)) if self.dbd_lib: - dbdlib_data_set_definitions = [DatasetDefinition(dbdlib) for dbdlib in self.dbd_lib] - ims_dataset_list.append(dbdlib_data_set_definitions) - print("print dbdlib: ", self.dbd_lib) - - print("Within the list: ") - for i in ims_dataset_list: - print("List : ", i) - #print(" ".join(ims_dataset_list)) - ims_data_set_definitions = DDStatement("IMS", ims_dataset_list) - print(" After the list: ") - acbgen_utility_fields.append(ims_data_set_definitions) - print(" IMS Dataset list: ") + for dbdlib in self.dbd_lib: + ims_dataset_list.append(DatasetDefinition(dbdlib)) + + if ims_dataset_list: + ims_data_set_definitions = DDStatement("IMS", ims_dataset_list) + acbgen_utility_fields.append(ims_data_set_definitions) if self.acb_lib: acblib_data_set_definitions = DDStatement("IMSACB", DatasetDefinition(self.acb_lib)) acbgen_utility_fields.append(acblib_data_set_definitions) - print("print acblib: ", self.acb_lib) compctl_stdin_definitions = DDStatement("COMPCTL", StdinDefinition(" COPY INDD=IMSACB,OUTDD=IMSACB")) acbgen_utility_fields.append(compctl_stdin_definitions) - print("Build DD statement 2: ") + commandList = [] #Generate DD statements for commands - psb_name_str = "" - if command_input: - if psb_name: - psb_name_str, psb = split_lines_psb(command_input, psb_name) - - if psb_name_str: - if psb: - psb_name_str = ' ' + psb - else: - psb_name_str = psb - print("psb command: ", psb_name_str) - commandList.append(psb_name_str) - elif psb: - msg = 'A PSB named ' + str(psb) + ' provided in the module input was not found.' - result['rc'] = -1 - result['msg'] = msg - return result - + if self.command_input: + psb_name_str = "" + if self.psb_name: + psb_name_str = " " + self._split_lines_psb()#_format_psb_command() + commandList.append(psb_name_str) dbd_name_str = "" - if dbd_name: - dbd_name_str, dbd = split_lines_dbd(command_input, dbd_name, build_psb) - if dbd_name_str: - dbd_name_str = ' ' + dbd - commandList.append(dbd_name_str) - else: - msg = 'A DBD named ' + str(dbd) + ' provided in the module input was not found.' - result['rc'] = -1 - result['msg'] = msg - return result + if self.dbd_name: + dbd_name_str = " " + self._split_lines_dbd() + commandList.append(dbd_name_str) + for a in commandList: + print(" commandList: ", a) command_stdin_definitions = DDStatement("SYSIN",StdinDefinition("\n".join(commandList))) acbgen_utility_fields.append(command_stdin_definitions) + return acbgen_utility_fields - - # def str_or_list_of_str(contents, dependencies): - # print("contents: ", contents) - # if isinstance(contents, list): - # for item in contents: - # if not isinstance(item, str): - # raise ValueError( - # "Items provided in list do not match the string type expected." - # ) - # elif isinstance(contents, str): - # contents = [contents] # make this a list of strings to consistent format - # else: - # raise ValueError( - # "Incorrect type provided. A string or list of strings is expected" - # ) - # return contents - - def split_lines_psb(command_input, psbnames): - return_arr = [] - return_bool = False - if len(psbnames) < 6: - return_bool, return_str = build_psb_name_string(command_input, psbnames) - return return_bool, return_str - else: - for i in range(0, len(psbnames), 5): - new_db_names_five = psbnames[i: i + 5] - return_bool, psb_line = build_psb_name_string(command_input, new_db_names_five) - return_arr.append(psb_line) - return return_bool, "\n ".join(return_arr) - return return_bool, return_arr + + def _split_lines_psb(self): + return_str = "" + return_arr = [] + psbnames = self.psb_name + if len(psbnames) < 6: + return_str = self._build_psb_name_string(self.command_input, psbnames) + return return_str + else: + for i in range(0, len(psbnames), 5): + new_psb_names_five = psbnames[i: i + 5] + psb_line = self._build_psb_name_string(self.command_input, new_psb_names_five) + return_arr.append(psb_line) + return "\n ".join(return_arr) + return return_arr - def build_psb_name_string(command_input, psbnames): - psb_str = "" - if psbnames: - for psb in psbnames: - #if a match is not found - if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', psb, re.IGNORECASE): - return False, psb - else: - # if a match is found - if psb == "ALL": - psb_str = command_input + " PSB=ALL" - break - else: - psb_str = command_input + " PSB=(" + ",".join(psbnames) + ")" - return True, psb_str - - def split_lines_dbd(command_input, dbdnames, bldpsb): - return_arr = [] - return_bool = False - if len(dbdnames) < 6: - return_bool, return_str = build_dbd_name_string(command_input, dbdnames, bldpsb) - return return_bool, return_str - else: - for i in range(0, len(dbdnames), 5): - new_db_names_five = dbdnames[i: i + 5] - return_bool, dbd_line = build_dbd_name_string(command_input, new_db_names_five, bldpsb) - return_arr.append(dbd_line) - return return_bool, "\n ".join(return_arr) - return return_bool, return_arr - - def build_dbd_name_string(command_input, dbdnames, bldpsb): - dbd_str = "" - bldpsb_value = "" - if bldpsb: - bldpsb_value = "YES" - else: - bldpsb_value = "NO" - - if dbdnames: - for dbd in dbdnames: - #if a match is not found - if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', dbd, re.IGNORECASE): - return False, dbd - else: - # if a match is found - if dbdnames and bldpsb: - dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" - elif dbdnames and command_input == "BUILD": - dbd_str = ( - command_input - + " DBD=(" - + ",".join(dbdnames) - + ")" - + ",BLDPSB=" - + bldpsb_value - ) - elif dbdnames: - dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" - return True, dbd_str + def _build_psb_name_string(self, command_input, psbnames): + psb_str = "" + if psbnames: + for psb in psbnames: + #if a match is not found + if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', psb, re.IGNORECASE): + return psb + else: + # if a match is found + if psb == "ALL": + psb_str = command_input + " PSB=ALL" + break + else: + psb_str = command_input + " PSB=(" + ",".join(psbnames) + ")" + return psb_str + + def _split_lines_dbd(self): + return_str = "" + return_arr = [] + dbdnames = self.dbd_name + if len(dbdnames) < 6: + return_str = self._build_dbd_name_string(self.command_input, dbdnames, self.build_psb) + return return_str + else: + for i in range(0, len(dbdnames), 5): + new_db_names_five = dbdnames[i: i + 5] + dbd_line = self._build_dbd_name_string(self.command_input, new_db_names_five, self.build_psb) + return_arr.append(dbd_line) + return "\n ".join(return_arr) + return return_arr + + def _build_dbd_name_string(self, command_input, dbdnames, build_psb): + dbd_str = "" + bldpsb_value = "" + if build_psb: + bldpsb_value = "YES" + else: + bldpsb_value = "NO" + + if dbdnames: + for dbd in dbdnames: + #if a match is not found + if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', dbd, re.IGNORECASE): + return dbd + else: + # if a match is found + if dbdnames and build_psb: + dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" + elif dbdnames and command_input == "BUILD": + dbd_str = ( + command_input + + " DBD=(" + + ",".join(dbdnames) + + ")" + + ",BLDPSB=" + + bldpsb_value + ) + elif dbdnames: + dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" + return dbd_str def execute(self): """ """ - print("Within Interface: ") param_string = 'UPB,{0}'.format(self.compression) try: - #print("Within Interface: ") acbgen_utility_fields = self._build_utility_statements() - response = MVSCmd.execute(acbgen.ACBGEN_UTILITY, acbgen_utility_fields, param_string, verbose=True) - result = { + self.result = { "rc": response.rc, "output": response.stdout, "error": response.stderr, - # "changed": True } - #changed - #msg - #content except Exception as e: - result = { - "changed": False, - "rc": None, - "error": repr(e), + self.result = { + "rc": response.rc, + "output": response.stdout, + "error": response.stderr, } - finally: - return result + return self.result diff --git a/plugins/modules/ims_acb_gen.py b/plugins/modules/ims_acb_gen.py index f33400b9..d895665e 100644 --- a/plugins/modules/ims_acb_gen.py +++ b/plugins/modules/ims_acb_gen.py @@ -205,6 +205,7 @@ from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.import_handler import ( # pylint: disable=import-error MissingZOAUImport, ) +from ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.ims_module_error_messages import ACBGENErrorMessages as em import tempfile import pprint @@ -249,8 +250,12 @@ def run_module(): ) result = dict( - changed=False, + changed=True, msg='', + content='', + error='', + rc='', + debug='' ) module = AnsibleModule( @@ -275,8 +280,6 @@ def run_module(): parser = BetterArgParser(module_defs) parsed_args = parser.parse_args(module.params) - print("Before calling the interface:") - command_input = parsed_args.get("command_input") compression = parsed_args.get("compression") psb_name = parsed_args.get("psb_name") @@ -288,6 +291,16 @@ def run_module(): steplib = parsed_args.get("steplib") build_psb = parsed_args.get("build_psb") + if not steplib: + try: + steplib = [] + steplib_str = env_fallback('STEPLIB') + list_str = steplib_str.split(" ") + steplib += list_str + except AnsibleFallbackNotFound as e: + module.fail_json(msg="The input option 'steplib' is not provided. Please provide it in the environment " + "variables 'STEPLIB', or in the module input option 'steplib'. ", **result) + try: response = acbgen( command_input, @@ -301,13 +314,21 @@ def run_module(): steplib, build_psb).execute() - result['changed'] = True - - # # if not result['acbgen_output']: - # if response['rc'] and response['rc']) > 4: - # result['msg'] = response['error'] - # else: - # result['msg'] = em.EMPTY_OUTPUT_MSG + print(" response: ", response) + + # if not result['acbgen_output']: + if response['rc'] and int(response['rc']) > 4: + result['changed'] = False + result['msg'] = response['error'] + else: + result['content'] = response['output'] + result['changed'] = True + # result['rc'] = response['rc'] + result['error'] = response['error'] # ??? error when success + # result['msg'] = em.EMPTY_OUTPUT_MSG + result['msg'] = em.SUCCESS_MSG + if response['rc'] <= 4: + result['rc'] = '0' # if response['error']: # print("An error occurred:", response['error']) @@ -316,7 +337,7 @@ def run_module(): # else: # result['msg'] = em.SUCCESS_MSG except Exception as e: - result['msg'] = e + result['msg'] = repr(e) module.fail_json(**result) finally: @@ -329,127 +350,5 @@ def main(): if __name__ == "__main__": - main() - - #DD statement Generation - # dDStatementList = [] - # imsDatasetList = [] - # commandList = [] - - #Generate DD statement for SYSPRINT - # sysDefinition = StdoutDefinition() - # sysprintDDStatement = DDStatement("SYSPRINT", sysDefinition) - # dDStatementList.append(sysprintDDStatement) - - - #Generate DD statement for STEPLIB - # if steplib: - # steplibDatasets = [DatasetDefinition(step) for step in steplib] - # steplibDDStatement = DDStatement("STEPLIB", steplibDatasets) - # # dDStatementList.append(steplibDDStatement) DatasetDefinition(steplib) - # else: - # try: - # steplib = env_fallback('STEPLIB') #task_vars.get("environment_vars") - # print("STEPLIB: ", steplib) - # except AnsibleFallbackNotFound as e: - # module.fail_json(msg="The input option 'steplib' is not provided. Please provide it in the environment " - # "variables 'STEPLIB', or in the module input option 'steplib'. ", **result) - - # if not steplib: - # try: - # steplib = env_fallback('STEPLIB') - # except AnsibleFallbackNotFound as e: - # module.fail_json(msg="The input option 'steplib' is not provided. Please provide it in the environment " - # "variables 'STEPLIB', or in the module input option 'steplib'. ", **result) - - # steplibDDStatement = DDStatement("STEPLIB", DatasetDefinition(steplib)) - # dDStatementList.append(steplibDDStatement) - - #Generate DD statement for RESLIB - # if reslib: - # reslibDatasets = [DatasetDefinition(dfsres) for dfsres in reslib] - # dfsreslbDDStatement = DDStatement("DFSRESLB", reslibDatasets) # DatasetDefinition(reslib) - # dDStatementList.append(dfsreslbDDStatement) - - #Generate DD statements for DBDLIB and PSBLIB - # if psb_lib: - # psbDatasets = [DatasetDefinition(psb) for psb in psb_lib] - # imsDatasetList += psbDatasets - # if dbd_lib: - # dbdDatasets = [DatasetDefinition(dbd) for dbd in dbd_lib] - # imsDatasetList += dbdDatasets - # if imsDatasetList: - # imsDDStatement = DDStatement("IMS", imsDatasetList) - # dDStatementList.append(imsDDStatement) - - # if psb_lib: - # psbDataset = DatasetDefinition(psb_lib) - # imsDatasetList.append(psbDataset) - # if dbd_lib: - # dbdDataset = DatasetDefinition(dbd_lib) - # imsDatasetList.append(dbdDataset) - # if imsDatasetList: - # imsDDStatement = DDStatement("IMS", imsDatasetList) - # dDStatementList.append(imsDDStatement) - - # #Generate DD statement for ACBLIB - # if acb_lib: - # acbDataset = DDStatement("IMSACB", DatasetDefinition(acb_lib)) - # dDStatementList.append(acbDataset) - - # #Generate DD statement for COMPCTL - # compctlDDStatement = DDStatement("COMPCTL", StdinDefinition(" COPY INDD=IMSACB,OUTDD=IMSACB")) - # dDStatementList.append(compctlDDStatement) - - - # #Generate DD statements for commands - # psb_name_str = "" - # if command_input: - # if psb_name: - # psb_name_str, psb = split_lines_psb(command_input, psb_name) - - # if psb_name_str: - # if psb: - # psb_name_str = ' ' + psb - # else: - # psb_name_str = psb - # commandList.append(psb_name_str) - # elif psb: - # msg = 'A PSB named ' + str(psb) + ' provided in the module input was not found.' - # result['rc'] = -1 - # result['msg'] = msg - # return result - - # dbd_name_str = "" - # if dbd_name: - # dbd_name_str, dbd = split_lines_dbd(command_input, dbd_name, build_psb) - # if dbd_name_str: - # dbd_name_str = ' ' + dbd - # commandList.append(dbd_name_str) - # else: - # msg = 'A DBD named ' + str(dbd) + ' provided in the module input was not found.' - # result['rc'] = -1 - # result['msg'] = msg - # return result - - #raise ValueError("/n".join(commandList)) - - # commandDDStatement = DDStatement("SYSIN",StdinDefinition("\n".join(commandList))) - - # dDStatementList.append(commandDDStatement) - - # paramString = 'UPB,{0}'.format(compression) - - # try: - # response = MVSCmd.execute("DFSRRC00", dDStatementList, paramString, verbose=True) - # result["response"] = { - # "rc": response.rc, - # "stdout": response.stdout, - # "stderr": response.stderr, - # "changed": True - # } - # except Exception as e: - # module.fail_json(msg=repr(e), **result) - # finally: - # module.exit_json(**result) + main() diff --git a/tests/functional/module_utils/ims_test_gen_utils.py b/tests/functional/module_utils/ims_test_gen_utils.py index 2f485675..0014acae 100644 --- a/tests/functional/module_utils/ims_test_gen_utils.py +++ b/tests/functional/module_utils/ims_test_gen_utils.py @@ -81,7 +81,7 @@ class ACBInputParameters(): INVALID_DBD = ["DBD1$%HJ"] INVALID_DBDS = ["DBFSAMD3", "DBD1$%HJ"] INVALID_COMP = "INVALID" - INVALID_RECFOR = " IMSTESTU.ANSI.RECFOR" #invalid acblib with record format FB + INVALID_RECFOR = "IMSTESTU.ANSI.RECFOR" #invalid acblib with record format FB INVALID_PDSE = "IMSTESTU.ANSI.PDSE" EMPTY_PSBLIB = "IMSTESTU.ANSI.PSBLIB3" EMPTY_DBDLIB = "IMSTESTU.ANSI.DBDLIB3" \ No newline at end of file From 0af8bf42d407575a6dab6f12b4e88dc5a62ba5cb Mon Sep 17 00:00:00 2001 From: Dipti Date: Thu, 9 Jul 2020 17:04:43 -0700 Subject: [PATCH 04/21] acbgen interface --- plugins/module_utils/acbgen.py | 39 ++++++++++++++++++++++++++++------ plugins/modules/ims_acb_gen.py | 8 ++++--- tests/test_config.yml | 27 +++++++++++++++-------- 3 files changed, 55 insertions(+), 19 deletions(-) diff --git a/plugins/module_utils/acbgen.py b/plugins/module_utils/acbgen.py index f2d4365a..eaabc79f 100644 --- a/plugins/module_utils/acbgen.py +++ b/plugins/module_utils/acbgen.py @@ -25,16 +25,27 @@ class acbgen(): ACBGEN_UTILITY = "DFSRRC00" # REPLACEMENT_VALUES = { - # "YES": True - # "NO": False + # "True": YES + # "False": NO # } #def __init__(self, command_input, compression, psb_name=None, dbd_name=None, acb_lib, psb_lib, dbd_lib, reslib=None, steplib=None, build_psb): def __init__(self, command_input, compression, psb_name, dbd_name, acb_lib, psb_lib, dbd_lib, reslib, steplib, build_psb): """IMSAcbgen constructor for generating IMS ACB using zos_mvs_raw Args: - + command_input (str): 'BUILD' or 'DELETE' - command input to specify. + compression (str): 'PRECOMP','POSTCOMP' or 'PRECOMP,POSTCOMP' or default is none. + psb_name (list): 'ALL' or a list of psb names to be specified. + dbd_name (list): List of dbd names. + acb_lib (str): + psb_lib (list): List of psblib datasets. + dbd_lib (list): List of dbdlib datasets. + reslib (list): List of reslib datasets. + steplib (list): Points to the list of IMS SDFSRESL data set, which contains the IMS nucleus and required IMS modules. + build_psb (bool): TRUE for rebuilding all PSBs that reference the changed DBD, + FALSE for not rebuilding the PSBs that references teh changed DBD. """ + print(" COMP: ", compression) self.command_input = command_input self.compression = compression self.psb_name = psb_name @@ -55,11 +66,20 @@ def _assert_valid_input_types(self): """ if self.command_input and not isinstance(self.command_input, str): raise TypeError(em.INCORRECT_COMMAND_INPUT_TYPE) + if(self.compression and not isinstance(self.compression, str)): + raise TypeError(em.INCORRECT_COMPRESSION_TYPE) + if(self.acb_lib and not isinstance(self.acb_lib, str)): + raise TypeError(em.INCORRECT_ACBLIB_TYPE) + # if(self.dbd_name and not isinstance(self.dbd_name, str)): + # raise TypeError + # if(): + # if(): + # if(): if self.build_psb and not isinstance(self.build_psb, bool): raise TypeError(em.INCORRECT_BUILD_PSB_TYPE) def _build_utility_statements(self): - """Builds the list of DDStatements that will be provided zos_mvs_raw's execute function + """Builds the list of DDStatements that will be provided to the zos_mvs_raw's execute function based on the user input. Returns: @@ -103,7 +123,7 @@ def _build_utility_statements(self): if self.command_input: psb_name_str = "" if self.psb_name: - psb_name_str = " " + self._split_lines_psb()#_format_psb_command() + psb_name_str = " " + self._split_lines_psb() commandList.append(psb_name_str) dbd_name_str = "" if self.dbd_name: @@ -195,9 +215,14 @@ def _build_dbd_name_string(self, command_input, dbdnames, build_psb): def execute(self): + """Executes the ACBGEN utility DFSRRC00 using the zos_mvs_raw module based on the user input. + + Returns: + (dict): (1) rc: Return Code returned by zos_mvs_raw module. + (2) error: The stderr returned by the zos_raw module. + (3) output: The original output provided by zos_raw. """ - """ - param_string = 'UPB,{0}'.format(self.compression) + param_string = '\'' + 'UPB,{0}'.format(self.compression) + '\'' try: acbgen_utility_fields = self._build_utility_statements() diff --git a/plugins/modules/ims_acb_gen.py b/plugins/modules/ims_acb_gen.py index d895665e..c757d60e 100644 --- a/plugins/modules/ims_acb_gen.py +++ b/plugins/modules/ims_acb_gen.py @@ -102,7 +102,7 @@ notes: - The I(steplib) parameter can also be specified in the target inventory's environment_vars. - The I(steplib) input parameter to the module will take precedence over the value specified in the environment_vars. - - If only the I(steplib) parameter is specified, then only the I(steplib) concatination will be used to resolve the IMS RESLIB dataset. + - If only the I(steplib) parameter is specified, then only the I(steplib) concatenation will be used to resolve the IMS RESLIB dataset. - If both I(steplib) and I(reslib) are specified, then both parameters will be used by the ACB Maintenenace Utility and I(reslib) will be used to resolve the IMS RESLIB dataset. - Specifying only I(reslib) without I(steplib) is not supported. - The ACB Maintenenace utility SYSUT3/SYSUT4 DD options are not supported by this module. @@ -253,9 +253,9 @@ def run_module(): changed=True, msg='', content='', - error='', + #error='', rc='', - debug='' + #debug='' ) module = AnsibleModule( @@ -319,7 +319,9 @@ def run_module(): # if not result['acbgen_output']: if response['rc'] and int(response['rc']) > 4: result['changed'] = False + result['content'] = response['output'] result['msg'] = response['error'] + result['rc'] = response['rc'] else: result['content'] = response['output'] result['changed'] = True diff --git a/tests/test_config.yml b/tests/test_config.yml index 3d82e43a..ff1a227b 100755 --- a/tests/test_config.yml +++ b/tests/test_config.yml @@ -1,24 +1,31 @@ host: ec01105a.vmec.svl.ibm.com user: omvsadm python_path: /usr/lpp/izoda/v110/anaconda/bin/python3.6 + + environment: + ZOAU_ROOT: /u/omvsadm/mvsbuilds/103/mvsutil + PYTHON_ROOT: /u/omvsadm/mvsbuilds/103/mvsutil #/usr/lpp/izoda/v110/anaconda + JAVA_ROOT: /usr/lpp/java MANPATH: /usr/man/%L - FFI_LIB: "/usr/lpp/izoda/v110/anaconda/lib/ffi" + FFI_LIB: "/u/omvsadm/mvsbuilds/103/mvsutil/lib/ffi" RELEASE_NAME: python-2017-04-12 CURL_CA_BUNDLE: "/usr/lpp/izoda/v110/anaconda/etc/ssl/cacert.pem" RELEASE_DIR: /usr/lpp/rsusr/python27/python-2017-04-12-py27 RELEASE_TYPE: py27 - LIBPATH: "/usr/lpp/izoda/v110/anaconda/lib:/usr/lpp/zoautil/v100/lib:/lib:/usr/lib:." + LIBPATH: "/u/omvsadm/mvsbuilds/103/mvsutil/lib:/u/oeusr01/usr/lpp/IBM/cyp/v3r8/pyz/usr/lpp/IBM/cyp/v3r8/pyz/lib:/lib:/usr/lib:." + #LIBPATH: "/usr/lpp/izoda/v110/anaconda/lib:/usr/lpp/zoautil/v100/lib:/lib:/usr/lib:." NLSPATH: /usr/lib/nls/msg/%L/%N MAIL: /usr/mail/OMVSADM _: /bin/env STEPLIB: IMSBLD.I15RTSMM.COMRESL1 - TERMINFO: "/usr/lpp/izoda/v110/anaconda/share/terminfo" - ZOAU_ROOT: "/usr/lpp/zoautil/v100" - ZOAUTIL_DIR: "/usr/lpp/zoautil/v100" - PYTHONPATH: "/usr/lpp/izoda/v110/anaconda/lib:/usr/lpp/zoautil/v100/lib:/lib:/usr/lib" - PKG_CONFIG_PATH: "/usr/lpp/izoda/v110/anaconda/lib/pkgconfig:/usr/lpp/izoda/v110/anaconda/share/pkgconfig" - PYTHON_HOME: "/usr/lpp/izoda/v110/anaconda" + TERMINFO: "/u/omvsadm/mvsbuilds/103/mvsutil/share/terminfo" + #ZOAU_ROOT: "/usr/lpp/zoautil/v100" + ZOAUTIL_DIR: "/u/omvsadm/mvsbuilds/103/mvsutil" #"/usr/lpp/zoautil/v100" + PYTHONPATH: "/u/omvsadm/mvsbuilds/103/mvsutil/lib:/lib:/usr/lib" + #PYTHONPATH: "/usr/lpp/izoda/v110/anaconda/lib:/usr/lpp/zoautil/v100/lib:/lib:/usr/lib" + PKG_CONFIG_PATH: "/u/omvsadm/mvsbuilds/103/mvsutil/lib/pkgconfig:/usr/lpp/izoda/v110/anaconda/share/pkgconfig" + PYTHON_HOME: "/u/omvsadm/mvsbuilds/103/mvsutil" #"/usr/lpp/izoda/v110/anaconda" _BPXK_JOBLOG: STDERR # environment variables for mvsutils/mvscmd _BPXK_AUTOCVT: ON @@ -30,9 +37,11 @@ environment: GIT_SHELL: "/usr/lpp/rsusr/ported/bin/bash" GIT_EXEC_PATH: "/usr/lpp/rsusr/ported/libexec/git-core" GIT_TEMPLATE_DIR: "/usr/lpp/rsusr/ported/share/git-core/templates" - PATH: "/usr/lpp/zoautil/v100/bin:/usr/lpp/rsusr/ported/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin:/usr/lpp/izoda/v110/anaconda/bin" + #PATH: '/u/omvsadm/mvsbuilds/103/mvsutil/bin:/usr/lpp/rsusr/ported/bin:{{ JAVA_ROOT }}/java180/J8.0_64/bin:/bin:/var/bin:{{ JAVA_ROOT }}/J8.0/bin:{{ PYTHON_ROOT }}/bin' + PATH: "/u/omvsadm/mvsbuilds/103/mvsutil/bin:/usr/lpp/rsusr/ported/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin:/usr/lpp/izoda/v110/anaconda/bin" # Java environment JAVA_HOME: /usr/lpp/java/java180/J8.0_64 + LANG: C extra_args: STEPLIB: IMSNEW.DIPTI.IM00.SDFSRESL JOB_CARD: |- From fd52face77d24bc88cf6804c2499603486f18792 Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 10 Jul 2020 12:39:34 -0700 Subject: [PATCH 05/21] acbgen interface updates --- plugins/module_utils/acbgen.py | 36 ++++++++++++++----- .../module_utils/ims_module_error_messages.py | 14 ++++---- plugins/modules/ims_acb_gen.py | 24 +++++-------- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/plugins/module_utils/acbgen.py b/plugins/module_utils/acbgen.py index eaabc79f..0383aae6 100644 --- a/plugins/module_utils/acbgen.py +++ b/plugins/module_utils/acbgen.py @@ -45,7 +45,7 @@ def __init__(self, command_input, compression, psb_name, dbd_name, acb_lib, psb_ build_psb (bool): TRUE for rebuilding all PSBs that reference the changed DBD, FALSE for not rebuilding the PSBs that references teh changed DBD. """ - print(" COMP: ", compression) + print(" steplib: ", steplib) self.command_input = command_input self.compression = compression self.psb_name = psb_name @@ -64,17 +64,26 @@ def _assert_valid_input_types(self): Raises: TypeError: Raised if parameter is the wrong data type. """ + # print("COMMAND INPUT: ", self.command_input) + # print(" not isinstance(self.command_input, str): ", isinstance(self.command_input, str)) if self.command_input and not isinstance(self.command_input, str): raise TypeError(em.INCORRECT_COMMAND_INPUT_TYPE) - if(self.compression and not isinstance(self.compression, str)): + if self.compression and not isinstance(self.compression, str): raise TypeError(em.INCORRECT_COMPRESSION_TYPE) - if(self.acb_lib and not isinstance(self.acb_lib, str)): + if self.acb_lib and not isinstance(self.acb_lib, str): raise TypeError(em.INCORRECT_ACBLIB_TYPE) - # if(self.dbd_name and not isinstance(self.dbd_name, str)): - # raise TypeError - # if(): - # if(): - # if(): + if self.dbd_name and not all(isinstance(item, str) for item in self.dbd_name): + raise TypeError(em.INCORRECT_DBD_NAME_TYPE) + if self.psb_name and not all(isinstance(item, str) for item in self.psb_name): + raise TypeError(em.INCORRECT_PSB_NAME_TYPE) + if self.psb_lib and not all(isinstance(item, str) for item in self.psb_lib): + raise TypeError(em.INCORRECT_PSBLIB_TYPE) + if self.dbd_lib and not all(isinstance(item, str) for item in self.dbd_lib): + raise TypeError(em.INCORRECT_DBDLIB_TYPE) + if self.steplib and not all(isinstance(item, str) for item in self.steplib): + raise TypeError(em.INCORRECT_STEPLIB_TYPE) + if self.reslib and not all(isinstance(item, str) for item in self.reslib): + raise TypeError(em.INCORRECT_RESLIB_TYPE) if self.build_psb and not isinstance(self.build_psb, bool): raise TypeError(em.INCORRECT_BUILD_PSB_TYPE) @@ -112,7 +121,7 @@ def _build_utility_statements(self): acbgen_utility_fields.append(ims_data_set_definitions) if self.acb_lib: - acblib_data_set_definitions = DDStatement("IMSACB", DatasetDefinition(self.acb_lib)) + acblib_data_set_definitions = DDStatement("IMSACB", DatasetDefinition(self.acb_lib, disposition="old")) acbgen_utility_fields.append(acblib_data_set_definitions) compctl_stdin_definitions = DDStatement("COMPCTL", StdinDefinition(" COPY INDD=IMSACB,OUTDD=IMSACB")) @@ -153,6 +162,15 @@ def _split_lines_psb(self): return return_arr def _build_psb_name_string(self, command_input, psbnames): + """Build the PSB command string. + + Args: + command_input(str): + psbnames(list): + + Returns: Well-Formed command + """ + psb_str = "" if psbnames: for psb in psbnames: diff --git a/plugins/module_utils/ims_module_error_messages.py b/plugins/module_utils/ims_module_error_messages.py index 5ecc232a..558d4e24 100755 --- a/plugins/module_utils/ims_module_error_messages.py +++ b/plugins/module_utils/ims_module_error_messages.py @@ -18,12 +18,12 @@ class ACBGENErrorMessages(): INCORRECT_COMMAND_INPUT_TYPE = "'command_input' must be a string." INCORRECT_COMPRESSION_TYPE = "'compression' must be a string - PRECOMP,POSTCOMP, in any combination. The default is none." INCORRECT_PSB_NAME_TYPE = "'psb_name' must be string(ALL) or list of strings." - INCORRECT_DBD_NAME_TYPE = "'dbd_name' must be a string or list of strings." + INCORRECT_DBD_NAME_TYPE = "'dbd_name' must be a list of strings." INCORRECT_ACBLIB_TYPE = "'acb_lib' must be a string." - INCORRECT_PSBLIB_TYPE = "'psb_lib' must be string or list of strings." - INCORRECT_DBDLIB_TYPE = "'dbd_lib' must be string or list of strings." - INCORRECT_RESLIB_TYPE = "step_lib' must be string or list of strings." - INCORRECT_STEPLIB_TYPE = "res_lib' must be string or list of strings." + INCORRECT_PSBLIB_TYPE = "'psb_lib' must be a list of strings." + INCORRECT_DBDLIB_TYPE = "'dbd_lib' must be a list of strings." + INCORRECT_RESLIB_TYPE = "step_lib' must be a list of strings." + INCORRECT_STEPLIB_TYPE = "res_lib' must be a list of strings." INCORRECT_BUILD_PSB_TYPE = "'build_psb' must be boolean value - yes, no or true, false" COMMAND_INPUT_REQUIREMENT_MSG = "'command_input' must be specified" ACBLIB_REQUIREMENT_MSG = "'acb_lib' must be specified " @@ -31,4 +31,6 @@ class ACBGENErrorMessages(): DBDLIB_REQUIREMENT_MSG = "'dbd_lib' must be specified" SUCCESS_MSG = "ACBGEN execution is successful." FAILURE_MSG = "Failure. See output for details." - EMPTY_OUTPUT_MSG = "ACBGEN could not be processed. Please check input parameters." \ No newline at end of file + EMPTY_OUTPUT_MSG = "ACBGEN could not be processed. Please check input parameters." + INCORRECT_TYPE = "Incorrect type provided. A string or list of strings is expected" + INCORRECT_ITEM_LIST = "Items provided in list do not match the string type expected." \ No newline at end of file diff --git a/plugins/modules/ims_acb_gen.py b/plugins/modules/ims_acb_gen.py index c757d60e..6f5496c5 100644 --- a/plugins/modules/ims_acb_gen.py +++ b/plugins/modules/ims_acb_gen.py @@ -218,19 +218,14 @@ module = None def str_or_list_of_str(contents, dependencies): - print("contents: ", contents) if isinstance(contents, list): for item in contents: if not isinstance(item, str): - raise ValueError( - "Items provided in list do not match the string type expected." - ) + raise ValueError(em.INCORRECT_ITEM_LIST) elif isinstance(contents, str): contents = [contents] # make this a list of strings to consistent format else: - raise ValueError( - "Incorrect type provided. A string or list of strings is expected" - ) + raise ValueError(em.INCORRECT_TYPE) return contents def run_module(): @@ -253,9 +248,9 @@ def run_module(): changed=True, msg='', content='', - #error='', + error='', rc='', - #debug='' + debug='' ) module = AnsibleModule( @@ -316,18 +311,16 @@ def run_module(): print(" response: ", response) - # if not result['acbgen_output']: if response['rc'] and int(response['rc']) > 4: result['changed'] = False result['content'] = response['output'] - result['msg'] = response['error'] + result['msg'] = em.FAILURE_MSG + result['error'] = response['error'] result['rc'] = response['rc'] else: - result['content'] = response['output'] result['changed'] = True - # result['rc'] = response['rc'] - result['error'] = response['error'] # ??? error when success - # result['msg'] = em.EMPTY_OUTPUT_MSG + result['content'] = response['output'] + result['debug'] = response['error'] # ??? error when success result['msg'] = em.SUCCESS_MSG if response['rc'] <= 4: result['rc'] = '0' @@ -341,7 +334,6 @@ def run_module(): except Exception as e: result['msg'] = repr(e) module.fail_json(**result) - finally: pass From 1ab2a3e5077d68e29d5ee45e304dc84b54550e33 Mon Sep 17 00:00:00 2001 From: Dipti Date: Mon, 13 Jul 2020 15:31:35 -0700 Subject: [PATCH 06/21] acbgen with iebcopy and updated test code --- playbooks/group_vars/all.yml | 14 +- plugins/module_utils/acbgen.py | 496 ++++++++++-------- plugins/modules/ims_acb_gen.py | 255 ++++----- .../test_ims_acb_gen_invalid_input.py | 160 +++--- .../test_ims_acb_gen_valid_input.py | 134 ++--- tests/test_config.yml | 20 +- 6 files changed, 568 insertions(+), 511 deletions(-) diff --git a/playbooks/group_vars/all.yml b/playbooks/group_vars/all.yml index 76df5afd..2cf1f6f8 100755 --- a/playbooks/group_vars/all.yml +++ b/playbooks/group_vars/all.yml @@ -31,8 +31,8 @@ # // CLASS=H,MSGLEVEL=(1,1),REGION=0M, # // MSGCLASS=H,NOTIFY=&SYSUID -ZOAU_ROOT: /u/omvsadm/mvsbuilds/103/mvsutil -PYTHON_ROOT: /u/oeusr01/usr/lpp/IBM/cyp/v3r8/pyz/usr/lpp/IBM/cyp/v3r8/pyz #/usr/lpp/izoda/v110/anaconda +ZOAU_ROOT: /u/omvsadm/mvsbuilds/mvsutil +PYTHON_ROOT: /usr/lpp/izoda/v110/anaconda #/usr/lpp/izoda/v110/anaconda JAVA_ROOT: /usr/lpp/java environment_vars: @@ -43,15 +43,15 @@ environment_vars: PYTHONPATH: '{{ ZOAU_ROOT }}/lib:/lib:/usr/lib' _BPXK_JOBLOG: STDERR # environment variables for mvsutils/mvscmd - _BPXK_AUTOCVT: ON + _BPXK_AUTOCVT: "ON" #_CEE_RUNOPTS: '"FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"' - _TAG_REDIR_ERR: txt - _TAG_REDIR_IN: txt - _TAG_REDIR_OUT: txt + # _TAG_REDIR_ERR: txt + # _TAG_REDIR_IN: txt + # _TAG_REDIR_OUT: txt TOOLS_ROOT: '/usr/lpp/rsusr/ported' PATH: '{{ ZOAU_ROOT }}/bin:/usr/lpp/rsusr/ported/bin:{{ JAVA_ROOT }}/java180/J8.0_64/bin:/bin:/var/bin:{{ JAVA_ROOT }}/J8.0/bin:{{ PYTHON_ROOT }}/bin' JAVA_HOME: '{{ JAVA_ROOT }}/java180/J8.0_64' - STEPLIB: IMSBLD.I15RTSMM.COMRESL1 + STEPLIB: IMSNEW.DIPTI.IM00.SDFSRESL #IMSBLD.I15RTSMM.COMRESL1 LANG: C JOB_CARD: |- diff --git a/plugins/module_utils/acbgen.py b/plugins/module_utils/acbgen.py index 0383aae6..57ec8960 100644 --- a/plugins/module_utils/acbgen.py +++ b/plugins/module_utils/acbgen.py @@ -1,51 +1,35 @@ -from ansible.module_utils.basic import AnsibleModule, env_fallback, AnsibleFallbackNotFound -from ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.ims_gen_utils import ( - submit_uss_jcl, +from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.dd_statement import ( # pylint: disable=import-error + DDStatement, + DatasetDefinition, + StdoutDefinition, + StdinDefinition, ) -from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.dd_statement import ( # pylint: disable=import-error - DDStatement, - FileDefinition, - DatasetDefinition, - StdoutDefinition, - StdinDefinition, -) -from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.zos_raw import MVSCmd # pylint: disable=import-error -import tempfile +from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.zos_mvs_raw import MVSCmd # pylint: disable=import-error import re -from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.import_handler import ( # pylint: disable=import-error - MissingZOAUImport, -) -from ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.ims_module_error_messages import ACBGENErrorMessages as em # pylint: disable=import-error -try: - from zoautil_py import Datasets, types # pylint: disable=import-error -except Exception: - Datasets = MissingZOAUImport() - types = MissingZOAUImport() - -class acbgen(): + +from ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.ims_module_error_messages import ACBGENErrorMessages as em # pylint: disable=import-error + + +class acbgen(object): ACBGEN_UTILITY = "DFSRRC00" - # REPLACEMENT_VALUES = { - # "True": YES - # "False": NO - # } - - #def __init__(self, command_input, compression, psb_name=None, dbd_name=None, acb_lib, psb_lib, dbd_lib, reslib=None, steplib=None, build_psb): + COMPRESS_UTILITY = "IEBCOPY" + + # def __init__(self, command_input, compression, psb_name=None, dbd_name=None, acb_lib, psb_lib, dbd_lib, reslib=None, steplib=None, build_psb): def __init__(self, command_input, compression, psb_name, dbd_name, acb_lib, psb_lib, dbd_lib, reslib, steplib, build_psb): """IMSAcbgen constructor for generating IMS ACB using zos_mvs_raw Args: - command_input (str): 'BUILD' or 'DELETE' - command input to specify. + command_input (str): 'BUILD' or 'DELETE' - command input to specify. compression (str): 'PRECOMP','POSTCOMP' or 'PRECOMP,POSTCOMP' or default is none. psb_name (list): 'ALL' or a list of psb names to be specified. dbd_name (list): List of dbd names. - acb_lib (str): + acb_lib (str): This dataset is the consolidated library of PSB and DBD descriptions. psb_lib (list): List of psblib datasets. dbd_lib (list): List of dbdlib datasets. reslib (list): List of reslib datasets. steplib (list): Points to the list of IMS SDFSRESL data set, which contains the IMS nucleus and required IMS modules. build_psb (bool): TRUE for rebuilding all PSBs that reference the changed DBD, - FALSE for not rebuilding the PSBs that references teh changed DBD. + FALSE for not rebuilding the PSBs that references teh changed DBD. """ - print(" steplib: ", steplib) self.command_input = command_input self.compression = compression self.psb_name = psb_name @@ -60,205 +44,265 @@ def __init__(self, command_input, compression, psb_name, dbd_name, acb_lib, psb_ self.result = {} def _assert_valid_input_types(self): - """This assertion function validates that all parameters are the correct data type. - Raises: - TypeError: Raised if parameter is the wrong data type. - """ - # print("COMMAND INPUT: ", self.command_input) - # print(" not isinstance(self.command_input, str): ", isinstance(self.command_input, str)) - if self.command_input and not isinstance(self.command_input, str): - raise TypeError(em.INCORRECT_COMMAND_INPUT_TYPE) - if self.compression and not isinstance(self.compression, str): - raise TypeError(em.INCORRECT_COMPRESSION_TYPE) - if self.acb_lib and not isinstance(self.acb_lib, str): - raise TypeError(em.INCORRECT_ACBLIB_TYPE) - if self.dbd_name and not all(isinstance(item, str) for item in self.dbd_name): - raise TypeError(em.INCORRECT_DBD_NAME_TYPE) - if self.psb_name and not all(isinstance(item, str) for item in self.psb_name): - raise TypeError(em.INCORRECT_PSB_NAME_TYPE) - if self.psb_lib and not all(isinstance(item, str) for item in self.psb_lib): - raise TypeError(em.INCORRECT_PSBLIB_TYPE) - if self.dbd_lib and not all(isinstance(item, str) for item in self.dbd_lib): - raise TypeError(em.INCORRECT_DBDLIB_TYPE) - if self.steplib and not all(isinstance(item, str) for item in self.steplib): - raise TypeError(em.INCORRECT_STEPLIB_TYPE) - if self.reslib and not all(isinstance(item, str) for item in self.reslib): - raise TypeError(em.INCORRECT_RESLIB_TYPE) - if self.build_psb and not isinstance(self.build_psb, bool): - raise TypeError(em.INCORRECT_BUILD_PSB_TYPE) - - def _build_utility_statements(self): - """Builds the list of DDStatements that will be provided to the zos_mvs_raw's execute function - based on the user input. - - Returns: - (list[DDStatement]): List of DDStatements - """ - acbgen_utility_fields = [] - ims_dataset_list = [] - sysprint = DDStatement("SYSPRINT", StdoutDefinition()) - acbgen_utility_fields.append(sysprint) - - if self.steplib: - steplib_data_set_definitions = [DatasetDefinition(steplib) for steplib in self.steplib] - steplib = DDStatement("STEPLIB", steplib_data_set_definitions) - acbgen_utility_fields.append(steplib) - - if self.reslib: - reslib_data_set_definitions = [DatasetDefinition(reslib) for reslib in self.reslib] - reslib = DDStatement("DFSRESLB", reslib_data_set_definitions) - acbgen_utility_fields.append(reslib) - - if self.psb_lib: - for psblib in self.psb_lib: - ims_dataset_list.append(DatasetDefinition(psblib)) - if self.dbd_lib: - for dbdlib in self.dbd_lib: - ims_dataset_list.append(DatasetDefinition(dbdlib)) - - if ims_dataset_list: - ims_data_set_definitions = DDStatement("IMS", ims_dataset_list) - acbgen_utility_fields.append(ims_data_set_definitions) - - if self.acb_lib: - acblib_data_set_definitions = DDStatement("IMSACB", DatasetDefinition(self.acb_lib, disposition="old")) - acbgen_utility_fields.append(acblib_data_set_definitions) - - compctl_stdin_definitions = DDStatement("COMPCTL", StdinDefinition(" COPY INDD=IMSACB,OUTDD=IMSACB")) - acbgen_utility_fields.append(compctl_stdin_definitions) - - commandList = [] - #Generate DD statements for commands - if self.command_input: - psb_name_str = "" - if self.psb_name: - psb_name_str = " " + self._split_lines_psb() - commandList.append(psb_name_str) - dbd_name_str = "" - if self.dbd_name: - dbd_name_str = " " + self._split_lines_dbd() - commandList.append(dbd_name_str) - - for a in commandList: - print(" commandList: ", a) - command_stdin_definitions = DDStatement("SYSIN",StdinDefinition("\n".join(commandList))) - acbgen_utility_fields.append(command_stdin_definitions) - - return acbgen_utility_fields - + """This assertion function validates that all parameters are the correct data type. + Raises: + TypeError: Raised if parameter is the wrong data type. + """ + if self.command_input and not isinstance(self.command_input, str): + raise TypeError(em.INCORRECT_COMMAND_INPUT_TYPE) + if self.compression and not isinstance(self.compression, str): + raise TypeError(em.INCORRECT_COMPRESSION_TYPE) + if self.acb_lib and not isinstance(self.acb_lib, str): + raise TypeError(em.INCORRECT_ACBLIB_TYPE) + if self.dbd_name and not all(isinstance(item, str) for item in self.dbd_name): + raise TypeError(em.INCORRECT_DBD_NAME_TYPE) + if self.psb_name and not all(isinstance(item, str) for item in self.psb_name): + raise TypeError(em.INCORRECT_PSB_NAME_TYPE) + if self.psb_lib and not all(isinstance(item, str) for item in self.psb_lib): + raise TypeError(em.INCORRECT_PSBLIB_TYPE) + if self.dbd_lib and not all(isinstance(item, str) for item in self.dbd_lib): + raise TypeError(em.INCORRECT_DBDLIB_TYPE) + if self.steplib and not all(isinstance(item, str) for item in self.steplib): + raise TypeError(em.INCORRECT_STEPLIB_TYPE) + if self.reslib and not all(isinstance(item, str) for item in self.reslib): + raise TypeError(em.INCORRECT_RESLIB_TYPE) + if self.build_psb and not isinstance(self.build_psb, bool): + raise TypeError(em.INCORRECT_BUILD_PSB_TYPE) + + def _build_acbgen_statements(self): + """Builds the list of DDStatements that will be provided to the zos_mvs_raw to execute DFSRRC00 + based on the user input. + + Returns: + (list[DDStatement]): List of DDStatements + """ + acbgen_utility_fields = [] + ims_dataset_list = [] + sysprint = DDStatement("SYSPRINT", StdoutDefinition()) + + acbgen_utility_fields.append(sysprint) + + if self.steplib: + steplib_data_set_definitions = [ + DatasetDefinition(steplib) for steplib in self.steplib] + steplib = DDStatement("STEPLIB", steplib_data_set_definitions) + acbgen_utility_fields.append(steplib) + + if self.reslib: + reslib_data_set_definitions = [ + DatasetDefinition(reslib) for reslib in self.reslib] + reslib = DDStatement("DFSRESLB", reslib_data_set_definitions) + acbgen_utility_fields.append(reslib) + + if self.psb_lib: + for psblib in self.psb_lib: + ims_dataset_list.append(DatasetDefinition(psblib)) + if self.dbd_lib: + for dbdlib in self.dbd_lib: + ims_dataset_list.append(DatasetDefinition(dbdlib)) + + if ims_dataset_list: + ims_data_set_definitions = DDStatement("IMS", ims_dataset_list) + acbgen_utility_fields.append(ims_data_set_definitions) + + if self.acb_lib: + acblib_data_set_definitions = DDStatement( + "IMSACB", DatasetDefinition(self.acb_lib, disposition="old")) + acbgen_utility_fields.append(acblib_data_set_definitions) + + commandList = [] + # Generate DD statements for commands + if self.command_input: + psb_name_str = "" + if self.psb_name: + psb_name_str = " " + self._split_lines_psb() + commandList.append(psb_name_str) + dbd_name_str = "" + if self.dbd_name: + dbd_name_str = " " + self._split_lines_dbd() + commandList.append(dbd_name_str) + + for a in commandList: + print(" commandList: ", a) + command_stdin_definitions = DDStatement( + "SYSIN", StdinDefinition("\n".join(commandList))) + acbgen_utility_fields.append(command_stdin_definitions) + + return acbgen_utility_fields + + def _build_compress_statements(self): + """Builds the list of DDStatements that will be provided to the zos_mvs_raw to execute IEBCOPY + based on the user input. + + Returns: + (list[DDStatement]): List of DDStatements + """ + iebcopy_utility_fields = [] + sysprint = DDStatement("SYSPRINT", StdoutDefinition()) + iebcopy_utility_fields.append(sysprint) + compctl_stdin_definitions = DDStatement( + "SYSIN", StdinDefinition(" COPY INDD=IMSACB,OUTDD=IMSACB")) + iebcopy_utility_fields.append(compctl_stdin_definitions) + acblib_data_set_definitions = DDStatement( + "IMSACB", DatasetDefinition(self.acb_lib, disposition="old")) + iebcopy_utility_fields.append(acblib_data_set_definitions) + return iebcopy_utility_fields + def _split_lines_psb(self): - return_str = "" - return_arr = [] - psbnames = self.psb_name - if len(psbnames) < 6: - return_str = self._build_psb_name_string(self.command_input, psbnames) - return return_str - else: - for i in range(0, len(psbnames), 5): - new_psb_names_five = psbnames[i: i + 5] - psb_line = self._build_psb_name_string(self.command_input, new_psb_names_five) - return_arr.append(psb_line) - return "\n ".join(return_arr) - return return_arr - + """Splitting the command on new line in case if it exceeds 80 characters. + + Returns: A string or array of PSB commands. + """ + return_str = "" + return_arr = [] + psbnames = self.psb_name + if len(psbnames) < 6: + return_str = self._build_psb_name_string( + self.command_input, psbnames) + return return_str + else: + for i in range(0, len(psbnames), 5): + new_psb_names_five = psbnames[i: i + 5] + psb_line = self._build_psb_name_string( + self.command_input, new_psb_names_five) + return_arr.append(psb_line) + return "\n ".join(return_arr) + return return_arr + def _build_psb_name_string(self, command_input, psbnames): - """Build the PSB command string. - - Args: - command_input(str): - psbnames(list): - - Returns: Well-Formed command - """ - - psb_str = "" - if psbnames: - for psb in psbnames: - #if a match is not found - if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', psb, re.IGNORECASE): - return psb - else: - # if a match is found - if psb == "ALL": - psb_str = command_input + " PSB=ALL" - break - else: - psb_str = command_input + " PSB=(" + ",".join(psbnames) + ")" - return psb_str + """Build the PSB command string. + + Args: + command_input(str): The user input that can be either "BUILD" or "DELETE". + psbnames(list): This can be either "ALL" or a list of psb strings. + + Returns: Well-Formed PSB command. + """ + psb_str = "" + if psbnames: + for psb in psbnames: + # if a match is not found + if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', psb, re.IGNORECASE): + return psb + else: + # if a match is found + if psb == "ALL": + psb_str = command_input + " PSB=ALL" + break + else: + psb_str = command_input + \ + " PSB=(" + ",".join(psbnames) + ")" + return psb_str def _split_lines_dbd(self): - return_str = "" - return_arr = [] - dbdnames = self.dbd_name - if len(dbdnames) < 6: - return_str = self._build_dbd_name_string(self.command_input, dbdnames, self.build_psb) - return return_str - else: - for i in range(0, len(dbdnames), 5): - new_db_names_five = dbdnames[i: i + 5] - dbd_line = self._build_dbd_name_string(self.command_input, new_db_names_five, self.build_psb) - return_arr.append(dbd_line) - return "\n ".join(return_arr) - return return_arr + """Splitting the command on new line in case if it exceeds 80 characters. + + Returns: A string or array of DBD commands. + """ + return_str = "" + return_arr = [] + dbdnames = self.dbd_name + if len(dbdnames) < 6: + return_str = self._build_dbd_name_string( + self.command_input, dbdnames, self.build_psb) + return return_str + else: + for i in range(0, len(dbdnames), 5): + new_db_names_five = dbdnames[i: i + 5] + dbd_line = self._build_dbd_name_string( + self.command_input, new_db_names_five, self.build_psb) + return_arr.append(dbd_line) + return "\n ".join(return_arr) + return return_arr def _build_dbd_name_string(self, command_input, dbdnames, build_psb): - dbd_str = "" - bldpsb_value = "" - if build_psb: - bldpsb_value = "YES" - else: - bldpsb_value = "NO" - - if dbdnames: - for dbd in dbdnames: - #if a match is not found - if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', dbd, re.IGNORECASE): - return dbd - else: - # if a match is found - if dbdnames and build_psb: - dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" - elif dbdnames and command_input == "BUILD": - dbd_str = ( - command_input - + " DBD=(" - + ",".join(dbdnames) - + ")" - + ",BLDPSB=" - + bldpsb_value - ) - elif dbdnames: - dbd_str = command_input + " DBD=(" + ",".join(dbdnames) + ")" - return dbd_str - - - def execute(self): - """Executes the ACBGEN utility DFSRRC00 using the zos_mvs_raw module based on the user input. - - Returns: - (dict): (1) rc: Return Code returned by zos_mvs_raw module. - (2) error: The stderr returned by the zos_raw module. - (3) output: The original output provided by zos_raw. - """ - param_string = '\'' + 'UPB,{0}'.format(self.compression) + '\'' - - try: - acbgen_utility_fields = self._build_utility_statements() - response = MVSCmd.execute(acbgen.ACBGEN_UTILITY, acbgen_utility_fields, param_string, verbose=True) - self.result = { - "rc": response.rc, - "output": response.stdout, - "error": response.stderr, - } - except Exception as e: - self.result = { - "rc": response.rc, - "output": response.stdout, - "error": response.stderr, - } - finally: + """Build the DBD command string. + + Args: + command_input(str): The user input that can be either "BUILD" or "DELETE". + psbnames(list): This must be a list of dbd strings. + build_psb(bool): This option is available for BUILD DBD. By default its set to true(yes). + + Returns: Well-Formed DBD command. + """ + dbd_str = "" + bldpsb_value = "" + if build_psb: + bldpsb_value = "YES" + else: + bldpsb_value = "NO" + + if dbdnames: + for dbd in dbdnames: + # if a match is not found + if not re.fullmatch(r'[A-Z$#@]{1}[A-Z0-9$#@]{0,7}', dbd, re.IGNORECASE): + return dbd + else: + # if a match is found + if dbdnames and build_psb: + dbd_str = command_input + \ + " DBD=(" + ",".join(dbdnames) + ")" + elif dbdnames and command_input == "BUILD": + dbd_str = ( + command_input + + " DBD=(" + + ",".join(dbdnames) + + ")" + + ",BLDPSB=" + + bldpsb_value + ) + elif dbdnames: + dbd_str = command_input + \ + " DBD=(" + ",".join(dbdnames) + ")" + return dbd_str + + def combine_results(self, result): + """Add results of execution to existing + results if there are any. + + Args: + result ([type]): [description] + + Returns: + [type]: [description] + """ + if self.result is None: + self.result = {} + self.result['rc'] = max(self.result.get("rc", -1), result.rc) + self.result["output"] = self.result.get("output", "") + result.stdout + self.result["error"] = self.result.get("error", "") + result.stderr return self.result - + def compress(self): + """Executes the compression utility IEBCOPY using the zos_mvs_raw module based on the user input. + """ + iebcopy_utility_fields = self._build_compress_statements() + response = MVSCmd.execute( + acbgen.COMPRESS_UTILITY, iebcopy_utility_fields, verbose=True) + return response + + def execute(self): + """Executes the ACBGEN utility DFSRRC00 using the zos_mvs_raw module based on the user input. - \ No newline at end of file + Returns: + (dict): (1) rc: Return Code returned by zos_mvs_raw module. + (2) error: The stderr returned by the zos_raw module. + (3) output: The original output provided by zos_raw. + """ + self.result = {} + response = None + param_string = "UPB," + print(" compression: ", self.compression) + if self.compression and self.compression.upper().startswith("PRECOMP"): + response = self.compress() + self.result = self.combine_results(response) + if self.result.get("rc") > 4: + return self.result + acbgen_utility_fields = self._build_acbgen_statements() + response = MVSCmd.execute( + acbgen.ACBGEN_UTILITY, acbgen_utility_fields, param_string, verbose=True) + self.result = self.combine_results(response) + if self.compression and self.compression.upper().endswith("POSTCOMP"): + response = self.compress() + self.result = self.combine_results(response) + return self.result diff --git a/plugins/modules/ims_acb_gen.py b/plugins/modules/ims_acb_gen.py index 6f5496c5..b118a69f 100644 --- a/plugins/modules/ims_acb_gen.py +++ b/plugins/modules/ims_acb_gen.py @@ -4,6 +4,10 @@ # Apache License, Version 2.0 (see https://opensource.org/licenses/Apache-2.0) from __future__ import absolute_import, print_function +from ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.ims_module_error_messages import ACBGENErrorMessages as em +from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.better_arg_parser import BetterArgParser # pylint: disable=import-error +from ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.acbgen.acbgen import acbgen # pylint: disable=import-error +from ansible.module_utils.basic import AnsibleModule, env_fallback, AnsibleFallbackNotFound __metaclass__ = type @@ -18,9 +22,9 @@ short_description: Generate IMS ACB version_added: "2.9" description: - - The ims_acb_gen module generates an IMS application control block (ACB) necessary for an IMS application program to be scheduled and run. - - The ims_dbd_gen and ims_psb_gen modules can be used to generate the associated IMS database descriptors (DBDs) and program specification - block (PSBs) to be used with the ims_acb_gen module. + - The ims_acb_gen module generates an IMS application control block (ACB) necessary for an IMS application program to be scheduled and run. + - The ims_dbd_gen and ims_psb_gen modules can be used to generate the associated IMS database descriptors (DBDs) and program specification + block (PSBs) to be used with the ims_acb_gen module. - The DBD and PSB control blocks will be merged and expanded into an IMS internal format called application control blocks (ACBs). author: @@ -79,17 +83,17 @@ type: list steplib: description: - - Points to the IMS SDFSRESL data set, which contains the IMS nucleus and required IMS modules. If STEPLIB is unauthorized by having unauthorized libraries - that are concatenated to SDFSRESL, you must specify the I(reslib) parameter. - - The steplib parameter can also be specified in the target inventory's environment_vars. - - The steplib input parameter to the module will take precedence over the value specified in the environment_vars. + - Points to the IMS SDFSRESL data set, which contains the IMS nucleus and required IMS modules. If STEPLIB is unauthorized by having unauthorized libraries + that are concatenated to SDFSRESL, you must specify the I(reslib) parameter. + - The steplib parameter can also be specified in the target inventory's environment_vars. + - The steplib input parameter to the module will take precedence over the value specified in the environment_vars. required: false type: list reslib: description: - - Points to an authorized library that contains the IMS SVC modules. For IMS batch, SDFSRESL and any data set that is concatenated to it in the + - Points to an authorized library that contains the IMS SVC modules. For IMS batch, SDFSRESL and any data set that is concatenated to it in the reslib field must be authorized through the Authorized Program Facility (APF). - required: false + required: false type: list build_psb: description: @@ -100,15 +104,12 @@ type: bool default: true notes: - - The I(steplib) parameter can also be specified in the target inventory's environment_vars. + - The I(steplib) parameter can also be specified in the target inventory's environment_vars. - The I(steplib) input parameter to the module will take precedence over the value specified in the environment_vars. - - If only the I(steplib) parameter is specified, then only the I(steplib) concatenation will be used to resolve the IMS RESLIB dataset. - - If both I(steplib) and I(reslib) are specified, then both parameters will be used by the ACB Maintenenace Utility and I(reslib) will be used to resolve the IMS RESLIB dataset. - - Specifying only I(reslib) without I(steplib) is not supported. + - If only the I(steplib) parameter is specified, then only the I(steplib) concatenation will be used to resolve the IMS RESLIB dataset. + - If both I(steplib) and I(reslib) are specified, then both parameters will be used by the ACB Maintenenace Utility and I(reslib) will be used to resolve the IMS RESLIB dataset. + - Specifying only I(reslib) without I(steplib) is not supported. - The ACB Maintenenace utility SYSUT3/SYSUT4 DD options are not supported by this module. - - The current implementation of the ims_acb_gen module requires a jobcard to be specified using the JOB_CARD variable in the target inventory's group variables. - See the sample L(group_vars,https://github.com/ansible-collections/ibm_zos_ims/blob/master/playbooks/group_vars/all.yml) provided with our sample playbook for an example of - the JOB_CARD variable. ''' EXAMPLES = r''' @@ -137,7 +138,7 @@ steplib: - SOME.IMS.SDFSRESL1 - SOME.IMS.SDFSRESL2 - build_psb: false + build_psb: false - name: Example of creating blocks for all PSBs in the psb_lib data set. ims_acb_gen: @@ -148,7 +149,7 @@ dbd_lib: - SOME.IMS.DBDLIB1 acb_lib: SOME.IMS.ACBLIB - + - name: Example of deleting PSBs and DBDs ims_acb_gen: command_input: DELETE @@ -189,160 +190,134 @@ type: bool ''' -from ansible.module_utils.basic import AnsibleModule, env_fallback, AnsibleFallbackNotFound -from ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.acbgen.acbgen import acbgen # pylint: disable=import-error -from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.dd_statement import ( # pylint: disable=import-error - DDStatement, - FileDefinition, - DatasetDefinition, - StdoutDefinition, - StdinDefinition, -) -from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.better_arg_parser import BetterArgParser # pylint: disable=import-error -from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.zos_raw import MVSCmd # pylint: disable=import-error -import tempfile -import re -from ansible_collections.ibm.ibm_zos_core.plugins.module_utils.import_handler import ( # pylint: disable=import-error - MissingZOAUImport, -) -from ansible_collections.ibm.ibm_zos_ims.plugins.module_utils.ims_module_error_messages import ACBGENErrorMessages as em -import tempfile -import pprint - -try: - from zoautil_py import Datasets, types # pylint: disable=import-error -except Exception: - Datasets = MissingZOAUImport() - types = MissingZOAUImport() module = None + def str_or_list_of_str(contents, dependencies): if isinstance(contents, list): for item in contents: if not isinstance(item, str): raise ValueError(em.INCORRECT_ITEM_LIST) elif isinstance(contents, str): - contents = [contents] # make this a list of strings to consistent format + # make this a list of strings to consistent format + contents = [contents] else: raise ValueError(em.INCORRECT_TYPE) return contents + def run_module(): - global module + global module - module_args = dict( - command_input=dict(type="str", required=True), - compression=dict(type="str", required=False, default=""), - psb_name=dict(type="list", elements="str", required=False), - dbd_name=dict(type="list", elements="str", required=False), - acb_lib=dict(type="str", required=True), - psb_lib=dict(type="list", required=True), - dbd_lib=dict(type="list", required=True), - reslib=dict(type="list", required=False), - steplib=dict(type="list", required=False), - build_psb=dict(type="bool", required=False, default=True), - ) + module_args = dict( + command_input=dict(type="str", required=True, choices=["build", "BUILD", "delete", "DELETE"]), + compression=dict(type="str", required=False, choices=[ + "precomp", "postcomp", "precomp,postcomp", + "PRECOMP", "POSTCOMP", "PRECOMP,POSTCOMP","", None]), + psb_name=dict(type="list", elements="str", required=False), + dbd_name=dict(type="list", elements="str", required=False), + acb_lib=dict(type="str", required=True), + psb_lib=dict(type="list", required=True), + dbd_lib=dict(type="list", required=True), + reslib=dict(type="list", required=False), + steplib=dict(type="list", required=False), + build_psb=dict(type="bool", required=False, default=True), + ) - result = dict( - changed=True, - msg='', - content='', - error='', - rc='', - debug='' + result = dict( + changed=True, + msg='', + content='', + error='', + rc='', + debug='' ) - module = AnsibleModule( + module = AnsibleModule( argument_spec=module_args, supports_check_mode=True) - # Retrieve properties set by the user - module_defs = dict( - command_input=dict(arg_type="str", required=True), - compression=dict(arg_type="str", required=False, default=""), - psb_name=dict(arg_type=str_or_list_of_str, required=False), - dbd_name=dict(arg_type=str_or_list_of_str, required=False), #elements="str", - acb_lib=dict(arg_type="str", required=True), - psb_lib=dict(arg_type="list", elements="str", required=True), - dbd_lib=dict(arg_type="list", elements="str", required=True), - reslib=dict(arg_type="list", elements="str", required=False), - steplib=dict(arg_type="list", elements="str", required=False), - build_psb=dict(arg_type="bool", required=False, default=True), - ) + # Retrieve properties set by the user + module_defs = dict( + command_input=dict(arg_type="str", required=True), + compression=dict(arg_type="str", required=False, default=""), + psb_name=dict(arg_type=str_or_list_of_str, required=False), + dbd_name=dict(arg_type=str_or_list_of_str, + required=False), + acb_lib=dict(arg_type="str", required=True), + psb_lib=dict(arg_type="list", elements="str", required=True), + dbd_lib=dict(arg_type="list", elements="str", required=True), + reslib=dict(arg_type="list", elements="str", required=False), + steplib=dict(arg_type="list", elements="str", required=False), + build_psb=dict(arg_type="bool", required=False, default=True), + ) - # Parse the properties - parser = BetterArgParser(module_defs) - parsed_args = parser.parse_args(module.params) + # Parse the properties + parser = BetterArgParser(module_defs) + parsed_args = parser.parse_args(module.params) - command_input = parsed_args.get("command_input") - compression = parsed_args.get("compression") - psb_name = parsed_args.get("psb_name") - dbd_name = parsed_args.get("dbd_name") - acb_lib = parsed_args.get("acb_lib") - psb_lib = parsed_args.get("psb_lib") - dbd_lib = parsed_args.get("dbd_lib") - reslib = parsed_args.get("reslib") - steplib = parsed_args.get("steplib") - build_psb = parsed_args.get("build_psb") + command_input = parsed_args.get("command_input") + compression = parsed_args.get("compression") + psb_name = parsed_args.get("psb_name") + dbd_name = parsed_args.get("dbd_name") + acb_lib = parsed_args.get("acb_lib") + psb_lib = parsed_args.get("psb_lib") + dbd_lib = parsed_args.get("dbd_lib") + reslib = parsed_args.get("reslib") + steplib = parsed_args.get("steplib") + build_psb = parsed_args.get("build_psb") - if not steplib: - try: - steplib = [] - steplib_str = env_fallback('STEPLIB') - list_str = steplib_str.split(" ") - steplib += list_str - except AnsibleFallbackNotFound as e: - module.fail_json(msg="The input option 'steplib' is not provided. Please provide it in the environment " + if not steplib: + try: + steplib = [] + steplib_str = env_fallback('STEPLIB') + list_str = steplib_str.split(" ") + steplib += list_str + except AnsibleFallbackNotFound as e: + module.fail_json(msg="The input option 'steplib' is not provided. Please provide it in the environment " "variables 'STEPLIB', or in the module input option 'steplib'. ", **result) - try: - response = acbgen( - command_input, - compression, - psb_name, - dbd_name, - acb_lib, - psb_lib, - dbd_lib, - reslib, - steplib, - build_psb).execute() + try: + acbgen_obj = acbgen( + command_input, + compression, + psb_name, + dbd_name, + acb_lib, + psb_lib, + dbd_lib, + reslib, + steplib, + build_psb) + response = acbgen_obj.execute() - print(" response: ", response) - - if response['rc'] and int(response['rc']) > 4: - result['changed'] = False - result['content'] = response['output'] - result['msg'] = em.FAILURE_MSG - result['error'] = response['error'] - result['rc'] = response['rc'] - else: - result['changed'] = True - result['content'] = response['output'] - result['debug'] = response['error'] # ??? error when success - result['msg'] = em.SUCCESS_MSG - if response['rc'] <= 4: - result['rc'] = '0' + if response.get('rc') and int(response.get('rc')) > 4: + result['changed'] = False + result['content'] = response.get('output', "") + result['msg'] = em.FAILURE_MSG + result['error'] = response.get('error', "") + result['rc'] = response.get('rc') + else: + result['changed'] = True + result['content'] = response.get('output', "") + result['debug'] = response.get('error', "") + result['msg'] = em.SUCCESS_MSG + if response.get('rc', 8) <= 4: + result['rc'] = 0 - # if response['error']: - # print("An error occurred:", response['error']) - # result['changed'] = False - # module.fail_json(**result) - # else: - # result['msg'] = em.SUCCESS_MSG - except Exception as e: - result['msg'] = repr(e) - module.fail_json(**result) - finally: - pass + except Exception as e: + result['msg'] = repr(e) + module.fail_json(**result) + finally: + pass + + module.exit_json(**result) - module.exit_json(**result) def main(): run_module() if __name__ == "__main__": - main() - + main() diff --git a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_invalid_input.py b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_invalid_input.py index 2bd65b79..2cf04feb 100755 --- a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_invalid_input.py +++ b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_invalid_input.py @@ -94,167 +94,191 @@ # assert result['msg'] == GEN_SUCCESS_MSG_PSB -def validate_build(hosts, psb_name, dbd_name, psb_lib, -dbd_lib, acb_lib, steplib, reslib, -compression, build_psb, command_input='BUILD'): - response = hosts.all.ims_acb_gen( - command_input=command_input, - psb_name=psb_name, - dbd_name=dbd_name, - psb_lib=psb_lib, - dbd_lib=dbd_lib, - acb_lib=acb_lib, - steplib=steplib, - reslib=reslib, - compression=compression, - build_psb=build_psb) +def validate_acbgen(hosts, psb_name=None, dbd_name=None, psb_lib=None, + dbd_lib=None, acb_lib=None, steplib=None, reslib=None, + compression=None, build_psb=None, command_input=None): + arguments = {} + if psb_name: + arguments["psb_name"] = psb_name + if dbd_name: + arguments["dbd_name"] = dbd_name + if psb_lib: + arguments["psb_lib"] = psb_lib + if dbd_lib: + arguments["dbd_lib"] = dbd_lib + if acb_lib: + arguments["acb_lib"] = acb_lib + if steplib: + arguments["steplib"] = steplib + if reslib: + arguments["reslib"] = reslib + if compression: + arguments["compression"] = compression + if build_psb: + arguments["build_psb"] = build_psb + if command_input: + arguments["command_input"] = command_input + + response = hosts.all.ims_acb_gen(**arguments) print("Result:", response) for result in response.contacted.values(): pprint(result) - print("Changed:", result['changed']) - assert result['changed'] == False - # if result['rc']: - # assert result['rc'] != 0 - # else: - # print(result['rc']) - # print("Return code:", result['rc']) - assert result['rc'] != 0 - -def validate_delete(hosts, psb_name, dbd_name, psb_lib, dbd_lib, acb_lib, steplib, - reslib, compression, command_input="DELETE"): - response = hosts.all.ims_acb_gen( - command_input=command_input, - psb_name=psb_name, - dbd_name=dbd_name, - psb_lib=psb_lib, - dbd_lib=dbd_lib, - acb_lib=acb_lib, - steplib=steplib, - reslib=reslib, - compression=compression) - print("Result:", response) - for result in response.contacted.values(): - pprint(result) - print("Changed:", result['changed']) - assert result['changed'] == False - # if result['rc']: - # assert result['rc'] != '0' - # else: - # print("Return code: ", result['rc']) - assert result['rc'] != '0' + print("Changed:", result.get('changed')) + assert result.get('changed') == False + if result.get('rc'): + assert result.get('rc') != 0 + elif result.get('msg'): + assert "value of compression must be one of: precomp, postcomp, precomp,postcomp," in result.get('msg') + + +# def validate_acbgen(hosts, **kwargs): +# response = hosts.all.ims_acb_gen(**kwargs) +# print("Result:", response) +# for result in response.contacted.values(): +# pprint(result) +# print("Changed:", result['changed']) +# assert result['changed'] == False +# # if result['rc']: +# # assert result['rc'] != 0 +# # else: +# # print(result['rc']) +# # print("Return code:", result['rc']) +# assert result['rc'] != 0 + +# def validate_delete(hosts, psb_name, dbd_name, psb_lib, dbd_lib, acb_lib, steplib, +# reslib, compression, command_input="DELETE"): +# response = hosts.all.ims_acb_gen( +# command_input=command_input, +# psb_name=psb_name, +# dbd_name=dbd_name, +# psb_lib=psb_lib, +# dbd_lib=dbd_lib, +# acb_lib=acb_lib, +# steplib=steplib, +# reslib=reslib, +# compression=compression) +# print("Result:", response) +# for result in response.contacted.values(): +# pprint(result) +# print("Changed:", result['changed']) +# assert result['changed'] == False +# # if result['rc']: +# # assert result['rc'] != '0' +# # else: +# # print("Return code: ", result['rc']) +# assert result['rc'] != '0' #1. PSB name doesn't exists as string, BUILD PSB=PSB_NAME def test_acb_gen_build_invalid_psbName_str(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, INVALID_PSB, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD,psb_name=INVALID_PSB, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=True) #2. Invalid PSBs as list, BUILD PSB=PSB_NAME def test_acb_gen_build_invalid_psbNames(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, INVALID_PSBS, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=INVALID_PSBS, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=True) #3. Invalid DBD, BUILD DBD=DBD_NAME def test_acb_gen_build_invalid_dbdName(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, None, INVALID_DBD, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, dbd_name=INVALID_DBD, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=True) #4. Invalid DBDs, BUILD DBD=DBD_NAME def test_acb_gen_build_invalid_dbdNames(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, None, INVALID_DBDS, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, dbd_name=INVALID_DBDS, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=True) #5. Invalid PSB and invalid DBD, BUILD PSB=PSB_NAME and BUILD DBD=DBD_NAME,BLDPSB=NO def test_acb_gen_build_invalid_psbName_list(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, INVALID_PSB, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=INVALID_PSB, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=True) def test_acb_gen_build_invalid_psbName_invalid_dbdName(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, INVALID_PSB, INVALID_DBD, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, False) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=INVALID_PSB, dbd_name=INVALID_DBD, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=False) #6. Valid PSB and invalid DBD, BUILD PSB=PSB_NAME and BUILD DBD=DBD_NAME,BLDPSB=YES def test_acb_gen_build_valid_psbName_invalid_dbdName(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, INVALID_DBD, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, dbd_name=INVALID_DBD, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=True) #7. Invalid PSB and valid DBD, BUILD PSB=PSB_NAME and BUILD DBD=DBD_NAME,BLDPSB=NO def test_acb_gen_build_invalid_psbName_valid_dbdName(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, INVALID_PSB, DBD_NAME, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, False) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=INVALID_PSB, dbd_name=DBD_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=False) #8. Invalid PSB, DELETE PSB=PSB_NAME def test_acb_gen_delete_invalid_psbName(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, INVALID_PSB, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=INVALID_PSB, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB) #9. Invalid DBD, DELETE DBD=DBD_NAME def test_acb_gen_delete_invalid_dbdName(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, None, INVALID_DBD, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, dbd_name=INVALID_DBD, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB) #10. Invalid PSB and invalid DBD, DELETE PSB=PSB_NAME and DELETE DBD=DBD_NAME def test_acb_gen_delete_invalid_psbName_invalid_dbdName(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, INVALID_PSB, INVALID_DBD, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=INVALID_PSB, dbd_name=INVALID_DBD, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB) #11. Valid PSB and invalid DBD, DELETE PSB=PSB_NAME and DELETE DBD=DBD_NAME def test_acb_gen_delete_valid_psbName_invalid_dbdName(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, PSB_NAME, INVALID_DBD, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=PSB_NAME, dbd_name=INVALID_DBD, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB) #12. Invalid PSB and valid DBD, DELETE PSB=PSB_NAME and DELETE DBD=DBD_NAME def test_acb_gen_delete_invalid_psbName_valid_dbdName(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, INVALID_PSB, DBD_NAME, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=INVALID_PSB, dbd_name=DBD_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB) #13. Invalid PSBLIB - LIB not exists def test_acb_gen_delete_invalid_psblib(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, PSB_NAME, DBD_NAME, INVALID_PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=PSB_NAME, dbd_name=DBD_NAME, psb_lib=INVALID_PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB) #14. Invalid DBDLIB - LIB not exists def test_acb_gen_delete_invalid_dbdlib(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, PSB_NAME, DBD_NAME, PSBLIB, INVALID_DBDLIB, ACBLIB, STEPLIB, RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=PSB_NAME, dbd_name=DBD_NAME, psb_lib=PSBLIB, dbd_lib=INVALID_DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB) #15. Invalid STEPLIB - LIB authorized and exists def test_acb_gen_delete_invalid_steplib(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, PSB_NAME, DBD_NAME, PSBLIB, DBDLIB, ACBLIB, INVALID_STEPLIB, RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=PSB_NAME, dbd_name=DBD_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=INVALID_STEPLIB, reslib=RESLIB) #16. Invalid RESLIB - LIB authorized and exists def test_acb_gen_delete_invalid_reslib(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, PSB_NAME, DBD_NAME, PSBLIB, DBDLIB, ACBLIB, STEPLIB, INVALID_RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=PSB_NAME, dbd_name=DBD_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=INVALID_RESLIB) #17. Invalid COMP def test_acb_gen_build_invalid_comp(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, INVALID_COMP, True) - + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, compression=INVALID_COMP, build_psb=True) #18. PSBLIB with no psbs and DBDLIB populated, BUILD PSB=ALL def test_acb_gen_delete_no_psbs(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, PSB_NAME, DBD_NAME, EMPTY_PSBLIB, DBDLIB, ACBLIB, STEPLIB, INVALID_RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=PSB_NAME, dbd_name=DBD_NAME, psb_lib=EMPTY_PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=INVALID_RESLIB) #19. DBDLIB with no dbds and PSBLIB populated, BUILD PSB=ALL def test_acb_gen_delete_no_dbds(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, PSB_NAME, DBD_NAME, PSBLIB, EMPTY_DBDLIB, ACBLIB, STEPLIB, INVALID_RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=PSB_NAME, dbd_name=DBD_NAME, psb_lib=PSBLIB, dbd_lib=EMPTY_DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=INVALID_RESLIB) #20. Invalid ACBLIB def test_acb_gen_build_invalid_acblib(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, None, PSBLIB, DBDLIB, INVALID_ACBLIB, STEPLIB, RESLIB, COMP, False) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=INVALID_ACBLIB, steplib=STEPLIB, reslib=RESLIB, compression=COMP, build_psb=False) #21. ACBLIB with invalid record format FB def test_acb_gen_build_acblib_recordFormat_FB(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, None, PSBLIB, DBDLIB, INVALID_RECFOR, STEPLIB, RESLIB, COMP, False) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=INVALID_RECFOR, steplib=STEPLIB, reslib=RESLIB, build_psb=False) diff --git a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_valid_input.py b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_valid_input.py index 199f0b1c..75443271 100755 --- a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_valid_input.py +++ b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_valid_input.py @@ -50,83 +50,97 @@ """ # check in acblib if the member exists - dataset member exists (zos_dataset) -def validate_build(hosts, psb_name, dbd_name, psb_lib, -dbd_lib, acb_lib, steplib, reslib, -compression, build_psb, command_input='BUILD'): - response = hosts.all.ims_acb_gen( - command_input=command_input, - psb_name=psb_name, - dbd_name=dbd_name, - psb_lib=psb_lib, - dbd_lib=dbd_lib, - acb_lib=acb_lib, - steplib=steplib, - reslib=reslib, - compression=compression, - build_psb=build_psb) - print("Result:", response) - for result in response.contacted.values(): - pprint(result) - print("Changed:", result['changed']) - print("Return code:", result['rc']) - assert result['changed'] == True - assert result['rc'] <= '4' - - -def validate_delete(hosts, psb_name, dbd_name, psb_lib, dbd_lib, acb_lib, steplib, - reslib, compression, command_input="DELETE"): - response = hosts.all.ims_acb_gen( - command_input=command_input, - psb_name=psb_name, - dbd_name=dbd_name, - psb_lib=psb_lib, - dbd_lib=dbd_lib, - acb_lib=acb_lib, - steplib=steplib, - reslib=reslib, - compression=compression) +def validate_acbgen(hosts, psb_name=None, dbd_name=None, psb_lib=None, + dbd_lib=None, acb_lib=None, steplib=None, reslib=None, + compression=None, build_psb=None, command_input=None): + + arguments = {} + if psb_name: + arguments["psb_name"] = psb_name + if dbd_name: + arguments["dbd_name"] = dbd_name + if psb_lib: + arguments["psb_lib"] = psb_lib + if dbd_lib: + arguments["dbd_lib"] = dbd_lib + if acb_lib: + arguments["acb_lib"] = acb_lib + if steplib: + arguments["steplib"] = steplib + if reslib: + arguments["reslib"] = reslib + if compression: + arguments["compression"] = compression + if build_psb: + arguments["build_psb"] = build_psb + if command_input: + arguments["command_input"] = command_input + + response = hosts.all.ims_acb_gen(**arguments) + print("Result:", response) for result in response.contacted.values(): pprint(result) - print("Changed:", result['changed']) - print("Return code: ", result['rc']) - assert result['changed'] == True - assert result['rc'] <= '4' + print("Changed:", result.get('changed')) + print("Return code:", result.get('rc')) + assert result.get('changed') == True + assert result.get('rc') <= '4' + + +# def validate_delete(hosts, psb_name, dbd_name, psb_lib, dbd_lib, acb_lib, steplib, +# reslib, compression, command_input="DELETE"): +# response = hosts.all.ims_acb_gen( +# command_input=command_input, +# psb_name=psb_name, +# dbd_name=dbd_name, +# psb_lib=psb_lib, +# dbd_lib=dbd_lib, +# acb_lib=acb_lib, +# steplib=steplib, +# reslib=reslib, +# compression=compression) +# print("Result:", response) +# for result in response.contacted.values(): +# pprint(result) +# print("Changed:", result['changed']) +# print("Return code: ", result['rc']) +# assert result['changed'] == True +# assert result['rc'] <= '4' #1. BUILD PSB=ALL as string def test_acb_gen_build_psbName_all(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME_ALL, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME_ALL, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=True) #2. DELETE PSB=PSB_NAME as list def test_acb_gen_delete_psbName(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, PSB_NAME, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB) #3. BUILD PSB=PSB_NAME def test_acb_gen_build_psbName(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=True) #4. DELETE DBD=(DBFSAMD3) def test_acb_gen_delete_dbdName(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, None, DBD_NAME, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, dbd_name=DBD_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB) #5. BUILD DBD=(HOSPVARD),BLDPSB=NO def test_acb_gen_build_dbdName_bldPsb_no(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, None, "HOSPVARD", PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, False) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, dbd_name="HOSPVARD", psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=False) #6. BUILD DBD=(HOSPVARD),BLDPSB=YES def test_acb_gen_build_dbdName_bldPsb_yes(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, None, "HOSPVARD", PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, dbd_name="HOSPVARD", psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=True) #7. BUILD PSB=PSB_NAME def test_acb_gen_build_psbName2(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=True) #8. DELETE PSB=PSB_NAME, DELETE DBD=DBD_NAMES #DELETE PSB=(PSBGENL)\n' @@ -140,64 +154,64 @@ def test_acb_gen_build_psbName2(ansible_zos_module): # check in acblib if this member got deleted def test_acb_gen_delete_psbName_dbdName(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, PSB_NAME, DBD_NAMES, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=PSB_NAME, dbd_name=DBD_NAMES, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB) #9. BUILD PSB=PSB_NAME def test_acb_gen_build_psbName3(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=True) #10.BUILD PSB=PSB_NAME, BUILD DBD=DBD_NAMES,BLDPSB=NO def test_acb_gen_build_psbName_dbdNames_bldPsb_no(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, DBD_NAMES, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, False) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, dbd_name=DBD_NAMES, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=False) #11.BUILD PSB=PSB_NAME, BUILD DBD=DBD_NAMES,BLDPSB=YES def test_acb_gen_build_psbName_dbdNames_bldPsb_yes(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, DBD_NAMES, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, dbd_name=DBD_NAMES, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=True) #12.BUILD PSB=PSB_NAME, BUILD DBD=DBD_NAME,BLDPSB=YES, COMP='PRECOMP' def test_acb_gen_build_psbName_dbdName_bldPsb_yes_comp_precomp(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, COMP_PRE, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, compression=COMP_PRE, build_psb=True) #13.BUILD PSB=PSB_NAME, BUILD DBD=DBDNAME,BLDPSB=YES, COMP='POSTCOMP' def test_acb_gen_build_psbName_dbdName_bldPsb_yes_comp_postcomp(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, COMP_POST, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, compression=COMP_POST, build_psb=True) #14.BUILD PSB=PSB_NAME, BUILD DBD=DBDNAME,BLDPSB=YES, COMP='PRECOMP,POSTCOMP' def test_acb_gen_build_psbName_dbdName_bldPsb_yes_comp_precomp_postcomp(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, COMP, True) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, compression=COMP, build_psb=True) #15.Multi line PSB and DBD - BUILD with BLDPSB=NO def test_acb_gen_build_psbNames_dbdNames_list(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, DBD_NAMES_LIST, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None, False) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, dbd_name=DBD_NAMES_LIST, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, build_psb=False) #16.Multi line PSB list over 6 PSB's in the list def test_acb_gen_delete_psbNames_list_comp_postcomp(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, PSB_NAMES, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, COMP_POST) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=PSB_NAMES, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB, compression=COMP_POST) #17.Multi line DBD list over 6 DBD's in the list def test_acb_gen_delete_dbdNames_list(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, None, DBD_NAMES, PSBLIB, DBDLIB, ACBLIB, STEPLIB, RESLIB, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, dbd_name=DBD_NAMES, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB) #18.STEPLIB=STEPLIB, RESLIB=None def test_acb_gen_build_psbName_no_reslib(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, None, PSBLIB, DBDLIB, ACBLIB, STEPLIB, None, None, False) + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, build_psb=False) -#19.RESLIB=None, STEPLIB=None(STEPLIB should be retrieved from environment_vars) +#19.RESLIB=STEPLIB=None(STEPLIB should be retrieved from environment_vars) def test_acb_gen_delete_dbdName_no_reslib_env_steplib(ansible_zos_module): hosts = ansible_zos_module - validate_delete(hosts, None, DBD_NAME, PSBLIB, DBDLIB, ACBLIB, None, None, None) + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, dbd_name=DBD_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB) #20.STEPLIB=None(STEPLIB should be retrieved from environment_vars), RESLIB=RESLIB def test_acb_gen_build_dbdName_only_reslib(ansible_zos_module): hosts = ansible_zos_module - validate_build(hosts, PSB_NAME, None, PSBLIB, DBDLIB, ACBLIB, None, RESLIB, None, False) \ No newline at end of file + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, reslib=RESLIB, build_psb=False) \ No newline at end of file diff --git a/tests/test_config.yml b/tests/test_config.yml index ff1a227b..fadf2c9c 100755 --- a/tests/test_config.yml +++ b/tests/test_config.yml @@ -4,28 +4,28 @@ python_path: /usr/lpp/izoda/v110/anaconda/bin/python3.6 environment: - ZOAU_ROOT: /u/omvsadm/mvsbuilds/103/mvsutil - PYTHON_ROOT: /u/omvsadm/mvsbuilds/103/mvsutil #/usr/lpp/izoda/v110/anaconda + ZOAU_ROOT: /u/omvsadm/mvsbuilds/mvsutil + PYTHON_ROOT: /u/omvsadm/mvsbuilds/mvsutil #/usr/lpp/izoda/v110/anaconda JAVA_ROOT: /usr/lpp/java MANPATH: /usr/man/%L - FFI_LIB: "/u/omvsadm/mvsbuilds/103/mvsutil/lib/ffi" + FFI_LIB: "/u/omvsadm/mvsbuilds/mvsutil/lib/ffi" RELEASE_NAME: python-2017-04-12 CURL_CA_BUNDLE: "/usr/lpp/izoda/v110/anaconda/etc/ssl/cacert.pem" RELEASE_DIR: /usr/lpp/rsusr/python27/python-2017-04-12-py27 RELEASE_TYPE: py27 - LIBPATH: "/u/omvsadm/mvsbuilds/103/mvsutil/lib:/u/oeusr01/usr/lpp/IBM/cyp/v3r8/pyz/usr/lpp/IBM/cyp/v3r8/pyz/lib:/lib:/usr/lib:." + LIBPATH: "/u/omvsadm/mvsbuilds/mvsutil/lib:/u/oeusr01/usr/lpp/IBM/cyp/v3r8/pyz/usr/lpp/IBM/cyp/v3r8/pyz/lib:/lib:/usr/lib:." #LIBPATH: "/usr/lpp/izoda/v110/anaconda/lib:/usr/lpp/zoautil/v100/lib:/lib:/usr/lib:." NLSPATH: /usr/lib/nls/msg/%L/%N MAIL: /usr/mail/OMVSADM _: /bin/env STEPLIB: IMSBLD.I15RTSMM.COMRESL1 - TERMINFO: "/u/omvsadm/mvsbuilds/103/mvsutil/share/terminfo" + TERMINFO: "/u/omvsadm/mvsbuilds/mvsutil/share/terminfo" #ZOAU_ROOT: "/usr/lpp/zoautil/v100" - ZOAUTIL_DIR: "/u/omvsadm/mvsbuilds/103/mvsutil" #"/usr/lpp/zoautil/v100" - PYTHONPATH: "/u/omvsadm/mvsbuilds/103/mvsutil/lib:/lib:/usr/lib" + ZOAUTIL_DIR: "/u/omvsadm/mvsbuild/mvsutil" #"/usr/lpp/zoautil/v100" + PYTHONPATH: "/u/omvsadm/mvsbuilds/mvsutil/lib:/lib:/usr/lib" #PYTHONPATH: "/usr/lpp/izoda/v110/anaconda/lib:/usr/lpp/zoautil/v100/lib:/lib:/usr/lib" - PKG_CONFIG_PATH: "/u/omvsadm/mvsbuilds/103/mvsutil/lib/pkgconfig:/usr/lpp/izoda/v110/anaconda/share/pkgconfig" - PYTHON_HOME: "/u/omvsadm/mvsbuilds/103/mvsutil" #"/usr/lpp/izoda/v110/anaconda" + PKG_CONFIG_PATH: "/u/omvsadm/mvsbuilds/mvsutil/lib/pkgconfig:/usr/lpp/izoda/v110/anaconda/share/pkgconfig" + PYTHON_HOME: "/u/omvsadm/mvsbuilds/mvsutil" #"/usr/lpp/izoda/v110/anaconda" _BPXK_JOBLOG: STDERR # environment variables for mvsutils/mvscmd _BPXK_AUTOCVT: ON @@ -38,7 +38,7 @@ environment: GIT_EXEC_PATH: "/usr/lpp/rsusr/ported/libexec/git-core" GIT_TEMPLATE_DIR: "/usr/lpp/rsusr/ported/share/git-core/templates" #PATH: '/u/omvsadm/mvsbuilds/103/mvsutil/bin:/usr/lpp/rsusr/ported/bin:{{ JAVA_ROOT }}/java180/J8.0_64/bin:/bin:/var/bin:{{ JAVA_ROOT }}/J8.0/bin:{{ PYTHON_ROOT }}/bin' - PATH: "/u/omvsadm/mvsbuilds/103/mvsutil/bin:/usr/lpp/rsusr/ported/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin:/usr/lpp/izoda/v110/anaconda/bin" + PATH: "/u/omvsadm/mvsbuilds/mvsutil/bin:/usr/lpp/rsusr/ported/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin:/usr/lpp/izoda/v110/anaconda/bin" # Java environment JAVA_HOME: /usr/lpp/java/java180/J8.0_64 LANG: C From cd9a8ca227fd6e25ffd95f11f39dc1bc5b321290 Mon Sep 17 00:00:00 2001 From: Dipti Date: Mon, 13 Jul 2020 16:32:27 -0700 Subject: [PATCH 07/21] updates acbgen --- plugins/modules/ims_acb_gen.py | 11 ++++++++--- .../ims_acb_gen/test_ims_acb_gen_valid_input.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/modules/ims_acb_gen.py b/plugins/modules/ims_acb_gen.py index b118a69f..ae61c4ca 100644 --- a/plugins/modules/ims_acb_gen.py +++ b/plugins/modules/ims_acb_gen.py @@ -188,6 +188,12 @@ - True is always returned unless a module or failure has occurred. returned: always type: bool +debug: + description: + - additional messages returned from ZOAU. + - For more information, refer to the L(ZOAU messages documentation,https://www.ibm.com/support/knowledgecenter/en/SSKFYE_1.0.0/bgy.html) + returned: always + type: str ''' @@ -214,7 +220,7 @@ def run_module(): command_input=dict(type="str", required=True, choices=["build", "BUILD", "delete", "DELETE"]), compression=dict(type="str", required=False, choices=[ "precomp", "postcomp", "precomp,postcomp", - "PRECOMP", "POSTCOMP", "PRECOMP,POSTCOMP","", None]), + "PRECOMP", "POSTCOMP", "PRECOMP,POSTCOMP"]), psb_name=dict(type="list", elements="str", required=False), dbd_name=dict(type="list", elements="str", required=False), acb_lib=dict(type="str", required=True), @@ -229,7 +235,6 @@ def run_module(): changed=True, msg='', content='', - error='', rc='', debug='' ) @@ -296,7 +301,7 @@ def run_module(): result['changed'] = False result['content'] = response.get('output', "") result['msg'] = em.FAILURE_MSG - result['error'] = response.get('error', "") + result['debug'] = response.get('error', "") result['rc'] = response.get('rc') else: result['changed'] = True diff --git a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_valid_input.py b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_valid_input.py index 75443271..bdcb51dc 100755 --- a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_valid_input.py +++ b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_valid_input.py @@ -84,7 +84,7 @@ def validate_acbgen(hosts, psb_name=None, dbd_name=None, psb_lib=None, print("Changed:", result.get('changed')) print("Return code:", result.get('rc')) assert result.get('changed') == True - assert result.get('rc') <= '4' + assert result.get('rc') <= 4 # def validate_delete(hosts, psb_name, dbd_name, psb_lib, dbd_lib, acb_lib, steplib, From 9292b17be75c7d0b7d0f5ac821d7fb962d3a31b7 Mon Sep 17 00:00:00 2001 From: Dipti Date: Mon, 13 Jul 2020 16:52:35 -0700 Subject: [PATCH 08/21] fix reslib, steplib bug --- playbooks/ims-collection-sample.yaml | 8 ++++---- plugins/module_utils/acbgen.py | 11 ++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/playbooks/ims-collection-sample.yaml b/playbooks/ims-collection-sample.yaml index 9b297377..e0e22ab6 100644 --- a/playbooks/ims-collection-sample.yaml +++ b/playbooks/ims-collection-sample.yaml @@ -112,10 +112,10 @@ dbd_lib: - IMSTESTU.ANSI.DBDLIB2 acb_lib: IMSTESTU.ANSI.ACBLIB1 - reslib: - - IMSNEW.DIPTI.IM00.SDFSRESL - steplib: - - IMSNEW.DIPTI.IM00.SDFSRESL + # reslib: + # - IMSNEW.DIPTI.IM00.SDFSRESL + # steplib: + # - IMSNEW.DIPTI.IM00.SDFSRESL - name: IMS Command ims_command: diff --git a/plugins/module_utils/acbgen.py b/plugins/module_utils/acbgen.py index 57ec8960..046f8d17 100644 --- a/plugins/module_utils/acbgen.py +++ b/plugins/module_utils/acbgen.py @@ -89,11 +89,16 @@ def _build_acbgen_statements(self): acbgen_utility_fields.append(steplib) if self.reslib: + reslib = self.reslib + else: + reslib = self.steplib + + if self.reslib: reslib_data_set_definitions = [ DatasetDefinition(reslib) for reslib in self.reslib] - reslib = DDStatement("DFSRESLB", reslib_data_set_definitions) - acbgen_utility_fields.append(reslib) - + reslib_dd_statement = DDStatement("DFSRESLB", reslib_data_set_definitions) + acbgen_utility_fields.append(reslib_dd_statement) + if self.psb_lib: for psblib in self.psb_lib: ims_dataset_list.append(DatasetDefinition(psblib)) From 2dd8566353b80e99a75296da7862d558d90bff62 Mon Sep 17 00:00:00 2001 From: Dipti Date: Mon, 13 Jul 2020 16:53:16 -0700 Subject: [PATCH 09/21] playbook --- playbooks/ims-collection-sample.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/playbooks/ims-collection-sample.yaml b/playbooks/ims-collection-sample.yaml index e0e22ab6..9b297377 100644 --- a/playbooks/ims-collection-sample.yaml +++ b/playbooks/ims-collection-sample.yaml @@ -112,10 +112,10 @@ dbd_lib: - IMSTESTU.ANSI.DBDLIB2 acb_lib: IMSTESTU.ANSI.ACBLIB1 - # reslib: - # - IMSNEW.DIPTI.IM00.SDFSRESL - # steplib: - # - IMSNEW.DIPTI.IM00.SDFSRESL + reslib: + - IMSNEW.DIPTI.IM00.SDFSRESL + steplib: + - IMSNEW.DIPTI.IM00.SDFSRESL - name: IMS Command ims_command: From f84be9a6364c205a027fc46fc7132ad117b9c6d4 Mon Sep 17 00:00:00 2001 From: Dipti Date: Mon, 13 Jul 2020 17:11:52 -0700 Subject: [PATCH 10/21] pointing to latest zoau build --- tests/test_config.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/test_config.yml b/tests/test_config.yml index fadf2c9c..c2bd749e 100755 --- a/tests/test_config.yml +++ b/tests/test_config.yml @@ -4,28 +4,28 @@ python_path: /usr/lpp/izoda/v110/anaconda/bin/python3.6 environment: - ZOAU_ROOT: /u/omvsadm/mvsbuilds/mvsutil - PYTHON_ROOT: /u/omvsadm/mvsbuilds/mvsutil #/usr/lpp/izoda/v110/anaconda + ZOAU_ROOT: /u/omvsadm/mvsbuilds/1032 + PYTHON_ROOT: /u/omvsadm/mvsbuilds/1032 #/usr/lpp/izoda/v110/anaconda JAVA_ROOT: /usr/lpp/java MANPATH: /usr/man/%L - FFI_LIB: "/u/omvsadm/mvsbuilds/mvsutil/lib/ffi" + FFI_LIB: "/u/omvsadm/mvsbuilds/1032/lib/ffi" RELEASE_NAME: python-2017-04-12 CURL_CA_BUNDLE: "/usr/lpp/izoda/v110/anaconda/etc/ssl/cacert.pem" RELEASE_DIR: /usr/lpp/rsusr/python27/python-2017-04-12-py27 RELEASE_TYPE: py27 - LIBPATH: "/u/omvsadm/mvsbuilds/mvsutil/lib:/u/oeusr01/usr/lpp/IBM/cyp/v3r8/pyz/usr/lpp/IBM/cyp/v3r8/pyz/lib:/lib:/usr/lib:." + LIBPATH: "/u/omvsadm/mvsbuilds/1032/lib:/u/oeusr01/usr/lpp/IBM/cyp/v3r8/pyz/usr/lpp/IBM/cyp/v3r8/pyz/lib:/lib:/usr/lib:." #LIBPATH: "/usr/lpp/izoda/v110/anaconda/lib:/usr/lpp/zoautil/v100/lib:/lib:/usr/lib:." NLSPATH: /usr/lib/nls/msg/%L/%N MAIL: /usr/mail/OMVSADM _: /bin/env - STEPLIB: IMSBLD.I15RTSMM.COMRESL1 - TERMINFO: "/u/omvsadm/mvsbuilds/mvsutil/share/terminfo" + STEPLIB: IMSNEW.DIPTI.IM00.SDFSRESL #IMSBLD.I15RTSMM.COMRESL1 + TERMINFO: "/u/omvsadm/mvsbuilds/1032/share/terminfo" #ZOAU_ROOT: "/usr/lpp/zoautil/v100" ZOAUTIL_DIR: "/u/omvsadm/mvsbuild/mvsutil" #"/usr/lpp/zoautil/v100" - PYTHONPATH: "/u/omvsadm/mvsbuilds/mvsutil/lib:/lib:/usr/lib" + PYTHONPATH: "/u/omvsadm/mvsbuilds/1032/lib:/lib:/usr/lib" #PYTHONPATH: "/usr/lpp/izoda/v110/anaconda/lib:/usr/lpp/zoautil/v100/lib:/lib:/usr/lib" - PKG_CONFIG_PATH: "/u/omvsadm/mvsbuilds/mvsutil/lib/pkgconfig:/usr/lpp/izoda/v110/anaconda/share/pkgconfig" - PYTHON_HOME: "/u/omvsadm/mvsbuilds/mvsutil" #"/usr/lpp/izoda/v110/anaconda" + PKG_CONFIG_PATH: "/u/omvsadm/mvsbuilds/1032/lib/pkgconfig:/usr/lpp/izoda/v110/anaconda/share/pkgconfig" + PYTHON_HOME: "/u/omvsadm/mvsbuilds/1032" #"/usr/lpp/izoda/v110/anaconda" _BPXK_JOBLOG: STDERR # environment variables for mvsutils/mvscmd _BPXK_AUTOCVT: ON @@ -38,7 +38,7 @@ environment: GIT_EXEC_PATH: "/usr/lpp/rsusr/ported/libexec/git-core" GIT_TEMPLATE_DIR: "/usr/lpp/rsusr/ported/share/git-core/templates" #PATH: '/u/omvsadm/mvsbuilds/103/mvsutil/bin:/usr/lpp/rsusr/ported/bin:{{ JAVA_ROOT }}/java180/J8.0_64/bin:/bin:/var/bin:{{ JAVA_ROOT }}/J8.0/bin:{{ PYTHON_ROOT }}/bin' - PATH: "/u/omvsadm/mvsbuilds/mvsutil/bin:/usr/lpp/rsusr/ported/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin:/usr/lpp/izoda/v110/anaconda/bin" + PATH: "/u/omvsadm/mvsbuilds/1032/bin:/usr/lpp/rsusr/ported/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin:/usr/lpp/izoda/v110/anaconda/bin" # Java environment JAVA_HOME: /usr/lpp/java/java180/J8.0_64 LANG: C From fa5734b0f6f0613d8e9aa2b0ed0ba547189c1546 Mon Sep 17 00:00:00 2001 From: Dipti Date: Mon, 13 Jul 2020 17:50:30 -0700 Subject: [PATCH 11/21] acbgen changes --- .../test_ims_acb_gen_invalid_input.py | 49 +------------------ .../test_ims_acb_gen_valid_input.py | 24 --------- tests/test_config.yml | 49 +++++-------------- 3 files changed, 12 insertions(+), 110 deletions(-) diff --git a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_invalid_input.py b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_invalid_input.py index 2cf04feb..c7fd09df 100755 --- a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_invalid_input.py +++ b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_invalid_input.py @@ -62,7 +62,6 @@ 18. PSBLIB with no psbs and DBDLIB populated, BUILD PSB=ALL 19. DBDLIB with no dbds and PSBLIB populated, BUILD PSB=ALL 20. Invalid ACBLIB -21. ACBLIB with invalid record format FB """ @@ -129,45 +128,6 @@ def validate_acbgen(hosts, psb_name=None, dbd_name=None, psb_lib=None, assert result.get('rc') != 0 elif result.get('msg'): assert "value of compression must be one of: precomp, postcomp, precomp,postcomp," in result.get('msg') - - -# def validate_acbgen(hosts, **kwargs): -# response = hosts.all.ims_acb_gen(**kwargs) -# print("Result:", response) -# for result in response.contacted.values(): -# pprint(result) -# print("Changed:", result['changed']) -# assert result['changed'] == False -# # if result['rc']: -# # assert result['rc'] != 0 -# # else: -# # print(result['rc']) -# # print("Return code:", result['rc']) -# assert result['rc'] != 0 - -# def validate_delete(hosts, psb_name, dbd_name, psb_lib, dbd_lib, acb_lib, steplib, -# reslib, compression, command_input="DELETE"): -# response = hosts.all.ims_acb_gen( -# command_input=command_input, -# psb_name=psb_name, -# dbd_name=dbd_name, -# psb_lib=psb_lib, -# dbd_lib=dbd_lib, -# acb_lib=acb_lib, -# steplib=steplib, -# reslib=reslib, -# compression=compression) -# print("Result:", response) -# for result in response.contacted.values(): -# pprint(result) -# print("Changed:", result['changed']) -# assert result['changed'] == False -# # if result['rc']: -# # assert result['rc'] != '0' -# # else: -# # print("Return code: ", result['rc']) -# assert result['rc'] != '0' - #1. PSB name doesn't exists as string, BUILD PSB=PSB_NAME def test_acb_gen_build_invalid_psbName_str(ansible_zos_module): @@ -274,11 +234,4 @@ def test_acb_gen_delete_no_dbds(ansible_zos_module): #20. Invalid ACBLIB def test_acb_gen_build_invalid_acblib(ansible_zos_module): hosts = ansible_zos_module - validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=INVALID_ACBLIB, steplib=STEPLIB, reslib=RESLIB, compression=COMP, build_psb=False) - -#21. ACBLIB with invalid record format FB -def test_acb_gen_build_acblib_recordFormat_FB(ansible_zos_module): - hosts = ansible_zos_module - validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=INVALID_RECFOR, steplib=STEPLIB, reslib=RESLIB, build_psb=False) - - + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=INVALID_ACBLIB, steplib=STEPLIB, reslib=RESLIB, compression=COMP, build_psb=False) \ No newline at end of file diff --git a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_valid_input.py b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_valid_input.py index bdcb51dc..0057bfe8 100755 --- a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_valid_input.py +++ b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_valid_input.py @@ -49,11 +49,9 @@ 20.STEPLIB=None(STEPLIB should be retrieved from environment_vars), RESLIB=RESLIB """ -# check in acblib if the member exists - dataset member exists (zos_dataset) def validate_acbgen(hosts, psb_name=None, dbd_name=None, psb_lib=None, dbd_lib=None, acb_lib=None, steplib=None, reslib=None, compression=None, build_psb=None, command_input=None): - arguments = {} if psb_name: arguments["psb_name"] = psb_name @@ -77,7 +75,6 @@ def validate_acbgen(hosts, psb_name=None, dbd_name=None, psb_lib=None, arguments["command_input"] = command_input response = hosts.all.ims_acb_gen(**arguments) - print("Result:", response) for result in response.contacted.values(): pprint(result) @@ -86,27 +83,6 @@ def validate_acbgen(hosts, psb_name=None, dbd_name=None, psb_lib=None, assert result.get('changed') == True assert result.get('rc') <= 4 - -# def validate_delete(hosts, psb_name, dbd_name, psb_lib, dbd_lib, acb_lib, steplib, -# reslib, compression, command_input="DELETE"): -# response = hosts.all.ims_acb_gen( -# command_input=command_input, -# psb_name=psb_name, -# dbd_name=dbd_name, -# psb_lib=psb_lib, -# dbd_lib=dbd_lib, -# acb_lib=acb_lib, -# steplib=steplib, -# reslib=reslib, -# compression=compression) -# print("Result:", response) -# for result in response.contacted.values(): -# pprint(result) -# print("Changed:", result['changed']) -# print("Return code: ", result['rc']) -# assert result['changed'] == True -# assert result['rc'] <= '4' - #1. BUILD PSB=ALL as string def test_acb_gen_build_psbName_all(ansible_zos_module): hosts = ansible_zos_module diff --git a/tests/test_config.yml b/tests/test_config.yml index c2bd749e..dad48b71 100755 --- a/tests/test_config.yml +++ b/tests/test_config.yml @@ -1,50 +1,23 @@ host: ec01105a.vmec.svl.ibm.com user: omvsadm -python_path: /usr/lpp/izoda/v110/anaconda/bin/python3.6 - - +python_path: /python/v3.8.0-ga/usr/lpp/IBM/cyp/v3r8/pyz/bin/python3 environment: - ZOAU_ROOT: /u/omvsadm/mvsbuilds/1032 - PYTHON_ROOT: /u/omvsadm/mvsbuilds/1032 #/usr/lpp/izoda/v110/anaconda - JAVA_ROOT: /usr/lpp/java - MANPATH: /usr/man/%L - FFI_LIB: "/u/omvsadm/mvsbuilds/1032/lib/ffi" - RELEASE_NAME: python-2017-04-12 - CURL_CA_BUNDLE: "/usr/lpp/izoda/v110/anaconda/etc/ssl/cacert.pem" - RELEASE_DIR: /usr/lpp/rsusr/python27/python-2017-04-12-py27 - RELEASE_TYPE: py27 - LIBPATH: "/u/omvsadm/mvsbuilds/1032/lib:/u/oeusr01/usr/lpp/IBM/cyp/v3r8/pyz/usr/lpp/IBM/cyp/v3r8/pyz/lib:/lib:/usr/lib:." - #LIBPATH: "/usr/lpp/izoda/v110/anaconda/lib:/usr/lpp/zoautil/v100/lib:/lib:/usr/lib:." - NLSPATH: /usr/lib/nls/msg/%L/%N - MAIL: /usr/mail/OMVSADM - _: /bin/env - STEPLIB: IMSNEW.DIPTI.IM00.SDFSRESL #IMSBLD.I15RTSMM.COMRESL1 - TERMINFO: "/u/omvsadm/mvsbuilds/1032/share/terminfo" - #ZOAU_ROOT: "/usr/lpp/zoautil/v100" - ZOAUTIL_DIR: "/u/omvsadm/mvsbuild/mvsutil" #"/usr/lpp/zoautil/v100" - PYTHONPATH: "/u/omvsadm/mvsbuilds/1032/lib:/lib:/usr/lib" - #PYTHONPATH: "/usr/lpp/izoda/v110/anaconda/lib:/usr/lpp/zoautil/v100/lib:/lib:/usr/lib" - PKG_CONFIG_PATH: "/u/omvsadm/mvsbuilds/1032/lib/pkgconfig:/usr/lpp/izoda/v110/anaconda/share/pkgconfig" - PYTHON_HOME: "/u/omvsadm/mvsbuilds/1032" #"/usr/lpp/izoda/v110/anaconda" - _BPXK_JOBLOG: STDERR - # environment variables for mvsutils/mvscmd - _BPXK_AUTOCVT: ON - _CEE_RUNOPTS: '"FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"' + _BPXK_AUTOCVT: "ON" + _CEE_RUNOPTS: "'FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)'" _TAG_REDIR_ERR: txt _TAG_REDIR_IN: txt _TAG_REDIR_OUT: txt - TOOLS_ROOT: "/usr/lpp/rsusr/ported" - GIT_SHELL: "/usr/lpp/rsusr/ported/bin/bash" - GIT_EXEC_PATH: "/usr/lpp/rsusr/ported/libexec/git-core" - GIT_TEMPLATE_DIR: "/usr/lpp/rsusr/ported/share/git-core/templates" - #PATH: '/u/omvsadm/mvsbuilds/103/mvsutil/bin:/usr/lpp/rsusr/ported/bin:{{ JAVA_ROOT }}/java180/J8.0_64/bin:/bin:/var/bin:{{ JAVA_ROOT }}/J8.0/bin:{{ PYTHON_ROOT }}/bin' - PATH: "/u/omvsadm/mvsbuilds/1032/bin:/usr/lpp/rsusr/ported/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin:/usr/lpp/izoda/v110/anaconda/bin" - # Java environment - JAVA_HOME: /usr/lpp/java/java180/J8.0_64 LANG: C + ZOAU_ROOT: "/u/omvsadm/mvsbuilds/1032" + ZOAU_HOME: "/u/omvsadm/mvsbuilds/1032" + LIBPATH: "/u/omvsadm/mvsbuilds/1032/lib:/python/v3.8.0-ga/usr/lpp/IBM/cyp/v3r8/pyz/lib:/lib:/usr/lib:." + ZOAUTIL_DIR: "/u/omvsadm/mvsbuilds/1032" + PYTHONPATH: "/u/omvsadm/mvsbuilds/1032/lib" + PATH: "/u/omvsadm/mvsbuilds/1032/bin:/python/v3.8.0-ga/usr/lpp/IBM/cyp/v3r8/pyz/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin" + STEPLIB: IMSNEW.DIPTI.IM00.SDFSRESL #'IMSBLD.I15RTSMM.COMRESL1' extra_args: STEPLIB: IMSNEW.DIPTI.IM00.SDFSRESL JOB_CARD: |- //ANSIBLE JOB 'testing', // CLASS=H,MSGLEVEL=(1,1),REGION=0M, - // MSGCLASS=H,NOTIFY=&SYSUID \ No newline at end of file + // MSGCLASS=H,NOTIFY=&SYSUID \ No newline at end of file From 02c8048dd512e3386ce54752560774a31a4606a9 Mon Sep 17 00:00:00 2001 From: Dipti Date: Mon, 13 Jul 2020 18:16:08 -0700 Subject: [PATCH 12/21] corrected typo - steplib/reslib --- plugins/module_utils/ims_module_error_messages.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/ims_module_error_messages.py b/plugins/module_utils/ims_module_error_messages.py index 558d4e24..556a276f 100755 --- a/plugins/module_utils/ims_module_error_messages.py +++ b/plugins/module_utils/ims_module_error_messages.py @@ -22,8 +22,8 @@ class ACBGENErrorMessages(): INCORRECT_ACBLIB_TYPE = "'acb_lib' must be a string." INCORRECT_PSBLIB_TYPE = "'psb_lib' must be a list of strings." INCORRECT_DBDLIB_TYPE = "'dbd_lib' must be a list of strings." - INCORRECT_RESLIB_TYPE = "step_lib' must be a list of strings." - INCORRECT_STEPLIB_TYPE = "res_lib' must be a list of strings." + INCORRECT_RESLIB_TYPE = "'reslib' must be a list of strings." + INCORRECT_STEPLIB_TYPE = "'steplib' must be a list of strings." INCORRECT_BUILD_PSB_TYPE = "'build_psb' must be boolean value - yes, no or true, false" COMMAND_INPUT_REQUIREMENT_MSG = "'command_input' must be specified" ACBLIB_REQUIREMENT_MSG = "'acb_lib' must be specified " From d25e524260860f31e5a6cda4c7e8f2b514548793 Mon Sep 17 00:00:00 2001 From: BRYANT PANYARACHUN Date: Mon, 13 Jul 2020 18:24:58 -0700 Subject: [PATCH 13/21] remove comment from test script. --- tests/run.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index 95b25018..4dab232a 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -11,7 +11,4 @@ export ANSIBLE_ACTION_PLUGINS=${plugins_dir}/action export ANSIBLE_CONNECTION_PLUGINS=${plugins_dir}/connection export ANSIBLE_CONFIG=$(pwd)/ansible.cfg -python3 -m pytest --host-pattern=all --zinventory=${1:-test_config.yml} $2 -vvv - - -# ./run.sh test_config.yml functional/modules/ims_acb_gen/test_ims_acb_gen_sample.py \ No newline at end of file +python3 -m pytest --host-pattern=all --zinventory=${1:-test_config.yml} $2 -vvv \ No newline at end of file From cf1f0d14ae0940d44b54c0f8d1106769d2d9518f Mon Sep 17 00:00:00 2001 From: BRYANT PANYARACHUN Date: Mon, 13 Jul 2020 18:27:50 -0700 Subject: [PATCH 14/21] update test script with beta3 refs. --- tests/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run.sh b/tests/run.sh index 4dab232a..786e165a 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -1,7 +1,7 @@ #!/bin/bash ansible-galaxy collection build ../ --force -ansible-galaxy collection install ibm.ibm_zos_ims:1.0.0-beta2 -c +ansible-galaxy collection install ibm.ibm_zos_ims:1.0.0-beta3 -c -f --force-with-deps plugins_dir=$(pwd)/../plugins core_dir=~/.ansible/collections/ansible_collections/ibm/ibm_zos_core/plugins From b9c80f63fe91b22cc8b7c60692ba6ecfcdd7e4be Mon Sep 17 00:00:00 2001 From: BRYANT PANYARACHUN Date: Mon, 13 Jul 2020 18:37:59 -0700 Subject: [PATCH 15/21] update group_vars for consistency. --- playbooks/group_vars/all.yml | 145 ++++++++++++++++++++++------------- 1 file changed, 91 insertions(+), 54 deletions(-) diff --git a/playbooks/group_vars/all.yml b/playbooks/group_vars/all.yml index 2cf1f6f8..5b5447ed 100755 --- a/playbooks/group_vars/all.yml +++ b/playbooks/group_vars/all.yml @@ -1,60 +1,97 @@ -# ZOAU_ROOT: /u/omvsadm/mvsbuilds/103/mvsutil -# PYTHON_ROOT: /usr/lpp/izoda/v110/anaconda -# JAVA_ROOT: /usr/lpp/java +################################################################################ +# Copyright (c) IBM Corporation 2020 +################################################################################ -# environment_vars: -# LIBPATH: '{{ ZOAU_ROOT}}/lib:{{ PYTHON_ROOT }}/lib:/lib:/usr/lib:.' -# # ZOAU_ROOT: '/u/omvsadm/mvsbuilds/103/mvsutil' #'zoautil/v100' -# ZOAUTIL_DIR: '{{ ZOAU_ROOT }}' -# ZOAU_ROOT: '{{ ZOAU_ROOT }}' -# ZOAU_HOME: '{{ ZOAU_ROOT }}' -# #ZOAUTIL_DIR: '/u/omvsadm/mvsbuilds/103/mvsutil' #'/usr/lpp/zoautil/v100' -# #ZOAU_HOME: '/u/omvsadm/mvsbuilds/103/mvsutil' -# PYTHONPATH: '{{ ZOAU_ROOT }}/lib:/lib:/usr/lib' -# PYTHON_HOME: '/usr/lpp/izoda/v110/anaconda' -# _BPXK_JOBLOG: STDERR -# # environment variables for mvsutils/mvscmd -# _BPXK_AUTOCVT: ON -# #_CEE_RUNOPTS: '"FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"' -# _TAG_REDIR_ERR: txt -# _TAG_REDIR_IN: txtbc -# _TAG_REDIR_OUT: txt -# TOOLS_ROOT: '/usr/lpp/rsusr/ported' -# PATH: '{{ ZOAU_ROOT }}/bin:/usr/lpp/rsusr/ported/bin:{{ JAVA_ROOT }}/java180/J8.0_64/bin:/bin:/var/bin:{{ JAVA_ROOT }}/J8.0/bin:{{ PYTHON_ROOT }}/bin' -# #PATH: '/u/omvsadm/mvsutil/bin:/usr/lpp/rsusr/ported/bin:/usr/lpp/java/java180/J8.0_64/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin:/usr/lpp/izoda/v110/anaconda/bin' -# JAVA_HOME: /usr/lpp/java/java180/J8.0_64 -# STEPLIB: IMSBLD.I15RTSMM.COMRESL1 # IMSNEW.DIPTI.IM00.SDFSRESL -# LANG: C +################################################################################ +# - The value for the property BPXK_AUTOCVT must be configured to "ON"; +# for example: _BPXK_AUTOCVT: "ON" +# - The value for the property ZOAU_HOME is the ZOA Utilities install root path; +# for example: ZOAU_HOME: "/usr/lpp/IBM/zoautil" +# - The value for the property PYTHONPATH is the ZOA Utilities Python library path; +# for example: PYTHONPATH: "/usr/lpp/IBM/zoautil/lib" +# - The value for the property LIBPATH is both the path to the Python libraries on +# the target and the ZOA Utilities Python library path separated by +# semi-colons; for example: +# LIBPATH: "/usr/lpp/IBM/zoautil/lib/:/usr/lpp/IBM/cyp/v3r8/pyz/lib:/usr/lib:/lib:." +# - The value for the property PATH is the ZOA utilities BIN path and Python +# interpreter path, for example: +# PATH: "/usr/lpp/IBM/zoautil/bin:/usr/lpp/IBM/cyp/v3r8/pyz/bin:/bin" +# - The value for the property _CEE_RUNOPTS is the invocation Language +# Environment® runtime options for programs and used by Python. For example, +# _CEE_RUNOPTS: "FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)" +# - The value for the properties __TAG_REDIR_ERR, _TAG_REDIR_IN, _TAG_REDIR_OUT +# are txt and used by the shell; for example: +# _TAG_REDIR_ERR: "txt" +# _TAG_REDIR_IN: "txt" +# _TAG_REDIR_OUT: "txt" +# - The value for the property LANG is the name of the default locale; value +# C specifies the POSIX locale; for example: ``LANG: "C"``. +# - The bash shell is unsupported. If that is the only shell available, you must +# control how new and existing files are tagged and encoded. An +# example of what is needed in addition to the files environment variables +# are "_ENCODE_FILE_NEW" and "_ENCODE_FILE_EXISTING"; for example, +# _ENCODE_FILE_NEW: "IBM-1047" +# _ENCODE_FILE_EXISTING: "IBM-1047" +# Please review the README.ZOS guide included with the ported ``bash`` shell +# for further configurations. +# +# Note: +# In ZOAU 1.0.2 and later, the property ZOAU_ROOT is no longer supported +# and must be replaced with the property ZOAU_HOME. If you are using ZOAU +# version 1.0.1 or lower, you must continue to use the property +# ZOAU_ROOT which is the ZOA Utilities install root path required for +# ZOAU; for example, ``/usr/lpp/IBM/zoautil``. +# +################################################################################ -# JOB_CARD: |- -# //ANSIBLE JOB 'testing', -# // CLASS=H,MSGLEVEL=(1,1),REGION=0M, -# // MSGCLASS=H,NOTIFY=&SYSUID - -ZOAU_ROOT: /u/omvsadm/mvsbuilds/mvsutil -PYTHON_ROOT: /usr/lpp/izoda/v110/anaconda #/usr/lpp/izoda/v110/anaconda -JAVA_ROOT: /usr/lpp/java +################################################################################ +# Configure dependency installations +################################################################################ +PYZ: "/usr/lpp/IBM/cyp/v3r8/pyz" +ZOAU: "/usr/lpp/IBM/zoautil" +################################################################################ +# Playbook enviroment variables +################################################################################ environment_vars: - LIBPATH: '{{ ZOAU_ROOT}}/lib:{{ PYTHON_ROOT }}/lib:/lib:/usr/lib:.' - ZOAUTIL_DIR: '{{ ZOAU_ROOT }}' - ZOAU_ROOT: '{{ ZOAU_ROOT }}' - ZOAU_HOME: '{{ ZOAU_ROOT }}' - PYTHONPATH: '{{ ZOAU_ROOT }}/lib:/lib:/usr/lib' - _BPXK_JOBLOG: STDERR - # environment variables for mvsutils/mvscmd - _BPXK_AUTOCVT: "ON" - #_CEE_RUNOPTS: '"FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"' - # _TAG_REDIR_ERR: txt - # _TAG_REDIR_IN: txt - # _TAG_REDIR_OUT: txt - TOOLS_ROOT: '/usr/lpp/rsusr/ported' - PATH: '{{ ZOAU_ROOT }}/bin:/usr/lpp/rsusr/ported/bin:{{ JAVA_ROOT }}/java180/J8.0_64/bin:/bin:/var/bin:{{ JAVA_ROOT }}/J8.0/bin:{{ PYTHON_ROOT }}/bin' - JAVA_HOME: '{{ JAVA_ROOT }}/java180/J8.0_64' - STEPLIB: IMSNEW.DIPTI.IM00.SDFSRESL #IMSBLD.I15RTSMM.COMRESL1 - LANG: C + _BPXK_AUTOCVT: "ON" + ZOAU_HOME: "{{ ZOAU }}" + PYTHONPATH: "{{ ZOAU_HOME }}/lib" + LIBPATH: "{{ ZOAU_HOME }}/lib:{{ PYZ }}/lib:/lib:/usr/lib:." + PATH: "{{ ZOAU_HOME }}/bin:{{ PYZ }}/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin" + _CEE_RUNOPTS: "FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)" + _TAG_REDIR_ERR: "txt" + _TAG_REDIR_IN: "txt" + _TAG_REDIR_OUT: "txt" + LANG: "C" + ##################### + _BPXK_JOBLOG: STDERR + STEPLIB: IMSBLD.I15RTSMM.COMRESL1 # IMSNEW.DIPTI.IM00.SDFSRESL JOB_CARD: |- - //ANSIBLE JOB 'testing', - // CLASS=H,MSGLEVEL=(1,1),REGION=0M, - // MSGCLASS=H,NOTIFY=&SYSUID \ No newline at end of file + //ANSIBLE JOB 'testing', + // CLASS=H,MSGLEVEL=(1,1),REGION=0M, + // MSGCLASS=H,NOTIFY=&SYSUID + +## environment_vars: +## LIBPATH: '/usr/lpp/izoda/v110/anaconda/lib:/u/omvsadm/mvsutil/lib:/lib:/usr/lib:.' +## ZOAU_ROOT: '/usr/lpp/zoautil/v100' +## ZOAUTIL_DIR: '/usr/lpp/zoautil/v100' +## PYTHONPATH: '/usr/lpp/izoda/v110/anaconda/lib:/u/omvsadm/mvsutil/lib:/lib:/usr/lib' +## PYTHON_HOME: '/usr/lpp/izoda/v110/anaconda' +## _BPXK_JOBLOG: STDERR +## # environment variables for mvsutils/mvscmd +## _BPXK_AUTOCVT: ON +## #_CEE_RUNOPTS: '"FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"' +## _TAG_REDIR_ERR: txt +## _TAG_REDIR_IN: txt +## _TAG_REDIR_OUT: txt +## TOOLS_ROOT: '/usr/lpp/rsusr/ported' +## PATH: '/u/omvsadm/mvsutil/bin:/usr/lpp/rsusr/ported/bin:/usr/lpp/java/java180/J8.0_64/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin:/usr/lpp/izoda/v110/anaconda/bin' +## JAVA_HOME: /usr/lpp/java/java180/J8.0_64 +## STEPLIB: IMSBLD.I15RTSMM.COMRESL1 # IMSNEW.DIPTI.IM00.SDFSRESL +## +## JOB_CARD: |- +## //ANSIBLE JOB 'testing', +## // CLASS=H,MSGLEVEL=(1,1),REGION=0M, +## // MSGCLASS=H,NOTIFY=&SYSUID \ No newline at end of file From 6c82cf15fe5f604daecddd416be8b5a75593ae0e Mon Sep 17 00:00:00 2001 From: Dipti Date: Mon, 13 Jul 2020 19:10:12 -0700 Subject: [PATCH 16/21] acbgen updates --- playbooks/group_vars/all.yml | 57 +++++++++++++++---- plugins/module_utils/acbgen.py | 2 + .../module_utils/ims_module_error_messages.py | 3 +- 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/playbooks/group_vars/all.yml b/playbooks/group_vars/all.yml index 2cf1f6f8..43fa9dd3 100755 --- a/playbooks/group_vars/all.yml +++ b/playbooks/group_vars/all.yml @@ -31,16 +31,50 @@ # // CLASS=H,MSGLEVEL=(1,1),REGION=0M, # // MSGCLASS=H,NOTIFY=&SYSUID -ZOAU_ROOT: /u/omvsadm/mvsbuilds/mvsutil -PYTHON_ROOT: /usr/lpp/izoda/v110/anaconda #/usr/lpp/izoda/v110/anaconda +# ZOAU_ROOT: /u/omvsadm/mvsbuilds/mvsutil +# PYTHON_ROOT: /usr/lpp/izoda/v110/anaconda #/usr/lpp/izoda/v110/anaconda +# JAVA_ROOT: /usr/lpp/java + +# environment_vars: +# LIBPATH: '{{ ZOAU_ROOT}}/lib:{{ PYTHON_ROOT }}/lib:/lib:/usr/lib:.' +# ZOAUTIL_DIR: '{{ ZOAU_ROOT }}' +# ZOAU_ROOT: '{{ ZOAU_ROOT }}' +# ZOAU_HOME: '{{ ZOAU_ROOT }}' +# PYTHONPATH: '{{ ZOAU_ROOT }}/lib:/lib:/usr/lib' +# _BPXK_JOBLOG: STDERR +# # environment variables for mvsutils/mvscmd +# _BPXK_AUTOCVT: "ON" +# #_CEE_RUNOPTS: '"FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"' +# # _TAG_REDIR_ERR: txt +# # _TAG_REDIR_IN: txt +# # _TAG_REDIR_OUT: txt +# TOOLS_ROOT: '/usr/lpp/rsusr/ported' +# PATH: '{{ ZOAU_ROOT }}/bin:/usr/lpp/rsusr/ported/bin:{{ JAVA_ROOT }}/java180/J8.0_64/bin:/bin:/var/bin:{{ JAVA_ROOT }}/J8.0/bin:{{ PYTHON_ROOT }}/bin' +# JAVA_HOME: '{{ JAVA_ROOT }}/java180/J8.0_64' +# STEPLIB: IMSNEW.DIPTI.IM00.SDFSRESL #IMSBLD.I15RTSMM.COMRESL1 +# LANG: C + +# JOB_CARD: |- +# //ANSIBLE JOB 'testing', +# // CLASS=H,MSGLEVEL=(1,1),REGION=0M, +# // MSGCLASS=H,NOTIFY=&SYSUID + + ################################################################################ +# Configure dependency installations +################################################################################ +PYZ: /python/v3.8.0-ga/usr/lpp/IBM/cyp/v3r8/pyz/bin/python3 +ZOAU: /u/omvsadm/mvsbuilds/1032 JAVA_ROOT: /usr/lpp/java +################################################################################ +# Playbook enviroment variables +################################################################################ environment_vars: - LIBPATH: '{{ ZOAU_ROOT}}/lib:{{ PYTHON_ROOT }}/lib:/lib:/usr/lib:.' - ZOAUTIL_DIR: '{{ ZOAU_ROOT }}' - ZOAU_ROOT: '{{ ZOAU_ROOT }}' - ZOAU_HOME: '{{ ZOAU_ROOT }}' - PYTHONPATH: '{{ ZOAU_ROOT }}/lib:/lib:/usr/lib' + LIBPATH: '{{ ZOAU}}/lib:{{ PYZ }}/lib:/lib:/usr/lib:.' + ZOAUTIL_DIR: '{{ ZOAU }}' + ZOAU_ROOT: '{{ ZOAU }}' + ZOAU_HOME: '{{ ZOAU }}' + PYTHONPATH: '{{ ZOAU }}/lib:/lib:/usr/lib' _BPXK_JOBLOG: STDERR # environment variables for mvsutils/mvscmd _BPXK_AUTOCVT: "ON" @@ -49,12 +83,13 @@ environment_vars: # _TAG_REDIR_IN: txt # _TAG_REDIR_OUT: txt TOOLS_ROOT: '/usr/lpp/rsusr/ported' - PATH: '{{ ZOAU_ROOT }}/bin:/usr/lpp/rsusr/ported/bin:{{ JAVA_ROOT }}/java180/J8.0_64/bin:/bin:/var/bin:{{ JAVA_ROOT }}/J8.0/bin:{{ PYTHON_ROOT }}/bin' + PATH: '{{ ZOAU }}/bin:/usr/lpp/rsusr/ported/bin:{{ JAVA_ROOT }}/java180/J8.0_64/bin:/bin:/var/bin:{{ JAVA_ROOT }}/J8.0/bin:{{ PYZ }}/bin' JAVA_HOME: '{{ JAVA_ROOT }}/java180/J8.0_64' STEPLIB: IMSNEW.DIPTI.IM00.SDFSRESL #IMSBLD.I15RTSMM.COMRESL1 LANG: C + JOB_CARD: |- - //ANSIBLE JOB 'testing', - // CLASS=H,MSGLEVEL=(1,1),REGION=0M, - // MSGCLASS=H,NOTIFY=&SYSUID \ No newline at end of file + //ANSIBLE JOB 'testing', + // CLASS=H,MSGLEVEL=(1,1),REGION=0M, + // MSGCLASS=H,NOTIFY=&SYSUID \ No newline at end of file diff --git a/plugins/module_utils/acbgen.py b/plugins/module_utils/acbgen.py index 046f8d17..6372cd06 100644 --- a/plugins/module_utils/acbgen.py +++ b/plugins/module_utils/acbgen.py @@ -68,6 +68,8 @@ def _assert_valid_input_types(self): raise TypeError(em.INCORRECT_RESLIB_TYPE) if self.build_psb and not isinstance(self.build_psb, bool): raise TypeError(em.INCORRECT_BUILD_PSB_TYPE) + if not self.psb_name and not self.dbd_name: + raise ValueError(em.INCORRECT_COMMAND_ARGS) def _build_acbgen_statements(self): """Builds the list of DDStatements that will be provided to the zos_mvs_raw to execute DFSRRC00 diff --git a/plugins/module_utils/ims_module_error_messages.py b/plugins/module_utils/ims_module_error_messages.py index 556a276f..f21c5fe1 100755 --- a/plugins/module_utils/ims_module_error_messages.py +++ b/plugins/module_utils/ims_module_error_messages.py @@ -33,4 +33,5 @@ class ACBGENErrorMessages(): FAILURE_MSG = "Failure. See output for details." EMPTY_OUTPUT_MSG = "ACBGEN could not be processed. Please check input parameters." INCORRECT_TYPE = "Incorrect type provided. A string or list of strings is expected" - INCORRECT_ITEM_LIST = "Items provided in list do not match the string type expected." \ No newline at end of file + INCORRECT_ITEM_LIST = "Items provided in list do not match the string type expected." + INCORRECT_COMMAND_ARGS = "Must provide at least one of 'pdb_name', 'dbd_name'" \ No newline at end of file From b4d2c0343fcd8d7ff8da1585cbab9efda193157e Mon Sep 17 00:00:00 2001 From: BRYANT PANYARACHUN Date: Mon, 13 Jul 2020 19:41:17 -0700 Subject: [PATCH 17/21] remove steplib from extra args. --- tests/test_config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_config.yml b/tests/test_config.yml index dad48b71..b0e555aa 100755 --- a/tests/test_config.yml +++ b/tests/test_config.yml @@ -16,7 +16,6 @@ environment: PATH: "/u/omvsadm/mvsbuilds/1032/bin:/python/v3.8.0-ga/usr/lpp/IBM/cyp/v3r8/pyz/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin" STEPLIB: IMSNEW.DIPTI.IM00.SDFSRESL #'IMSBLD.I15RTSMM.COMRESL1' extra_args: - STEPLIB: IMSNEW.DIPTI.IM00.SDFSRESL JOB_CARD: |- //ANSIBLE JOB 'testing', // CLASS=H,MSGLEVEL=(1,1),REGION=0M, From 97827c9fabb4ae26d5c950bd5450e605f62e6f5f Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 17 Jul 2020 18:17:17 -0700 Subject: [PATCH 18/21] acbgen updates Co-authored-by: Asif Mahmud --- playbooks/group_vars/all.yml | 10 +-- .../ims_acb_gen/test_ims_acb_gen_sample.py | 68 ++++++++++--------- 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/playbooks/group_vars/all.yml b/playbooks/group_vars/all.yml index 940981d5..d208d5b6 100755 --- a/playbooks/group_vars/all.yml +++ b/playbooks/group_vars/all.yml @@ -45,17 +45,17 @@ ################################################################################ # Configure dependency installations ################################################################################ -PYZ: "/usr/lpp/IBM/cyp/v3r8/pyz" -ZOAU: "/usr/lpp/IBM/zoautil" +PYZ: "/python/v3.8.0-ga/usr/lpp/IBM/cyp/v3r8/pyz" +ZOAU: "/u/omvsadm/mvsbuilds/1032" ################################################################################ # Playbook enviroment variables ################################################################################ environment_vars: _BPXK_AUTOCVT: "ON" ZOAU_HOME: "{{ ZOAU }}" - PYTHONPATH: "{{ ZOAU_HOME }}/lib" - LIBPATH: "{{ ZOAU_HOME }}/lib:{{ PYZ }}/lib:/lib:/usr/lib:." - PATH: "{{ ZOAU_HOME }}/bin:{{ PYZ }}/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin" + PYTHONPATH: "{{ ZOAU}}/lib" + LIBPATH: "{{ ZOAU }}/lib:{{ PYZ }}/lib:/lib:/usr/lib:." + PATH: "{{ ZOAU }}/bin:{{ PYZ }}/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin" _CEE_RUNOPTS: "FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)" _TAG_REDIR_ERR: "txt" _TAG_REDIR_IN: "txt" diff --git a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_sample.py b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_sample.py index ed47f4d5..280e9381 100755 --- a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_sample.py +++ b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_sample.py @@ -23,45 +23,49 @@ COMP_POST = ip.COMP_POST COMP = ip.COMP +def validate_acbgen(hosts, psb_name=None, dbd_name=None, psb_lib=None, + dbd_lib=None, acb_lib=None, steplib=None, reslib=None, + compression=None, build_psb=None, command_input=None): + arguments = {} + if psb_name: + arguments["psb_name"] = psb_name + if dbd_name: + arguments["dbd_name"] = dbd_name + if psb_lib: + arguments["psb_lib"] = psb_lib + if dbd_lib: + arguments["dbd_lib"] = dbd_lib + if acb_lib: + arguments["acb_lib"] = acb_lib + if steplib: + arguments["steplib"] = steplib + if reslib: + arguments["reslib"] = reslib + if compression: + arguments["compression"] = compression + if build_psb: + arguments["build_psb"] = build_psb + if command_input: + arguments["command_input"] = command_input + + response = hosts.all.ims_acb_gen(**arguments) + print("Result:", response) + for result in response.contacted.values(): + pprint(result) + print("Changed:", result.get('changed')) + print("Return code:", result.get('rc')) + assert result.get('changed') == True + assert result.get('rc') <= 4 + def test_ims_acb_gen_sample_build(ansible_zos_module): hosts = ansible_zos_module - - results = hosts.all.ims_acb_gen( - command_input=COMMAND_INPUT_BUILD, - psb_name=PSB_NAME, - psb_lib=PSBLIB, - dbd_lib=DBDLIB, - acb_lib=ACBLIB, - reslib=RESLIB, - steplib=STEPLIB, - ) - print("Result:", results) - for result in results.contacted.values(): - pprint(result) - print("Changed:", result['changed']) - assert result['changed'] == True - assert result['rc'] <= '4' + validate_acbgen(hosts, command_input=COMMAND_INPUT_BUILD, psb_name=PSB_NAME, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB) def test_ims_acb_gen_sample_delete(ansible_zos_module): hosts = ansible_zos_module - results = hosts.all.ims_acb_gen( - command_input=COMMAND_INPUT_DELETE, - psb_name=PSB_NAME, - dbd_name=DBD_NAMES, - psb_lib=PSBLIB, - dbd_lib=DBDLIB, - acb_lib=ACBLIB, - reslib=RESLIB, - steplib=STEPLIB, - ) - print("Result:", results) - for result in results.contacted.values(): - pprint(result) - print("Changed:", result['changed']) - assert result['changed'] == True - assert result['rc'] <= '4' + validate_acbgen(hosts, command_input=COMMAND_INPUT_DELETE, psb_name=PSB_NAME, dbd_name=DBD_NAMES, psb_lib=PSBLIB, dbd_lib=DBDLIB, acb_lib=ACBLIB, steplib=STEPLIB, reslib=RESLIB) From d25b7cfe3352f55c6a3f3620fab5962c0604c447 Mon Sep 17 00:00:00 2001 From: Dipti Date: Fri, 17 Jul 2020 21:09:47 -0700 Subject: [PATCH 19/21] acbgen updates --- tests/functional/modules/ims_acb_gen/test_ims_acb_gen_sample.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_sample.py b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_sample.py index 280e9381..48cfb870 100755 --- a/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_sample.py +++ b/tests/functional/modules/ims_acb_gen/test_ims_acb_gen_sample.py @@ -23,6 +23,7 @@ COMP_POST = ip.COMP_POST COMP = ip.COMP + def validate_acbgen(hosts, psb_name=None, dbd_name=None, psb_lib=None, dbd_lib=None, acb_lib=None, steplib=None, reslib=None, compression=None, build_psb=None, command_input=None): From df8e642cc6afe9792b43418a68140d4cd88e1c67 Mon Sep 17 00:00:00 2001 From: Dipti Date: Sat, 18 Jul 2020 17:38:57 -0700 Subject: [PATCH 20/21] updated galaxy build path --- plugins/module_utils/acbgen.py | 1 - tests/run.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/module_utils/acbgen.py b/plugins/module_utils/acbgen.py index 6372cd06..7e9f81e9 100644 --- a/plugins/module_utils/acbgen.py +++ b/plugins/module_utils/acbgen.py @@ -14,7 +14,6 @@ class acbgen(object): ACBGEN_UTILITY = "DFSRRC00" COMPRESS_UTILITY = "IEBCOPY" - # def __init__(self, command_input, compression, psb_name=None, dbd_name=None, acb_lib, psb_lib, dbd_lib, reslib=None, steplib=None, build_psb): def __init__(self, command_input, compression, psb_name, dbd_name, acb_lib, psb_lib, dbd_lib, reslib, steplib, build_psb): """IMSAcbgen constructor for generating IMS ACB using zos_mvs_raw Args: diff --git a/tests/run.sh b/tests/run.sh index 786e165a..3b541743 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -1,7 +1,7 @@ #!/bin/bash ansible-galaxy collection build ../ --force -ansible-galaxy collection install ibm.ibm_zos_ims:1.0.0-beta3 -c -f --force-with-deps +ansible-galaxy collection install ./ibm-ibm_zos_ims*.tar.gz -c -f --force-with-deps plugins_dir=$(pwd)/../plugins core_dir=~/.ansible/collections/ansible_collections/ibm/ibm_zos_core/plugins From e7f1844d37a4cb8fe693e267b55005b2afcf33f5 Mon Sep 17 00:00:00 2001 From: BRYANT PANYARACHUN Date: Sat, 18 Jul 2020 22:11:24 -0700 Subject: [PATCH 21/21] change sample playbook variables back to external. --- playbooks/group_vars/all.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/playbooks/group_vars/all.yml b/playbooks/group_vars/all.yml index d208d5b6..5b5447ed 100755 --- a/playbooks/group_vars/all.yml +++ b/playbooks/group_vars/all.yml @@ -1,6 +1,7 @@ ################################################################################ # Copyright (c) IBM Corporation 2020 ################################################################################ + ################################################################################ # - The value for the property BPXK_AUTOCVT must be configured to "ON"; # for example: _BPXK_AUTOCVT: "ON" @@ -42,20 +43,22 @@ # ZOAU; for example, ``/usr/lpp/IBM/zoautil``. # ################################################################################ + ################################################################################ # Configure dependency installations ################################################################################ -PYZ: "/python/v3.8.0-ga/usr/lpp/IBM/cyp/v3r8/pyz" -ZOAU: "/u/omvsadm/mvsbuilds/1032" +PYZ: "/usr/lpp/IBM/cyp/v3r8/pyz" +ZOAU: "/usr/lpp/IBM/zoautil" + ################################################################################ # Playbook enviroment variables ################################################################################ environment_vars: _BPXK_AUTOCVT: "ON" ZOAU_HOME: "{{ ZOAU }}" - PYTHONPATH: "{{ ZOAU}}/lib" - LIBPATH: "{{ ZOAU }}/lib:{{ PYZ }}/lib:/lib:/usr/lib:." - PATH: "{{ ZOAU }}/bin:{{ PYZ }}/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin" + PYTHONPATH: "{{ ZOAU_HOME }}/lib" + LIBPATH: "{{ ZOAU_HOME }}/lib:{{ PYZ }}/lib:/lib:/usr/lib:." + PATH: "{{ ZOAU_HOME }}/bin:{{ PYZ }}/bin:/bin:/var/bin:/usr/lpp/java/J8.0/bin" _CEE_RUNOPTS: "FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)" _TAG_REDIR_ERR: "txt" _TAG_REDIR_IN: "txt" @@ -64,10 +67,12 @@ environment_vars: ##################### _BPXK_JOBLOG: STDERR STEPLIB: IMSBLD.I15RTSMM.COMRESL1 # IMSNEW.DIPTI.IM00.SDFSRESL + JOB_CARD: |- //ANSIBLE JOB 'testing', // CLASS=H,MSGLEVEL=(1,1),REGION=0M, // MSGCLASS=H,NOTIFY=&SYSUID + ## environment_vars: ## LIBPATH: '/usr/lpp/izoda/v110/anaconda/lib:/u/omvsadm/mvsutil/lib:/lib:/usr/lib:.' ## ZOAU_ROOT: '/usr/lpp/zoautil/v100'