blob: faeffcf94c3069ef65cc3ad9e28cc394ef1bc432 [file] [log] [blame]
Jesse Andrewsf6705492011-11-01 16:04:14 -07001#!/usr/bin/env bash
2
3# **exercise.sh** - using the cloud can be fun
4
5# we will use the ``nova`` cli tool provided by the ``python-novaclient``
6# package
7#
8
9
10# This script exits on an error so that errors don't compound and you see
11# only the first error that occured.
12set -o errexit
13
14# Print the commands being run so that we can see the command that triggers
15# an error. It is also useful for following allowing as the install occurs.
16set -o xtrace
17
18
19# Settings
20# ========
21
22# Use openrc + stackrc + localrc for settings
23source ./openrc
24
25# Max time till the vm is bootable
26BOOT_TIMEOUT=${BOOT_TIMEOUT:-15}
27
28IMAGE=`euca-describe-images | grep machine | cut -f2`
29
30INSTANCE=`euca-run-instance $IMAGE | grep INSTANCE | cut -f2`
31
32if ! timeout $BOOT_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then
33 echo "server didn't become active within $BOOT_TIMEOUT seconds"
34 exit 1
35fi
36
37euca-terminate-instances $INSTANCE