Adds v6 capability to the deploy validation test (pings)
This changes the ping_controller_ips function in the all-nodes.sh
bash validation script which is run during deployment to check
network connectivity (to fail early).
The main differences are using the v6 routes when it is a v6 address
and using python -c to check if the v6 address is in the network and
(thanks emachi!) using ping6 instead of ping.
Closes-Bug: 1534578
Change-Id: Id41950f767e11884b4123fcb0bd2339636fdda68
(cherry picked from commit 45be848991
)
This commit is contained in:
parent
a074b6ce06
commit
33fa615a0e
@ -5,17 +5,19 @@
|
|||||||
# attempt a ping test on that networks remote IP.
|
# attempt a ping test on that networks remote IP.
|
||||||
function ping_controller_ips() {
|
function ping_controller_ips() {
|
||||||
local REMOTE_IPS=$1
|
local REMOTE_IPS=$1
|
||||||
|
|
||||||
for REMOTE_IP in $(echo $REMOTE_IPS | sed -e "s| |\n|g" | sort -u); do
|
for REMOTE_IP in $(echo $REMOTE_IPS | sed -e "s| |\n|g" | sort -u); do
|
||||||
|
if [[ $REMOTE_IP =~ ":" ]]; then
|
||||||
for LOCAL_NETWORK in $(ip r | grep -v default | cut -d " " -f 1); do
|
networks=$(ip -6 r | grep -v default | cut -d " " -f 1 | grep -v "unreachable")
|
||||||
local LOCAL_CIDR=$(echo $LOCAL_NETWORK | cut -d "/" -f 2)
|
ping=ping6
|
||||||
local LOCAL_NETMASK=$(ipcalc -m $LOCAL_NETWORK | grep NETMASK | cut -d "=" -f 2)
|
else
|
||||||
local REMOTE_NETWORK=$(ipcalc -np $REMOTE_IP $LOCAL_NETMASK | grep NETWORK | cut -d "=" -f 2)
|
networks=$(ip r | grep -v default | cut -d " " -f 1)
|
||||||
|
ping=ping
|
||||||
if [ $REMOTE_NETWORK/$LOCAL_CIDR == $LOCAL_NETWORK ]; then
|
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..."
|
echo -n "Trying to ping $REMOTE_IP for local network $LOCAL_NETWORK..."
|
||||||
if ! ping -W 300 -c 1 $REMOTE_IP &> /dev/null; then
|
if ! $ping -W 300 -c 1 $REMOTE_IP &> /dev/null; then
|
||||||
echo "FAILURE"
|
echo "FAILURE"
|
||||||
echo "$REMOTE_IP is not pingable. Local Network: $LOCAL_NETWORK" >&2
|
echo "$REMOTE_IP is not pingable. Local Network: $LOCAL_NETWORK" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user