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