Fix the way to get localhost IP in devstack

In Ubuntu Bionic, the following command returns "uid" so that the
guest-agent service will fail because of invalid IP address.

$ ip route get 8.8.8.8 | head -1 | cut -d' ' -f8
uid
$ ip route get 8.8.8.8 | head -1
8.8.8.8 via 10.0.17.1 dev ens3 src 10.0.17.131 uid 0

In Ubuntu Xenial:

$ ip route get 8.8.8.8 | head -1 | cut -d' ' -f8
10.0.17.132
$ ip route get 8.8.8.8 | head -1
8.8.8.8 via 192.168.192.1 dev eth0  src 10.0.17.132

Change-Id: Iae24686fa65603b7d22b09da99b7590e4e117454
This commit is contained in:
Lingxian Kong 2019-03-22 21:03:54 +13:00
parent b00bad9495
commit 4a85d9b77f
1 changed files with 1 additions and 1 deletions

View File

@ -583,7 +583,7 @@ function _setup_minimal_image {
##### - we assume tripleo elements and all other elements have been downloaded
echo "Exporting image-related environmental variables"
PRIMARY_IP=$(ip route get 8.8.8.8 | head -1 | cut -d' ' -f8)
PRIMARY_IP=$(ip route get 8.8.8.8 | head -1 | awk '{print $7}')
export CONTROLLER_IP=${CONTROLLER_IP:-$PRIMARY_IP}
export HOST_USERNAME=${HOST_USERNAME:-'stack'}
export HOST_SCP_USERNAME=${HOST_SCP_USERNAME:-'stack'}