summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authordongwenjuan <dong.wenjuan@zte.com.cn>2016-07-28 19:23:05 +0800
committerdongwenjuan <dong.wenjuan@zte.com.cn>2016-07-29 09:30:02 +0800
commitcdc9787dafbdf4dd491748c0307ae7240024846a (patch)
tree546fd899b39ec64ae518d403b99e707445bef8e3 /tests
parent1e490b1d4f9003471d64ea0b433a80122924cff3 (diff)
fix bugs to get `CONSUMER_IP`
use `ip route get $COMPUTE_IP` to get CONSUMER_IP. And add script fail if it failed to get CONSUMER_IP. Change-Id: I2e330c9be6e00f31e6c3e27dd674f9aabbb74a41 Signed-off-by: dongwenjuan <dong.wenjuan@zte.com.cn>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/run.sh15
1 files changed, 5 insertions, 10 deletions
diff --git a/tests/run.sh b/tests/run.sh
index ae030e22..0bd9ee64 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -96,17 +96,12 @@ prepare_compute_ssh() {
}
get_consumer_ip() {
- #get network of the compute_ip address
- network_pre=${COMPUTE_IP%.*}
- network=${network_pre}.0/24
+ CONSUMER_IP=$(ip route get $COMPUTE_IP | awk '/ src /{print $NF}')
- #if there is a dedicated route, use it
- dev=$(ip route |grep $network | awk '{print $3}' |head -n 1)
-
- #if there is no route, use default route
- [[ -z $dev ]] && dev=$(ip route |grep ^default | awk '{print $3}' |head -n 1)
-
- CONSUMER_IP=$(ip addr show $dev |grep inet | grep $network_pre | awk '{print $2}' | cut -d'/' -f1)
+ if [[ -z "$CONSUMER_IP" ]]; then
+ echo "ERROR: Could not get CONSUMER_IP."
+ exit 1
+ fi
}
download_image() {