4 function ping_retry() {
9 if [[ $IP_ADDR =~ ":" ]]; then
12 until [ $COUNT -ge $TIMES ]; do
13 if $PING_CMD -w 300 -c 1 $IP_ADDR &> /dev/null; then
14 echo "Ping to $IP_ADDR succeeded."
17 echo "Ping to $IP_ADDR failed. Retrying..."
23 # For each unique remote IP (specified via Heat) we check to
24 # see if one of the locally configured networks matches and if so we
25 # attempt a ping test the remote network IP.
26 function ping_controller_ips() {
28 for REMOTE_IP in $(echo $REMOTE_IPS | sed -e "s| |\n|g" | sort -u); do
29 if [[ $REMOTE_IP =~ ":" ]]; then
30 networks=$(ip -6 r | grep -v default | cut -d " " -f 1 | grep -v "unreachable")
32 networks=$(ip r | grep -v default | cut -d " " -f 1)
34 for LOCAL_NETWORK in $networks; do
35 in_network=$(python -c "import ipaddr; net=ipaddr.IPNetwork('$LOCAL_NETWORK'); addr=ipaddr.IPAddress('$REMOTE_IP'); print(addr in net)")
36 if [[ $in_network == "True" ]]; then
37 echo "Trying to ping $REMOTE_IP for local network ${LOCAL_NETWORK}."
39 if ! ping_retry $REMOTE_IP; then
41 echo "$REMOTE_IP is not pingable. Local Network: $LOCAL_NETWORK" >&2
51 # Ping all default gateways. There should only be one
52 # if using upstream t-h-t network templates but we test
53 # all of them should some manual network config have
55 function ping_default_gateways() {
56 DEFAULT_GW=$(ip r | grep ^default | cut -d " " -f 3)
58 for GW in $DEFAULT_GW; do
59 echo -n "Trying to ping default gateway ${GW}..."
60 if ! ping_retry $GW; then
62 echo "$GW is not pingable."
70 ping_controller_ips "$ping_test_ips"