Use default route to find HOST_IP
When running devstack, nova moves the host ip from eth0 onto the
bridge. This causes devstack to fail on the second run unless you
explicitly set HOST_IP in localrc.
This patch searches for an ip on the interface that is used for
the default route. This will be eth0 (or en0) in most cases, but
it will search br100 instead if nova has moved the ip, since it
moves the default route as well.
It also will filter out ips from the potential list that are part
of the fixed range and floating range if the netaddr library is
installed. This allows us to find the proper ip even if we have
accidentally left a floating ip or fixed ip on the bridge.
Change-Id: I13288e53ee2786c5ae0edb3f9ab457be8303f1f6
diff --git a/functions b/functions
index 46a6f8a..e46a2fc 100644
--- a/functions
+++ b/functions
@@ -9,6 +9,18 @@
set +o xtrace
+# Exit 0 if address is in network or 1 if
+# address is not in network or netaddr library
+# is not installed.
+function address_in_net() {
+ python -c "
+import netaddr
+import sys
+sys.exit(netaddr.IPAddress('$1') not in netaddr.IPNetwork('$2'))
+"
+}
+
+
# apt-get wrapper to set arguments correctly
# apt_get operation package [package ...]
function apt_get() {