From 4cb2a317cfc3c189b733c6b8dd22ea388823a76f Mon Sep 17 00:00:00 2001 From: dongwenjuan Date: Thu, 18 Aug 2016 10:48:22 +0800 Subject: resolve controller cannot talk to consumer in fuel Change-Id: I0d5aac135d66bb41b4ecfe651f071800c323902d Signed-off-by: dongwenjuan --- tests/run.sh | 67 +++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 25 deletions(-) (limited to 'tests') diff --git a/tests/run.sh b/tests/run.sh index a972c35d..f425879a 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -205,8 +205,16 @@ get_compute_host_info() { } get_consumer_ip() { - CONSUMER_IP=$(sudo ssh $ssh_opts root@$INSTALLER_IP \ - "ip route get $COMPUTE_IP | awk '/ src /{print \$NF}'") + local get_consumer_command="ip route get $COMPUTE_IP | awk '/ src /{print \$NF}'" + if [[ "$INSTALLER_TYPE" == "apex" ]] ; then + CONSUMER_IP=$(sudo ssh $ssh_opts root@$INSTALLER_IP \ + "$get_consumer_command") + elif [[ "$INSTALLER_TYPE" == "fuel" ]] ; then + CONSUMER_IP=$(sudo sshpass -p r00tme ssh $ssh_opts root@${INSTALLER_IP} \ + "$get_consumer_command") + elif [[ "$INSTALLER_TYPE" == "local" ]] ; then + CONSUMER_IP=`$get_consumer_command` + fi echo "CONSUMER_IP=$CONSUMER_IP" if [[ -z "$CONSUMER_IP" ]]; then @@ -366,22 +374,28 @@ start_consumer() { # NOTE(r-mibu): create tunnel to the controller nodes, so that we can # avoid some network problems dpends on infra and installers. # This tunnel will be terminated by stop_consumer() or after 10 mins passed. - if [[ "$INSTALLER_TYPE" == "apex" ]] ; then - CONTROLLER_IPS=$(sudo ssh $ssh_opts $INSTALLER_IP \ - "source stackrc; \ - nova list | grep ' overcloud-controller-[0-9] ' \ - | sed -e 's/^.*ctlplane=//' -e 's/ *|\$//'") - fi - if [[ -z "$CONTROLLER_IPS" ]]; then - echo "ERROR: Could not get CONTROLLER_IPS." - exit 1 + if [[ "$INSTALLER_TYPE" != "local" ]] ; then + if [[ "$INSTALLER_TYPE" == "apex" ]] ; then + CONTROLLER_IPS=$(sudo ssh $ssh_opts $INSTALLER_IP \ + "source stackrc; \ + nova list | grep ' overcloud-controller-[0-9] ' \ + | sed -e 's/^.*ctlplane=//' -e 's/ *|\$//'") + elif [[ "$INSTALLER_TYPE" == "fuel" ]] ; then + CONTROLLER_IPS=$(sshpass -p r00tme ssh 2>/dev/null $ssh_opts root@${INSTALLER_IP} \ + "fuel node | grep controller | cut -d '|' -f 5|xargs") + fi + + if [[ -z "$CONTROLLER_IPS" ]]; then + echo "ERROR: Could not get CONTROLLER_IPS." + exit 1 + fi + for ip in $CONTROLLER_IPS + do + forward_rule="-R $CONSUMER_PORT:localhost:$CONSUMER_PORT" + tunnel_command="sudo ssh $ssh_opts_cpu $COMPUTE_USER@$ip $forward_rule sleep 600" + $tunnel_command > "ssh_tunnel.${ip}.log" 2>&1 < /dev/null & + done fi - for ip in $CONTROLLER_IPS - do - forward_rule="-R $CONSUMER_PORT:localhost:$CONSUMER_PORT" - tunnel_command="sudo ssh $ssh_opts_cpu $COMPUTE_USER@$ip $forward_rule sleep 600" - $tunnel_command > "ssh_tunnel.${ip}.log" 2>&1 < /dev/null & - done } stop_consumer() { @@ -390,13 +404,15 @@ stop_consumer() { print_log consumer.log # NOTE(r-mibu): terminate tunnels to the controller nodes - for ip in $CONTROLLER_IPS - do - forward_rule="-R $CONSUMER_PORT:localhost:$CONSUMER_PORT" - tunnel_command="sudo ssh $ssh_opts_cpu $COMPUTE_USER@$ip $forward_rule sleep 600" - kill $(pgrep -f "$tunnel_command") - print_log "ssh_tunnel.${ip}.log" - done + if [[ "$INSTALLER_TYPE" != "local" ]] ; then + for ip in $CONTROLLER_IPS + do + forward_rule="-R $CONSUMER_PORT:localhost:$CONSUMER_PORT" + tunnel_command="sudo ssh $ssh_opts_cpu $COMPUTE_USER@$ip $forward_rule sleep 600" + kill $(pgrep -f "$tunnel_command") + print_log "ssh_tunnel.${ip}.log" + done + fi } wait_for_vm_launch() { @@ -518,7 +534,8 @@ echo "get computer host info..." get_compute_host_info echo "creating alarm..." -get_consumer_ip +#TODO: change back to use, network problems depends on infra and installers +#get_consumer_ip create_alarm echo "starting doctor sample components..." -- cgit 1.2.3-korg