devstack/exercises/euca.sh
Dean Troyer 67787e6b4c Add cinder support
* using the new functional pattern: cinder_XXX functions are in
  lib/cinder
* enable with 'c-api,c-sch,c-vol' in ENABLED_SERVICES, n-vol is still the default
* exercises/volumes.sh runs for cinder and n-vol
* move config to /etc/cinder
* change volume_group to stack-volumes; this also renames the backing file
  to /opt/stack/data/stack-volumes-backing-file.
* removes osapi_volume from nova.conf enabled_apis
* integrates cinder + keystone
* launches c-sch
* tweaks for multi node
* move enabled_apis substitution to init_cinder

18Jun2010
* restored & rebased
* update setup.py to use setup_develop() in lib/cinder

Change-Id: I1e1aa4387031c56e4fa239eb73bea2af8cef0e38
2012-06-20 14:11:19 -06:00

132 lines
4.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# **euca.sh**
# we will use the ``euca2ools`` cli tool that wraps the python boto
# library to test ec2 compatibility
echo "*********************************************************************"
echo "Begin DevStack Exercise: $0"
echo "*********************************************************************"
# This script exits on an error so that errors don't compound and you see
# only the first error that occured.
set -o errexit
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
# Settings
# ========
# Keep track of the current directory
EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
VOLUME_ZONE=cinder
VOLUME_SIZE=1
ATTACH_DEVICE=/dev/vdc
# Import common functions
source $TOP_DIR/functions
# Import EC2 configuration
source $TOP_DIR/eucarc
# Import exercise configuration
source $TOP_DIR/exerciserc
# Instance type to create
DEFAULT_INSTANCE_TYPE=${DEFAULT_INSTANCE_TYPE:-m1.tiny}
# Launching a server
# ==================
# Find a machine image to boot
IMAGE=`euca-describe-images | grep machine | cut -f2 | head -n1`
# Define secgroup
SECGROUP=euca_secgroup
# Add a secgroup
if ! euca-describe-groups | grep -q $SECGROUP; then
euca-add-group -d "$SECGROUP description" $SECGROUP
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! euca-describe-groups | grep -q $SECGROUP; do sleep 1; done"; then
echo "Security group not created"
exit 1
fi
fi
# Launch it
INSTANCE=`euca-run-instances -g $SECGROUP -t $DEFAULT_INSTANCE_TYPE $IMAGE | grep INSTANCE | cut -f2`
die_if_not_set INSTANCE "Failure launching instance"
# Assure it has booted within a reasonable time
if ! timeout $RUNNING_TIMEOUT sh -c "while ! euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then
echo "server didn't become active within $RUNNING_TIMEOUT seconds"
exit 1
fi
# Allocate floating address
FLOATING_IP=`euca-allocate-address | cut -f2`
die_if_not_set FLOATING_IP "Failure allocating floating IP"
# Associate floating address
euca-associate-address -i $INSTANCE $FLOATING_IP || \
die "Failure associating address $FLOATING_IP to $INSTANCE"
# Authorize pinging
euca-authorize -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP || \
die "Failure authorizing rule in $SECGROUP"
# Test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
echo "Couldn't ping server with floating ip"
exit 1
fi
# Revoke pinging
euca-revoke -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP || \
die "Failure revoking rule in $SECGROUP"
# Release floating address
euca-disassociate-address $FLOATING_IP || \
die "Failure disassociating address $FLOATING_IP"
# Wait just a tick for everything above to complete so release doesn't fail
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while euca-describe-addresses | grep $INSTANCE | grep -q $FLOATING_IP; do sleep 1; done"; then
echo "Floating ip $FLOATING_IP not disassociated within $ASSOCIATE_TIMEOUT seconds"
exit 1
fi
# Release floating address
euca-release-address $FLOATING_IP || \
die "Failure releasing address $FLOATING_IP"
# Wait just a tick for everything above to complete so terminate doesn't fail
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while euca-describe-addresses | grep -q $FLOATING_IP; do sleep 1; done"; then
echo "Floating ip $FLOATING_IP not released within $ASSOCIATE_TIMEOUT seconds"
exit 1
fi
# Terminate instance
euca-terminate-instances $INSTANCE || \
die "Failure terminating instance $INSTANCE"
# Assure it has terminated within a reasonable time
if ! timeout $TERMINATE_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then
echo "server didn't terminate within $TERMINATE_TIMEOUT seconds"
exit 1
fi
# Delete group
euca-delete-group $SECGROUP || \
die "Failure deleting security group $SECGROUP"
set +o xtrace
echo "*********************************************************************"
echo "SUCCESS: End DevStack Exercise: $0"
echo "*********************************************************************"