4 function ping_retry() {
9 if [[ $IP_ADDR =~ ":" ]]; then
12 until [ $COUNT -ge $TIMES ]; do
13 if $PING_CMD -w 10 -c 1 $IP_ADDR &> /dev/null; then
14 echo "Ping to $IP_ADDR succeeded."
17 echo "Ping to $IP_ADDR failed. Retrying..."
24 # For each unique remote IP (specified via Heat) we check to
25 # see if one of the locally configured networks matches and if so we
26 # attempt a ping test the remote network IP.
27 function ping_controller_ips() {
29 for REMOTE_IP in $(echo $REMOTE_IPS | sed -e "s| |\n|g" | sort -u); do
30 if [[ $REMOTE_IP =~ ":" ]]; then
31 networks=$(ip -6 r | grep -v default | cut -d " " -f 1 | grep -v "unreachable")
33 networks=$(ip r | grep -v default | cut -d " " -f 1)
35 for LOCAL_NETWORK in $networks; do
36 in_network=$(python -c "import ipaddr; net=ipaddr.IPNetwork('$LOCAL_NETWORK'); addr=ipaddr.IPAddress('$REMOTE_IP'); print(addr in net)")
37 if [[ $in_network == "True" ]]; then
38 echo "Trying to ping $REMOTE_IP for local network ${LOCAL_NETWORK}."
40 if ! ping_retry $REMOTE_IP; then
42 echo "$REMOTE_IP is not pingable. Local Network: $LOCAL_NETWORK" >&2
52 # Ping all default gateways. There should only be one
53 # if using upstream t-h-t network templates but we test
54 # all of them should some manual network config have
56 function ping_default_gateways() {
57 DEFAULT_GW=$(ip r | grep ^default | cut -d " " -f 3)
59 for GW in $DEFAULT_GW; do
60 echo -n "Trying to ping default gateway ${GW}..."
61 if ! ping_retry $GW; then
63 echo "$GW is not pingable."
71 # Verify the FQDN from the nova/ironic deployment matches
72 # FQDN in the heat templates.
73 function fqdn_check() {
75 SHORT_NAME=$(hostname -s)
76 FQDN_FROM_HOSTS=$(awk '$3 == "'${SHORT_NAME}'"{print $2}' /etc/hosts)
77 echo -n "Checking hostname vs /etc/hosts entry..."
78 if [[ $HOSTNAME != $FQDN_FROM_HOSTS ]]; then
80 echo -e "System hostname: ${HOSTNAME}\nEntry from /etc/hosts: ${FQDN_FROM_HOSTS}\n"
86 # Verify at least one time source is available.
87 function ntp_check() {
88 NTP_SERVERS=$(hiera ntp::servers nil |tr -d '[],"')
89 if [[ "$NTP_SERVERS" != "nil" ]];then
90 echo -n "Testing NTP..."
92 for NTP_SERVER in $NTP_SERVERS; do
94 NTPDATE_OUT=$(ntpdate -qud $NTP_SERVER 2>&1)
97 if [[ "$NTPDATE_EXIT" == "0" ]];then
101 NTPDATE_OUT_FULL="$NTPDATE_OUT_FULL $NTPDATE_OUT"
104 if [[ "$NTP_SUCCESS" == "0" ]];then
106 echo "$NTPDATE_OUT_FULL"
113 ping_controller_ips "$ping_test_ips"
114 ping_default_gateways
115 if [[ $validate_fqdn == "True" ]];then
118 if [[ $validate_ntp == "True" ]];then