F #85: Retry report READY

Signed-off-by: Petr Ospalý <pospaly@opennebula.io>
pull/228/head
Petr Ospalý 4 years ago committed by Vlastimil Holer
parent 8a4026e4f6
commit 7a8cb816c8

@ -17,6 +17,8 @@
#--------------------------------------------------------------------------- # #--------------------------------------------------------------------------- #
ENV_FILE=${ENV_FILE:-/var/run/one-context/one_env} ENV_FILE=${ENV_FILE:-/var/run/one-context/one_env}
RETRY_COUNT="${RETRY_COUNT:-3}"
RETRY_WAIT_PERIOD="${RETRY_WAIT_PERIOD:-10}"
if [ "$REPORT_READY" != "YES" ]; then if [ "$REPORT_READY" != "YES" ]; then
exit 0 exit 0
@ -29,34 +31,44 @@ fi
### ###
if which curl >/dev/null 2>&1; then if command -v curl ; then
curl -X "PUT" "${ONEGATE_ENDPOINT}/vm" \ _command=curl
--header "X-ONEGATE-TOKEN: $TOKENTXT" \ elif command -v wget ; then
--header "X-ONEGATE-VMID: $VMID" \ _command=wget
--insecure \ elif command -v onegate ; then
-d "READY=YES" _command=onegate
else
echo "ERROR: No way to signal READY=YES (no usable binary)" >&2
exit 1
fi > /dev/null # this will not drop the error message which goes to stderr
if [ "$?" = "0" ]; then while [ "$RETRY_COUNT" -gt 0 ] ; do
exit 0 case "$_command" in
fi curl)
fi curl -X "PUT" "${ONEGATE_ENDPOINT}/vm" \
--header "X-ONEGATE-TOKEN: $TOKENTXT" \
if which wget >/dev/null 2>&1; then --header "X-ONEGATE-VMID: $VMID" \
wget --method=PUT "${ONEGATE_ENDPOINT}/vm" \ --insecure \
--body-data="READY=YES" \ -d "READY=YES"
--header "X-ONEGATE-TOKEN: $TOKENTXT" \ ;;
--header "X-ONEGATE-VMID: $VMID" \ wget)
--no-check-certificate wget --method=PUT "${ONEGATE_ENDPOINT}/vm" \
--body-data="READY=YES" \
--header "X-ONEGATE-TOKEN: $TOKENTXT" \
--header "X-ONEGATE-VMID: $VMID" \
--no-check-certificate
;;
onegate)
onegate vm update --data "READY=YES"
;;
esac
if [ "$?" = "0" ]; then if [ "$?" = "0" ]; then
exit 0 exit 0
fi fi
fi
if which onegate >/dev/null 2>&1; then RETRY_COUNT=$(( RETRY_COUNT - 1 ))
onegate vm update --data "READY=YES" sleep "${RETRY_WAIT_PERIOD}"
done
if [ "$?" = "0" ]; then exit 1
exit 0
fi
fi

Loading…
Cancel
Save