3 # For each unique remote IP (specified via Heat) we check to
4 # see if one of the locally configured networks matches and if so we
5 # attempt a ping test the remote network IP.
6 function ping_controller_ips() {
9 for REMOTE_IP in $(echo $REMOTE_IPS | sed -e "s| |\n|g" | sort -u); do
11 for LOCAL_NETWORK in $(ip r | grep -v default | cut -d " " -f 1); do
12 local LOCAL_CIDR=$(echo $LOCAL_NETWORK | cut -d "/" -f 2)
13 local LOCAL_NETMASK=$(ipcalc -m $LOCAL_NETWORK | grep NETMASK | cut -d "=" -f 2)
14 local REMOTE_NETWORK=$(ipcalc -np $REMOTE_IP $LOCAL_NETMASK | grep NETWORK | cut -d "=" -f 2)
16 if [ $REMOTE_NETWORK/$LOCAL_CIDR == $LOCAL_NETWORK ]; then
17 echo -n "Trying to ping $REMOTE_IP for local network $LOCAL_NETWORK..."
18 if ! ping -W 300 -c 1 $REMOTE_IP &> /dev/null; then
20 echo "$REMOTE_IP is not pingable. Local Network: $LOCAL_NETWORK" >&2
29 # Ping all default gateways. There should only be one
30 # if using upstream t-h-t network templates but we test
31 # all of them should some manual network config have
33 function ping_default_gateways() {
34 DEFAULT_GW=$(ip r | grep ^default | cut -d " " -f 3)
35 for GW in $DEFAULT_GW; do
36 echo -n "Trying to ping default gateway ${GW}..."
37 if ! ping -c 1 $GW &> /dev/null; then
39 echo "$GW is not pingable."
46 ping_controller_ips "$ping_test_ips"