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 API_TOKEN=$3
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
@@ -26,10 +27,12 @@ initialize_json() {
"job_id": "'$RD_JOB_ID'",
"execution_id": "'$RD_EXEC_ID'",
"status": "ok",
"DC": {},
"WB": {"load_balancer": true, VM: []},
"APP": {"load_balancer": false, VM: []},
"GPU": {"load_balancer": false, VM: []}
"data": {
"DC": {},
"WB": {"load_balancer": true, VM: []},
"APP": {"load_balancer": false, VM: []},
"GPU": {"load_balancer": false, VM: []}
}
}' > $OUTPUT_FILE
declare -g -r VM_JSON="/deployments/$OS_PROJECT-$WIN_PROJECT/data.json"
}
@@ -42,16 +45,16 @@ add_vm() {
declare -r TYPE=$4
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
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
fi
}
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
curl \
-X POST \