From bd7986773386753e46097f7bea344edb73e60f37 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml <66114686+Martin-Zeithaml@users.noreply.github.com> Date: Wed, 16 Oct 2024 09:47:24 +0200 Subject: [PATCH 01/11] Wrong error check Signed-off-by: Martin Zeithaml <66114686+Martin-Zeithaml@users.noreply.github.com> --- bin/libs/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/libs/common.ts b/bin/libs/common.ts index 76f94ae3c0..ad3457926c 100644 --- a/bin/libs/common.ts +++ b/bin/libs/common.ts @@ -345,7 +345,7 @@ export function getZoweRuntimeManifest(): any|undefined { if (!runtimeManifest) { const manifestFileName = `${std.getenv('ZWE_zowe_runtimeDirectory')}/manifest.json`; const result = xplatform.loadFileUTF8(manifestFileName,xplatform.AUTO_DETECT); - if (result){ + if (!result) { printError('Could not read runtime manifest in '+manifestFileName); } else { runtimeManifest=JSON.parse(result); From f8817b6c2f74f7e87d4fc492e12c0e00968a3e6d Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Wed, 23 Oct 2024 13:28:33 +0200 Subject: [PATCH 02/11] Small schema update Signed-off-by: Martin Zeithaml --- CHANGELOG.md | 1 + schemas/zowe-yaml-schema.json | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e1601c2b7..bb8747abc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to the Zowe Installer will be documented in this file. ## `3.0.1` - Enhancement: new javascript funtion `getStatvfs()` to obtain information about the file sysytem [#3994](https://github.com/zowe/zowe-install-packaging/pull/3994) +- Enhancement: schema validation update for `zowe.job.name` and `zowe.job.prefix` [#40nn](https://github.com/zowe/zowe-install-packaging/pull/40nn) ## `3.0.0` diff --git a/schemas/zowe-yaml-schema.json b/schemas/zowe-yaml-schema.json index deadae3492..73747e3591 100644 --- a/schemas/zowe-yaml-schema.json +++ b/schemas/zowe-yaml-schema.json @@ -465,11 +465,11 @@ "description": "Customize your Zowe z/OS JES job.", "properties": { "name": { - "type": "string", + "$ref": "/schemas/v2/server-common#zoweJobname", "description": "Job name of Zowe primary ZWESLSTC started task." }, "prefix": { - "type": "string", + "$ref": "/schemas/v2/server-common#zoweJobname", "description": "A short prefix to customize address spaces created by Zowe job." } } From ce2a47ab72570f03b9406bafdb90451309700694 Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Wed, 23 Oct 2024 13:34:21 +0200 Subject: [PATCH 03/11] Changelog PR number update Signed-off-by: Martin Zeithaml --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb8747abc7..c41887b177 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Zowe Installer will be documented in this file. ## `3.0.1` - Enhancement: new javascript funtion `getStatvfs()` to obtain information about the file sysytem [#3994](https://github.com/zowe/zowe-install-packaging/pull/3994) -- Enhancement: schema validation update for `zowe.job.name` and `zowe.job.prefix` [#40nn](https://github.com/zowe/zowe-install-packaging/pull/40nn) +- Enhancement: schema validation update for `zowe.job.name` and `zowe.job.prefix` [#4060](https://github.com/zowe/zowe-install-packaging/pull/4060) ## `3.0.0` From 37f022d7498784269e148b81404375239e88df75 Mon Sep 17 00:00:00 2001 From: mm667937 Date: Thu, 24 Oct 2024 16:46:44 +0200 Subject: [PATCH 04/11] I need to not delet the pswi so we can check where the issue happened - like if the PSWI wouuld be fine then there is a problem with testing Signed-off-by: mm667937 --- pswi/PSWI-marist.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pswi/PSWI-marist.sh b/pswi/PSWI-marist.sh index 5a9e03bfa7..c86e4e7365 100755 --- a/pswi/PSWI-marist.sh +++ b/pswi/PSWI-marist.sh @@ -140,15 +140,15 @@ if [ $presmpe -eq 0 ]; then sh 051_test_workflows.sh wf_test=$? fi - + # # Cleanup after the test - sh 06_test_cleanup.sh + #sh 06_test_cleanup.sh fi - else + #else # Cleanup of SMP/E if PTF weren't successful - because the earlier cleanup runs only it it was success - sh 07_smpe_cleanup.sh + # sh 07_smpe_cleanup.sh # Clean RELFILEs and PTFs - sh 08_presmpe_cleanup.sh + # sh 08_presmpe_cleanup.sh fi else # Cleanup of SMP/E if SMPE weren't successful - because the earlier cleanup runs only it it was success From d0545d8795671e21bf63c527075f3ef74e425c11 Mon Sep 17 00:00:00 2001 From: mm667937 Date: Fri, 25 Oct 2024 13:42:26 +0200 Subject: [PATCH 05/11] there was some deletion Signed-off-by: mm667937 --- pswi/PSWI-marist.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pswi/PSWI-marist.sh b/pswi/PSWI-marist.sh index c86e4e7365..69246ffcaf 100755 --- a/pswi/PSWI-marist.sh +++ b/pswi/PSWI-marist.sh @@ -122,7 +122,7 @@ if [ $presmpe -eq 0 ]; then # Create PSWI sh 03_create.sh create=$? - +exit -1 # Cleanup after the creation of PSWI sh 04_create_cleanup.sh # Cleanup of SMP/E @@ -144,11 +144,11 @@ if [ $presmpe -eq 0 ]; then # Cleanup after the test #sh 06_test_cleanup.sh fi - #else + else # Cleanup of SMP/E if PTF weren't successful - because the earlier cleanup runs only it it was success - # sh 07_smpe_cleanup.sh + sh 07_smpe_cleanup.sh # Clean RELFILEs and PTFs - # sh 08_presmpe_cleanup.sh + sh 08_presmpe_cleanup.sh fi else # Cleanup of SMP/E if SMPE weren't successful - because the earlier cleanup runs only it it was success From f40ea2b169e4a5c3403ce8190fdea67493eb5584 Mon Sep 17 00:00:00 2001 From: mm667937 Date: Fri, 25 Oct 2024 14:29:28 +0200 Subject: [PATCH 06/11] I can download the pswi to my folder which I am uploading as part of the github workflow so everything can be cleaned Signed-off-by: mm667937 --- pswi/03_create.sh | 6 ++++-- pswi/PSWI-marist.sh | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pswi/03_create.sh b/pswi/03_create.sh index 6feb2d56a7..d0c6e5ec5c 100644 --- a/pswi/03_create.sh +++ b/pswi/03_create.sh @@ -331,12 +331,14 @@ sh scripts/submit_jcl.sh "`cat JCL`" if [ $? -gt 0 ];then exit -1;fi rm JCL -cd ../.pax +#cd ../.pax +set -x +pwd sshpass -p${ZOSMF_PASS} sftp -o HostKeyAlgorithms=+ssh-rsa -o BatchMode=no -o StrictHostKeyChecking=no -o PubkeyAuthentication=no -b - -P ${ZZOW_SSH_PORT} ${ZOSMF_USER}@${HOST} << EOF cd ${TMP_MOUNT} get ${SWI_NAME}.pax.Z EOF -cd ../pswi +#cd ../pswi #TODO: redirect everything to $log/x ? #TODO: Check why there is name in mountpoints responses and it still doesn't show (although the mount points are different so it's good it is not doing anything) diff --git a/pswi/PSWI-marist.sh b/pswi/PSWI-marist.sh index 69246ffcaf..ab528ab8d1 100755 --- a/pswi/PSWI-marist.sh +++ b/pswi/PSWI-marist.sh @@ -91,6 +91,13 @@ export WORKFLOW_DSN=${CSIHLQ}.WORKFLOW export ZOWE_ZFS="${CSIHLQ}.ZFS" export VERSION=$(cat ../manifest.json.template | grep -o '"version": ".*"' | head -1 | cut -f4 -d\") +# Cleanup after the creation of PSWI +sh 04_create_cleanup.sh +# Cleanup of SMP/E +sh 07_smpe_cleanup.sh +# Clean RELFILEs and PTFs +sh 08_presmpe_cleanup.sh + # Initialize variables presmpe=0 smpe=0 @@ -122,7 +129,7 @@ if [ $presmpe -eq 0 ]; then # Create PSWI sh 03_create.sh create=$? -exit -1 + # Cleanup after the creation of PSWI sh 04_create_cleanup.sh # Cleanup of SMP/E From 41ede539aae73be49d060dd1384d60195199d3bc Mon Sep 17 00:00:00 2001 From: mm667937 Date: Fri, 25 Oct 2024 17:11:54 +0200 Subject: [PATCH 07/11] 2.3 won't be probable needed. Don't know if there still isn't anything left from that time when we had only 2.3 Signed-off-by: mm667937 --- pswi/03_create.sh | 49 ++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/pswi/03_create.sh b/pswi/03_create.sh index d0c6e5ec5c..d270d9bf3f 100644 --- a/pswi/03_create.sh +++ b/pswi/03_create.sh @@ -282,30 +282,31 @@ fi echo "Downloading export JCL" curl -s ${BASE_URL}/zosmf/restfiles/ds/${DSN} -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS > EXPORT -if [ "$ZOSMF_V" = "2.3" ] -then -echo "Changing jobcard and adding SYSAFF" -sed "s|//IZUD01EX JOB (ACCOUNT),'NAME'|$JOBST1\n$JOBST2|g" EXPORT > EXPJCL0 - -echo "Changing working directory from /tmp/ to ${WORK_MOUNT} directory where is zFS mounted" -sed "s|//SMPWKDIR DD PATH='/tmp/.*'|//SMPWKDIR DD PATH='$WORK_MOUNT'|g" EXPJCL0 > EXPJCL1 - -echo "Switching WORKFLOW and CSI datasets because of internal GIMZIP setting" # It is not working when CSI is in the beginning (1st or 2nd) -sed "s|\.CSI|\.1WORKFLOW|g" EXPJCL1 > EXPJCL2 -sed "s|\.WORKFLOW|\.CSI|g" EXPJCL2 > EXPJCL3 -sed "s|\.1WORKFLOW|\.WORKFLOW|g" EXPJCL3 > EXPJCL4 -sed "s|DSNTYPE=LARGE|DSNTYPE=LARGE,VOL=SER=$VOLUME|g" EXPJCL4 > EXPJCL - -rm ./EXPJCL0 -rm ./EXPJCL1 -rm ./EXPJCL2 -rm ./EXPJCL3 -rm ./EXPJCL4 - -else +echo "Showing EXPORT JCL how it looks before the change" +#if [ "$ZOSMF_V" = "2.3" ] +#then +#echo "Changing jobcard and adding SYSAFF" +#sed "s|//IZUD01EX JOB (ACCOUNT),'NAME'|$JOBST1\n$JOBST2|g" EXPORT > EXPJCL0 +# +#echo "Changing working directory from /tmp/ to ${WORK_MOUNT} directory where is zFS mounted" +#sed "s|//SMPWKDIR DD PATH='/tmp/.*'|//SMPWKDIR DD PATH='$WORK_MOUNT'|g" EXPJCL0 > EXPJCL1 +# +#echo "Switching WORKFLOW and CSI datasets because of internal GIMZIP setting" # It is not working when CSI is in the beginning (1st or 2nd) +#sed "s|\.CSI|\.1WORKFLOW|g" EXPJCL1 > EXPJCL2 +#sed "s|\.WORKFLOW|\.CSI|g" EXPJCL2 > EXPJCL3 +#sed "s|\.1WORKFLOW|\.WORKFLOW|g" EXPJCL3 > EXPJCL4 +#sed "s|DSNTYPE=LARGE|DSNTYPE=LARGE,VOL=SER=$VOLUME|g" EXPJCL4 > EXPJCL +# +#rm ./EXPJCL0 +#rm ./EXPJCL1 +#rm ./EXPJCL2 +#rm ./EXPJCL3 +#rm ./EXPJCL4 +# +#else echo "Changing jobcard and adding SYSAFF" sed "s|//IZUD01EX JOB (ACCOUNT),'NAME'|$JOBST1\n$JOBST2|g" EXPORT > EXPJCL -fi +#fi sh scripts/submit_jcl.sh "`cat EXPJCL`" if [ $? -gt 0 ];then exit -1;fi @@ -331,14 +332,14 @@ sh scripts/submit_jcl.sh "`cat JCL`" if [ $? -gt 0 ];then exit -1;fi rm JCL -#cd ../.pax +cd ../.pax set -x pwd sshpass -p${ZOSMF_PASS} sftp -o HostKeyAlgorithms=+ssh-rsa -o BatchMode=no -o StrictHostKeyChecking=no -o PubkeyAuthentication=no -b - -P ${ZZOW_SSH_PORT} ${ZOSMF_USER}@${HOST} << EOF cd ${TMP_MOUNT} get ${SWI_NAME}.pax.Z EOF -#cd ../pswi +cd ../pswi #TODO: redirect everything to $log/x ? #TODO: Check why there is name in mountpoints responses and it still doesn't show (although the mount points are different so it's good it is not doing anything) From 6c93f78c7360473c8a02d81d45ca4812dd1b46eb Mon Sep 17 00:00:00 2001 From: Martin Zeithaml Date: Thu, 31 Oct 2024 10:44:17 +0100 Subject: [PATCH 08/11] Check log directory Signed-off-by: Martin Zeithaml --- CHANGELOG.md | 1 + bin/libs/logging.sh | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e1601c2b7..352a7f174e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to the Zowe Installer will be documented in this file. ## `3.0.1` +- Bugfix: When `--log-dir` parameter for `zwe` command is a file, there might be an error "InternalError: stack overflow". [#40nn](https://github.com/zowe/zowe-install-packaging/pull/40nn) - Enhancement: new javascript funtion `getStatvfs()` to obtain information about the file sysytem [#3994](https://github.com/zowe/zowe-install-packaging/pull/3994) ## `3.0.0` diff --git a/bin/libs/logging.sh b/bin/libs/logging.sh index 6e41778aca..787c4fe7a4 100755 --- a/bin/libs/logging.sh +++ b/bin/libs/logging.sh @@ -14,6 +14,9 @@ export ZWE_PRIVATE_LOG_FILE= prepare_log_file() { + if [ -f "${1}" ]; then + print_error_and_exit "Error ZWEL0102E: Invalid parameter --log-dir=${1} (not a directory)" "" 102 + fi # use absolute path to make sure we can always write to correct location even # if other scripts changed current working directory log_dir=$(convert_to_absolute_path "${1}" | remove_trailing_slash) From 2b322e13bb5d20f519e17ca24a991c136ae44ce7 Mon Sep 17 00:00:00 2001 From: MarkAckert Date: Thu, 31 Oct 2024 12:31:07 -0400 Subject: [PATCH 09/11] update pswi logs, fix pswi creation Signed-off-by: MarkAckert --- .github/workflows/build-packaging.yml | 2 +- .github/workflows/pswi-zowe-config-test.yml | 1 + pswi/.gitignore | 4 + pswi/03_create.sh | 301 ++++++++++---------- pswi/04_create_cleanup.sh | 134 +++++---- pswi/06_test_cleanup.sh | 222 +++++++-------- pswi/07_smpe_cleanup.sh | 66 ++--- pswi/08_presmpe_cleanup.sh | 62 ++-- pswi/PSWI-marist.sh | 39 +-- pswi/scripts/spool_files.sh | 23 +- pswi/scripts/submit_jcl.sh | 43 +-- 11 files changed, 427 insertions(+), 470 deletions(-) create mode 100644 pswi/.gitignore diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index 4ed87e1d07..73e526a4f3 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -374,7 +374,7 @@ jobs: with: name: pswi-folder path: | - pswi/** + pswi/logs/** - name: '[K8S] Build Kubernetes' timeout-minutes: 10 diff --git a/.github/workflows/pswi-zowe-config-test.yml b/.github/workflows/pswi-zowe-config-test.yml index fa29d9c5e8..5fcf430e54 100644 --- a/.github/workflows/pswi-zowe-config-test.yml +++ b/.github/workflows/pswi-zowe-config-test.yml @@ -58,3 +58,4 @@ jobs: pswi/**.txt pswi/zowe_.yaml pswi/ZWECONF1/** + pswi/logs/** diff --git a/pswi/.gitignore b/pswi/.gitignore new file mode 100644 index 0000000000..a5e2c10550 --- /dev/null +++ b/pswi/.gitignore @@ -0,0 +1,4 @@ +logs/ +EXP* +report.txt +unzipped/ diff --git a/pswi/03_create.sh b/pswi/03_create.sh index d270d9bf3f..23d19d57bd 100644 --- a/pswi/03_create.sh +++ b/pswi/03_create.sh @@ -16,7 +16,7 @@ echo "SWI name :" $SWI_NAME echo "Existing DSN :" $EXPORT_DSN echo "Temporary zFS :" $TMP_ZFS echo "Temporary directory:" $TMP_MOUNT -echo "Work zFS :" $WORK_ZFS # For z/OSMF v2.3 +echo "Work zFS :" $WORK_ZFS # For z/OSMF v2.3 echo "Work mount point :" $WORK_MOUNT # For z/OSMF v2.3 echo "ZOWE zFS :" $ZOWE_ZFS echo "ZOWE mount point :" $ZOWE_MOUNT @@ -25,7 +25,7 @@ echo "ACCOUNT :" $ACCOUNT echo "SYSAFF :" $SYSAFF echo "z/OSMF version :" $ZOSMF_V -# JSONs +# JSONs ADD_SWI_JSON='{"name":"'${SWI_NAME}'","system":"'${ZOSMF_SYSTEM}'","description":"ZOWE v'${VERSION}' Portable Software Instance", "globalzone":"'${GLOBAL_ZONE}'","targetzones":["'${TZONE}'"],"workflows":[{"name":"ZOWE Mount Workflow","description":"This workflow performs mount action of ZOWE zFS.", "location": {"dsname":"'${WORKFLOW_DSN}'(ZWEWRF02)"}},{"name":"ZOWE Configuration of Zowe 3.0","description":"This workflow configures Zowe v3.0.", @@ -39,7 +39,7 @@ ADD_EXPORT_DSN_JSON='{"dsorg":"PO","alcunit":"TRK","primary":10,"secondary":5,"d EXPORT_JCL_JSON='{"packagedir":"'${EXPORT}'","jcldataset":"'${EXPORT_DSN}'","workvolume":"'${VOLUME}'"}' MOUNT_ZOWE_ZFS_JSON='{"action":"mount","mount-point":"'${ZOWE_MOUNT}'","fs-type":"zFS","mode":"rdwr"}' -# URLs +# URLs ADD_SWI_URL="${BASE_URL}/zosmf/swmgmt/swi" LOAD_PRODUCTS_URL="${BASE_URL}/zosmf/swmgmt/swi/${ZOSMF_SYSTEM}/${SWI_NAME}/products" WORKFLOW_DSN_URL="${BASE_URL}/zosmf/restfiles/ds/${WORKFLOW_DSN}" @@ -55,132 +55,121 @@ CHECK_EXPORT_DSN_URL="${BASE_URL}/zosmf/restfiles/ds?dslevel=${EXPORT_DSN}" # Check if temp zFS for PSWI is mounted echo "Checking/mounting ${TMP_ZFS}" sh scripts/tmp_mounts.sh "${TMP_ZFS}" "${TMP_MOUNT}" -if [ $? -gt 0 ];then exit -1;fi - -if [ "$ZOSMF_V" = "2.3" ] -then -# z/OSMF 2.3 +if [ $? -gt 0 ]; then exit -1; fi # Check if work zFS for PSWI is mounted echo "Checking/mounting ${WORK_ZFS}" sh scripts/tmp_mounts.sh "${WORK_ZFS}" "${WORK_MOUNT}" -if [ $? -gt 0 ];then exit -1;fi -fi - +if [ $? -gt 0 ]; then exit -1; fi + # Check if ZOWE zFS is mounted echo "Checking if file system ${ZOWE_ZFS} is mounted." -RESP=`curl -s $GET_ZOWE_ZFS_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` -MOUNTZ=`echo $RESP | grep -o '"mountpoint":".*"' | cut -f4 -d\"` +RESP=$(curl -s $GET_ZOWE_ZFS_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) +MOUNTZ=$(echo $RESP | grep -o '"mountpoint":".*"' | cut -f4 -d\") -if [ -n "$MOUNTZ" ] -then +if [ -n "$MOUNTZ" ]; then # Check if ZOWE zFS is mounted to given ZOWE mountpoint - if [ "$MOUNTZ/" = "$ZOWE_MOUNT" ] - then + if [ "$MOUNTZ/" = "$ZOWE_MOUNT" ]; then echo "${ZOWE_MOUNT} with zFS ${ZOWE_ZFS} mounted will be used." else - echo "The file system ${ZOWE_ZFS} exists but is mounted to different mount point ${MOUNTZ}." >> report.txt - echo "It is required to have the file system ${ZOWE_ZFS} mounted to the exact mount point (${ZOWE_MOUNT}) to successfully export Zowe PSWI." >> report.txt + echo "The file system ${ZOWE_ZFS} exists but is mounted to different mount point ${MOUNTZ}." >>report.txt + echo "It is required to have the file system ${ZOWE_ZFS} mounted to the exact mount point (${ZOWE_MOUNT}) to successfully export Zowe PSWI." >>report.txt exit -1 fi else echo "${ZOWE_ZFS} is not mounted anywhere. Checking if ${ZOWE_MOUNT} has any zFS mounted." - RESP=`curl -s $GET_ZOWE_PATH_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` - MOUNTZFS=`echo $RESP | grep -o "name":".*" | cut -f4 -d\"` - if [ -n "$MOUNTZFS" ] - then + RESP=$(curl -s $GET_ZOWE_PATH_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + MOUNTZFS=$(echo $RESP | grep -o "name":".*" | cut -f4 -d\") + if [ -n "$MOUNTZFS" ]; then # If ZFS is not mounted to the mountpoint then this ZOWE mountpoint has different zFS - echo "The mountpoint ${ZOWE_MOUNT} has different zFS ${MOUNTZFS}." >> report.txt + echo "The mountpoint ${ZOWE_MOUNT} has different zFS ${MOUNTZFS}." >>report.txt exit -1 else - # Mount zFS to Zowe mountpoint - echo "Mounting zFS ${ZOWE_ZFS} to ${ZOWE_MOUNT} mount point." - RESP=`curl -s $ACTION_ZOWE_ZFS_URL -k -X "PUT" -d "$MOUNT_ZOWE_ZFS_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` - sh scripts/check_response.sh "${RESP}" $? - if [ $? -gt 0 ];then exit -1;fi + # Mount zFS to Zowe mountpoint + echo "Mounting zFS ${ZOWE_ZFS} to ${ZOWE_MOUNT} mount point." + RESP=$(curl -s $ACTION_ZOWE_ZFS_URL -k -X "PUT" -d "$MOUNT_ZOWE_ZFS_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + sh scripts/check_response.sh "${RESP}" $? + if [ $? -gt 0 ]; then exit -1; fi fi fi # Add workflow to ZOWE data sets echo "Checking if WORKFLOW data set already exists." -RESP=`curl -s $CHECK_WORKFLOW_DSN_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` -DS_COUNT=`echo $RESP | grep -o '"returnedRows":[0-9]*' | cut -f2 -d:` -if [ $DS_COUNT -ne 0 ] -then - echo "The ${WORKFLOW_DSN} already exist. Because there is a possibility that it contains something unwanted the script does not continue." >> report.txt - exit -1 +RESP=$(curl -s $CHECK_WORKFLOW_DSN_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) +DS_COUNT=$(echo $RESP | grep -o '"returnedRows":[0-9]*' | cut -f2 -d:) +if [ $DS_COUNT -ne 0 ]; then + echo "The ${WORKFLOW_DSN} already exist. Because there is a possibility that it contains something unwanted the script does not continue." >>report.txt + exit -1 else echo "Creating a data set where the post-Deployment workflow will be stored." - RESP=`curl -s $WORKFLOW_DSN_URL -k -X "POST" -d "$ADD_WORKFLOW_DSN_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` - if [ -n "$RESP" ] - then - echo "The creation of the ${WORKFLOW_DSN} was not successful. Error message: ${RESP}" >> report.txt + RESP=$(curl -s $WORKFLOW_DSN_URL -k -X "POST" -d "$ADD_WORKFLOW_DSN_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + if [ -n "$RESP" ]; then + echo "The creation of the ${WORKFLOW_DSN} was not successful. Error message: ${RESP}" >>report.txt exit -1 - fi + fi fi echo "Copying workflows to ${WORKFLOW_DSN} data set." -echo ${JOBST1} > JCL -echo ${JOBST2} >> JCL -echo "//COPYWRFS EXEC PGM=BPXBATCH" >> JCL -echo "//STDOUT DD SYSOUT=*" >> JCL -echo "//STDERR DD SYSOUT=*" >> JCL -echo "//STDPARM DD *" >> JCL -echo "SH set -x;set -e;" >> JCL -echo "cd ${WORK_MOUNT};" >> JCL -echo "source=\"${ZOWE_MOUNT}files/workflows/ZWEWRF02.xml\";" >> JCL -echo "target=\"//'${WORKFLOW_DSN}(ZWEWRF02)'\";" >> JCL -echo "iconv -f ISO8859-1 -t IBM-1047 \$source > _ZWEWRF02;" >> JCL -echo "sed 's|UTF-8|IBM-1047|g' _ZWEWRF02 > ZWEWRF02;" >> JCL -echo "cp -T ZWEWRF02 \$target;" >> JCL -echo "source=\"${ZOWE_MOUNT}files/workflows/ZWECRECR.xml\";" >> JCL -echo "target=\"//'${WORKFLOW_DSN}(ZWECRECR)'\";" >> JCL -echo "iconv -f ISO8859-1 -t IBM-1047 \$source > _ZWECRECR;" >> JCL -echo "sed 's|UTF-8|IBM-1047|g' _ZWECRECR > ZWECRECR;" >> JCL -echo "cp -T ZWECRECR \$target;" >> JCL -echo "source=\"${ZOWE_MOUNT}files/workflows/ZWEKRING.xml\";" >> JCL -echo "target=\"//'${WORKFLOW_DSN}(ZWEKRING)'\";" >> JCL -echo "iconv -f ISO8859-1 -t IBM-1047 \$source > _ZWEKRING;" >> JCL -echo "sed 's|UTF-8|IBM-1047|g' _ZWEKRING > ZWEKRING;" >> JCL -echo "cp -T ZWEKRING \$target;" >> JCL -echo "source=\"${ZOWE_MOUNT}files/workflows/ZWELOADC.xml\";" >> JCL -echo "target=\"//'${WORKFLOW_DSN}(ZWELOADC)'\";" >> JCL -echo "iconv -f ISO8859-1 -t IBM-1047 \$source > _ZWELOADC;" >> JCL -echo "sed 's|UTF-8|IBM-1047|g' _ZWELOADC > ZWELOADC;" >> JCL -echo "cp -T ZWELOADC \$target;" >> JCL -echo "source=\"${ZOWE_MOUNT}files/workflows/ZWESIGNC.xml\";" >> JCL -echo "target=\"//'${WORKFLOW_DSN}(ZWESIGNC)'\";" >> JCL -echo "iconv -f ISO8859-1 -t IBM-1047 \$source > _ZWESIGNC;" >> JCL -echo "sed 's|UTF-8|IBM-1047|g' _ZWESIGNC > ZWESIGNC;" >> JCL -echo "cp -T ZWESIGNC \$target;" >> JCL -echo "source=\"${ZOWE_MOUNT}files/workflows/ZWECONF.xml\";" >> JCL -echo "target=\"//'${WORKFLOW_DSN}(ZWECONF)'\";" >> JCL -echo "iconv -f ISO8859-1 -t IBM-1047 \$source > _ZWECONF;" >> JCL -echo "sed 's|UTF-8|IBM-1047|g' _ZWECONF > ZWECONF;" >> JCL -echo "cp -T ZWECONF \$target;" >> JCL -echo "/*" >> JCL - -sh scripts/submit_jcl.sh "`cat JCL`" -if [ $? -gt 0 ];then exit -1;fi +echo ${JOBST1} >JCL +echo ${JOBST2} >>JCL +echo "//COPYWRFS EXEC PGM=BPXBATCH" >>JCL +echo "//STDOUT DD SYSOUT=*" >>JCL +echo "//STDERR DD SYSOUT=*" >>JCL +echo "//STDPARM DD *" >>JCL +echo "SH set -x;set -e;" >>JCL +echo "cd ${WORK_MOUNT};" >>JCL +echo "source=\"${ZOWE_MOUNT}files/workflows/ZWEWRF02.xml\";" >>JCL +echo "target=\"//'${WORKFLOW_DSN}(ZWEWRF02)'\";" >>JCL +echo "iconv -f ISO8859-1 -t IBM-1047 \$source > _ZWEWRF02;" >>JCL +echo "sed 's|UTF-8|IBM-1047|g' _ZWEWRF02 > ZWEWRF02;" >>JCL +echo "cp -T ZWEWRF02 \$target;" >>JCL +echo "source=\"${ZOWE_MOUNT}files/workflows/ZWECRECR.xml\";" >>JCL +echo "target=\"//'${WORKFLOW_DSN}(ZWECRECR)'\";" >>JCL +echo "iconv -f ISO8859-1 -t IBM-1047 \$source > _ZWECRECR;" >>JCL +echo "sed 's|UTF-8|IBM-1047|g' _ZWECRECR > ZWECRECR;" >>JCL +echo "cp -T ZWECRECR \$target;" >>JCL +echo "source=\"${ZOWE_MOUNT}files/workflows/ZWEKRING.xml\";" >>JCL +echo "target=\"//'${WORKFLOW_DSN}(ZWEKRING)'\";" >>JCL +echo "iconv -f ISO8859-1 -t IBM-1047 \$source > _ZWEKRING;" >>JCL +echo "sed 's|UTF-8|IBM-1047|g' _ZWEKRING > ZWEKRING;" >>JCL +echo "cp -T ZWEKRING \$target;" >>JCL +echo "source=\"${ZOWE_MOUNT}files/workflows/ZWELOADC.xml\";" >>JCL +echo "target=\"//'${WORKFLOW_DSN}(ZWELOADC)'\";" >>JCL +echo "iconv -f ISO8859-1 -t IBM-1047 \$source > _ZWELOADC;" >>JCL +echo "sed 's|UTF-8|IBM-1047|g' _ZWELOADC > ZWELOADC;" >>JCL +echo "cp -T ZWELOADC \$target;" >>JCL +echo "source=\"${ZOWE_MOUNT}files/workflows/ZWESIGNC.xml\";" >>JCL +echo "target=\"//'${WORKFLOW_DSN}(ZWESIGNC)'\";" >>JCL +echo "iconv -f ISO8859-1 -t IBM-1047 \$source > _ZWESIGNC;" >>JCL +echo "sed 's|UTF-8|IBM-1047|g' _ZWESIGNC > ZWESIGNC;" >>JCL +echo "cp -T ZWESIGNC \$target;" >>JCL +echo "source=\"${ZOWE_MOUNT}files/workflows/ZWECONF.xml\";" >>JCL +echo "target=\"//'${WORKFLOW_DSN}(ZWECONF)'\";" >>JCL +echo "iconv -f ISO8859-1 -t IBM-1047 \$source > _ZWECONF;" >>JCL +echo "sed 's|UTF-8|IBM-1047|g' _ZWECONF > ZWECONF;" >>JCL +echo "cp -T ZWECONF \$target;" >>JCL +echo "/*" >>JCL + +sh scripts/submit_jcl.sh "$(cat JCL)" +if [ $? -gt 0 ]; then exit -1; fi rm JCL # Add data set for export jobs echo "Checking if the data set for export jobs already exists." -RESP=`curl -s $CHECK_EXPORT_DSN_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` -DSN_COUNT=`echo $RESP | grep -o '"returnedRows":[0-9]*' | cut -f2 -d:` -if [ $DSN_COUNT -ne 0 ] -then - echo "The ${EXPORT_DSN} already exist. Because there is a possibility that it contains something unwanted the script does not continue." >> report.txt +RESP=$(curl -s $CHECK_EXPORT_DSN_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) +DSN_COUNT=$(echo $RESP | grep -o '"returnedRows":[0-9]*' | cut -f2 -d:) +if [ $DSN_COUNT -ne 0 ]; then + echo "The ${EXPORT_DSN} already exist. Because there is a possibility that it contains something unwanted the script does not continue." >>report.txt exit -1 else echo "Creating a data set where the export jobs will be stored." - RESP=`curl -s $EXPORT_DSN_URL -k -X "POST" -d "$ADD_EXPORT_DSN_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` - if [ -n "$RESP" ] - then echo "The creation of the ${EXPORT_DSN} was not successful. Error message: ${RESP}" - fi + RESP=$(curl -s $EXPORT_DSN_URL -k -X "POST" -d "$ADD_EXPORT_DSN_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + if [ -n "$RESP" ]; then + echo "The creation of the ${EXPORT_DSN} was not successful. Error message: ${RESP}" + fi fi # Delete Software instance if it already exists @@ -192,24 +181,22 @@ curl -s $DELETE_SWI_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X # Add Software Instance echo 'Invoking REST API to add a Software Instance.' -RESP=`curl -s $ADD_SWI_URL -k -X "POST" -d "$ADD_SWI_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` +RESP=$(curl -s $ADD_SWI_URL -k -X "POST" -d "$ADD_SWI_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) sh scripts/check_response.sh "${RESP}" $? -if [ $? -gt 0 ];then exit -1;fi +if [ $? -gt 0 ]; then exit -1; fi # Load the products, features, and FMIDs for a software instance # The response is in format "statusurl":"https:\/\/:ZOSMF_URL:post\/restofurl" # On statusurl can be checked actual status of loading the products, features, and FMIDs echo 'Invoking REST API to load SMP/E managed products from the SMP/E CSI.' - -RESP=`curl -s $LOAD_PRODUCTS_URL -k -X "PUT" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` +RESP=$(curl -s $LOAD_PRODUCTS_URL -k -X "PUT" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) sh scripts/check_response.sh "${RESP}" $? -if [ $? -gt 0 ];then exit -1;fi +if [ $? -gt 0 ]; then exit -1; fi -LOAD_STATUS_URL=`echo $RESP | grep -o '"statusurl":".*"' | cut -f4 -d\" | tr -d '\' 2>/dev/null` -if [ -z "$LOAD_STATUS_URL" ] -then - echo "No response from the load product REST API call." >> report.txt +LOAD_STATUS_URL=$(echo $RESP | grep -o '"statusurl":".*"' | cut -f4 -d\" | tr -d '\' 2>/dev/null) +if [ -z "$LOAD_STATUS_URL" ]; then + echo "No response from the load product REST API call." >>report.txt exit -1 fi @@ -217,29 +204,26 @@ fi echo 'Invoking REST API to check if load products has finished.' STATUS="" -until [ "$STATUS" = "complete" ] -do -RESP=`curl -s $LOAD_STATUS_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` -sh scripts/check_response.sh "${RESP}" $? -if [ $? -gt 0 ];then exit -1;fi -STATUS=`echo $RESP | grep -o '"status":".*"' | cut -f4 -d\"` -sleep 3 +until [ "$STATUS" = "complete" ]; do + RESP=$(curl -s $LOAD_STATUS_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + sh scripts/check_response.sh "${RESP}" $? + if [ $? -gt 0 ]; then exit -1; fi + STATUS=$(echo $RESP | grep -o '"status":".*"' | cut -f4 -d\") + sleep 3 done echo "Load Products finished successfully." - # Create JCL that will export Portable Software Instance # The response is in format "statusurl":"https:\/\/:ZOSMF_URL:post\/restofurl" echo 'Invoking REST API to export the software instance.' -RESP=`curl -s $EXPORT_JCL_URL -k -X "POST" -d "$EXPORT_JCL_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS ` +RESP=$(curl -s $EXPORT_JCL_URL -k -X "POST" -d "$EXPORT_JCL_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) sh scripts/check_response.sh "${RESP}" $? -if [ $? -gt 0 ];then exit -1;fi -EXPORT_STATUS_URL=`echo $RESP | grep -o '"statusurl":".*"' | cut -f4 -d\" | tr -d '\' 2>/dev/null` -if [ -z "$EXPORT_STATUS_URL" ] -then - echo "No response from the export REST API call." >> report.txt +if [ $? -gt 0 ]; then exit -1; fi +EXPORT_STATUS_URL=$(echo $RESP | grep -o '"statusurl":".*"' | cut -f4 -d\" | tr -d '\' 2>/dev/null) +if [ -z "$EXPORT_STATUS_URL" ]; then + echo "No response from the export REST API call." >>report.txt exit -1 fi @@ -247,40 +231,36 @@ fi echo 'Invoking REST API to check if export has finished.' STATUS="" -until [ "$STATUS" = "complete" ] -do -# Status is not shown until the recentage is not 100 -RESP=`curl -s $EXPORT_STATUS_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` -sh scripts/check_response.sh "${RESP}" $? -if [ $? -gt 0 ];then exit -1;fi -PERCENTAGE=`echo ${RESP} | grep -o '"percentcomplete":".*"' | cut -f4 -d\"` +until [ "$STATUS" = "complete" ]; do + # Status is not shown until the recentage is not 100 + RESP=$(curl -s $EXPORT_STATUS_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + sh scripts/check_response.sh "${RESP}" $? + if [ $? -gt 0 ]; then exit -1; fi + PERCENTAGE=$(echo ${RESP} | grep -o '"percentcomplete":".*"' | cut -f4 -d\") -echo ${PERCENTAGE} "% of the Export JCL created." + echo ${PERCENTAGE} "% of the Export JCL created." -if [ "$PERCENTAGE" = "100" ] -then - STATUS=`echo $RESP | grep -o '"status":".*"' | cut -f4 -d\"` - DSN=`echo $RESP | grep -o '"jcl":.*\]' | cut -f4 -d\"` + if [ "$PERCENTAGE" = "100" ]; then + STATUS=$(echo $RESP | grep -o '"status":".*"' | cut -f4 -d\") + DSN=$(echo $RESP | grep -o '"jcl":.*\]' | cut -f4 -d\") - echo "The status is: "$STATUS - # Can be 100% but still running - if [ "$STATUS" != "complete" ] && [ "$STATUS" != "running" ] - then - echo "Status of generation of Export JCL failed." >> report.txt - exit -1 + echo "The status is: "$STATUS + # Can be 100% but still running + if [ "$STATUS" != "complete" ] && [ "$STATUS" != "running" ]; then + echo "Status of generation of Export JCL failed." >>report.txt + exit -1 + fi fi -fi -sleep 3 + sleep 3 done -if [ -z "$DSN" ] -then - echo "The creation of export JCL failed" >> report.txt +if [ -z "$DSN" ]; then + echo "The creation of export JCL failed" >>report.txt exit -1 fi echo "Downloading export JCL" -curl -s ${BASE_URL}/zosmf/restfiles/ds/${DSN} -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS > EXPORT +curl -s ${BASE_URL}/zosmf/restfiles/ds/${DSN} -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS >EXPORT echo "Showing EXPORT JCL how it looks before the change" #if [ "$ZOSMF_V" = "2.3" ] @@ -305,41 +285,46 @@ echo "Showing EXPORT JCL how it looks before the change" # #else echo "Changing jobcard and adding SYSAFF" -sed "s|//IZUD01EX JOB (ACCOUNT),'NAME'|$JOBST1\n$JOBST2|g" EXPORT > EXPJCL +sed "s|//IZUD01EX JOB (ACCOUNT),'NAME'|$JOBST1\n$JOBST2|g" EXPORT >EXPJCL0 +sed "s|//.*gimzipInputFile.*,|EXPJCL1 +sed "s|// FILEDATA=TEXT| archid=\"ZOS003.ZWE.PSWI.AZWE003.ZFS\"/>|g" EXPJCL1 >EXPJCL2 +sed "s|// DD \*||g" EXPJCL2 >EXPJCL +# sed "s|ZOS003.ZWE.PSWI.|ZWE.PSWI.|g" EXPJCL3 >EXPJCL + #fi -sh scripts/submit_jcl.sh "`cat EXPJCL`" -if [ $? -gt 0 ];then exit -1;fi +sh scripts/submit_jcl.sh "$(cat EXPJCL)" +if [ $? -gt 0 ]; then exit -1; fi rm ./EXPJCL rm ./EXPORT -# Pax the directory +# Pax the directory echo "PAXing the final PSWI." -echo ${JOBST1} > JCL -echo ${JOBST2} >> JCL -echo "//PAXDIREC EXEC PGM=BPXBATCH" >> JCL -echo "//STDOUT DD SYSOUT=*" >> JCL -echo "//STDERR DD SYSOUT=*" >> JCL -echo "//STDPARM DD *" >> JCL -echo "SH set -x;set -e;" >> JCL -echo "cd ${EXPORT};" >> JCL -echo "pax -wv -f ${TMP_MOUNT}/${SWI_NAME}.pax.Z ." >> JCL -echo "/*" >> JCL - -sh scripts/submit_jcl.sh "`cat JCL`" -if [ $? -gt 0 ];then exit -1;fi +echo ${JOBST1} >JCL +echo ${JOBST2} >>JCL +echo "//PAXDIREC EXEC PGM=BPXBATCH" >>JCL +echo "//STDOUT DD SYSOUT=*" >>JCL +echo "//STDERR DD SYSOUT=*" >>JCL +echo "//STDPARM DD *" >>JCL +echo "SH set -x;set -e;" >>JCL +echo "cd ${EXPORT};" >>JCL +echo "pax -wv -f ${TMP_MOUNT}/${SWI_NAME}.pax.Z ." >>JCL +echo "/*" >>JCL + +sh scripts/submit_jcl.sh "$(cat JCL)" +if [ $? -gt 0 ]; then exit -1; fi rm JCL cd ../.pax set -x pwd -sshpass -p${ZOSMF_PASS} sftp -o HostKeyAlgorithms=+ssh-rsa -o BatchMode=no -o StrictHostKeyChecking=no -o PubkeyAuthentication=no -b - -P ${ZZOW_SSH_PORT} ${ZOSMF_USER}@${HOST} << EOF +sshpass -p${ZOSMF_PASS} sftp -o HostKeyAlgorithms=+ssh-rsa -o BatchMode=no -o StrictHostKeyChecking=no -o PubkeyAuthentication=no -b - -P ${ZZOW_SSH_PORT} ${ZOSMF_USER}@${HOST} <> $LOG_FILE + + REASON=$(echo $RESP | grep -o '"reason":') + EMPTY=$(echo $RESP | grep -o '\[\]') + MSG=$(echo $RESP | grep -o '"messageText":') + if [ -n "$REASON" ] || [ -n "$MSG" ]; then + echo "Info: Logging to file ${LOG_FILE}." + echo "$RESP" >>$LOG_FILE fi - if [ -n "$EMPTY" ] - then - echo "Info: Logging to file ${LOG_FILE}." - echo "$RESP" >> $LOG_FILE + if [ -n "$EMPTY" ]; then + echo "Info: Logging to file ${LOG_FILE}." + echo "$RESP" >>$LOG_FILE fi - if [ $RESPCODE -ne 0 ] - then - echo "Info: Logging to file ${LOG_FILE}." - if [ "$RESP" != "" ] - then - echo "$RESP" >> $LOG_FILE + if [ $RESPCODE -ne 0 ]; then + echo "Info: Logging to file ${LOG_FILE}." + if [ "$RESP" != "" ]; then + echo "$RESP" >>$LOG_FILE else - echo "REST API call wasn't successful." >> $LOG_FILE - fi + echo "REST API call wasn't successful." >>$LOG_FILE + fi else echo "REST API call was successful." fi - - return - } + + return +} # Create a log file touch $LOG_FILE @@ -68,69 +63,68 @@ touch $LOG_FILE # Delete the Software instance echo 'Invoking REST API to delete the first Software Instance.' -RESP=`curl -s $DELETE_SWI_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` +RESP=$(curl -s $DELETE_SWI_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) check_response "${RESP}" $? # Delete data set with export jobs echo "Invoking REST API to delete ${EXPORT_DSN} data set with export jobs." -RESP=`curl -s $EXPORT_DSN_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` +RESP=$(curl -s $EXPORT_DSN_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) check_response "${RESP}" $? # Delete echo "Invoking REST API to delete ${WORKFLOW_DSN} data set." -RESP=`curl -s $WORKFLOW_DSN_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` +RESP=$(curl -s $WORKFLOW_DSN_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) check_response "${RESP}" $? # Unmount and delete echo "Unmounting and deleting zFS ${TMP_ZFS}." -echo ${JOBST1} > JCL -echo ${JOBST2} >> JCL -echo "//UNMNTZFS EXEC PGM=IKJEFT01,REGION=4096K,DYNAMNBR=50" >> JCL -echo "//SYSTSPRT DD SYSOUT=*" >> JCL -echo "//SYSTSOUT DD SYSOUT=*" >> JCL -echo "//SYSTSIN DD * " >> JCL -echo "UNMOUNT FILESYSTEM('${TMP_ZFS}') + " >> JCL -echo "IMMEDIATE" >> JCL -echo "/*" >> JCL -echo "//DELTZFST EXEC PGM=IDCAMS" >> JCL -echo "//SYSPRINT DD SYSOUT=*" >> JCL -echo "//SYSIN DD *" >> JCL -echo " DELETE ${TMP_ZFS}" >> JCL -echo "/*" >> JCL - -sh scripts/submit_jcl.sh "`cat JCL`" +echo ${JOBST1} >JCL +echo ${JOBST2} >>JCL +echo "//UNMNTZFS EXEC PGM=IKJEFT01,REGION=4096K,DYNAMNBR=50" >>JCL +echo "//SYSTSPRT DD SYSOUT=*" >>JCL +echo "//SYSTSOUT DD SYSOUT=*" >>JCL +echo "//SYSTSIN DD * " >>JCL +echo "UNMOUNT FILESYSTEM('${TMP_ZFS}') + " >>JCL +echo "IMMEDIATE" >>JCL +echo "/*" >>JCL +echo "//DELTZFST EXEC PGM=IDCAMS" >>JCL +echo "//SYSPRINT DD SYSOUT=*" >>JCL +echo "//SYSIN DD *" >>JCL +echo " DELETE ${TMP_ZFS}" >>JCL +echo "/*" >>JCL + +sh scripts/submit_jcl.sh "$(cat JCL)" # Not checking results so the script doesn't fail rm JCL -if [ "$ZOSMF_V" = "2.3" ] -then -# Unmount and delete -echo "Unmounting and deleting zFS ${WORK_ZFS}." - -echo ${JOBST1} > JCL -echo ${JOBST2} >> JCL -echo "//UNMNTZFS EXEC PGM=IKJEFT01,REGION=4096K,DYNAMNBR=50" >> JCL -echo "//SYSTSPRT DD SYSOUT=*" >> JCL -echo "//SYSTSOUT DD SYSOUT=*" >> JCL -echo "//SYSTSIN DD * " >> JCL -echo "UNMOUNT FILESYSTEM('${WORK_ZFS}') + " >> JCL -echo "IMMEDIATE" >> JCL -echo "/*" >> JCL -echo "//DELTZFST EXEC PGM=IDCAMS" >> JCL -echo "//SYSPRINT DD SYSOUT=*" >> JCL -echo "//SYSIN DD *" >> JCL -echo " DELETE ${WORK_ZFS}" >> JCL -echo "/*" >> JCL - -sh scripts/submit_jcl.sh "`cat JCL`" -# Not checking results so the script doesn't fail -rm JCL -fi +if [ "$ZOSMF_V" = "2.3" ]; then + # Unmount and delete + echo "Unmounting and deleting zFS ${WORK_ZFS}." + + echo ${JOBST1} >JCL + echo ${JOBST2} >>JCL + echo "//UNMNTZFS EXEC PGM=IKJEFT01,REGION=4096K,DYNAMNBR=50" >>JCL + echo "//SYSTSPRT DD SYSOUT=*" >>JCL + echo "//SYSTSOUT DD SYSOUT=*" >>JCL + echo "//SYSTSIN DD * " >>JCL + echo "UNMOUNT FILESYSTEM('${WORK_ZFS}') + " >>JCL + echo "IMMEDIATE" >>JCL + echo "/*" >>JCL + echo "//DELTZFST EXEC PGM=IDCAMS" >>JCL + echo "//SYSPRINT DD SYSOUT=*" >>JCL + echo "//SYSIN DD *" >>JCL + echo " DELETE ${WORK_ZFS}" >>JCL + echo "/*" >>JCL + + sh scripts/submit_jcl.sh "$(cat JCL)" + # Not checking results so the script doesn't fail + rm JCL +fi echo "Invoking REST API to unmount Zowe zFS ${ZOWE_ZFS} from its mountpoint." -RESP=`curl -s $ACTION_ZOWE_ZFS_URL -k -X "PUT" -d "$UNMOUNT_ZFS_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` +RESP=$(curl -s $ACTION_ZOWE_ZFS_URL -k -X "PUT" -d "$UNMOUNT_ZFS_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) check_response "${RESP}" $? diff --git a/pswi/06_test_cleanup.sh b/pswi/06_test_cleanup.sh index f426f11ed5..efecd53df5 100644 --- a/pswi/06_test_cleanup.sh +++ b/pswi/06_test_cleanup.sh @@ -2,7 +2,7 @@ #version=1.0 export BASE_URL="${ZOSMF_URL}:${ZOSMF_PORT}" -LOG_FILE=${LOGDIR}log_pswi_"`date +%y-%j-%H-%M-%S`" +LOG_FILE=$$LOG_DIR/log_test_cleanup.txt echo "" echo "" @@ -20,166 +20,156 @@ echo "ACCOUNT :" $ACCOUNT echo "SYSAFF :" $SYSAFF echo "z/OSMF version :" $ZOSMF_V - # URLs DELETE_PSWI_URL="${BASE_URL}/zosmf/swmgmt/pswi/${ZOSMF_SYSTEM}/${PSWI}" WORKFLOW_LIST_URL="${BASE_URL}/zosmf/workflow/rest/1.0/workflows?owner=${ZOSMF_USER}&workflowName=${WORKFLOW_NAME}.*" DELETE_DEPL_SWI_URL="${BASE_URL}/zosmf/swmgmt/swi/${ZOSMF_SYSTEM}/${DEPLOY_NAME}" - check_response() { RESP=$1 RESPCODE=$2 - - REASON=`echo $RESP | grep -o '"reason":'` - EMPTY=`echo $RESP | grep -o '\[\]'` - MSG=`echo $RESP | grep -o '"messageText":'` - if [ -n "$REASON" ] || [ -n "$MSG" ] - then - echo "Info: Logging to file ${LOG_FILE}." - echo "$RESP" >> $LOG_FILE - fi - if [ -n "$EMPTY" ] - then - echo "Info: Logging to file ${LOG_FILE}." - echo "$RESP" >> $LOG_FILE + + REASON=$(echo $RESP | grep -o '"reason":') + EMPTY=$(echo $RESP | grep -o '\[\]') + MSG=$(echo $RESP | grep -o '"messageText":') + if [ -n "$REASON" ] || [ -n "$MSG" ]; then + echo "Info: Logging to file ${LOG_FILE}." + echo "$RESP" >>$LOG_FILE + fi + if [ -n "$EMPTY" ]; then + echo "Info: Logging to file ${LOG_FILE}." + echo "$RESP" >>$LOG_FILE fi - if [ $RESPCODE -ne 0 ] - then - echo "Info: Logging to file ${LOG_FILE}." - if [ -n "$RESP" ] - then - echo "$RESP" >> $LOG_FILE + if [ $RESPCODE -ne 0 ]; then + echo "Info: Logging to file ${LOG_FILE}." + if [ -n "$RESP" ]; then + echo "$RESP" >>$LOG_FILE else - echo "REST API call wasn't successful." >> $LOG_FILE - fi + echo "REST API call wasn't successful." >>$LOG_FILE + fi else echo "REST API call was successful." fi - - return - } + + return +} # Create a log file touch $LOG_FILE - + # Delete the Software instance echo "Invoking REST API to delete the Software Instance created by deployment." -RESP=`curl -s $DELETE_DEPL_SWI_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` +RESP=$(curl -s $DELETE_DEPL_SWI_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) check_response "${RESP}" $? -if [ "$ZOSMF_V" = "2.4" ] -then +if [ "$ZOSMF_V" = "2.4" ]; then -# Delete the Portable Software Instance -echo "Invoking REST API to delete the portable software instance." + # Delete the Portable Software Instance + echo "Invoking REST API to delete the portable software instance." -RESP=`curl -s $DELETE_PSWI_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` -check_response "${RESP}" $? + RESP=$(curl -s $DELETE_PSWI_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + check_response "${RESP}" $? fi # Unmount and delete echo "Unmounting and deleting zFS ${TMP_ZFS}." -echo ${JOBST1} > JCL -echo ${JOBST2} >> JCL -echo "//UNMNTZFS EXEC PGM=IKJEFT01,REGION=4096K,DYNAMNBR=50" >> JCL -echo "//SYSTSPRT DD SYSOUT=*" >> JCL -echo "//SYSTSOUT DD SYSOUT=*" >> JCL -echo "//SYSTSIN DD * " >> JCL -echo "UNMOUNT FILESYSTEM('${TMP_ZFS}') + " >> JCL -echo "IMMEDIATE" >> JCL -echo "/*" >> JCL -echo "//DELTZFST EXEC PGM=IDCAMS" >> JCL -echo "//SYSPRINT DD SYSOUT=*" >> JCL -echo "//SYSIN DD *" >> JCL -echo " DELETE ${TMP_ZFS}" >> JCL -echo "/*" >> JCL - -sh scripts/submit_jcl.sh "`cat JCL`" +echo ${JOBST1} >JCL +echo ${JOBST2} >>JCL +echo "//UNMNTZFS EXEC PGM=IKJEFT01,REGION=4096K,DYNAMNBR=50" >>JCL +echo "//SYSTSPRT DD SYSOUT=*" >>JCL +echo "//SYSTSOUT DD SYSOUT=*" >>JCL +echo "//SYSTSIN DD * " >>JCL +echo "UNMOUNT FILESYSTEM('${TMP_ZFS}') + " >>JCL +echo "IMMEDIATE" >>JCL +echo "/*" >>JCL +echo "//DELTZFST EXEC PGM=IDCAMS" >>JCL +echo "//SYSPRINT DD SYSOUT=*" >>JCL +echo "//SYSIN DD *" >>JCL +echo " DELETE ${TMP_ZFS}" >>JCL +echo "/*" >>JCL + +sh scripts/submit_jcl.sh "$(cat JCL)" # Not checking results so the script doesn't fail rm JCL -if [ "$ZOSMF_V" = "2.3" ] -then -# Unmount and delete -echo "Unmounting and deleting zFS ${WORK_ZFS}." - -echo ${JOBST1} > JCL -echo ${JOBST2} >> JCL -echo "//UNMNTZFS EXEC PGM=IKJEFT01,REGION=4096K,DYNAMNBR=50" >> JCL -echo "//SYSTSPRT DD SYSOUT=*" >> JCL -echo "//SYSTSOUT DD SYSOUT=*" >> JCL -echo "//SYSTSIN DD * " >> JCL -echo "UNMOUNT FILESYSTEM('${WORK_ZFS}') + " >> JCL -echo "IMMEDIATE" >> JCL -echo "/*" >> JCL -echo "//DELTZFST EXEC PGM=IDCAMS" >> JCL -echo "//SYSPRINT DD SYSOUT=*" >> JCL -echo "//SYSIN DD *" >> JCL -echo " DELETE ${WORK_ZFS}" >> JCL -echo "/*" >> JCL - -sh scripts/submit_jcl.sh "`cat JCL`" -# Not checking results so the script doesn't fail -rm JCL -fi +if [ "$ZOSMF_V" = "2.3" ]; then + # Unmount and delete + echo "Unmounting and deleting zFS ${WORK_ZFS}." + + echo ${JOBST1} >JCL + echo ${JOBST2} >>JCL + echo "//UNMNTZFS EXEC PGM=IKJEFT01,REGION=4096K,DYNAMNBR=50" >>JCL + echo "//SYSTSPRT DD SYSOUT=*" >>JCL + echo "//SYSTSOUT DD SYSOUT=*" >>JCL + echo "//SYSTSIN DD * " >>JCL + echo "UNMOUNT FILESYSTEM('${WORK_ZFS}') + " >>JCL + echo "IMMEDIATE" >>JCL + echo "/*" >>JCL + echo "//DELTZFST EXEC PGM=IDCAMS" >>JCL + echo "//SYSPRINT DD SYSOUT=*" >>JCL + echo "//SYSIN DD *" >>JCL + echo " DELETE ${WORK_ZFS}" >>JCL + echo "/*" >>JCL + + sh scripts/submit_jcl.sh "$(cat JCL)" + # Not checking results so the script doesn't fail + rm JCL +fi # Unmount and delete echo "Unmounting and deleting zFS ${TEST_HLQ}.ZFS." -echo ${JOBST1} > JCL -echo ${JOBST2} >> JCL -echo "//UNMNTZFS EXEC PGM=IKJEFT01,REGION=4096K,DYNAMNBR=50" >> JCL -echo "//SYSTSPRT DD SYSOUT=*" >> JCL -echo "//SYSTSOUT DD SYSOUT=*" >> JCL -echo "//SYSTSIN DD * " >> JCL -echo "UNMOUNT FILESYSTEM('${TEST_HLQ}.ZFS') + " >> JCL -echo "IMMEDIATE" >> JCL -echo "/*" >> JCL -echo "//DELTZFST EXEC PGM=IDCAMS" >> JCL -echo "//SYSPRINT DD SYSOUT=*" >> JCL -echo "//SYSIN DD *" >> JCL -echo " DELETE ${TEST_HLQ}.ZFS" >> JCL -echo "/*" >> JCL - -sh scripts/submit_jcl.sh "`cat JCL`" +echo ${JOBST1} >JCL +echo ${JOBST2} >>JCL +echo "//UNMNTZFS EXEC PGM=IKJEFT01,REGION=4096K,DYNAMNBR=50" >>JCL +echo "//SYSTSPRT DD SYSOUT=*" >>JCL +echo "//SYSTSOUT DD SYSOUT=*" >>JCL +echo "//SYSTSIN DD * " >>JCL +echo "UNMOUNT FILESYSTEM('${TEST_HLQ}.ZFS') + " >>JCL +echo "IMMEDIATE" >>JCL +echo "/*" >>JCL +echo "//DELTZFST EXEC PGM=IDCAMS" >>JCL +echo "//SYSPRINT DD SYSOUT=*" >>JCL +echo "//SYSIN DD *" >>JCL +echo " DELETE ${TEST_HLQ}.ZFS" >>JCL +echo "/*" >>JCL + +sh scripts/submit_jcl.sh "$(cat JCL)" # Not checking results so the script doesn't fail rm JCL # Delete deployed datasets echo "Deleting deployed datasets." -echo ${JOBST1} > JCL -echo ${JOBST2} >> JCL -echo "//DELTZOWE EXEC PGM=IDCAMS" >> JCL -echo "//SYSPRINT DD SYSOUT=*" >> JCL -echo "//SYSIN DD *" >> JCL -echo " DELETE ${TEST_HLQ}.** MASK" >> JCL -echo " SET MAXCC=0" >> JCL -echo "/*" >> JCL +echo ${JOBST1} >JCL +echo ${JOBST2} >>JCL +echo "//DELTZOWE EXEC PGM=IDCAMS" >>JCL +echo "//SYSPRINT DD SYSOUT=*" >>JCL +echo "//SYSIN DD *" >>JCL +echo " DELETE ${TEST_HLQ}.** MASK" >>JCL +echo " SET MAXCC=0" >>JCL +echo "/*" >>JCL -sh scripts/submit_jcl.sh "`cat JCL`" +sh scripts/submit_jcl.sh "$(cat JCL)" rm JCL -if [ "$ZOSMF_V" = "2.4" ] -then -# Delete Post-deployment workflow in z/OSMF -echo "Invoking REST API to delete Post-deployment workflows." +if [ "$ZOSMF_V" = "2.4" ]; then + # Delete Post-deployment workflow in z/OSMF + echo "Invoking REST API to delete Post-deployment workflows." -# Get workflowKey for Post-deployment workflow owned by user -RESP=`curl -s $WORKFLOW_LIST_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` -check_response "${RESP}" $? -WFKEYS=`echo $RESP | sed 's/},/},\n/g' | grep -oP '"workflowKey":".*"' | cut -f4 -d\"` + # Get workflowKey for Post-deployment workflow owned by user + RESP=$(curl -s $WORKFLOW_LIST_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + check_response "${RESP}" $? + WFKEYS=$(echo $RESP | sed 's/},/},\n/g' | grep -oP '"workflowKey":".*"' | cut -f4 -d\") -IFS=$'\n' -for KEY in $WFKEYS -do + IFS=$'\n' + for KEY in $WFKEYS; do -echo "Deleting a workflow." -RESP=`curl -s ${BASE_URL}/zosmf/workflow/rest/1.0/workflows/${KEY} -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` -check_response "${RESP}" $? - -done + echo "Deleting a workflow." + RESP=$(curl -s ${BASE_URL}/zosmf/workflow/rest/1.0/workflows/${KEY} -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + check_response "${RESP}" $? + + done fi diff --git a/pswi/07_smpe_cleanup.sh b/pswi/07_smpe_cleanup.sh index 53106174b3..97e7830b9f 100644 --- a/pswi/07_smpe_cleanup.sh +++ b/pswi/07_smpe_cleanup.sh @@ -2,7 +2,7 @@ #version=1.0 export BASE_URL="${ZOSMF_URL}:${ZOSMF_PORT}" -LOG_FILE=${LOGDIR}log_pswi_"`date +%y-%j-%H-%M-%S`" +LOG_FILE=$LOG_DIR/log_pswi_smpe_cleanup.txt echo "" echo "" @@ -17,60 +17,56 @@ echo "Directory for logs :" $LOGDIR # URLs ACTION_ZOWE_ZFS_URL="${BASE_URL}/zosmf/restfiles/mfs/${ZOWE_ZFS}" -# JSONs +# JSONs UNMOUNT_ZFS_JSON='{"action":"unmount"}' check_response() { RESP=$1 RESPCODE=$2 - - REASON=`echo $RESP | grep -o '"reason":'` - EMPTY=`echo $RESP | grep -o '\[\]'` - MSG=`echo $RESP | grep -o '"messageText":'` - if [ -n "$REASON" ] || [ -n "$MSG" ] - then - echo "Info: Logging to file ${LOG_FILE}." - echo "$RESP" >> $LOG_FILE + + REASON=$(echo $RESP | grep -o '"reason":') + EMPTY=$(echo $RESP | grep -o '\[\]') + MSG=$(echo $RESP | grep -o '"messageText":') + if [ -n "$REASON" ] || [ -n "$MSG" ]; then + echo "Info: Logging to file ${LOG_FILE}." + echo "$RESP" >>$LOG_FILE fi - if [ -n "$EMPTY" ] - then - echo "Info: Logging to file ${LOG_FILE}." - echo "$RESP" >> $LOG_FILE + if [ -n "$EMPTY" ]; then + echo "Info: Logging to file ${LOG_FILE}." + echo "$RESP" >>$LOG_FILE fi - if [ $RESPCODE -ne 0 ] - then - echo "Info: Logging to file ${LOG_FILE}." - if [ -n "$RESP" ] - then - echo "$RESP" >> $LOG_FILE + if [ $RESPCODE -ne 0 ]; then + echo "Info: Logging to file ${LOG_FILE}." + if [ -n "$RESP" ]; then + echo "$RESP" >>$LOG_FILE else - echo "REST API call wasn't successful." >> $LOG_FILE - fi + echo "REST API call wasn't successful." >>$LOG_FILE + fi else echo "REST API call was successful." fi - - return - } + + return +} # Create a log file touch $LOG_FILE echo "Invoking REST API to unmount SMPE zFS ${ZOWE_ZFS} from its mountpoint." -RESP=`curl -s $ACTION_ZOWE_ZFS_URL -k -X "PUT" -d "$UNMOUNT_ZFS_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` +RESP=$(curl -s $ACTION_ZOWE_ZFS_URL -k -X "PUT" -d "$UNMOUNT_ZFS_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) check_response "${RESP}" $? # Delete SMPE datasets -echo ${JOBST1} > JCL -echo ${JOBST2} >> JCL -echo "//DELTZOWE EXEC PGM=IDCAMS" >> JCL -echo "//SYSPRINT DD SYSOUT=*" >> JCL -echo "//SYSIN DD *" >> JCL -echo " DELETE ${CSIHLQ}.** MASK" >> JCL -echo " SET MAXCC=0" >> JCL -echo "/*" >> JCL +echo ${JOBST1} >JCL +echo ${JOBST2} >>JCL +echo "//DELTZOWE EXEC PGM=IDCAMS" >>JCL +echo "//SYSPRINT DD SYSOUT=*" >>JCL +echo "//SYSIN DD *" >>JCL +echo " DELETE ${CSIHLQ}.** MASK" >>JCL +echo " SET MAXCC=0" >>JCL +echo "/*" >>JCL -sh scripts/submit_jcl.sh "`cat JCL`" +sh scripts/submit_jcl.sh "$(cat JCL)" rm JCL diff --git a/pswi/08_presmpe_cleanup.sh b/pswi/08_presmpe_cleanup.sh index df0a83805c..df7521e12a 100644 --- a/pswi/08_presmpe_cleanup.sh +++ b/pswi/08_presmpe_cleanup.sh @@ -2,7 +2,7 @@ #version=1.0 export BASE_URL="${ZOSMF_URL}:${ZOSMF_PORT}" -LOG_FILE=${LOGDIR}log_pswi_"`date +%y-%j-%H-%M-%S`" +LOG_FILE=$LOG_DIR/log_pswi_presmpe_cleanup echo "" echo "" @@ -17,49 +17,45 @@ echo "Directory for logs :" $LOGDIR check_response() { RESP=$1 RESPCODE=$2 - - REASON=`echo $RESP | grep -o '"reason":'` - EMPTY=`echo $RESP | grep -o '\[\]'` - MSG=`echo $RESP | grep -o '"messageText":'` - if [ -n "$REASON" ] || [ -n "$MSG" ] - then - echo "Info: Logging to file ${LOG_FILE}." - echo "$RESP" >> $LOG_FILE + + REASON=$(echo $RESP | grep -o '"reason":') + EMPTY=$(echo $RESP | grep -o '\[\]') + MSG=$(echo $RESP | grep -o '"messageText":') + if [ -n "$REASON" ] || [ -n "$MSG" ]; then + echo "Info: Logging to file ${LOG_FILE}." + echo "$RESP" >>$LOG_FILE fi - if [ -n "$EMPTY" ] - then - echo "Info: Logging to file ${LOG_FILE}." - echo "$RESP" >> $LOG_FILE + if [ -n "$EMPTY" ]; then + echo "Info: Logging to file ${LOG_FILE}." + echo "$RESP" >>$LOG_FILE fi - if [ $RESPCODE -ne 0 ] - then - echo "Info: Logging to file ${LOG_FILE}." - if [ -n "$RESP" ] - then - echo "$RESP" >> $LOG_FILE + if [ $RESPCODE -ne 0 ]; then + echo "Info: Logging to file ${LOG_FILE}." + if [ -n "$RESP" ]; then + echo "$RESP" >>$LOG_FILE else - echo "REST API call wasn't successful." >> $LOG_FILE - fi + echo "REST API call wasn't successful." >>$LOG_FILE + fi else echo "REST API call was successful." fi - - return - } + + return +} # Create a log file touch $LOG_FILE # Delete pre-SMPE datasets -echo ${JOBST1} > JCL -echo ${JOBST2} >> JCL -echo "//DELTZOWE EXEC PGM=IDCAMS" >> JCL -echo "//SYSPRINT DD SYSOUT=*" >> JCL -echo "//SYSIN DD *" >> JCL -echo " DELETE ${SMPE}.** MASK" >> JCL -echo " SET MAXCC=0" >> JCL -echo "/*" >> JCL +echo ${JOBST1} >JCL +echo ${JOBST2} >>JCL +echo "//DELTZOWE EXEC PGM=IDCAMS" >>JCL +echo "//SYSPRINT DD SYSOUT=*" >>JCL +echo "//SYSIN DD *" >>JCL +echo " DELETE ${SMPE}.** MASK" >>JCL +echo " SET MAXCC=0" >>JCL +echo "/*" >>JCL -sh scripts/submit_jcl.sh "`cat JCL`" +sh scripts/submit_jcl.sh "$(cat JCL)" rm JCL diff --git a/pswi/PSWI-marist.sh b/pswi/PSWI-marist.sh index 9e9e77ed53..50c719367d 100755 --- a/pswi/PSWI-marist.sh +++ b/pswi/PSWI-marist.sh @@ -1,4 +1,3 @@ -set -x export ZOSMF_URL="https://zzow10.zowe.marist.cloud" export ZOSMF_PORT=10443 export ZOSMF_SYSTEM="S0W1" @@ -10,7 +9,9 @@ export VOLUME="ZOS003" export TEST_HLQ="ZOWEAD2.PSWIT" export SYSAFF="(S0W1)" export ACCOUNT=1 - +CURR_TIME=$(date +%s) +export LOG_DIR="logs/$CURR_TIME" +mkdir -p $LOG_DIR # Variables for workflows # SMPE export TZONE="TZONE" @@ -31,7 +32,7 @@ export TEST_MOUNT="${DIR}/test_mount" export EXPORT="${TMP_MOUNT}/export/" export WORK_MOUNT="${DIR}/work" export WORK_ZFS="ZOWEAD2.WORK.ZFS" -export ZOSMF_V="2.3" +export ZOSMF_V="3.1" export SMPE_WF_NAME="ZOWE_SMPE_WF" export PTF_WF_NAME="ZOWE_PTF_WF" export HOST=${ZOSMF_URL#https:\/\/} @@ -42,7 +43,7 @@ if [ -f ../.pax/zowe-smpe.zip ]; then mkdir -p "unzipped" unzip ../.pax/zowe-smpe.zip -d unzipped else - echo "zowe-smpe file not found" >>report.txt + echo "zowe-smpe file not found" >>"$LOG_DIR/report.txt" exit -1 fi @@ -74,7 +75,7 @@ else if [ -f ../.pax/${FMID}.zip ]; then unzip ../.pax/${FMID}.zip -d unzipped else - echo "File with FMID not found" >>report.txt + echo "File with FMID not found" >>"$LOG_DIR/report.txt" exit -1 fi fi @@ -91,13 +92,6 @@ export WORKFLOW_DSN=${CSIHLQ}.WORKFLOW export ZOWE_ZFS="${CSIHLQ}.ZFS" export VERSION=$(cat ../manifest.json.template | grep -o '"version": ".*"' | head -1 | cut -f4 -d\") -# Cleanup after the creation of PSWI -sh 04_create_cleanup.sh -# Cleanup of SMP/E -sh 07_smpe_cleanup.sh -# Clean RELFILEs and PTFs -sh 08_presmpe_cleanup.sh - # Initialize variables presmpe=0 smpe=0 @@ -147,13 +141,8 @@ if [ $presmpe -eq 0 ]; then sh 051_test_workflows.sh wf_test=$? fi -<<<<<<< HEAD - # -======= - ->>>>>>> v3.x/staging # Cleanup after the test - #sh 06_test_cleanup.sh + sh 06_test_cleanup.sh fi else # Cleanup of SMP/E if PTF weren't successful - because the earlier cleanup runs only it it was success @@ -176,19 +165,19 @@ echo "" echo "" if [ $smpe -ne 0 ] || [ $ptf -ne 0 ] || [ $create -ne 0 ] || [ $test -ne 0 ] || [ $presmpe -ne 0 ] || [ $wf_test -ne 0 ]; then - echo "Build unsuccessful!" >>report.txt + echo "Build unsuccessful!" >>"$LOG_DIR/report.txt" if [ $presmpe -ne 0 ]; then - echo "Pre-SMP/E wasn't successful." >>report.txt + echo "Pre-SMP/E wasn't successful." >>"$LOG_DIR/report.txt" elif [ $smpe -ne 0 ]; then - echo "SMP/E wasn't successful." >>report.txt + echo "SMP/E wasn't successful." >>"$LOG_DIR/report.txt" elif [ $ptf -ne 0 ]; then - echo "Applying PTFs wasn't successful." >>report.txt + echo "Applying PTFs wasn't successful." >>"$LOG_DIR/report.txt" elif [ $create -ne 0 ]; then - echo "Creation of PSWI wasn't successful." >>report.txt + echo "Creation of PSWI wasn't successful." >>"$LOG_DIR/report.txt" elif [ $test -ne 0 ]; then - echo "Testing of PSWI wasn't successful." >>report.txt + echo "Testing of PSWI wasn't successful." >>"$LOG_DIR/report.txt" elif [ $wf_test -ne 0 ]; then - echo "Workflow testing wasn't successful." >>report.txt + echo "Workflow testing wasn't successful." >>"$LOG_DIR/report.txt" fi exit -1 else diff --git a/pswi/scripts/spool_files.sh b/pswi/scripts/spool_files.sh index ff8fd0df4f..289fe3ce8c 100644 --- a/pswi/scripts/spool_files.sh +++ b/pswi/scripts/spool_files.sh @@ -1,22 +1,23 @@ # $1 = JOBNAME # $2 = JOBID - + IDENTIFIER="${1}/${2}" JOBNAME=${1} +JOB_OUTPUT_DIR=$LOG_DIR/jobs/output +JOB_OUTPUT_FILE=$JOB_OUTPUT_DIR/$JOBNAME_$2 -RESP=`curl -s ${BASE_URL}/zosmf/restjobs/jobs/${IDENTIFIER}/files -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` +RESP=$(curl -s ${BASE_URL}/zosmf/restjobs/jobs/${IDENTIFIER}/files -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) sh scripts/check_response.sh "$RESP" $? -if [ $? -gt 0 ];then exit $?;fi +if [ $? -gt 0 ]; then exit $?; fi echo $RESP | sed 's/},/},\n/g' | grep -o '"records-url":".*records"' | cut -f4 -d\" | tr -d '\' 2>/dev/null 1>urls - -mkdir -p $JOBNAME -while read -r line -do - curl -s $line?mode=text -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS >> $IDENTIFIER -done < urls - +mkdir -p $JOB_OUTPUT_DIR + +while read -r line; do + curl -s $line?mode=text -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS >>$JOB_OUTPUT_FILE +done /dev/null` -if [ -z "$JOB_STATUS_URL" ] -then - echo "No response from the REST API call." >> report.txt +JOB_STATUS_URL=$(echo $RESP | grep -o '"url":".*"' | cut -f4 -d\" | tr -d '\' 2>/dev/null) +if [ -z "$JOB_STATUS_URL" ]; then + echo "No response from the REST API call." >>$LOG_DIR/report.txt exit -1 fi -JOBID=`echo $RESP | grep -o '"jobid":".*"' | cut -f4 -d\"` -JOBNAME=`echo $RESP | grep -o '"jobname":".*"' | cut -f4 -d\"` +JOBID=$(echo $RESP | grep -o '"jobid":".*"' | cut -f4 -d\") +JOBNAME=$(echo $RESP | grep -o '"jobname":".*"' | cut -f4 -d\") echo "Job ${JOBNAME} ${JOBID} submitted." @@ -23,14 +25,12 @@ echo "Job ${JOBNAME} ${JOBID} submitted." echo "Invoking REST API to check if the job ${JOBNAME} ${JOBID} has finished." STATUS="" -until [ "$STATUS" = "OUTPUT" ] -do - RESP=`curl -s $JOB_STATUS_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` +until [ "$STATUS" = "OUTPUT" ]; do + RESP=$(curl -s $JOB_STATUS_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) sh scripts/check_response.sh "${RESP}" $? - STATUS=`echo $RESP | grep -o '"status":".*"' | cut -f4 -d\"` + STATUS=$(echo $RESP | grep -o '"status":".*"' | cut -f4 -d\") echo "The status of the job is ${STATUS}" - if [ -f EXPJCL ] # If file with export JCL exists that mean that export JCL was submitted and it needs to wait longer - then + if [ -f EXPJCL ]; then # If file with export JCL exists that mean that export JCL was submitted and it needs to wait longer sleep 30 else sleep 5 @@ -38,18 +38,19 @@ do done # Check return code -RC=`echo $RESP | grep -o '"retcode":".*"' | cut -f4 -d\"` +RC=$(echo $RESP | grep -o '"retcode":".*"' | cut -f4 -d\") echo "Return code of the job ${JOBNAME} ${JOBID} is ${RC}." - + # Download spool files echo "Downloading spool files." sh scripts/spool_files.sh $JOBNAME $JOBID - -if [ "$RC" = "CC 0000" ] -then + +echo "$JCL" >>$JCL_LOG_DIR/JCL_$JOBNAME_$JOBID + +if [ "$RC" = "CC 0000" ]; then echo "${JOBNAME} ${JOBID} was completed." else - echo "${JOBNAME} ${JOBID} failed." >> report.txt - cat $JOBNAME/$JOBID >> report.txt + echo "${JOBNAME} ${JOBID} failed." >>$LOG_DIR/report.txt + cat $JOBNAME/$JOBID >>$LOG_DIR/report.txt exit -1 -fi +fi From a278f0b0e3b50caf83cd091b3ea246542b4a490c Mon Sep 17 00:00:00 2001 From: MarkAckert Date: Thu, 31 Oct 2024 15:28:20 -0400 Subject: [PATCH 10/11] correct more logs Signed-off-by: MarkAckert --- pswi/01_smpe.sh | 66 +++++++++---------- pswi/02_ptf.sh | 66 +++++++++---------- pswi/03_create.sh | 20 +++--- pswi/06_test_cleanup.sh | 2 +- pswi/scripts/check_response.sh | 20 +++--- pswi/scripts/tmp_mounts.sh | 87 ++++++++++++------------- pswi/scripts/wf_run_test.sh | 113 +++++++++++++++------------------ 7 files changed, 173 insertions(+), 201 deletions(-) diff --git a/pswi/01_smpe.sh b/pswi/01_smpe.sh index 42d9f89aff..38a40b11c3 100644 --- a/pswi/01_smpe.sh +++ b/pswi/01_smpe.sh @@ -18,7 +18,7 @@ echo "SMPE workflow name :" $SMPE_WF_NAME CREATE_SMPE_WF_URL="${BASE_URL}/zosmf/workflow/rest/1.0/workflows" SMPE_WF_LIST_URL="${BASE_URL}/zosmf/workflow/rest/1.0/workflows?owner=${ZOSMF_USER}&workflowName=${SMPE_WF_NAME}" -# JSONs +# JSONs ADD_WORKFLOW_JSON='{"workflowName":"'$SMPE_WF_NAME'", "workflowDefinitionFile":"'${DIR}'/SMPE20", @@ -43,7 +43,7 @@ echo "Uploading workflow SMPE into ${DIR} directory thru SSH" cd workflows -sshpass -p${ZOSMF_PASS} sftp -o HostKeyAlgorithms=+ssh-rsa -o BatchMode=no -o StrictHostKeyChecking=no -o PubkeyAuthentication=no -b - -P ${ZZOW_SSH_PORT} ${ZOSMF_USER}@${HOST} << EOF +sshpass -p${ZOSMF_PASS} sftp -o HostKeyAlgorithms=+ssh-rsa -o BatchMode=no -o StrictHostKeyChecking=no -o PubkeyAuthentication=no -b - -P ${ZZOW_SSH_PORT} ${ZOSMF_USER}@${HOST} <> report.txt - echo $RESP >> report.txt - exit -1 -elif [ "$STATUS_NAME" = "complete" ] -then - echo "Workflow finished successfully." - STATUS="FINISHED" -fi +until [ "$STATUS" = "FINISHED" ]; do + sleep 20 + + # Get the result of the workflow + RESP=$(curl -s ${WORKFLOW_URL} -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + if [ $? -gt 0 ]; then exit -1; fi + STATUS_NAME=$(echo $RESP | grep -o '"statusName":".*"' | cut -f4 -d\") + + if [ "$STATUS_NAME" = "in-progress" ]; then + echo "Workflow with SMP/E ended with an error." >>$LOG_DIR/report.txt + echo $RESP >>$LOG_DIR/report.txt + exit -1 + elif [ "$STATUS_NAME" = "complete" ]; then + echo "Workflow finished successfully." + STATUS="FINISHED" + fi done - diff --git a/pswi/02_ptf.sh b/pswi/02_ptf.sh index e5174333d7..c6f189e43a 100644 --- a/pswi/02_ptf.sh +++ b/pswi/02_ptf.sh @@ -22,7 +22,7 @@ echo "PTF workflow name :" $PTF_WF_NAME CREATE_PTF_WF_URL="${BASE_URL}/zosmf/workflow/rest/1.0/workflows" PTF_WF_LIST_URL="${BASE_URL}/zosmf/workflow/rest/1.0/workflows?owner=${ZOSMF_USER}&workflowName=${PTF_WF_NAME}" -# JSONs +# JSONs ADD_WORKFLOW_JSON='{"workflowName":"'$PTF_WF_NAME'", "workflowDefinitionFile":"'${DIR}'/WFPTF", "system":"'$ZOSMF_SYSTEM'", @@ -38,7 +38,7 @@ ADD_WORKFLOW_JSON='{"workflowName":"'$PTF_WF_NAME'", cd workflows -sshpass -p${ZOSMF_PASS} sftp -o HostKeyAlgorithms=+ssh-rsa -o BatchMode=no -o StrictHostKeyChecking=no -o PubkeyAuthentication=no -b - -P ${ZZOW_SSH_PORT} ${ZOSMF_USER}@${HOST} << EOF +sshpass -p${ZOSMF_PASS} sftp -o HostKeyAlgorithms=+ssh-rsa -o BatchMode=no -o StrictHostKeyChecking=no -o PubkeyAuthentication=no -b - -P ${ZZOW_SSH_PORT} ${ZOSMF_USER}@${HOST} <> report.txt - echo $RESP >> report.txt - exit -1 -elif [ "$STATUS_NAME" = "complete" ] -then - echo "Workflow finished successfully." - STATUS="FINISHED" -fi +until [ "$STATUS" = "FINISHED" ]; do + sleep 20 + + # Get the result of the workflow + RESP=$(curl -s ${WORKFLOW_URL} -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + if [ $? -gt 0 ]; then exit -1; fi + + STATUS_NAME=$(echo $RESP | grep -o '"statusName":".*"' | cut -f4 -d\") + + if [ "$STATUS_NAME" = "in-progress" ]; then + echo "Workflow with PTFs ended with an error." >>$LOG_DIR/report.txt + echo $RESP >>$LOG_DIR/report.txt + exit -1 + elif [ "$STATUS_NAME" = "complete" ]; then + echo "Workflow finished successfully." + STATUS="FINISHED" + fi done diff --git a/pswi/03_create.sh b/pswi/03_create.sh index 23d19d57bd..3f0727843c 100644 --- a/pswi/03_create.sh +++ b/pswi/03_create.sh @@ -72,8 +72,8 @@ if [ -n "$MOUNTZ" ]; then if [ "$MOUNTZ/" = "$ZOWE_MOUNT" ]; then echo "${ZOWE_MOUNT} with zFS ${ZOWE_ZFS} mounted will be used." else - echo "The file system ${ZOWE_ZFS} exists but is mounted to different mount point ${MOUNTZ}." >>report.txt - echo "It is required to have the file system ${ZOWE_ZFS} mounted to the exact mount point (${ZOWE_MOUNT}) to successfully export Zowe PSWI." >>report.txt + echo "The file system ${ZOWE_ZFS} exists but is mounted to different mount point ${MOUNTZ}." >>$LOG_DIR/report.txt + echo "It is required to have the file system ${ZOWE_ZFS} mounted to the exact mount point (${ZOWE_MOUNT}) to successfully export Zowe PSWI." >>$LOG_DIR/report.txt exit -1 fi else @@ -82,7 +82,7 @@ else MOUNTZFS=$(echo $RESP | grep -o "name":".*" | cut -f4 -d\") if [ -n "$MOUNTZFS" ]; then # If ZFS is not mounted to the mountpoint then this ZOWE mountpoint has different zFS - echo "The mountpoint ${ZOWE_MOUNT} has different zFS ${MOUNTZFS}." >>report.txt + echo "The mountpoint ${ZOWE_MOUNT} has different zFS ${MOUNTZFS}." >>$LOG_DIR/report.txt exit -1 else # Mount zFS to Zowe mountpoint @@ -99,13 +99,13 @@ echo "Checking if WORKFLOW data set already exists." RESP=$(curl -s $CHECK_WORKFLOW_DSN_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) DS_COUNT=$(echo $RESP | grep -o '"returnedRows":[0-9]*' | cut -f2 -d:) if [ $DS_COUNT -ne 0 ]; then - echo "The ${WORKFLOW_DSN} already exist. Because there is a possibility that it contains something unwanted the script does not continue." >>report.txt + echo "The ${WORKFLOW_DSN} already exist. Because there is a possibility that it contains something unwanted the script does not continue." >>$LOG_DIR/report.txt exit -1 else echo "Creating a data set where the post-Deployment workflow will be stored." RESP=$(curl -s $WORKFLOW_DSN_URL -k -X "POST" -d "$ADD_WORKFLOW_DSN_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) if [ -n "$RESP" ]; then - echo "The creation of the ${WORKFLOW_DSN} was not successful. Error message: ${RESP}" >>report.txt + echo "The creation of the ${WORKFLOW_DSN} was not successful. Error message: ${RESP}" >>$LOG_DIR/report.txt exit -1 fi fi @@ -162,7 +162,7 @@ echo "Checking if the data set for export jobs already exists." RESP=$(curl -s $CHECK_EXPORT_DSN_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) DSN_COUNT=$(echo $RESP | grep -o '"returnedRows":[0-9]*' | cut -f2 -d:) if [ $DSN_COUNT -ne 0 ]; then - echo "The ${EXPORT_DSN} already exist. Because there is a possibility that it contains something unwanted the script does not continue." >>report.txt + echo "The ${EXPORT_DSN} already exist. Because there is a possibility that it contains something unwanted the script does not continue." >>$LOG_DIR/report.txt exit -1 else echo "Creating a data set where the export jobs will be stored." @@ -196,7 +196,7 @@ if [ $? -gt 0 ]; then exit -1; fi LOAD_STATUS_URL=$(echo $RESP | grep -o '"statusurl":".*"' | cut -f4 -d\" | tr -d '\' 2>/dev/null) if [ -z "$LOAD_STATUS_URL" ]; then - echo "No response from the load product REST API call." >>report.txt + echo "No response from the load product REST API call." >>$LOG_DIR/report.txt exit -1 fi @@ -223,7 +223,7 @@ sh scripts/check_response.sh "${RESP}" $? if [ $? -gt 0 ]; then exit -1; fi EXPORT_STATUS_URL=$(echo $RESP | grep -o '"statusurl":".*"' | cut -f4 -d\" | tr -d '\' 2>/dev/null) if [ -z "$EXPORT_STATUS_URL" ]; then - echo "No response from the export REST API call." >>report.txt + echo "No response from the export REST API call." >>$LOG_DIR/report.txt exit -1 fi @@ -247,7 +247,7 @@ until [ "$STATUS" = "complete" ]; do echo "The status is: "$STATUS # Can be 100% but still running if [ "$STATUS" != "complete" ] && [ "$STATUS" != "running" ]; then - echo "Status of generation of Export JCL failed." >>report.txt + echo "Status of generation of Export JCL failed." >>$LOG_DIR/report.txt exit -1 fi fi @@ -255,7 +255,7 @@ until [ "$STATUS" = "complete" ]; do done if [ -z "$DSN" ]; then - echo "The creation of export JCL failed" >>report.txt + echo "The creation of export JCL failed" >>$LOG_DIR/report.txt exit -1 fi diff --git a/pswi/06_test_cleanup.sh b/pswi/06_test_cleanup.sh index efecd53df5..a45144a454 100644 --- a/pswi/06_test_cleanup.sh +++ b/pswi/06_test_cleanup.sh @@ -2,7 +2,7 @@ #version=1.0 export BASE_URL="${ZOSMF_URL}:${ZOSMF_PORT}" -LOG_FILE=$$LOG_DIR/log_test_cleanup.txt +LOG_FILE=$LOG_DIR/log_test_cleanup.txt echo "" echo "" diff --git a/pswi/scripts/check_response.sh b/pswi/scripts/check_response.sh index b589cf88d2..2a2deb11cd 100644 --- a/pswi/scripts/check_response.sh +++ b/pswi/scripts/check_response.sh @@ -1,17 +1,15 @@ RESP=$1 RESPCODE=$2 - -REASON=`echo $RESP | grep -o '"reason":'` -MSG=`echo $RESP | grep -o '"messageText":'` -if [ -n "$REASON" ] || [ -n "$MSG" ] -then - echo $RESP >> report.txt + +REASON=$(echo $RESP | grep -o '"reason":') +MSG=$(echo $RESP | grep -o '"messageText":') +if [ -n "$REASON" ] || [ -n "$MSG" ]; then + echo $RESP >>$LOG_DIR/report.txt exit -1 -fi -if [ $RESPCODE -ne 0 ] -then - echo "REST API call failed." >> report.txt - echo $RESP >> report.txt +fi +if [ $RESPCODE -ne 0 ]; then + echo "REST API call failed." >>$LOG_DIR/report.txt + echo $RESP >>$LOG_DIR/report.txt exit -1 else echo "REST API call was successful." diff --git a/pswi/scripts/tmp_mounts.sh b/pswi/scripts/tmp_mounts.sh index eb44340d58..9f8d55e724 100644 --- a/pswi/scripts/tmp_mounts.sh +++ b/pswi/scripts/tmp_mounts.sh @@ -6,57 +6,50 @@ MOUNT=${2} MOUNTED=false echo "Checking if file system ${ZFS} is mounted." -RESP=`curl -s "${BASE_URL}/zosmf/restfiles/mfs?fsname=${ZFS}" -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` -MOUNTP=`echo $RESP | grep -o '"mountpoint":".*"' | cut -f4 -d\"` +RESP=$(curl -s "${BASE_URL}/zosmf/restfiles/mfs?fsname=${ZFS}" -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) +MOUNTP=$(echo $RESP | grep -o '"mountpoint":".*"' | cut -f4 -d\") NEW_ZFS_JSON='{"cylsPri":2000,"cylsSec": 140,"volumes":[ "'${VOLUME}'" ]}' - - -if [ -n "$MOUNTP" ] -then + +if [ -n "$MOUNTP" ]; then # Check if temp zFS is mounted to given mount point - if [ "$MOUNTP" = "$MOUNT" ] - then + if [ "$MOUNTP" = "$MOUNT" ]; then echo "${MOUNT} with zFS ${ZFS} mounted will be used as is." MOUNTED=true else - echo "The file system ${ZFS} exists but is mounted to different mount point(${MOUNTP})." >> report.txt - echo "Use different name of zFS or ${MOUNTP} for mount point." >> report.txt + echo "The file system ${ZFS} exists but is mounted to different mount point(${MOUNTP})." >>$LOG_DIR/report.txt + echo "Use different name of zFS or ${MOUNTP} for mount point." >>$LOG_DIR/report.txt exit -1 fi else echo "Temporary zFS isn't mounted. Now checking if mount point has any other zFS mounted." - RESP=`curl -s "${BASE_URL}/zosmf/restfiles/mfs?path=${MOUNT}" -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` + RESP=$(curl -s "${BASE_URL}/zosmf/restfiles/mfs?path=${MOUNT}" -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) sh scripts/check_response.sh "${RESP}" $? - if [ $? -gt 0 ];then exit -1;fi - MOUNTZFS=`echo $RESP | grep -o "name":".*" | cut -f4 -d\"` - if [ -n "$MOUNTZFS" ] - then + if [ $? -gt 0 ]; then exit -1; fi + MOUNTZFS=$(echo $RESP | grep -o "name":".*" | cut -f4 -d\") + if [ -n "$MOUNTZFS" ]; then # If zFS is not mounted to the mount point then this mount point has different zFS - echo "The mount point ${MOUNT} has different zFS (${MOUNTZFS}) mounted." >> report.txt - echo "Use different mount point (not ${MOUNT})." >> report.txt - echo "Or use ${MOUNTZFS} for zFS." >> report.txt + echo "The mount point ${MOUNT} has different zFS (${MOUNTZFS}) mounted." >>$LOG_DIR/report.txt + echo "Use different mount point (not ${MOUNT})." >>$LOG_DIR/report.txt + echo "Or use ${MOUNTZFS} for zFS." >>$LOG_DIR/report.txt exit -1 fi fi - -if [ "$MOUNTED" = false ] -then +if [ "$MOUNTED" = false ]; then # Check if data set exists echo "Checking if temporary zFS ${ZFS} exists." - RESP=`curl -s "${BASE_URL}/zosmf/restfiles/ds?dslevel=${ZFS}" -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` + RESP=$(curl -s "${BASE_URL}/zosmf/restfiles/ds?dslevel=${ZFS}" -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) sh scripts/check_response.sh "${RESP}" $? - if [ $? -gt 0 ];then exit -1;fi - ZFS_COUNT=`echo $RESP | grep -o '"returnedRows":[0-9]*' | cut -f2 -d:` - if [ "$ZFS_COUNT" = "0" ] - then + if [ $? -gt 0 ]; then exit -1; fi + ZFS_COUNT=$(echo $RESP | grep -o '"returnedRows":[0-9]*' | cut -f2 -d:) + if [ "$ZFS_COUNT" = "0" ]; then # Create new zFS if not echo "${ZFS} does not exists." echo "Creating new zFS ${ZFS}." - RESP=`curl -s "${BASE_URL}/zosmf/restfiles/mfs/zfs/${ZFS}" -k -X "POST" -d "$NEW_ZFS_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` + RESP=$(curl -s "${BASE_URL}/zosmf/restfiles/mfs/zfs/${ZFS}" -k -X "POST" -d "$NEW_ZFS_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) sh scripts/check_response.sh "${RESP}" $? - if [ $? -gt 0 ];then exit -1;fi + if [ $? -gt 0 ]; then exit -1; fi else #TODO: also check the first dsname because it can be something that just has tmp_zfs as HLQ echo @@ -64,25 +57,25 @@ then # Mount zFS to MOUNT echo "Mounting zFS ${ZFS} to ${MOUNT} mount point with JCL because REST API doesn't allow AGGRGROW parm." -echo ${JOBST1} > JCL -echo ${JOBST2} >> JCL -echo "//MKDIR EXEC PGM=BPXBATCH" >> JCL -echo "//STDOUT DD SYSOUT=*" >> JCL -echo "//STDERR DD SYSOUT=*" >> JCL -echo "//STDPARM DD *" >> JCL -echo "SH mkdir -p ${MOUNT}" >> JCL -echo "/*" >> JCL -echo "//MNT1ZFS1 EXEC PGM=IKJEFT01,REGION=4096K,DYNAMNBR=50" >> JCL -echo "//SYSTSPRT DD SYSOUT=*" >> JCL -echo "//SYSTSOUT DD SYSOUT=*" >> JCL -echo "//SYSTSIN DD * " >> JCL -echo "MOUNT FILESYSTEM('${ZFS}') + " >> JCL -echo "TYPE(ZFS) MODE(RDWR) + " >> JCL -echo "PARM('AGGRGROW') + " >> JCL -echo "MOUNTPOINT('${MOUNT}') " >> JCL -echo "/*" >> JCL + echo ${JOBST1} >JCL + echo ${JOBST2} >>JCL + echo "//MKDIR EXEC PGM=BPXBATCH" >>JCL + echo "//STDOUT DD SYSOUT=*" >>JCL + echo "//STDERR DD SYSOUT=*" >>JCL + echo "//STDPARM DD *" >>JCL + echo "SH mkdir -p ${MOUNT}" >>JCL + echo "/*" >>JCL + echo "//MNT1ZFS1 EXEC PGM=IKJEFT01,REGION=4096K,DYNAMNBR=50" >>JCL + echo "//SYSTSPRT DD SYSOUT=*" >>JCL + echo "//SYSTSOUT DD SYSOUT=*" >>JCL + echo "//SYSTSIN DD * " >>JCL + echo "MOUNT FILESYSTEM('${ZFS}') + " >>JCL + echo "TYPE(ZFS) MODE(RDWR) + " >>JCL + echo "PARM('AGGRGROW') + " >>JCL + echo "MOUNTPOINT('${MOUNT}') " >>JCL + echo "/*" >>JCL - sh scripts/submit_jcl.sh "`cat JCL`" - if [ $? -gt 0 ];then exit -1;fi + sh scripts/submit_jcl.sh "$(cat JCL)" + if [ $? -gt 0 ]; then exit -1; fi rm JCL fi diff --git a/pswi/scripts/wf_run_test.sh b/pswi/scripts/wf_run_test.sh index e31a8e3c19..7429c91a9a 100755 --- a/pswi/scripts/wf_run_test.sh +++ b/pswi/scripts/wf_run_test.sh @@ -21,17 +21,16 @@ WF_NAME="Testing_workflows" CREATE_WF_URL="${BASE_URL}/zosmf/workflow/rest/1.0/workflows" WF_LIST_URL="${BASE_URL}/zosmf/workflow/rest/1.0/workflows?owner=${ZOSMF_USER}&workflowName=${WF_NAME}" -# JSONs -if [ -n "$INPUT_FILE" ] -then -ADD_WORKFLOW_JSON='{"workflowName":"'$WF_NAME'", +# JSONs +if [ -n "$INPUT_FILE" ]; then + ADD_WORKFLOW_JSON='{"workflowName":"'$WF_NAME'", "workflowDefinitionFile":"'${WF_DEF_FILE}'", "variableInputFile":"'${INPUT_FILE}'", "system":"'$ZOSMF_SYSTEM'", "owner":"'$ZOSMF_USER'", "assignToOwner" :true}' else -ADD_WORKFLOW_JSON='{"workflowName":"'$WF_NAME'", + ADD_WORKFLOW_JSON='{"workflowName":"'$WF_NAME'", "workflowDefinitionFile":"'${WF_DEF_FILE}'", "system":"'$ZOSMF_SYSTEM'", "owner":"'$ZOSMF_USER'", @@ -42,75 +41,67 @@ set -x # Get workflowKey for the workflow owned by user echo "Get workflowKey for the workflow if it exists." -RESP=`curl -s $WF_LIST_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` -WFKEY=`echo $RESP | grep -o '"workflowKey":".*"' | cut -f4 -d\"` +RESP=$(curl -s $WF_LIST_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) +WFKEY=$(echo $RESP | grep -o '"workflowKey":".*"' | cut -f4 -d\") -if [ -n "$WFKEY" ] -then -WORKFLOW_URL="${CREATE_WF_URL}/${WFKEY}" +if [ -n "$WFKEY" ]; then + WORKFLOW_URL="${CREATE_WF_URL}/${WFKEY}" -echo "Deleting the workflow." -RESP=`curl -s $WORKFLOW_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` -sh scripts/check_response.sh "${RESP}" $? + echo "Deleting the workflow." + RESP=$(curl -s $WORKFLOW_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + sh scripts/check_response.sh "${RESP}" $? fi # Create workflow with REST API echo 'Invoking REST API to create the workflow.' -RESP=`curl -s $CREATE_WF_URL -k -X "POST" -d "$ADD_WORKFLOW_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` +RESP=$(curl -s $CREATE_WF_URL -k -X "POST" -d "$ADD_WORKFLOW_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) sh scripts/check_response.sh "${RESP}" $? -if [ $? -gt 0 ];then exit -1;fi -WFKEY=`echo $RESP | grep -o '"workflowKey":".*"' | cut -f4 -d\"` +if [ $? -gt 0 ]; then exit -1; fi +WFKEY=$(echo $RESP | grep -o '"workflowKey":".*"' | cut -f4 -d\") WORKFLOW_URL="${CREATE_WF_URL}/${WFKEY}" -if [ "$run" = "run" ] -then -# Run workflow -echo "Invoking REST API to start the workflow." - -RESP=`curl -s ${WORKFLOW_URL}/operations/start -k -X "PUT" -d "{}" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` -sh scripts/check_response.sh "${RESP}" $? -if [ $? -gt 0 ];then exit -1;fi -STATUS="" -until [ "$STATUS" = "FINISHED" ] -do -sleep 20 - - -# Get the result of the workflow -RESP=`curl -s ${WORKFLOW_URL} -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` -if [ $? -gt 0 ];then exit -1;fi -STATUS_NAME=`echo $RESP | grep -o '"statusName":".*"' | cut -f4 -d\"` - -if [ "$STATUS_NAME" = "in-progress" ] -then - echo "Workflow ended with an error." >> report.txt - echo $RESP >> report.txt - echo "Checking if the workflow is ZWECONF" >> report.txt - if [ "$ZWECONF" = "ZWECONF" ] - then - STEP_NAME=`echo $RESP | grep -o '"currentStepName":".*"' | cut -f4 -d\"` - if [ "$STEP_NAME" = "init_zowe" ] - then - echo "The workflow is ZWECONF and should end in step 'init_zowe'" +if [ "$run" = "run" ]; then + # Run workflow + echo "Invoking REST API to start the workflow." + + RESP=$(curl -s ${WORKFLOW_URL}/operations/start -k -X "PUT" -d "{}" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + sh scripts/check_response.sh "${RESP}" $? + if [ $? -gt 0 ]; then exit -1; fi + STATUS="" + until [ "$STATUS" = "FINISHED" ]; do + sleep 20 + + # Get the result of the workflow + RESP=$(curl -s ${WORKFLOW_URL} -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) + if [ $? -gt 0 ]; then exit -1; fi + STATUS_NAME=$(echo $RESP | grep -o '"statusName":".*"' | cut -f4 -d\") + + if [ "$STATUS_NAME" = "in-progress" ]; then + echo "Workflow ended with an error." >>$LOG_DIR/report.txt + echo $RESP >>$LOG_DIR/report.txt + echo "Checking if the workflow is ZWECONF" >>$LOG_DIR/report.txt + if [ "$ZWECONF" = "ZWECONF" ]; then + STEP_NAME=$(echo $RESP | grep -o '"currentStepName":".*"' | cut -f4 -d\") + if [ "$STEP_NAME" = "init_zowe" ]; then + echo "The workflow is ZWECONF and should end in step 'init_zowe'" + STATUS="FINISHED" + else + echo "The workflow is ZWECONF but ended in different step: '$STEP_NAME'" >>$LOG_DIR/report.txt + exit -1 + fi + else + echo "Workflow ended with an error and it is not ZWECONF." >>$LOG_DIR/report.txt + echo $RESP >>$LOG_DIR/report.txt + exit -1 + fi + elif [ "$STATUS_NAME" = "complete" ]; then + echo "Workflow finished successfully." STATUS="FINISHED" - else - echo "The workflow is ZWECONF but ended in different step: '$STEP_NAME'" >> report.txt - exit -1 fi - else - echo "Workflow ended with an error and it is not ZWECONF." >> report.txt - echo $RESP >> report.txt - exit -1 - fi -elif [ "$STATUS_NAME" = "complete" ] -then - echo "Workflow finished successfully." - STATUS="FINISHED" -fi -done + done fi echo "Deleting the workflow." -RESP=`curl -s $WORKFLOW_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS` +RESP=$(curl -s $WORKFLOW_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS) sh scripts/check_response.sh "${RESP}" $? From a55de535a5c2d9b1f04dd3bfa53f2369de7d03c9 Mon Sep 17 00:00:00 2001 From: MarkAckert Date: Thu, 31 Oct 2024 15:58:01 -0400 Subject: [PATCH 11/11] fix zosmf_system parameter Signed-off-by: MarkAckert --- pswi/ZWECONF_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pswi/ZWECONF_test.sh b/pswi/ZWECONF_test.sh index d12ff959d0..a8ba9fbf7a 100755 --- a/pswi/ZWECONF_test.sh +++ b/pswi/ZWECONF_test.sh @@ -1,6 +1,6 @@ export ZOSMF_URL="https://zzow10.zowe.marist.cloud" export ZOSMF_PORT=10443 -export ZOSMF_SYSTEM="S0W1_" +export ZOSMF_SYSTEM="S0W1" export JOBNAME="ZWECONF1" export HOST=${ZOSMF_URL#https:\/\/} export BASE_URL="${ZOSMF_URL}:${ZOSMF_PORT}"