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() {
8 for REMOTE_IP in $(echo $REMOTE_IPS | sed -e "s| |\n|g" | sort -u); do
9 if [[ $REMOTE_IP =~ ":" ]]; then
10 networks=$(ip -6 r | grep -v default | cut -d " " -f 1 | grep -v "unreachable")
13 networks=$(ip r | grep -v default | cut -d " " -f 1)
16 for LOCAL_NETWORK in $networks; do
17 in_network=$(python -c "import ipaddr; net=ipaddr.IPNetwork('$LOCAL_NETWORK'); addr=ipaddr.IPAddress('$REMOTE_IP'); print(addr in net)")
18 if [[ $in_network == "True" ]]; then
19 echo -n "Trying to ping $REMOTE_IP for local network $LOCAL_NETWORK..."
20 if ! $ping -W 300 -c 1 $REMOTE_IP &> /dev/null; then
22 echo "$REMOTE_IP is not pingable. Local Network: $LOCAL_NETWORK" >&2
31 # Ping all default gateways. There should only be one
32 # if using upstream t-h-t network templates but we test
33 # all of them should some manual network config have
35 function ping_default_gateways() {
36 DEFAULT_GW=$(ip r | grep ^default | cut -d " " -f 3)
37 for GW in $DEFAULT_GW; do
38 echo -n "Trying to ping default gateway ${GW}..."
39 if ! ping -c 1 $GW &> /dev/null; then
41 echo "$GW is not pingable."
48 ping_controller_ips "$ping_test_ips"