mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 13:30:02 +08:00
fix: Retry if needed
This commit is contained in:
parent
2d97bc1cef
commit
899687d3f2
56
run/print.sh
56
run/print.sh
@ -5,38 +5,46 @@ info () { echo -e "\E[1;34m❯\E[1;36m $1\E[0m" ; }
|
||||
error () { echo -e >&2 "\E[1;31m❯ ERROR: $1\E[0m" ; }
|
||||
|
||||
sleep 1
|
||||
retry=true
|
||||
|
||||
# Retrieve IP from guest VM
|
||||
RESPONSE=$(curl -s -m 16 -S http://127.0.0.1:2210/read?command=10 2>&1)
|
||||
while [ "$retry" = true ]
|
||||
do
|
||||
|
||||
if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then
|
||||
error "Failed to connect to guest: $RESPONSE" && exit 1
|
||||
fi
|
||||
# Retrieve IP from guest VM
|
||||
RESPONSE=$(curl -s -m 16 -S http://127.0.0.1:2210/read?command=10 2>&1)
|
||||
|
||||
# Retrieve the HTTP port number
|
||||
if [[ ! "${RESPONSE}" =~ "\"http_port\"" ]] ; then
|
||||
error "Failed to parse response from guest: $RESPONSE" && exit 1
|
||||
fi
|
||||
if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then
|
||||
error "Failed to connect to guest: $RESPONSE" && exit 1
|
||||
fi
|
||||
|
||||
rest=${RESPONSE#*http_port}
|
||||
rest=${rest#*:}
|
||||
rest=${rest%%,*}
|
||||
PORT=${rest%%\"*}
|
||||
# Retrieve the HTTP port number
|
||||
if [[ ! "${RESPONSE}" =~ "\"http_port\"" ]] ; then
|
||||
error "Failed to parse response from guest: $RESPONSE" && exit 1
|
||||
fi
|
||||
|
||||
[ -z "${PORT}" ] && error "Guest has not set a portnumber yet.." && exit 1
|
||||
rest=${RESPONSE#*http_port}
|
||||
rest=${rest#*:}
|
||||
rest=${rest%%,*}
|
||||
PORT=${rest%%\"*}
|
||||
|
||||
# Retrieve the IP address
|
||||
if [[ ! "${RESPONSE}" =~ "eth0" ]] ; then
|
||||
error "Failed to parse response from guest: $RESPONSE" && exit 1
|
||||
fi
|
||||
[ -z "${PORT}" ] && error "Guest has not set a portnumber yet.." && sleep 3 && continue
|
||||
|
||||
rest=${RESPONSE#*eth0}
|
||||
rest=${rest#*ip}
|
||||
rest=${rest#*:}
|
||||
rest=${rest#*\"}
|
||||
IP=${rest%%\"*}
|
||||
# Retrieve the IP address
|
||||
if [[ ! "${RESPONSE}" =~ "eth0" ]] ; then
|
||||
error "Failed to parse response from guest: $RESPONSE" && exit 1
|
||||
fi
|
||||
|
||||
[ -z "${IP}" ] && error "Guest has not received an IP yet.." && exit 1
|
||||
rest=${RESPONSE#*eth0}
|
||||
rest=${rest#*ip}
|
||||
rest=${rest#*:}
|
||||
rest=${rest#*\"}
|
||||
IP=${rest%%\"*}
|
||||
|
||||
[ -z "${IP}" ] && error "Guest has not received an IP yet.." && sleep 3 && continue
|
||||
|
||||
retry=false
|
||||
|
||||
done
|
||||
|
||||
if [[ "$IP" == "20.20"* ]]; then
|
||||
MSG="port ${PORT}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user