Adds ability to power off nodes in clean
[apex.git] / lib / common-functions.sh
index 2ace997..6941093 100644 (file)
@@ -21,13 +21,19 @@ function prefix2mask {
 }
 
 ##find ip of interface
-##params: interface name
+##params: interface name, address family
 function find_ip {
+  local af
   if [[ -z "$1" ]]; then
     return 1
   fi
+  if [[ -z "$2" ]]; then
+    af=4
+  else
+    af=$2
+  fi
 
-  python3.4 -B $LIB/python/apex_python_utils.py find-ip -i $1
+  python3.4 -B $LIB/python/apex_python_utils.py find-ip -i $1 -af $af
 }
 
 ##attach interface to OVS and set the network config correctly
@@ -287,3 +293,16 @@ function verify_internet {
     return 1
   fi
 }
+
+##tests if overcloud nodes have external connectivity
+#params:none
+function test_overcloud_connectivity {
+  for node in $(undercloud_connect stack ". stackrc && nova list" | grep -Eo "controller-[0-9]+|compute-[0-9]+" | tr -d -) ; do
+    if ! overcloud_connect $node "ping -c 2 $ping_site > /dev/null"; then
+      echo "${blue}Node ${node} was unable to ping site ${ping_site}${reset}"
+      return 1
+    fi
+  done
+  echo "${blue}Overcloud external connectivity OK${reset}"
+}
+