From 6db4a791448ad981b4f8ce69a2790a43f5b8eae7 Mon Sep 17 00:00:00 2001 From: MarkAckert Date: Fri, 18 Oct 2024 10:17:13 -0400 Subject: [PATCH 1/6] update automation for new zzow systems Signed-off-by: MarkAckert --- .github/scripts/cicd_test/make_matrix.sh | 10 +++++----- .../03_process_test_server.sh | 12 ++++++------ .github/workflows/build-packaging.yml | 2 +- .github/workflows/cicd-test-readme.md | 10 +++++----- .github/workflows/cicd-test.yml | 10 +++++----- .../host_vars/{marist-7.yml => marist-10.yml} | 0 .../host_vars/{marist-8.yml => marist-11.yml} | 0 .../host_vars/{marist-6.yml => marist-9.yml} | 0 playbooks/hosts | 6 +++--- pswi/PSWI-marist.sh | 19 +++++++++---------- .../extended/keyring-modes/acf2-keyring.ts | 2 +- .../extended/keyring-modes/racf-keyring.ts | 2 +- .../extended/keyring-modes/tss-keyring.ts | 2 +- .../extended/node-versions/node-v18.ts | 2 +- .../security-systems/convenience/acf2.ts | 6 +++--- .../security-systems/convenience/racf.ts | 4 ++-- .../security-systems/convenience/ts.ts | 6 +++--- .../extended/security-systems/fmid/acf2.ts | 6 +++--- .../extended/security-systems/fmid/racf.ts | 4 ++-- .../extended/security-systems/fmid/ts.ts | 6 +++--- .../extended/security-systems/ptf/acf2.ts | 6 +++--- .../extended/security-systems/ptf/racf.ts | 4 ++-- .../extended/security-systems/ptf/ts.ts | 6 +++--- 23 files changed, 62 insertions(+), 63 deletions(-) rename playbooks/host_vars/{marist-7.yml => marist-10.yml} (100%) rename playbooks/host_vars/{marist-8.yml => marist-11.yml} (100%) rename playbooks/host_vars/{marist-6.yml => marist-9.yml} (100%) diff --git a/.github/scripts/cicd_test/make_matrix.sh b/.github/scripts/cicd_test/make_matrix.sh index cee6b60426..81273471ab 100644 --- a/.github/scripts/cicd_test/make_matrix.sh +++ b/.github/scripts/cicd_test/make_matrix.sh @@ -34,7 +34,7 @@ case $install_test_choice in "z/OS node v18") test_file="$ZOS_NODE_V18_TESTFILE" - test_force_system="zzow08" + test_force_system="zzow11" ;; "z/OS node v20") @@ -87,18 +87,18 @@ if [[ ! -z "$test_force_system" ]]; then else if [[ -z "$dont_parse_test_server" ]]; then if [[ "$test_server" == "Any zzow servers" ]]; then - test_server="zzow0"$(echo $(($RANDOM % 3 + 6))) + test_server="zzow"$(printf %02d $(($RANDOM % 3 + 9))) fi TEST_FILE_SERVER="$test_file($test_server)" else any_occurrence=$(echo $test_file | grep -o "(any)" | wc -l) interim_test_file_server=$test_file for i in $(seq $any_occurrence); do - # Generates zzow06, zzow07, zzow08 - interim_test_file_server=$(echo $interim_test_file_server | sed "s#(any)#(zzow0$(echo $(($RANDOM % 3 + 6))))#") + # Generates zzow09, zzow10, zzow11 + interim_test_file_server=$(echo $interim_test_file_server | sed "s#(any)#(zzow$(printf %02d $(($RANDOM % 3 + 9))))#") done - TEST_FILE_SERVER=$(echo $interim_test_file_server | sed "s#(all)#(zzow06,zzow07,zzow08)#g") + TEST_FILE_SERVER=$(echo $interim_test_file_server | sed "s#(all)#(zzow09,zzow10,zzow11)#g") fi fi diff --git a/.github/scripts/cicd_test/prep7_more_test_prep/03_process_test_server.sh b/.github/scripts/cicd_test/prep7_more_test_prep/03_process_test_server.sh index 7e7b80ad07..508d7d093e 100644 --- a/.github/scripts/cicd_test/prep7_more_test_prep/03_process_test_server.sh +++ b/.github/scripts/cicd_test/prep7_more_test_prep/03_process_test_server.sh @@ -14,16 +14,16 @@ TEST_SERVER=$(echo "$MATRIX_SERVER" | cut -d "-" -f2) case $TEST_SERVER in -"zzow06") - TEST_SERVER_NICKNAME=marist-6 +"zzow09") + TEST_SERVER_NICKNAME=marist-9 ;; -"zzow07") - TEST_SERVER_NICKNAME=marist-7 +"zzow10") + TEST_SERVER_NICKNAME=marist-10 ;; -"zzow08") - TEST_SERVER_NICKNAME=marist-8 +"zzow11") + TEST_SERVER_NICKNAME=marist-11 ;; *) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index 1b64e08db8..78debe2788 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -344,7 +344,7 @@ jobs: with: lock-repository: ${{ github.repository }} github-token: ${{ secrets.GITHUB_TOKEN }} - lock-resource-name: zowe-psi-build-zzow07-lock + lock-resource-name: zowe-psi-build-zzow10-lock lock-avg-retry-interval: 60 - name: '[PSWI 0] PSWI pre-build check for existing smpe' diff --git a/.github/workflows/cicd-test-readme.md b/.github/workflows/cicd-test-readme.md index 082639da7b..e1b081a2e5 100644 --- a/.github/workflows/cicd-test-readme.md +++ b/.github/workflows/cicd-test-readme.md @@ -4,9 +4,9 @@ This guide will describe how you should input into Github Actions workflow input Currently we support three testing z/OS servers: -- zzow06 (ACF2) -- zzow07 (Top Secret/TSS) -- zzow08 (RACF) +- zzow09 (ACF2) +- zzow10 (Top Secret/TSS) +- zzow11 (RACF) Testing pipeline is running tests in parallel. The workflow will try to acquire the resource lock if available. If the resource lock is occupied, the workflow will wait until the lock is succesfully acquired. @@ -17,7 +17,7 @@ Workflow trigger is at [cicd-test](https://github.com/zowe/zowe-install-packagin ### Choose Test Server - This input is a choice, and it's mandatory. -- You can choose from one of `zzow06`, `zzow07`, `zzow08`, `zzow06,zzow07,zzow08` (if you want to run the test on all zzow servers), or `Any zzow servers` (pick any zzow servers, potentially help reduce wait time) +- You can choose from one of `zzow09`, `zzow10`, `zzow11`, `zzow09,zzow10,zzow11` (if you want to run the test on all zzow servers), or `Any zzow servers` (pick any zzow servers, potentially help reduce wait time) - Default is `Any zzow servers` ### Choose Install Test @@ -109,7 +109,7 @@ Background: CICD testing relies on a `zowe.pax` or `zowe-smpe.zip` (for SMPE ins When running CICD integration tests during RC stage, the following string will be parsed into the Github Actions matrix. As a result, a total of 21 independent jobs will be spawned. ``` -basic/install.ts(zzow06,zzow07,zzow08);basic/install-ptf.ts(zzow06,zzow07,zzow08);basic/install-ext.ts(zzow07);extended/keyring.ts(zzow06,zzow07,zzow08);extended/node-versions/node-v18.ts(zzow06,zzow07,zzow08);extended/node-versions/node-v20.ts(zzow06,zzow07,zzow08);extended/certificates/nonstrict-verify-external-certificate.ts(zzow06) +basic/install.ts(zzow09,zzow10,zzow11);basic/install-ptf.ts(zzow09,zzow10,zzow11);basic/install-ext.ts(zzow10);extended/keyring.ts(zzow09,zzow10,zzow11);extended/node-versions/node-v18.ts(zzow09,zzow10,zzow11);extended/node-versions/node-v20.ts(zzow09,zzow10,zzow11);extended/certificates/nonstrict-verify-external-certificate.ts(zzow09) ``` Total elapsed time when running in parallel is approximately 3.5 hours on paper idealy if all parallel jobs are executing at the same time. In reality, from numerous tests performed, total elapsed time is around 4 hours. diff --git a/.github/workflows/cicd-test.yml b/.github/workflows/cicd-test.yml index 6bbb222e2f..ca6ee6e670 100644 --- a/.github/workflows/cicd-test.yml +++ b/.github/workflows/cicd-test.yml @@ -16,10 +16,10 @@ on: default: 'Any zzow servers' options: - Any zzow servers - - zzow06 - - zzow07 - - zzow08 - - zzow06,zzow07,zzow08 + - zzow09 + - zzow10 + - zzow11 + - zzow09,zzow10,zzow11 install-test: description: 'Choose Install Test' type: choice @@ -90,7 +90,7 @@ env: CONFIG_MANAGER_TESTFILE: extended/config-manager/enable-config-manager.ts GENERAL_API_DOCUMENTATION_TESTFILE: basic/install-api-gen.ts ZOWE_NIGHTLY_TESTS_FULL: basic/install.ts(all);basic/install-ptf.ts(all) - ZOWE_RELEASE_TESTS_FULL: basic/install.ts(all);basic/install-ptf.ts(all);basic/install-ext.ts(any);extended/keyring.ts(all);extended/node-versions/node-v18.ts(zzow08);extended/node-versions/node-v20.ts(any);extended/certificates/nonstrict-verify-external-certificate.ts(any);extended/caching-storages/infinispan-storage.ts(any);extended/config-manager/enable-config-manager.ts(any) + ZOWE_RELEASE_TESTS_FULL: basic/install.ts(all);basic/install-ptf.ts(all);basic/install-ext.ts(any);extended/keyring.ts(all);extended/node-versions/node-v18.ts(zzow11);extended/node-versions/node-v20.ts(any);extended/certificates/nonstrict-verify-external-certificate.ts(any);extended/caching-storages/infinispan-storage.ts(any);extended/config-manager/enable-config-manager.ts(any) jobs: display-dispatch-event-id: diff --git a/playbooks/host_vars/marist-7.yml b/playbooks/host_vars/marist-10.yml similarity index 100% rename from playbooks/host_vars/marist-7.yml rename to playbooks/host_vars/marist-10.yml diff --git a/playbooks/host_vars/marist-8.yml b/playbooks/host_vars/marist-11.yml similarity index 100% rename from playbooks/host_vars/marist-8.yml rename to playbooks/host_vars/marist-11.yml diff --git a/playbooks/host_vars/marist-6.yml b/playbooks/host_vars/marist-9.yml similarity index 100% rename from playbooks/host_vars/marist-6.yml rename to playbooks/host_vars/marist-9.yml diff --git a/playbooks/hosts b/playbooks/hosts index f53a1884e8..85fcbfebf3 100644 --- a/playbooks/hosts +++ b/playbooks/hosts @@ -1,7 +1,7 @@ [marist] -marist-6 -marist-7 -marist-8 +marist-9 +marist-10 +marist-11 [tvt] tvt4188 diff --git a/pswi/PSWI-marist.sh b/pswi/PSWI-marist.sh index 80441508af..80f1b3aa9a 100755 --- a/pswi/PSWI-marist.sh +++ b/pswi/PSWI-marist.sh @@ -1,4 +1,4 @@ -export ZOSMF_URL="https://zzow07.zowe.marist.cloud" +export ZOSMF_URL="https://zzow10.zowe.marist.cloud" export ZOSMF_PORT=10443 export ZOSMF_SYSTEM="S0W1" export DIR="/u/zowead2" @@ -41,7 +41,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" + echo "zowe-smpe file not found" >>report.txt exit -1 fi @@ -73,7 +73,7 @@ else if [ -f ../.pax/${FMID}.zip ]; then unzip ../.pax/${FMID}.zip -d unzipped else - echo "File with FMID not found" + echo "File with FMID not found" >>report.txt exit -1 fi fi @@ -147,18 +147,17 @@ echo "" echo "" if [ $smpe -ne 0 ] || [ $ptf -ne 0 ] || [ $create -ne 0 ] || [ $test -ne 0 ] || [ $presmpe -ne 0 ]; then - echo "Build unsuccessful!" + echo "Build unsuccessful!" >>report.txt if [ $presmpe -ne 0 ]; then - echo "Pre-SMP/E wasn't successful." + echo "Pre-SMP/E wasn't successful." >>report.txt elif [ $smpe -ne 0 ]; then - echo "SMP/E wasn't successful." + echo "SMP/E wasn't successful." >>report.txt elif [ $ptf -ne 0 ]; then - echo "Applying PTFs wasn't successful." + echo "Applying PTFs wasn't successful." >>report.txt elif [ $create -ne 0 ]; then - echo "Creation of PSWI wasn't successful." + echo "Creation of PSWI wasn't successful." >>report.txt elif [ $test -ne 0 ]; then - echo "Testing of PSWI wasn't successful." - fi + echo "Testing of PSWI wasn't successful." >>report.txt exit -1 else echo "Build successful!" diff --git a/tests/installation/src/__tests__/extended/keyring-modes/acf2-keyring.ts b/tests/installation/src/__tests__/extended/keyring-modes/acf2-keyring.ts index 8b740588ee..8a8efd8916 100644 --- a/tests/installation/src/__tests__/extended/keyring-modes/acf2-keyring.ts +++ b/tests/installation/src/__tests__/extended/keyring-modes/acf2-keyring.ts @@ -18,7 +18,7 @@ import { KEYSTORE_MODE_KEYRING, } from '../../../constants'; -const testServer = 'marist-6'; +const testServer = 'marist-9'; const testSuiteName = 'Test convenience build installation with keystore pointing to an ACF2 keyring'; describe(testSuiteName, () => { beforeAll(() => { diff --git a/tests/installation/src/__tests__/extended/keyring-modes/racf-keyring.ts b/tests/installation/src/__tests__/extended/keyring-modes/racf-keyring.ts index f2399de380..7b91837222 100644 --- a/tests/installation/src/__tests__/extended/keyring-modes/racf-keyring.ts +++ b/tests/installation/src/__tests__/extended/keyring-modes/racf-keyring.ts @@ -18,7 +18,7 @@ import { KEYSTORE_MODE_KEYRING, } from '../../../constants'; -const testServer = 'marist-8'; +const testServer = 'marist-11'; const testSuiteName = 'Test convenience build installation with keystore pointing to a RACF keyring'; describe(testSuiteName, () => { beforeAll(() => { diff --git a/tests/installation/src/__tests__/extended/keyring-modes/tss-keyring.ts b/tests/installation/src/__tests__/extended/keyring-modes/tss-keyring.ts index fbd1f1f69d..b47a617dca 100644 --- a/tests/installation/src/__tests__/extended/keyring-modes/tss-keyring.ts +++ b/tests/installation/src/__tests__/extended/keyring-modes/tss-keyring.ts @@ -18,7 +18,7 @@ import { KEYSTORE_MODE_KEYRING, } from '../../../constants'; -const testServer = 'marist-7'; +const testServer = 'marist-10'; const testSuiteName = 'Test convenience build installation with keystore pointing to a TSS keyring'; describe(testSuiteName, () => { beforeAll(() => { diff --git a/tests/installation/src/__tests__/extended/node-versions/node-v18.ts b/tests/installation/src/__tests__/extended/node-versions/node-v18.ts index 4758b24904..d6345a1df6 100644 --- a/tests/installation/src/__tests__/extended/node-versions/node-v18.ts +++ b/tests/installation/src/__tests__/extended/node-versions/node-v18.ts @@ -15,7 +15,7 @@ import { } from '../../../utils'; import { TEST_TIMEOUT_CONVENIENCE_BUILD } from '../../../constants'; -// Only runs on zzow08 at time of change (04.2023). See cicd-test.yml and make_matrix.sh. +// Only runs on zzow11 at time of change (04.2023). See cicd-test.yml and make_matrix.sh. const testServer = process.env.TEST_SERVER; const testSuiteName = 'Test convenience build installation with node.js v18'; describe(testSuiteName, () => { diff --git a/tests/installation/src/__tests__/extended/security-systems/convenience/acf2.ts b/tests/installation/src/__tests__/extended/security-systems/convenience/acf2.ts index 7989dd6204..14df79ca42 100644 --- a/tests/installation/src/__tests__/extended/security-systems/convenience/acf2.ts +++ b/tests/installation/src/__tests__/extended/security-systems/convenience/acf2.ts @@ -18,10 +18,10 @@ import {TEST_TIMEOUT_CONVENIENCE_BUILD} from '../../../../constants'; /** * Define this test should run in a specific worker * - * @worker marist-6 + * @worker marist-9 */ -// hard code to use marist-6 which we started with ACF2 -const testServer = 'marist-6'; +// hard code to use marist-9 which we started with ACF2 +const testServer = 'marist-9'; const testSuiteName = 'Test convenience build installation with ACF2'; describe(testSuiteName, () => { beforeAll(() => { diff --git a/tests/installation/src/__tests__/extended/security-systems/convenience/racf.ts b/tests/installation/src/__tests__/extended/security-systems/convenience/racf.ts index 8f5a5a4c01..58f8ca56c7 100644 --- a/tests/installation/src/__tests__/extended/security-systems/convenience/racf.ts +++ b/tests/installation/src/__tests__/extended/security-systems/convenience/racf.ts @@ -18,9 +18,9 @@ import {TEST_TIMEOUT_CONVENIENCE_BUILD} from '../../../../constants'; /** * Define this test should run in a specific worker * - * @worker marist-8 + * @worker marist-11 */ -const testServer = 'marist-8'; +const testServer = 'marist-11'; const testSuiteName = 'Test convenience build installation with RACF'; describe(testSuiteName, () => { beforeAll(() => { diff --git a/tests/installation/src/__tests__/extended/security-systems/convenience/ts.ts b/tests/installation/src/__tests__/extended/security-systems/convenience/ts.ts index 22f339ae6b..cd4e7a1fd8 100644 --- a/tests/installation/src/__tests__/extended/security-systems/convenience/ts.ts +++ b/tests/installation/src/__tests__/extended/security-systems/convenience/ts.ts @@ -18,10 +18,10 @@ import {TEST_TIMEOUT_CONVENIENCE_BUILD} from '../../../../constants'; /** * Define this test should run in a specific worker * - * @worker marist-7 + * @worker marist-10 */ -// hard code to use marist-7 which we started with Top Secret -const testServer = 'marist-7'; +// hard code to use marist-10 which we started with Top Secret +const testServer = 'marist-10'; const testSuiteName = 'Test convenience build installation with Top Secret'; describe(testSuiteName, () => { beforeAll(() => { diff --git a/tests/installation/src/__tests__/extended/security-systems/fmid/acf2.ts b/tests/installation/src/__tests__/extended/security-systems/fmid/acf2.ts index 9a6e32810b..2c04aa470e 100644 --- a/tests/installation/src/__tests__/extended/security-systems/fmid/acf2.ts +++ b/tests/installation/src/__tests__/extended/security-systems/fmid/acf2.ts @@ -18,10 +18,10 @@ import {TEST_TIMEOUT_SMPE_FMID} from '../../../../constants'; /** * Define this test should run in a specific worker * - * @worker marist-6 + * @worker marist-9 */ -// hard code to use marist-6 which we started with ACF2 -const testServer = 'marist-6'; +// hard code to use marist-9 which we started with ACF2 +const testServer = 'marist-9'; const testSuiteName = 'Test SMPE FMID installation with ACF2'; describe(testSuiteName, () => { beforeAll(() => { diff --git a/tests/installation/src/__tests__/extended/security-systems/fmid/racf.ts b/tests/installation/src/__tests__/extended/security-systems/fmid/racf.ts index a283327624..32205c4ac2 100644 --- a/tests/installation/src/__tests__/extended/security-systems/fmid/racf.ts +++ b/tests/installation/src/__tests__/extended/security-systems/fmid/racf.ts @@ -18,9 +18,9 @@ import {TEST_TIMEOUT_SMPE_FMID} from '../../../../constants'; /** * Define this test should run in a specific worker * - * @worker marist-8 + * @worker marist-11 */ -const testServer = 'marist-8'; +const testServer = 'marist-11'; const testSuiteName = 'Test SMPE FMID installation with RACF'; describe(testSuiteName, () => { beforeAll(() => { diff --git a/tests/installation/src/__tests__/extended/security-systems/fmid/ts.ts b/tests/installation/src/__tests__/extended/security-systems/fmid/ts.ts index d274358705..d15f77074c 100644 --- a/tests/installation/src/__tests__/extended/security-systems/fmid/ts.ts +++ b/tests/installation/src/__tests__/extended/security-systems/fmid/ts.ts @@ -18,10 +18,10 @@ import {TEST_TIMEOUT_SMPE_FMID} from '../../../../constants'; /** * Define this test should run in a specific worker * - * @worker marist-7 + * @worker marist-10 */ -// hard code to use marist-7 which we started with Top Secret -const testServer = 'marist-7'; +// hard code to use marist-10 which we started with Top Secret +const testServer = 'marist-10'; const testSuiteName = 'Test SMPE FMID installation with Top Secret'; describe(testSuiteName, () => { beforeAll(() => { diff --git a/tests/installation/src/__tests__/extended/security-systems/ptf/acf2.ts b/tests/installation/src/__tests__/extended/security-systems/ptf/acf2.ts index 3665c08d52..c5aceb2477 100644 --- a/tests/installation/src/__tests__/extended/security-systems/ptf/acf2.ts +++ b/tests/installation/src/__tests__/extended/security-systems/ptf/acf2.ts @@ -18,10 +18,10 @@ import {TEST_TIMEOUT_SMPE_PTF} from '../../../../constants'; /** * Define this test should run in a specific worker * - * @worker marist-6 + * @worker marist-9 */ -// hard code to use marist-6 which we started with ACF2 -const testServer = 'marist-6'; +// hard code to use marist-9 which we started with ACF2 +const testServer = 'marist-9'; const testSuiteName = 'Test SMPE PTF installation with ACF2'; describe(testSuiteName, () => { beforeAll(() => { diff --git a/tests/installation/src/__tests__/extended/security-systems/ptf/racf.ts b/tests/installation/src/__tests__/extended/security-systems/ptf/racf.ts index a796eed96c..cf9e56bd29 100644 --- a/tests/installation/src/__tests__/extended/security-systems/ptf/racf.ts +++ b/tests/installation/src/__tests__/extended/security-systems/ptf/racf.ts @@ -18,9 +18,9 @@ import {TEST_TIMEOUT_SMPE_PTF} from '../../../../constants'; /** * Define this test should run in a specific worker * - * @worker marist-8 + * @worker marist-11 */ -const testServer = 'marist-8'; +const testServer = 'marist-11'; const testSuiteName = 'Test SMPE PTF installation with RACF'; describe(testSuiteName, () => { beforeAll(() => { diff --git a/tests/installation/src/__tests__/extended/security-systems/ptf/ts.ts b/tests/installation/src/__tests__/extended/security-systems/ptf/ts.ts index 43d08633ca..65f44cf010 100644 --- a/tests/installation/src/__tests__/extended/security-systems/ptf/ts.ts +++ b/tests/installation/src/__tests__/extended/security-systems/ptf/ts.ts @@ -18,10 +18,10 @@ import {TEST_TIMEOUT_SMPE_PTF} from '../../../../constants'; /** * Define this test should run in a specific worker * - * @worker marist-7 + * @worker marist-10 */ -// hard code to use marist-7 which we started with Top Secret -const testServer = 'marist-7'; +// hard code to use marist-10 which we started with Top Secret +const testServer = 'marist-10'; const testSuiteName = 'Test SMPE PTF installation with Top Secret'; describe(testSuiteName, () => { beforeAll(() => { From a5cdb239d8ffb0ca465730ae6d4f6b2491ade348 Mon Sep 17 00:00:00 2001 From: MarkAckert Date: Wed, 23 Oct 2024 23:05:40 -0400 Subject: [PATCH 2/6] only run tests automatically from PRs Signed-off-by: MarkAckert --- .github/workflows/build-packaging.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index 78debe2788..81c329a4a2 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -99,8 +99,9 @@ jobs: echo "run_build=${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.ORIGIN_ISSUE_TRIGGER == 'false') || !contains(fromJson(steps.get-labels.outputs.result), 'Build: None') }}" >> $GITHUB_OUTPUT - id: check-test name: 'export conditional used to determine if we should run a test suite' + # run_test explanation: if we set "run_build" from the prior step and this is a PR, run unless "Test: None" label is present. If not initiated from a PR, only build. run: | - echo "run_test=${{ (steps.check-build.outputs.run_build == 'true' && !contains(fromJson(steps.get-labels.outputs.result), 'Test: None')) }}" >> $GITHUB_OUTPUT + echo "run_test=${{ (steps.check-build.outputs.run_build == 'true' && ( github.event_name != 'workflow_dispatch' && !contains(fromJson(steps.get-labels.outputs.result)), 'Test: None')) }}" >> $GITHUB_OUTPUT display-dispatch-event-id: if: github.event.inputs.RANDOM_DISPATCH_EVENT_ID != '' From e832aa5dc1a514f02678113b92a186e52ee473a8 Mon Sep 17 00:00:00 2001 From: MarkAckert Date: Wed, 23 Oct 2024 23:13:44 -0400 Subject: [PATCH 3/6] fix paren Signed-off-by: MarkAckert --- .github/workflows/build-packaging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index 81c329a4a2..3ed5a7c34b 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -101,7 +101,7 @@ jobs: name: 'export conditional used to determine if we should run a test suite' # run_test explanation: if we set "run_build" from the prior step and this is a PR, run unless "Test: None" label is present. If not initiated from a PR, only build. run: | - echo "run_test=${{ (steps.check-build.outputs.run_build == 'true' && ( github.event_name != 'workflow_dispatch' && !contains(fromJson(steps.get-labels.outputs.result)), 'Test: None')) }}" >> $GITHUB_OUTPUT + echo "run_test=${{ (steps.check-build.outputs.run_build == 'true' && ( github.event_name != 'workflow_dispatch' && !contains(fromJson(steps.get-labels.outputs.result), 'Test: None')) }}" >> $GITHUB_OUTPUT display-dispatch-event-id: if: github.event.inputs.RANDOM_DISPATCH_EVENT_ID != '' From 70f3434edf260147a7e24074e0c2d3ed73c253be Mon Sep 17 00:00:00 2001 From: MarkAckert Date: Wed, 23 Oct 2024 23:18:55 -0400 Subject: [PATCH 4/6] remove imbalanced paren Signed-off-by: MarkAckert --- .github/workflows/build-packaging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index 3ed5a7c34b..0ccd05b7fb 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -101,7 +101,7 @@ jobs: name: 'export conditional used to determine if we should run a test suite' # run_test explanation: if we set "run_build" from the prior step and this is a PR, run unless "Test: None" label is present. If not initiated from a PR, only build. run: | - echo "run_test=${{ (steps.check-build.outputs.run_build == 'true' && ( github.event_name != 'workflow_dispatch' && !contains(fromJson(steps.get-labels.outputs.result), 'Test: None')) }}" >> $GITHUB_OUTPUT + echo "run_test=${{ (steps.check-build.outputs.run_build == 'true' && github.event_name != 'workflow_dispatch' && !contains(fromJson(steps.get-labels.outputs.result), 'Test: None')) }}" >> $GITHUB_OUTPUT display-dispatch-event-id: if: github.event.inputs.RANDOM_DISPATCH_EVENT_ID != '' From bdb8507e64e5733bbf7a9deb2a0da13ead028125 Mon Sep 17 00:00:00 2001 From: Mark Ackert <35308966+MarkAckert@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:02:37 -0400 Subject: [PATCH 5/6] Merge pull request #4065 from zowe/users/pswi.test Fix PSWI build Signed-off-by: MarkAckert --- .github/workflows/build-packaging.yml | 8 + pswi/.gitignore | 4 + pswi/01_smpe.sh | 66 +++-- pswi/02_ptf.sh | 66 +++-- pswi/03_create.sh | 348 +++++++++++++------------- 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 | 23 +- pswi/scripts/check_response.sh | 20 +- pswi/scripts/spool_files.sh | 23 +- pswi/scripts/submit_jcl.sh | 43 ++-- pswi/scripts/tmp_mounts.sh | 89 +++---- 14 files changed, 568 insertions(+), 606 deletions(-) create mode 100644 pswi/.gitignore diff --git a/.github/workflows/build-packaging.yml b/.github/workflows/build-packaging.yml index 0ccd05b7fb..fde84a73cb 100644 --- a/.github/workflows/build-packaging.yml +++ b/.github/workflows/build-packaging.yml @@ -368,6 +368,14 @@ jobs: ZZOW_SSH_PORT: ${{ secrets.SSH_MARIST_ALLSYS_PORT }} VERSION: ${{ env.P_VERSION }} + - name: Store PSWI folder + uses: actions/upload-artifact@v4 + if: env.INPUTS_BUILD_PSWI == 'true' && failure() + with: + name: pswi-folder + path: | + pswi/logs/** + - name: '[K8S] Build Kubernetes' timeout-minutes: 10 if: env.INPUTS_BUILD_KUBERNETES == 'true' 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/01_smpe.sh b/pswi/01_smpe.sh index 8370b9ef54..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} <>$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 e2c23e54e3..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} <>$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 3f9e30fb84..fe742143bd 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 2.0","description":"This workflow configures Zowe v2.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}." - echo "It is required to have the file system ${ZOWE_ZFS} mounted to the exact mount point (${ZOWE_MOUNT}) to successfully export Zowe PSWI." + 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 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}." + echo "The mountpoint ${ZOWE_MOUNT} has different zFS ${MOUNTZFS}." >>$LOG_DIR/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." - 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." >>$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}" + 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}" >>$LOG_DIR/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." +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." >>$LOG_DIR/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 REST API call." +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." >>$LOG_DIR/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 REST API call." +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." >>$LOG_DIR/report.txt exit -1 fi @@ -247,96 +231,100 @@ 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." - 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." >>$LOG_DIR/report.txt + exit -1 + fi fi -fi -sleep 3 + sleep 3 done -if [ -z "$DSN" ] -then - echo "The creation of export JCL failed" +if [ -z "$DSN" ]; then + echo "The creation of export JCL failed" >>$LOG_DIR/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 - -if [ "$ZOSMF_V" = "2.3" ] -then +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" ] +#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 > 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 +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 -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 +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 -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 +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} <> $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..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=${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 80f1b3aa9a..98c269be04 100755 --- a/pswi/PSWI-marist.sh +++ b/pswi/PSWI-marist.sh @@ -9,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" @@ -30,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:\/\/} @@ -41,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 @@ -73,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 @@ -147,17 +149,18 @@ echo "" echo "" if [ $smpe -ne 0 ] || [ $ptf -ne 0 ] || [ $create -ne 0 ] || [ $test -ne 0 ] || [ $presmpe -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" + fi exit -1 else echo "Build successful!" diff --git a/pswi/scripts/check_response.sh b/pswi/scripts/check_response.sh index b9b280848e..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 + +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." - echo $RESP +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/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." +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." - cat $JOBNAME/$JOBID + echo "${JOBNAME} ${JOBID} failed." >>$LOG_DIR/report.txt + cat $JOBNAME/$JOBID >>$LOG_DIR/report.txt exit -1 -fi +fi diff --git a/pswi/scripts/tmp_mounts.sh b/pswi/scripts/tmp_mounts.sh index c2e5f89370..9408588af8 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})." - echo "Use different name of zFS or ${MOUNTP} for mount point." + 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." - echo "Use different mount point (not ${MOUNT})." - echo "Or use ${MOUNTZFS} for zFS." + 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 ${TMP_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` + 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) 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 TMP_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 From ed121e461ffc14cd5136d4f6796b68d57e5af877 Mon Sep 17 00:00:00 2001 From: MarkAckert Date: Mon, 4 Nov 2024 13:34:10 -0500 Subject: [PATCH 6/6] fix azwe version for v2 Signed-off-by: MarkAckert --- pswi/03_create.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pswi/03_create.sh b/pswi/03_create.sh index fe742143bd..0e79707819 100644 --- a/pswi/03_create.sh +++ b/pswi/03_create.sh @@ -286,8 +286,8 @@ 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 >EXPJCL0 -sed "s|//.*gimzipInputFile.*,|EXPJCL1 -sed "s|// FILEDATA=TEXT| archid=\"ZOS003.ZWE.PSWI.AZWE003.ZFS\"/>|g" EXPJCL1 >EXPJCL2 +sed "s|//.*gimzipInputFile.*,|EXPJCL1 +sed "s|// FILEDATA=TEXT| archid=\"ZOS003.ZWE.PSWI.AZWE002.ZFS\"/>|g" EXPJCL1 >EXPJCL2 sed "s|// DD \*||g" EXPJCL2 >EXPJCL # sed "s|ZOS003.ZWE.PSWI.|ZWE.PSWI.|g" EXPJCL3 >EXPJCL