Added functions for get a ip on an instance
The cause of some gating failure looks like because of getting ip address on instance. However current exercise didn't log the return value. In this commit, we add get_instance_ip function with error hanlding support, and apply it on the execise. Change-Id: I8e17ba68093faafe58a98eb780a032368eea38aa
This commit is contained in:
parent
55181d2cfb
commit
6769b166b1
@ -174,7 +174,8 @@ if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | g
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the instance IP
|
# Get the instance IP
|
||||||
IP=$(nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2)
|
IP=$(get_instance_ip $VM_UUID $PRIVATE_NETWORK_NAME)
|
||||||
|
|
||||||
die_if_not_set $LINENO IP "Failure retrieving IP address"
|
die_if_not_set $LINENO IP "Failure retrieving IP address"
|
||||||
|
|
||||||
# Private IPs can be pinged in single node deployments
|
# Private IPs can be pinged in single node deployments
|
||||||
|
@ -132,7 +132,7 @@ if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | g
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the instance IP
|
# Get the instance IP
|
||||||
IP=$(nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2)
|
IP=$(get_instance_ip $VM_UUID $PRIVATE_NETWORK_NAME)
|
||||||
die_if_not_set $LINENO IP "Failure retrieving IP address"
|
die_if_not_set $LINENO IP "Failure retrieving IP address"
|
||||||
|
|
||||||
# Private IPs can be pinged in single node deployments
|
# Private IPs can be pinged in single node deployments
|
||||||
|
@ -272,12 +272,12 @@ function create_vms {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ping_ip {
|
function ping_ip {
|
||||||
# Test agent connection. Assumes namespaces are disabled, and
|
# Test agent connection. Assumes namespaces are disabled, and
|
||||||
# that DHCP is in use, but not L3
|
# that DHCP is in use, but not L3
|
||||||
local VM_NAME=$1
|
local VM_NAME=$1
|
||||||
local NET_NAME=$2
|
local NET_NAME=$2
|
||||||
IP=`nova show $VM_NAME | grep 'network' | awk '{print $5}'`
|
IP=$(get_instance_ip $VM_NAME $NET_NAME)
|
||||||
ping_check $NET_NAME $IP $BOOT_TIMEOUT
|
ping_check $NET_NAME $IP $BOOT_TIMEOUT
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_vm {
|
function check_vm {
|
||||||
|
@ -135,7 +135,8 @@ if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | g
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the instance IP
|
# Get the instance IP
|
||||||
IP=$(nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2)
|
IP=$(get_instance_ip $VM_UUID $PRIVATE_NETWORK_NAME)
|
||||||
|
|
||||||
die_if_not_set $LINENO IP "Failure retrieving IP address"
|
die_if_not_set $LINENO IP "Failure retrieving IP address"
|
||||||
|
|
||||||
# Private IPs can be pinged in single node deployments
|
# Private IPs can be pinged in single node deployments
|
||||||
|
13
functions
13
functions
@ -1433,6 +1433,19 @@ function _ping_check_novanet() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get ip of instance
|
||||||
|
function get_instance_ip(){
|
||||||
|
local vm_id=$1
|
||||||
|
local network_name=$2
|
||||||
|
local nova_result="$(nova show $vm_id)"
|
||||||
|
local ip=$(echo "$nova_result" | grep "$network_name" | get_field 2)
|
||||||
|
if [[ $ip = "" ]];then
|
||||||
|
echo "$nova_result"
|
||||||
|
die $LINENO "[Fail] Coudn't get ipaddress of VM"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo $ip
|
||||||
|
}
|
||||||
|
|
||||||
# ssh check
|
# ssh check
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user