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 # Verify the FQDN from the nova/ironic deployment matches
71 # FQDN in the heat templates.
72 function fqdn_check() {
74 SHORT_NAME=$(hostname -s)
75 FQDN_FROM_HOSTS=$(awk '$3 == "'${SHORT_NAME}'"{print $2}' /etc/hosts)
76 echo -n "Checking hostname vs /etc/hosts entry..."
77 if [[ $HOSTNAME != $FQDN_FROM_HOSTS ]]; then
79 echo -e "System hostname: ${HOSTNAME}\nEntry from /etc/hosts: ${FQDN_FROM_HOSTS}\n"
85 # Verify at least one time source is available.
86 function ntp_check() {
87 NTP_SERVERS=$(hiera ntp::servers nil |tr -d '[],"')
88 if [[ "$NTP_SERVERS" != "nil" ]];then
89 echo -n "Testing NTP..."
91 for NTP_SERVER in $NTP_SERVERS; do
93 NTPDATE_OUT=$(ntpdate -qud $NTP_SERVER 2>&1)
96 if [[ "$NTPDATE_EXIT" == "0" ]];then
100 NTPDATE_OUT_FULL="$NTPDATE_OUT_FULL $NTPDATE_OUT"
103 if [[ "$NTP_SUCCESS" == "0" ]];then
105 echo "$NTPDATE_OUT_FULL"
112 ping_controller_ips "$ping_test_ips"
113 ping_default_gateways
114 if [[ $validate_fqdn == "True" ]];then
117 if [[ $validate_ntp == "True" ]];then