4 # For each unique remote IP (specified via Heat) we check to
5 # see if one of the locally configured networks matches and if so we
6 # attempt a ping test the remote network IP.
7 function ping_controller_ips() {
9 for REMOTE_IP in $(echo $REMOTE_IPS | sed -e "s| |\n|g" | sort -u); do
10 if [[ $REMOTE_IP =~ ":" ]]; then
11 networks=$(ip -6 r | grep -v default | cut -d " " -f 1 | grep -v "unreachable")
14 networks=$(ip r | grep -v default | cut -d " " -f 1)
17 for LOCAL_NETWORK in $networks; do
18 in_network=$(python -c "import ipaddr; net=ipaddr.IPNetwork('$LOCAL_NETWORK'); addr=ipaddr.IPAddress('$REMOTE_IP'); print(addr in net)")
19 if [[ $in_network == "True" ]]; then
20 echo -n "Trying to ping $REMOTE_IP for local network $LOCAL_NETWORK..."
22 if ! $ping -W 300 -c 1 $REMOTE_IP &> /dev/null; then
24 echo "$REMOTE_IP is not pingable. Local Network: $LOCAL_NETWORK" >&2
34 # Ping all default gateways. There should only be one
35 # if using upstream t-h-t network templates but we test
36 # all of them should some manual network config have
38 function ping_default_gateways() {
39 DEFAULT_GW=$(ip r | grep ^default | cut -d " " -f 3)
41 for GW in $DEFAULT_GW; do
42 echo -n "Trying to ping default gateway ${GW}..."
43 if ! ping -c 1 $GW &> /dev/null; then
45 echo "$GW is not pingable."
53 ping_controller_ips "$ping_test_ips"