Skip to content

Commit

Permalink
Merge pull request #4065 from zowe/users/pswi.test
Browse files Browse the repository at this point in the history
Fix PSWI build
  • Loading branch information
MarkAckert authored Oct 31, 2024
2 parents 14713e5 + a55de53 commit 01a399c
Show file tree
Hide file tree
Showing 17 changed files with 635 additions and 692 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ jobs:
with:
name: pswi-folder
path: |
pswi/**
pswi/logs/**
- name: '[K8S] Build Kubernetes'
timeout-minutes: 10
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pswi-zowe-config-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ jobs:
pswi/**.txt
pswi/zowe_.yaml
pswi/ZWECONF1/**
pswi/logs/**
4 changes: 4 additions & 0 deletions pswi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
logs/
EXP*
report.txt
unzipped/
66 changes: 30 additions & 36 deletions pswi/01_smpe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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} <<EOF
cd ${DIR}
put SMPE20
EOF
Expand All @@ -52,52 +52,46 @@ cd ..
# Get workflowKey for SMPE workflow owned by user
echo "Get workflowKey for SMPE workflow if it exists."

RESP=`curl -s $SMPE_WF_LIST_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS`
WFKEY=`echo $RESP | grep -o '"workflowKey":".*"' | cut -f4 -d\"`
if [ -n "$WFKEY" ]
then
SMPE_WORKFLOW_URL="${CREATE_SMPE_WF_URL}/${WFKEY}"
RESP=$(curl -s $SMPE_WF_LIST_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS)
WFKEY=$(echo $RESP | grep -o '"workflowKey":".*"' | cut -f4 -d\")
if [ -n "$WFKEY" ]; then
SMPE_WORKFLOW_URL="${CREATE_SMPE_WF_URL}/${WFKEY}"

echo "Deleting an SMPE workflow."
RESP=`curl -s $SMPE_WORKFLOW_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS`
sh scripts/check_response.sh "${RESP}" $?
echo "Deleting an SMPE workflow."
RESP=$(curl -s $SMPE_WORKFLOW_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS)
sh scripts/check_response.sh "${RESP}" $?
fi

# Create workflow with REST API
echo 'Invoking REST API to create SMPE workflow.'

RESP=`curl -s $CREATE_SMPE_WF_URL -k -X "POST" -d "$ADD_WORKFLOW_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS`
RESP=$(curl -s $CREATE_SMPE_WF_URL -k -X "POST" -d "$ADD_WORKFLOW_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS)
sh scripts/check_response.sh "${RESP}" $?
if [ $? -gt 0 ];then exit -1;fi
WFKEY=`echo $RESP | grep -o '"workflowKey":".*"' | cut -f4 -d\"`
if [ $? -gt 0 ]; then exit -1; fi
WFKEY=$(echo $RESP | grep -o '"workflowKey":".*"' | cut -f4 -d\")
WORKFLOW_URL="${CREATE_SMPE_WF_URL}/${WFKEY}"

# Run workflow
echo "Invoking REST API to start a SMPE workflow."

RESP=`curl -s ${WORKFLOW_URL}/operations/start -k -X "PUT" -d "{}" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS`
RESP=$(curl -s ${WORKFLOW_URL}/operations/start -k -X "PUT" -d "{}" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS)
sh scripts/check_response.sh "${RESP}" $?
if [ $? -gt 0 ];then exit -1;fi
if [ $? -gt 0 ]; then exit -1; fi
STATUS=""
until [ "$STATUS" = "FINISHED" ]
do
sleep 20


# Get the result of the workflow
RESP=`curl -s ${WORKFLOW_URL} -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS`
if [ $? -gt 0 ];then exit -1;fi
STATUS_NAME=`echo $RESP | grep -o '"statusName":".*"' | cut -f4 -d\"`

if [ "$STATUS_NAME" = "in-progress" ]
then
echo "Workflow with SMP/E ended with an error." >> report.txt
echo $RESP >> report.txt
exit -1
elif [ "$STATUS_NAME" = "complete" ]
then
echo "Workflow finished successfully."
STATUS="FINISHED"
fi
until [ "$STATUS" = "FINISHED" ]; do
sleep 20

# Get the result of the workflow
RESP=$(curl -s ${WORKFLOW_URL} -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS)
if [ $? -gt 0 ]; then exit -1; fi
STATUS_NAME=$(echo $RESP | grep -o '"statusName":".*"' | cut -f4 -d\")

if [ "$STATUS_NAME" = "in-progress" ]; then
echo "Workflow with SMP/E ended with an error." >>$LOG_DIR/report.txt
echo $RESP >>$LOG_DIR/report.txt
exit -1
elif [ "$STATUS_NAME" = "complete" ]; then
echo "Workflow finished successfully."
STATUS="FINISHED"
fi
done

66 changes: 31 additions & 35 deletions pswi/02_ptf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand All @@ -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} <<EOF
cd ${DIR}
put WFPTF
EOF
Expand All @@ -47,52 +47,48 @@ cd ..
# Get workflowKey for PTF workflow owned by user
echo "Get workflowKey for PTF workflow if it exists."

RESP=`curl -s $PTF_WF_LIST_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS`
WFKEY=`echo $RESP | grep -o '"workflowKey":".*"' | cut -f4 -d\"`
RESP=$(curl -s $PTF_WF_LIST_URL -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS)
WFKEY=$(echo $RESP | grep -o '"workflowKey":".*"' | cut -f4 -d\")

if [ -n "$WFKEY" ]
then
PTF_WORKFLOW_URL="${CREATE_PTF_WF_URL}/${WFKEY}"
if [ -n "$WFKEY" ]; then
PTF_WORKFLOW_URL="${CREATE_PTF_WF_URL}/${WFKEY}"

echo "Deleting a PTF workflow."
RESP=`curl -s $PTF_WORKFLOW_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS`
sh scripts/check_response.sh "${RESP}" $?
echo "Deleting a PTF workflow."
RESP=$(curl -s $PTF_WORKFLOW_URL -k -X "DELETE" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS)
sh scripts/check_response.sh "${RESP}" $?
fi

# Create workflow with REST API
echo 'Invoking REST API to create ptf workflow.'

RESP=`curl -s $CREATE_PTF_WF_URL -k -X "POST" -d "$ADD_WORKFLOW_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS`
RESP=$(curl -s $CREATE_PTF_WF_URL -k -X "POST" -d "$ADD_WORKFLOW_JSON" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS)
sh scripts/check_response.sh "${RESP}" $?
if [ $? -gt 0 ];then exit -1;fi
WFKEY=`echo $RESP | grep -o '"workflowKey":".*"' | cut -f4 -d\"`
if [ $? -gt 0 ]; then exit -1; fi
WFKEY=$(echo $RESP | grep -o '"workflowKey":".*"' | cut -f4 -d\")
WORKFLOW_URL="${CREATE_PTF_WF_URL}/${WFKEY}"

# Run workflow
echo "Invoking REST API to start a PTF apply workflow."

RESP=`curl -s ${WORKFLOW_URL}/operations/start -k -X "PUT" -d "{}" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS`
RESP=$(curl -s ${WORKFLOW_URL}/operations/start -k -X "PUT" -d "{}" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS)
sh scripts/check_response.sh "${RESP}" $?
if [ $? -gt 0 ];then exit -1;fi
if [ $? -gt 0 ]; then exit -1; fi
STATUS=""
until [ "$STATUS" = "FINISHED" ]
do
sleep 20

# Get the result of the workflow
RESP=`curl -s ${WORKFLOW_URL} -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS`
if [ $? -gt 0 ];then exit -1;fi

STATUS_NAME=`echo $RESP | grep -o '"statusName":".*"' | cut -f4 -d\"`

if [ "$STATUS_NAME" = "in-progress" ]
then
echo "Workflow with PTFs ended with an error." >> report.txt
echo $RESP >> report.txt
exit -1
elif [ "$STATUS_NAME" = "complete" ]
then
echo "Workflow finished successfully."
STATUS="FINISHED"
fi
until [ "$STATUS" = "FINISHED" ]; do
sleep 20

# Get the result of the workflow
RESP=$(curl -s ${WORKFLOW_URL} -k -X "GET" -H "Content-Type: application/json" -H "X-CSRF-ZOSMF-HEADER: A" --user $ZOSMF_USER:$ZOSMF_PASS)
if [ $? -gt 0 ]; then exit -1; fi

STATUS_NAME=$(echo $RESP | grep -o '"statusName":".*"' | cut -f4 -d\")

if [ "$STATUS_NAME" = "in-progress" ]; then
echo "Workflow with PTFs ended with an error." >>$LOG_DIR/report.txt
echo $RESP >>$LOG_DIR/report.txt
exit -1
elif [ "$STATUS_NAME" = "complete" ]; then
echo "Workflow finished successfully."
STATUS="FINISHED"
fi
done
Loading

0 comments on commit 01a399c

Please sign in to comment.