From 2a231ab855dfd3b8601bc61ad28fc50a8e9a5f35 Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Fri, 17 May 2013 11:25:25 +0100 Subject: [PATCH] Make wait_for mor flexable Adding LOOP nums and SLEEPTIME as params --- toci_functions.sh | 9 +++++++-- toci_setup.sh | 5 ++++- toci_test.sh | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/toci_functions.sh b/toci_functions.sh index 3f9529b44..c39252c4e 100644 --- a/toci_functions.sh +++ b/toci_functions.sh @@ -20,9 +20,14 @@ scp_noprompt(){ } wait_for(){ - for x in {0..60} ; do + LOOPS=$1 + SLEEPTIME=$2 + shift ; shift + i=0 + while [ $i -lt $LOOPS ] ; do + i=$((i + 1)) $@ && return 0 || true - sleep 10 + sleep $SLEEPTIME done return 1 } diff --git a/toci_setup.sh b/toci_setup.sh index 581dfbe9a..93ac48e07 100755 --- a/toci_setup.sh +++ b/toci_setup.sh @@ -21,6 +21,9 @@ cd $TOCI_WORKING_DIR/tripleo_incubator id | grep libvirt || ( echo "You have been added to the libvirt group, this script will now exit but will succeed if run again in a new shell" ; exit 1 ) +# looks like libvirt somtimes takes a little time to start +wait_for 3 3 ls /var/run/libvirt/libvirt-sock + cd $TOCI_WORKING_DIR/tripleo_bm_poseur sudo ./bm_poseur --bridge-ip=none create-bridge sudo service libvirt-bin restart @@ -37,5 +40,5 @@ DIB_PATH=$TOCI_WORKING_DIR/stackforge_diskimage-builder \ BOOTSTRAP_IP=`scripts/get-vm-ip bootstrap` # We're going to wait for it to finish firstboot -wait_for ssh_noprompt root@$BOOTSTRAP_IP ls /opt/stack/boot-stack/boot-stack.done && break || true +wait_for 30 10 ssh_noprompt root@$BOOTSTRAP_IP ls /opt/stack/boot-stack/boot-stack.done diff --git a/toci_test.sh b/toci_test.sh index 4b0b52866..58804cb43 100755 --- a/toci_test.sh +++ b/toci_test.sh @@ -28,7 +28,7 @@ ssh_noprompt root@$BOOTSTRAP_IP "cat /opt/stack/boot-stack/virtual-power-key.pub # Now we have to wait for the bm poseur to appear on the compute node and for the compute node to then # update the scheduler -wait_for ssh_noprompt root@$BOOTSTRAP_IP grep \'record updated for\' /var/log/upstart/nova-compute.log +wait_for 20 10 ssh_noprompt root@$BOOTSTRAP_IP grep \'record updated for\' /var/log/upstart/nova-compute.log -A 100 \| grep \'Updating host status\' # I've tried all kinds of things to wait for before doing the nova boot and can't find a reliable combination, # I suspect I need to watch the scheduler and compute log to follow a chain of events, @@ -38,4 +38,4 @@ sleep 67 nova boot --flavor 256 --image base --key_name default bmtest # ping the node TODO : make this more readable and output less errors -wait_for ssh_noprompt root@$BOOTSTRAP_IP 'source ~/stackrc ; ping -c 1 $(nova list | grep ctlplane | sed -e "s/.*=\(.*\) .*/\1/g")' +wait_for 20 10 ssh_noprompt root@$BOOTSTRAP_IP 'source ~/stackrc ; ping -c 1 $(nova list | grep ctlplane | sed -e "s/.*=\(.*\) .*/\1/g")'