Fix api endpoint, get exec id from file and wrap VMs in data key

This commit is contained in:
abrown38 committed 2024-12-11 11:59:30 +00:00
1 parent ed8c29f994
commit fa8520a079
1 file changed
+11 -8
+11 -8
View File
@@ -5,7 +5,8 @@ declare -gr OS_PROJECT=$1
declare -gr WIN_PROJECT=$2 declare -gr WIN_PROJECT=$2
declare -gr API_TOKEN=$3 declare -gr API_TOKEN=$3
declare -g RD_JOB_ID=$4 declare -g RD_JOB_ID=$4
declare -g RD_EXEC_ID=$5 #declare -g RD_EXEC_ID=$5
declare -g RD_EXEC_ID=$(cat /deployments/$OS_PROJECT-$WIN_PROJECT/EXEC_ID)
export OS_CLIENT_CONFIG_FILE=/deployments/$OS_PROJECT-$WIN_PROJECT/clouds.yaml export OS_CLIENT_CONFIG_FILE=/deployments/$OS_PROJECT-$WIN_PROJECT/clouds.yaml
@@ -26,10 +27,12 @@ initialize_json() {
"job_id": "'$RD_JOB_ID'", "job_id": "'$RD_JOB_ID'",
"execution_id": "'$RD_EXEC_ID'", "execution_id": "'$RD_EXEC_ID'",
"status": "ok", "status": "ok",
"DC": {}, "data": {
"WB": {"load_balancer": true, VM: []}, "DC": {},
"APP": {"load_balancer": false, VM: []}, "WB": {"load_balancer": true, VM: []},
"GPU": {"load_balancer": false, VM: []} "APP": {"load_balancer": false, VM: []},
"GPU": {"load_balancer": false, VM: []}
}
}' > $OUTPUT_FILE }' > $OUTPUT_FILE
declare -g -r VM_JSON="/deployments/$OS_PROJECT-$WIN_PROJECT/data.json" declare -g -r VM_JSON="/deployments/$OS_PROJECT-$WIN_PROJECT/data.json"
} }
@@ -42,16 +45,16 @@ add_vm() {
declare -r TYPE=$4 declare -r TYPE=$4
if [[ $TYPE == "DC" ]]; then if [[ $TYPE == "DC" ]]; then
jq ".${TYPE} += {\"name\": \"${NAME}\", \"ip\": \"${IP}\", \"uuid\": \"${UUID}\"}" $VM_JSON > temp.json jq ".data.${TYPE} += {\"name\": \"${NAME}\", \"ip\": \"${IP}\", \"uuid\": \"${UUID}\"}" $VM_JSON > temp.json
mv -f temp.json $VM_JSON mv -f temp.json $VM_JSON
else else
jq ".${TYPE}.VM += [{\"name\": \"${NAME}\", \"ip\": \"${IP}\", \"uuid\": \"${UUID}\"}]" $VM_JSON > temp.json jq ".data.${TYPE}.VM += [{\"name\": \"${NAME}\", \"ip\": \"${IP}\", \"uuid\": \"${UUID}\"}]" $VM_JSON > temp.json
mv -f temp.json $VM_JSON mv -f temp.json $VM_JSON
fi fi
} }
post_request() { post_request() {
declare -r API_ENDPOINT='https://projects.eidf.ac.uk/testportal/job/api/notification' declare -r API_ENDPOINT='https://portal.eidf.ac.uk/job/api/notification'
jq -c . $VM_JSON jq -c . $VM_JSON
curl \ curl \
-X POST \ -X POST \