blob: e1c949cf4792524262692d7360ccc640aae67c0e [file] [log] [blame]
Vishvananda Ishaya75bbd752012-01-19 23:28:46 +00001#!/usr/bin/env bash
2
3# we will use the ``euca2ools`` cli tool that wraps the python boto
4# library to test ec2 compatibility
Dean Troyer489bd2a2012-03-02 10:44:29 -06005
6echo "**************************************************"
7echo "Begin DevStack Exercise: $0"
8echo "**************************************************"
Vishvananda Ishaya75bbd752012-01-19 23:28:46 +00009
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# Settings
19# ========
20
21# Use openrc + stackrc + localrc for settings
Dean Troyer489bd2a2012-03-02 10:44:29 -060022pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null
23
24# Import common functions
25source ./functions
26
27# Import configuration
Vishvananda Ishaya75bbd752012-01-19 23:28:46 +000028source ./openrc
29
30# Remove old certificates
31rm -f cacert.pem
32rm -f cert.pem
33rm -f pk.pem
34
35# Get Certificates
36nova x509-get-root-cert
37nova x509-create-cert
Dean Troyer489bd2a2012-03-02 10:44:29 -060038popd >/dev/null
Vishvananda Ishaya75bbd752012-01-19 23:28:46 +000039
40# Max time to wait for image to be registered
41REGISTER_TIMEOUT=${REGISTER_TIMEOUT:-15}
42
43BUCKET=testbucket
44IMAGE=bundle.img
45truncate -s 5M /tmp/$IMAGE
46euca-bundle-image -i /tmp/$IMAGE
Dean Troyer489bd2a2012-03-02 10:44:29 -060047die_if_error "Failure bundling image $IMAGE"
Vishvananda Ishaya75bbd752012-01-19 23:28:46 +000048
49
50euca-upload-bundle -b $BUCKET -m /tmp/$IMAGE.manifest.xml
Dean Troyer489bd2a2012-03-02 10:44:29 -060051die_if_error "Failure uploading bundle $IMAGE to $BUCKET"
52
Vishvananda Ishaya75bbd752012-01-19 23:28:46 +000053AMI=`euca-register $BUCKET/$IMAGE.manifest.xml | cut -f2`
Dean Troyer489bd2a2012-03-02 10:44:29 -060054die_if_not_set AMI "Failure registering $BUCKET/$IMAGE"
Vishvananda Ishaya75bbd752012-01-19 23:28:46 +000055
56# Wait for the image to become available
57if ! timeout $REGISTER_TIMEOUT sh -c "while euca-describe-images | grep '$AMI' | grep 'available'; do sleep 1; done"; then
58 echo "Image $AMI not available within $REGISTER_TIMEOUT seconds"
59 exit 1
60fi
Dean Troyer80756ea2012-02-01 18:01:01 -060061
62# Clean up
63euca-deregister $AMI
Dean Troyer489bd2a2012-03-02 10:44:29 -060064die_if_error "Failure deregistering $AMI"
65
66set +o xtrace
67echo "**************************************************"
68echo "End DevStack Exercise: $0"
69echo "**************************************************"