summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeap Admins <sysdev@leap.se>2013-05-08 15:05:33 +0000
committerLeap Admins <sysdev@leap.se>2013-05-08 15:05:33 +0000
commit5b719d2a6f90a2ca16b13f9559c1ff8c2dc112d6 (patch)
treebeb2ed3f8df34469cd2d0890953d84817e4d43e7
parent2b5834967e60241c5b0f41fe22f944cc5f7502ce (diff)
added wait_for_node, add services
-rwxr-xr-xleap-platform-test41
1 files changed, 31 insertions, 10 deletions
diff --git a/leap-platform-test b/leap-platform-test
index 6b16fcc..9162f46 100755
--- a/leap-platform-test
+++ b/leap-platform-test
@@ -37,9 +37,13 @@ add_nodes() {
*)
config=''
;;
- esac
+ esac
- leap node add --local $i $config services:$i
+ # for now, we assume that the nodes are named after their service
+ # and we just cut off the number at the end
+ services=`echo $i | sed 's/[[:digit:]]//g'`
+
+ leap node add --local $i $config services:$services
done
}
@@ -48,7 +52,7 @@ bootstrap_nodes() {
for vm in $@
do
leap $OPTS local start $vm
- sleep $SLEEP
+ wait_for_node $i
leap $OPTS node init $vm
# set hostname + do dist-upgrade
leap $OPTS deploy $vm --tags site_apt::dist_upgrade,site_config::hosts
@@ -74,6 +78,7 @@ create_provider() {
leap $OPTS new --contacts $CONTACTS --domain $DOMAIN --name $PROVIDER --platform=$PLATFORMDIR .
cd $PLATFORMDIR
git checkout $PLATFORM_BRANCH
+ git submodule sync
git submodule update --init
cd $PROVIDERDIR
@@ -98,6 +103,7 @@ deploy() {
for vm in $@
do
+ [ -e $LOGDIR ] || mkdir -p $LOGDIR
LOG="$LOGDIR/deploy-$vm.log"
ERRLOG="$LOGDIR/deploy-$vm-`date +"%F-%H%M%S"`-error.log"
echo "Deploying \"$vm\" on `date`"|tee -a $LOG
@@ -122,6 +128,10 @@ deploy() {
done
}
+get_ip () {
+ grep ip_address $PROVIDERDIR/nodes/$1.json |cut -f 2 -d:|sed 's/"//g'
+}
+
reset_deploy() {
log_start
@@ -132,13 +142,7 @@ reset_deploy() {
for i in $@
do
leap $OPTS local reset $i
- # only sleep one time
- if $need_to_sleep ; then
- echo "Waiting $SLEEP secs for VM to come up..."
- sleep $SLEEP
- need_to_sleep=false
- fi
- echo $i
+ wait_for_node $i
deploy $i &
done
}
@@ -148,6 +152,22 @@ log_start() {
echo "Starting $0 on `date`"
}
+ip_pingable () {
+ ping -q -W10 -c1 $1 >/dev/null 2>&1
+ return $?
+}
+
+wait_for_node() {
+ echo "Waiting for VM to come up..."
+ ip=`get_ip $i`
+ online=0
+ while [ $online -eq 0 ]
+ do
+ ip_pingable $ip && online=1
+ sleep 1
+ done
+}
+
config=""
all=false
@@ -206,6 +226,7 @@ fi
case $cmd in
+ add_nodes) add_nodes "$nodes";;
bootstrap) bootstrap_nodes "$nodes";;
create_provider) create_provider;;
deploy) deploy "$nodes";;