Fix validation script

This change adds support for special routes on the host. Without this
the validation fails if any routes are present that don't have an IP
address in the first column, like blackhole, prohibit, throw, etc.
Instead of piping a bunch of `grep -v`, the regex filters all cases by
capturing all lines that start with an IP address. The regex doesn't
capture only valid IP addresses, but it should do just fine here.

Change-Id: I933b33ccf22fb42695be6ec9a5e62506a1b355fd
This commit is contained in:
Mihai Plasoianu 2020-04-27 16:12:09 +02:00
parent 5d1108d850
commit ab02fbe75d

View File

@ -35,7 +35,7 @@ function ping_controller_ips() {
if [[ $REMOTE_IP =~ ":" ]]; then
networks=$(ip -6 r | grep -v default | cut -d " " -f 1 | grep -v "unreachable")
else
networks=$(ip r | grep -v default | cut -d " " -f 1)
networks=$(ip r | grep -E '^([0-9]{1,3}\.?){4}' | cut -d " " -f 1)
fi
for LOCAL_NETWORK in $networks; do
in_network=$($(get_python) -c "import ipaddress; net=ipaddress.ip_network(u'$LOCAL_NETWORK'); addr=ipaddress.ip_address(u'$REMOTE_IP'); print(addr in net)")