Merge "Generate the endpoint map statically"
authorJenkins <jenkins@review.openstack.org>
Thu, 25 Feb 2016 10:09:36 +0000 (10:09 +0000)
committerGerrit Code Review <review@openstack.org>
Thu, 25 Feb 2016 10:09:36 +0000 (10:09 +0000)
tox.ini
validation-scripts/all-nodes.sh

diff --git a/tox.ini b/tox.ini
index 974971f..5d09e0a 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -10,5 +10,5 @@ deps = -r{toxinidir}/requirements.txt
 [testenv:venv]
 commands = {posargs}
 
-[testenv:linters]
+[testenv:pep8]
 commands = python ./tools/yaml-validate.py .
index 8057f20..ae1fddf 100644 (file)
@@ -5,23 +5,25 @@
 # attempt a ping test the remote network IP.
 function ping_controller_ips() {
   local REMOTE_IPS=$1
-
   for REMOTE_IP in $(echo $REMOTE_IPS | sed -e "s| |\n|g" | sort -u); do
-
-    for LOCAL_NETWORK in $(ip r | grep -v default | cut -d " " -f 1); do
-       local LOCAL_CIDR=$(echo $LOCAL_NETWORK | cut -d "/" -f 2)
-       local LOCAL_NETMASK=$(ipcalc -m $LOCAL_NETWORK | grep NETMASK | cut -d "=" -f 2)
-       local REMOTE_NETWORK=$(ipcalc -np $REMOTE_IP $LOCAL_NETMASK | grep NETWORK | cut -d "=" -f 2)
-
-       if [ $REMOTE_NETWORK/$LOCAL_CIDR == $LOCAL_NETWORK ]; then
-         echo -n "Trying to ping $REMOTE_IP for local network $LOCAL_NETWORK..."
-         if ! ping -W 300 -c 1 $REMOTE_IP &> /dev/null; then
-           echo "FAILURE"
-           echo "$REMOTE_IP is not pingable. Local Network: $LOCAL_NETWORK" >&2
-           exit 1
-         fi
-         echo "SUCCESS"
-       fi
+    if [[ $REMOTE_IP =~ ":" ]]; then
+      networks=$(ip -6 r | grep -v default | cut -d " " -f 1 | grep -v "unreachable")
+      ping=ping6
+    else
+      networks=$(ip r | grep -v default | cut -d " " -f 1)
+      ping=ping
+    fi
+    for LOCAL_NETWORK in $networks; do
+      in_network=$(python -c "import ipaddr; net=ipaddr.IPNetwork('$LOCAL_NETWORK'); addr=ipaddr.IPAddress('$REMOTE_IP'); print(addr in net)")
+      if [[ $in_network == "True" ]]; then
+        echo -n "Trying to ping $REMOTE_IP for local network $LOCAL_NETWORK..."
+        if ! $ping -W 300 -c 1 $REMOTE_IP &> /dev/null; then
+          echo "FAILURE"
+          echo "$REMOTE_IP is not pingable. Local Network: $LOCAL_NETWORK" >&2
+          exit 1
+        fi
+        echo "SUCCESS"
+      fi
     done
   done
 }