Merge "Stabilize gate: Fix CONTROLLER_IP is .1 issue"

This commit is contained in:
Jenkins 2017-03-05 07:56:46 +00:00 committed by Gerrit Code Review
commit 3b64992806

View File

@ -1283,29 +1283,29 @@ function cmd_dsvm_gate_tests() {
exclaim "Running cmd_dsvm_gate_tests ..."
# Sometimes in the gate the ACTUAL_HOSTNAME is blank - this code attempts to debug it
if [[ -z "${CONTROLLER_IP}" ]]; then
if [[ -z "${CONTROLLER_IP// }" ]]; then
echo "*** CONTROLLER_IP is blank, trying to determine actual hostname"
local hostname_part=$(hostname -I)
echo "Hostname pass 1: $hostname_part"
echo "Hostname pass 1: '$hostname_part'"
hostname_part=$(echo $hostname_part | sed 's/[0-9a-z][0-9a-z]*:.*:[0-9a-z][0-9a-z]*//g')
echo "Hostname pass 2: $hostname_part"
echo "Hostname pass 2: '$hostname_part'"
hostname_part_no_ip6=$hostname_part
hostname_part=$(echo $hostname_part | sed 's/[0-9]*\.[0-9]*\.[0-9]*\.1\b//g')
echo "Hostname pass 3: $hostname_part"
if [[ -z "${hostname_part}" ]]; then
echo "Hostname pass 3: '$hostname_part'"
if [[ -z "${hostname_part// }" ]]; then
# This seems to occur when the actual hostname ends with '.1'
# If this happens, take the first one that doesn't start with '192' or '172'
hostname_part=$(echo $hostname_part_no_ip6 | sed 's/1[79]2\.[0-9]*\.[0-9]*\.1\b//g')
echo "Hostname pass 3a: $hostname_part"
echo "Hostname pass 3a: '$hostname_part'"
fi
hostname_part=$(echo $hostname_part | sed 's/ /\n/g')
echo "Hostname pass 4: $hostname_part"
echo "Hostname pass 4: '$hostname_part'"
hostname_part=$(echo $hostname_part | sed '/^$/d')
echo "Hostname pass 5: $hostname_part"
echo "Hostname pass 5: '$hostname_part'"
hostname_part=$(echo $hostname_part | sort -bu)
echo "Hostname pass 6: $hostname_part"
echo "Hostname pass 6: '$hostname_part'"
hostname_part=$(echo $hostname_part | head -1)
echo "Hostname pass 7: $hostname_part"
echo "Hostname pass 7: '$hostname_part'"
CONTROLLER_IP=$hostname_part
echo "*** CONTROLLER_IP was blank (CONTROLLER_IP now set to '$CONTROLLER_IP')"
fi