Nova: Update compute start script for console

[0] added route command to identify multiple default routes.
In some deployments, route command is not available which set the
client_interface value incorrectly. In this case VNC clinet tries
to connect to default host 127.0.0.1 and fails.

[0] https://review.opendev.org/#/c/696187

Change-Id: I4a936af053114988e0b70048e276a71833c5638e
This commit is contained in:
Sangeet Gupta 2020-03-26 11:44:14 -05:00
parent 82881a0df7
commit 214feefd13
2 changed files with 12 additions and 4 deletions

View File

@ -32,8 +32,12 @@ fi
if [ -z "${client_address}" ] ; then
if [ -z "${client_interface}" ] ; then
# search for interface with default routing, if multiple default routes exist then select the one with the lowest metric.
client_interface=$(route -n | awk '/^0.0.0.0/ { print $5 " " $NF }' | sort | awk '{ print $NF; exit }')
if [ -x "$(command -v route)" ] ; then
# search for interface with default routing, if multiple default routes exist then select the one with the lowest metric.
client_interface=$(route -n | awk '/^0.0.0.0/ { print $5 " " $NF }' | sort | awk '{ print $NF; exit }')
else
client_interface=$(ip r | grep default | awk '{print $5}')
fi
fi
# determine client ip dynamically based on interface provided

View File

@ -32,8 +32,12 @@ fi
if [ -z "${client_address}" ] ; then
if [ -z "${client_interface}" ] ; then
# search for interface with default routing, if multiple default routes exist then select the one with the lowest metric.
client_interface=$(route -n | awk '/^0.0.0.0/ { print $5 " " $NF }' | sort | awk '{ print $NF; exit }')
if [ -x "$(command -v route)" ] ; then
# search for interface with default routing, if multiple default routes exist then select the one with the lowest metric.
client_interface=$(route -n | awk '/^0.0.0.0/ { print $5 " " $NF }' | sort | awk '{ print $NF; exit }')
else
client_interface=$(ip r | grep default | awk '{print $5}')
fi
fi
# determine client ip dynamically based on interface provided