Refactor error logging

It is hard to grep errors in current log. so in this patch,
I'm updating die function which also writes log for
screen_log_dir/error.log.
In future, we may categolize negative fault by using
this error.log.

Change-Id: I70a8cfe67ed408284f5c88c762c6bb8acb8ecdb2
This commit is contained in:
Nachi Ueno 2013-02-26 12:38:18 -08:00
parent 921f2dab62
commit 07115eb5c0
19 changed files with 125 additions and 171 deletions

View File

@ -56,7 +56,7 @@ exit_if_aggregate_present() {
if [ $(nova aggregate-list | grep -c " $aggregate_name ") == 0 ]; then if [ $(nova aggregate-list | grep -c " $aggregate_name ") == 0 ]; then
echo "SUCCESS $aggregate_name not present" echo "SUCCESS $aggregate_name not present"
else else
echo "ERROR found aggregate: $aggregate_name" die $LINENO "found aggregate: $aggregate_name"
exit -1 exit -1
fi fi
} }
@ -67,15 +67,14 @@ AGGREGATE_ID=$(nova aggregate-create $AGGREGATE_NAME $AGGREGATE_A_ZONE | grep "
AGGREGATE2_ID=$(nova aggregate-create $AGGREGATE2_NAME $AGGREGATE_A_ZONE | grep " $AGGREGATE2_NAME " | get_field 1) AGGREGATE2_ID=$(nova aggregate-create $AGGREGATE2_NAME $AGGREGATE_A_ZONE | grep " $AGGREGATE2_NAME " | get_field 1)
# check aggregate created # check aggregate created
nova aggregate-list | grep -q " $AGGREGATE_NAME " || die "Aggregate $AGGREGATE_NAME not created" nova aggregate-list | grep -q " $AGGREGATE_NAME " || die $LINENO "Aggregate $AGGREGATE_NAME not created"
# Ensure creating a duplicate fails # Ensure creating a duplicate fails
# ================================= # =================================
if nova aggregate-create $AGGREGATE_NAME $AGGREGATE_A_ZONE; then if nova aggregate-create $AGGREGATE_NAME $AGGREGATE_A_ZONE; then
echo "ERROR could create duplicate aggregate" die $LINENO "could create duplicate aggregate"
exit -1
fi fi
@ -113,7 +112,7 @@ nova aggregate-set-metadata $AGGREGATE_ID $META_DATA_2_KEY ${META_DATA_3_KEY}=78
nova aggregate-details $AGGREGATE_ID | grep $META_DATA_1_KEY nova aggregate-details $AGGREGATE_ID | grep $META_DATA_1_KEY
nova aggregate-details $AGGREGATE_ID | grep $META_DATA_3_KEY nova aggregate-details $AGGREGATE_ID | grep $META_DATA_3_KEY
nova aggregate-details $AGGREGATE_ID | grep $META_DATA_2_KEY && die "ERROR metadata was not cleared" nova aggregate-details $AGGREGATE_ID | grep $META_DATA_2_KEY && die $LINENO "ERROR metadata was not cleared"
nova aggregate-set-metadata $AGGREGATE_ID $META_DATA_3_KEY $META_DATA_1_KEY nova aggregate-set-metadata $AGGREGATE_ID $META_DATA_3_KEY $META_DATA_1_KEY
nova aggregate-details $AGGREGATE_ID | egrep "{u'availability_zone': u'$AGGREGATE_A_ZONE'}|{}" nova aggregate-details $AGGREGATE_ID | egrep "{u'availability_zone': u'$AGGREGATE_A_ZONE'}|{}"
@ -129,8 +128,7 @@ FIRST_HOST=$(nova host-list | grep compute | get_field 1 | head -1)
nova aggregate-add-host $AGGREGATE_ID $FIRST_HOST nova aggregate-add-host $AGGREGATE_ID $FIRST_HOST
nova aggregate-add-host $AGGREGATE2_ID $FIRST_HOST nova aggregate-add-host $AGGREGATE2_ID $FIRST_HOST
if nova aggregate-add-host $AGGREGATE2_ID $FIRST_HOST; then if nova aggregate-add-host $AGGREGATE2_ID $FIRST_HOST; then
echo "ERROR could add duplicate host to single aggregate" die $LINENO "could add duplicate host to single aggregate"
exit -1
fi fi
nova aggregate-remove-host $AGGREGATE2_ID $FIRST_HOST nova aggregate-remove-host $AGGREGATE2_ID $FIRST_HOST
nova aggregate-remove-host $AGGREGATE_ID $FIRST_HOST nova aggregate-remove-host $AGGREGATE_ID $FIRST_HOST

View File

@ -72,7 +72,7 @@ glance image-list
# Grab the id of the image to launch # Grab the id of the image to launch
IMAGE=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1) IMAGE=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1)
die_if_not_set IMAGE "Failure getting image $DEFAULT_IMAGE_NAME" die_if_not_set $LINENO IMAGE "Failure getting image $DEFAULT_IMAGE_NAME"
# Security Groups # Security Groups
# --------------- # ---------------
@ -140,7 +140,7 @@ fi
# Create the bootable volume # Create the bootable volume
start_time=$(date +%s) start_time=$(date +%s)
cinder create --image-id $IMAGE --display_name=$VOL_NAME --display_description "test bootable volume: $VOL_NAME" $DEFAULT_VOLUME_SIZE || \ cinder create --image-id $IMAGE --display_name=$VOL_NAME --display_description "test bootable volume: $VOL_NAME" $DEFAULT_VOLUME_SIZE || \
die "Failure creating volume $VOL_NAME" die $LINENO "Failure creating volume $VOL_NAME"
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! cinder list | grep $VOL_NAME | grep available; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while ! cinder list | grep $VOL_NAME | grep available; do sleep 1; done"; then
echo "Volume $VOL_NAME not created" echo "Volume $VOL_NAME not created"
exit 1 exit 1
@ -150,7 +150,7 @@ echo "Completed cinder create in $((end_time - start_time)) seconds"
# Get volume ID # Get volume ID
VOL_ID=$(cinder list | grep $VOL_NAME | get_field 1) VOL_ID=$(cinder list | grep $VOL_NAME | get_field 1)
die_if_not_set VOL_ID "Failure retrieving volume ID for $VOL_NAME" die_if_not_set $LINENO VOL_ID "Failure retrieving volume ID for $VOL_NAME"
# Boot instance # Boot instance
# ------------- # -------------
@ -159,7 +159,7 @@ die_if_not_set VOL_ID "Failure retrieving volume ID for $VOL_NAME"
# <dev_name>=<id>:<type>:<size(GB)>:<delete_on_terminate> # <dev_name>=<id>:<type>:<size(GB)>:<delete_on_terminate>
# Leaving the middle two fields blank appears to do-the-right-thing # Leaving the middle two fields blank appears to do-the-right-thing
VM_UUID=$(nova boot --flavor $INSTANCE_TYPE --image $IMAGE --block-device-mapping vda=$VOL_ID --security_groups=$SECGROUP --key_name $KEY_NAME $VM_NAME | grep ' id ' | get_field 2) VM_UUID=$(nova boot --flavor $INSTANCE_TYPE --image $IMAGE --block-device-mapping vda=$VOL_ID --security_groups=$SECGROUP --key_name $KEY_NAME $VM_NAME | grep ' id ' | get_field 2)
die_if_not_set VM_UUID "Failure launching $VM_NAME" die_if_not_set $LINENO VM_UUID "Failure launching $VM_NAME"
# Check that the status is active within ACTIVE_TIMEOUT seconds # Check that the status is active within ACTIVE_TIMEOUT seconds
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then
@ -169,7 +169,7 @@ fi
# Get the instance IP # Get the instance IP
IP=$(nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2) IP=$(nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2)
die_if_not_set IP "Failure retrieving IP address" die_if_not_set $LINENO IP "Failure retrieving IP address"
# Private IPs can be pinged in single node deployments # Private IPs can be pinged in single node deployments
ping_check "$PRIVATE_NETWORK_NAME" $IP $BOOT_TIMEOUT ping_check "$PRIVATE_NETWORK_NAME" $IP $BOOT_TIMEOUT
@ -178,7 +178,7 @@ ping_check "$PRIVATE_NETWORK_NAME" $IP $BOOT_TIMEOUT
# -------- # --------
# Delete volume backed instance # Delete volume backed instance
nova delete $VM_UUID || die "Failure deleting instance $VM_NAME" nova delete $VM_UUID || die $LINENO "Failure deleting instance $VM_NAME"
if ! timeout $TERMINATE_TIMEOUT sh -c "while nova list | grep -q $VM_UUID; do sleep 1; done"; then if ! timeout $TERMINATE_TIMEOUT sh -c "while nova list | grep -q $VM_UUID; do sleep 1; done"; then
echo "Server $VM_NAME not deleted" echo "Server $VM_NAME not deleted"
exit 1 exit 1
@ -192,7 +192,7 @@ fi
# Delete volume # Delete volume
start_time=$(date +%s) start_time=$(date +%s)
cinder delete $VOL_ID || die "Failure deleting volume $VOLUME_NAME" cinder delete $VOL_ID || die $LINENO "Failure deleting volume $VOLUME_NAME"
if ! timeout $ACTIVE_TIMEOUT sh -c "while cinder list | grep $VOL_NAME; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while cinder list | grep $VOL_NAME; do sleep 1; done"; then
echo "Volume $VOL_NAME not deleted" echo "Volume $VOL_NAME not deleted"
exit 1 exit 1
@ -201,7 +201,7 @@ end_time=$(date +%s)
echo "Completed cinder delete in $((end_time - start_time)) seconds" echo "Completed cinder delete in $((end_time - start_time)) seconds"
# Delete secgroup # Delete secgroup
nova secgroup-delete $SECGROUP || die "Failure deleting security group $SECGROUP" nova secgroup-delete $SECGROUP || die $LINENO "Failure deleting security group $SECGROUP"
set +o xtrace set +o xtrace
echo "*********************************************************************" echo "*********************************************************************"

View File

@ -49,21 +49,20 @@ REGISTER_TIMEOUT=${REGISTER_TIMEOUT:-15}
BUCKET=testbucket BUCKET=testbucket
IMAGE=bundle.img IMAGE=bundle.img
truncate -s 5M /tmp/$IMAGE truncate -s 5M /tmp/$IMAGE
euca-bundle-image -i /tmp/$IMAGE || die "Failure bundling image $IMAGE" euca-bundle-image -i /tmp/$IMAGE || die $LINENO "Failure bundling image $IMAGE"
euca-upload-bundle --debug -b $BUCKET -m /tmp/$IMAGE.manifest.xml || die "Failure uploading bundle $IMAGE to $BUCKET" euca-upload-bundle --debug -b $BUCKET -m /tmp/$IMAGE.manifest.xml || die $LINENO "Failure uploading bundle $IMAGE to $BUCKET"
AMI=`euca-register $BUCKET/$IMAGE.manifest.xml | cut -f2` AMI=`euca-register $BUCKET/$IMAGE.manifest.xml | cut -f2`
die_if_not_set AMI "Failure registering $BUCKET/$IMAGE" die_if_not_set $LINENO AMI "Failure registering $BUCKET/$IMAGE"
# Wait for the image to become available # Wait for the image to become available
if ! timeout $REGISTER_TIMEOUT sh -c "while euca-describe-images | grep $AMI | grep -q available; do sleep 1; done"; then if ! timeout $REGISTER_TIMEOUT sh -c "while euca-describe-images | grep $AMI | grep -q available; do sleep 1; done"; then
echo "Image $AMI not available within $REGISTER_TIMEOUT seconds" die $LINENO "Image $AMI not available within $REGISTER_TIMEOUT seconds"
exit 1
fi fi
# Clean up # Clean up
euca-deregister $AMI || die "Failure deregistering $AMI" euca-deregister $AMI || die $LINENO "Failure deregistering $AMI"
set +o xtrace set +o xtrace
echo "*********************************************************************" echo "*********************************************************************"

View File

@ -56,68 +56,62 @@ SECGROUP=${SECGROUP:-euca_secgroup}
# Find a machine image to boot # Find a machine image to boot
IMAGE=`euca-describe-images | grep machine | grep ${DEFAULT_IMAGE_NAME} | cut -f2 | head -n1` IMAGE=`euca-describe-images | grep machine | grep ${DEFAULT_IMAGE_NAME} | cut -f2 | head -n1`
die_if_not_set IMAGE "Failure getting image $DEFAULT_IMAGE_NAME" die_if_not_set $LINENO IMAGE "Failure getting image $DEFAULT_IMAGE_NAME"
# Add a secgroup # Add a secgroup
if ! euca-describe-groups | grep -q $SECGROUP; then if ! euca-describe-groups | grep -q $SECGROUP; then
euca-add-group -d "$SECGROUP description" $SECGROUP 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 if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! euca-describe-groups | grep -q $SECGROUP; do sleep 1; done"; then
echo "Security group not created" die $LINENO "Security group not created"
exit 1
fi fi
fi fi
# Launch it # Launch it
INSTANCE=`euca-run-instances -g $SECGROUP -t $DEFAULT_INSTANCE_TYPE $IMAGE | grep INSTANCE | cut -f2` INSTANCE=`euca-run-instances -g $SECGROUP -t $DEFAULT_INSTANCE_TYPE $IMAGE | grep INSTANCE | cut -f2`
die_if_not_set INSTANCE "Failure launching instance" die_if_not_set $LINENO INSTANCE "Failure launching instance"
# Assure it has booted within a reasonable time # 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 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" die $LINENO "server didn't become active within $RUNNING_TIMEOUT seconds"
exit 1
fi fi
# Volumes # Volumes
# ------- # -------
if [[ "$ENABLED_SERVICES" =~ "c-vol" ]]; then if [[ "$ENABLED_SERVICES" =~ "c-vol" ]]; then
VOLUME_ZONE=`euca-describe-availability-zones | head -n1 | cut -f2` VOLUME_ZONE=`euca-describe-availability-zones | head -n1 | cut -f2`
die_if_not_set VOLUME_ZONE "Failure to find zone for volume" die_if_not_set $LINENO VOLUME_ZONE "Failure to find zone for volume"
VOLUME=`euca-create-volume -s 1 -z $VOLUME_ZONE | cut -f2` VOLUME=`euca-create-volume -s 1 -z $VOLUME_ZONE | cut -f2`
die_if_not_set VOLUME "Failure to create volume" die_if_not_set $LINENO VOLUME "Failure to create volume"
# Test that volume has been created # Test that volume has been created
VOLUME=`euca-describe-volumes | cut -f2` VOLUME=`euca-describe-volumes | cut -f2`
die_if_not_set VOLUME "Failure to get volume" die_if_not_set $LINENO VOLUME "Failure to get volume"
# Test volume has become available # Test volume has become available
if ! timeout $RUNNING_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -q available; do sleep 1; done"; then if ! timeout $RUNNING_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -q available; do sleep 1; done"; then
echo "volume didnt become available within $RUNNING_TIMEOUT seconds" die $LINENO "volume didnt become available within $RUNNING_TIMEOUT seconds"
exit 1
fi fi
# Attach volume to an instance # Attach volume to an instance
euca-attach-volume -i $INSTANCE -d $ATTACH_DEVICE $VOLUME || \ euca-attach-volume -i $INSTANCE -d $ATTACH_DEVICE $VOLUME || \
die "Failure attaching volume $VOLUME to $INSTANCE" die $LINENO "Failure attaching volume $VOLUME to $INSTANCE"
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -q in-use; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -q in-use; do sleep 1; done"; then
echo "Could not attach $VOLUME to $INSTANCE" die $LINENO "Could not attach $VOLUME to $INSTANCE"
exit 1
fi fi
# Detach volume from an instance # Detach volume from an instance
euca-detach-volume $VOLUME || \ euca-detach-volume $VOLUME || \
die "Failure detaching volume $VOLUME to $INSTANCE" die $LINENO "Failure detaching volume $VOLUME to $INSTANCE"
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -q available; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -q available; do sleep 1; done"; then
echo "Could not detach $VOLUME to $INSTANCE" die $LINENO "Could not detach $VOLUME to $INSTANCE"
exit 1
fi fi
# Remove volume # Remove volume
euca-delete-volume $VOLUME || \ euca-delete-volume $VOLUME || \
die "Failure to delete volume" die $LINENO "Failure to delete volume"
if ! timeout $ACTIVE_TIMEOUT sh -c "while euca-describe-volumes | grep $VOLUME; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while euca-describe-volumes | grep $VOLUME; do sleep 1; done"; then
echo "Could not delete $VOLUME" die $LINENO "Could not delete $VOLUME"
exit 1
fi fi
else else
echo "Volume Tests Skipped" echo "Volume Tests Skipped"
@ -125,58 +119,55 @@ fi
# Allocate floating address # Allocate floating address
FLOATING_IP=`euca-allocate-address | cut -f2` FLOATING_IP=`euca-allocate-address | cut -f2`
die_if_not_set FLOATING_IP "Failure allocating floating IP" die_if_not_set $LINENO FLOATING_IP "Failure allocating floating IP"
# Associate floating address # Associate floating address
euca-associate-address -i $INSTANCE $FLOATING_IP || \ euca-associate-address -i $INSTANCE $FLOATING_IP || \
die "Failure associating address $FLOATING_IP to $INSTANCE" die $LINENO "Failure associating address $FLOATING_IP to $INSTANCE"
# Authorize pinging # Authorize pinging
euca-authorize -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP || \ euca-authorize -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP || \
die "Failure authorizing rule in $SECGROUP" die $LINENO "Failure authorizing rule in $SECGROUP"
# Test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds # Test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds
ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT
# Revoke pinging # Revoke pinging
euca-revoke -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP || \ euca-revoke -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP || \
die "Failure revoking rule in $SECGROUP" die $LINENO "Failure revoking rule in $SECGROUP"
# Release floating address # Release floating address
euca-disassociate-address $FLOATING_IP || \ euca-disassociate-address $FLOATING_IP || \
die "Failure disassociating address $FLOATING_IP" die $LINENO "Failure disassociating address $FLOATING_IP"
# Wait just a tick for everything above to complete so release doesn't fail # 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 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" die $LINENO "Floating ip $FLOATING_IP not disassociated within $ASSOCIATE_TIMEOUT seconds"
exit 1
fi fi
# Release floating address # Release floating address
euca-release-address $FLOATING_IP || \ euca-release-address $FLOATING_IP || \
die "Failure releasing address $FLOATING_IP" die $LINENO "Failure releasing address $FLOATING_IP"
# Wait just a tick for everything above to complete so terminate doesn't fail # 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 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" die $LINENO "Floating ip $FLOATING_IP not released within $ASSOCIATE_TIMEOUT seconds"
exit 1
fi fi
# Terminate instance # Terminate instance
euca-terminate-instances $INSTANCE || \ euca-terminate-instances $INSTANCE || \
die "Failure terminating instance $INSTANCE" die $LINENO "Failure terminating instance $INSTANCE"
# Assure it has terminated within a reasonable time. The behaviour of this # Assure it has terminated within a reasonable time. The behaviour of this
# case changed with bug/836978. Requesting the status of an invalid instance # case changed with bug/836978. Requesting the status of an invalid instance
# will now return an error message including the instance id, so we need to # will now return an error message including the instance id, so we need to
# filter that out. # filter that out.
if ! timeout $TERMINATE_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -ve \"\\\(InstanceNotFound\\\|InvalidInstanceID\[.\]NotFound\\\)\" | grep -q $INSTANCE; do sleep 1; done"; then if ! timeout $TERMINATE_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -ve \"\\\(InstanceNotFound\\\|InvalidInstanceID\[.\]NotFound\\\)\" | grep -q $INSTANCE; do sleep 1; done"; then
echo "server didn't terminate within $TERMINATE_TIMEOUT seconds" die $LINENO "server didn't terminate within $TERMINATE_TIMEOUT seconds"
exit 1
fi fi
# Delete secgroup # Delete secgroup
euca-delete-group $SECGROUP || die "Failure deleting security group $SECGROUP" euca-delete-group $SECGROUP || die $LINENO "Failure deleting security group $SECGROUP"
set +o xtrace set +o xtrace
echo "*********************************************************************" echo "*********************************************************************"

View File

@ -71,7 +71,7 @@ glance image-list
# Grab the id of the image to launch # Grab the id of the image to launch
IMAGE=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1) IMAGE=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1)
die_if_not_set IMAGE "Failure getting image $DEFAULT_IMAGE_NAME" die_if_not_set $LINENO IMAGE "Failure getting image $DEFAULT_IMAGE_NAME"
# Security Groups # Security Groups
# --------------- # ---------------
@ -83,8 +83,7 @@ nova secgroup-list
if ! nova secgroup-list | grep -q $SECGROUP; then if ! nova secgroup-list | grep -q $SECGROUP; then
nova secgroup-create $SECGROUP "$SECGROUP description" nova secgroup-create $SECGROUP "$SECGROUP description"
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova secgroup-list | grep -q $SECGROUP; do sleep 1; done"; then if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova secgroup-list | grep -q $SECGROUP; do sleep 1; done"; then
echo "Security group not created" die $LINENO "Security group not created"
exit 1
fi fi
fi fi
@ -115,7 +114,7 @@ fi
# Clean-up from previous runs # Clean-up from previous runs
nova delete $VM_NAME || true nova delete $VM_NAME || true
if ! timeout $ACTIVE_TIMEOUT sh -c "while nova show $VM_NAME; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while nova show $VM_NAME; do sleep 1; done"; then
echo "server didn't terminate!" die $LINENO "server didn't terminate!"
exit 1 exit 1
fi fi
@ -123,17 +122,16 @@ fi
# ------------- # -------------
VM_UUID=$(nova boot --flavor $INSTANCE_TYPE --image $IMAGE --security_groups=$SECGROUP $VM_NAME | grep ' id ' | get_field 2) VM_UUID=$(nova boot --flavor $INSTANCE_TYPE --image $IMAGE --security_groups=$SECGROUP $VM_NAME | grep ' id ' | get_field 2)
die_if_not_set VM_UUID "Failure launching $VM_NAME" die_if_not_set $LINENO VM_UUID "Failure launching $VM_NAME"
# Check that the status is active within ACTIVE_TIMEOUT seconds # Check that the status is active within ACTIVE_TIMEOUT seconds
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then
echo "server didn't become active!" die $LINENO "server didn't become active!"
exit 1
fi fi
# Get the instance IP # Get the instance IP
IP=$(nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2) IP=$(nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2)
die_if_not_set IP "Failure retrieving IP address" die_if_not_set $LINENO IP "Failure retrieving IP address"
# Private IPs can be pinged in single node deployments # Private IPs can be pinged in single node deployments
ping_check "$PRIVATE_NETWORK_NAME" $IP $BOOT_TIMEOUT ping_check "$PRIVATE_NETWORK_NAME" $IP $BOOT_TIMEOUT
@ -143,17 +141,16 @@ ping_check "$PRIVATE_NETWORK_NAME" $IP $BOOT_TIMEOUT
# Allocate a floating IP from the default pool # Allocate a floating IP from the default pool
FLOATING_IP=$(nova floating-ip-create | grep $DEFAULT_FLOATING_POOL | get_field 1) FLOATING_IP=$(nova floating-ip-create | grep $DEFAULT_FLOATING_POOL | get_field 1)
die_if_not_set FLOATING_IP "Failure creating floating IP from pool $DEFAULT_FLOATING_POOL" die_if_not_set $LINENO FLOATING_IP "Failure creating floating IP from pool $DEFAULT_FLOATING_POOL"
# List floating addresses # List floating addresses
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova floating-ip-list | grep -q $FLOATING_IP; do sleep 1; done"; then if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova floating-ip-list | grep -q $FLOATING_IP; do sleep 1; done"; then
echo "Floating IP not allocated" die $LINENO "Floating IP not allocated"
exit 1
fi fi
# Add floating IP to our server # Add floating IP to our server
nova add-floating-ip $VM_UUID $FLOATING_IP || \ nova add-floating-ip $VM_UUID $FLOATING_IP || \
die "Failure adding floating IP $FLOATING_IP to $VM_NAME" die $LINENO "Failure adding floating IP $FLOATING_IP to $VM_NAME"
# Test we can ping our floating IP within ASSOCIATE_TIMEOUT seconds # Test we can ping our floating IP within ASSOCIATE_TIMEOUT seconds
ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT
@ -161,18 +158,17 @@ ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT
if ! is_service_enabled quantum; then if ! is_service_enabled quantum; then
# Allocate an IP from second floating pool # Allocate an IP from second floating pool
TEST_FLOATING_IP=$(nova floating-ip-create $TEST_FLOATING_POOL | grep $TEST_FLOATING_POOL | get_field 1) TEST_FLOATING_IP=$(nova floating-ip-create $TEST_FLOATING_POOL | grep $TEST_FLOATING_POOL | get_field 1)
die_if_not_set TEST_FLOATING_IP "Failure creating floating IP in $TEST_FLOATING_POOL" die_if_not_set $LINENO TEST_FLOATING_IP "Failure creating floating IP in $TEST_FLOATING_POOL"
# list floating addresses # list floating addresses
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova floating-ip-list | grep $TEST_FLOATING_POOL | grep -q $TEST_FLOATING_IP; do sleep 1; done"; then if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova floating-ip-list | grep $TEST_FLOATING_POOL | grep -q $TEST_FLOATING_IP; do sleep 1; done"; then
echo "Floating IP not allocated" die $LINENO "Floating IP not allocated"
exit 1
fi fi
fi fi
# Dis-allow icmp traffic (ping) # Dis-allow icmp traffic (ping)
nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0 || \ nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0 || \
die "Failure deleting security group rule from $SECGROUP" die $LINENO "Failure deleting security group rule from $SECGROUP"
# FIXME (anthony): make xs support security groups # FIXME (anthony): make xs support security groups
if [ "$VIRT_DRIVER" != "xenserver" -a "$VIRT_DRIVER" != "openvz" ]; then if [ "$VIRT_DRIVER" != "xenserver" -a "$VIRT_DRIVER" != "openvz" ]; then
@ -186,24 +182,23 @@ fi
if ! is_service_enabled quantum; then if ! is_service_enabled quantum; then
# Delete second floating IP # Delete second floating IP
nova floating-ip-delete $TEST_FLOATING_IP || \ nova floating-ip-delete $TEST_FLOATING_IP || \
die "Failure deleting floating IP $TEST_FLOATING_IP" die $LINENO "Failure deleting floating IP $TEST_FLOATING_IP"
fi fi
# Delete the floating ip # Delete the floating ip
nova floating-ip-delete $FLOATING_IP || \ nova floating-ip-delete $FLOATING_IP || \
die "Failure deleting floating IP $FLOATING_IP" die $LINENO "Failure deleting floating IP $FLOATING_IP"
# Delete instance # Delete instance
nova delete $VM_UUID || die "Failure deleting instance $VM_NAME" nova delete $VM_UUID || die $LINENO "Failure deleting instance $VM_NAME"
# Wait for termination # Wait for termination
if ! timeout $TERMINATE_TIMEOUT sh -c "while nova list | grep -q $VM_UUID; do sleep 1; done"; then if ! timeout $TERMINATE_TIMEOUT sh -c "while nova list | grep -q $VM_UUID; do sleep 1; done"; then
echo "Server $VM_NAME not deleted" die $LINENO "Server $VM_NAME not deleted"
exit 1
fi fi
# Delete secgroup # Delete secgroup
nova secgroup-delete $SECGROUP || \ nova secgroup-delete $SECGROUP || \
die "Failure deleting security group $SECGROUP" die $LINENO "Failure deleting security group $SECGROUP"
set +o xtrace set +o xtrace
echo "*********************************************************************" echo "*********************************************************************"

View File

@ -36,7 +36,7 @@ source $TOP_DIR/exerciserc
is_service_enabled horizon || exit 55 is_service_enabled horizon || exit 55
# can we get the front page # can we get the front page
curl http://$SERVICE_HOST 2>/dev/null | grep -q '<h3>Log In</h3>' || die "Horizon front page not functioning!" curl http://$SERVICE_HOST 2>/dev/null | grep -q '<h3>Log In</h3>' || die $LINENO "Horizon front page not functioning!"
set +o xtrace set +o xtrace
echo "*********************************************************************" echo "*********************************************************************"

View File

@ -264,7 +264,7 @@ function create_vm {
--image $(get_image_id) \ --image $(get_image_id) \
$NIC \ $NIC \
$TENANT-server$NUM | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'` $TENANT-server$NUM | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'`
die_if_not_set VM_UUID "Failure launching $TENANT-server$NUM" VM_UUID die_if_not_set $LINENO VM_UUID "Failure launching $TENANT-server$NUM"
confirm_server_active $VM_UUID confirm_server_active $VM_UUID
} }
@ -309,8 +309,7 @@ function shutdown_vm {
function shutdown_vms { function shutdown_vms {
foreach_tenant_vm 'shutdown_vm ${%TENANT%_NAME} %NUM%' foreach_tenant_vm 'shutdown_vm ${%TENANT%_NAME} %NUM%'
if ! timeout $TERMINATE_TIMEOUT sh -c "while nova list | grep -q ACTIVE; do sleep 1; done"; then if ! timeout $TERMINATE_TIMEOUT sh -c "while nova list | grep -q ACTIVE; do sleep 1; done"; then
echo "Some VMs failed to shutdown" die $LINENO "Some VMs failed to shutdown"
false
fi fi
} }

View File

@ -68,7 +68,7 @@ done
# Delete secgroup # Delete secgroup
nova secgroup-delete $SEC_GROUP_NAME || \ nova secgroup-delete $SEC_GROUP_NAME || \
die "Failure deleting security group $SEC_GROUP_NAME" die $LINENO "Failure deleting security group $SEC_GROUP_NAME"
set +o xtrace set +o xtrace
echo "*********************************************************************" echo "*********************************************************************"

View File

@ -45,20 +45,20 @@ CONTAINER=ex-swift
# ============= # =============
# Check if we have to swift via keystone # Check if we have to swift via keystone
swift stat || die "Failure geting status" swift stat || die $LINENO "Failure geting status"
# We start by creating a test container # We start by creating a test container
swift post $CONTAINER || die "Failure creating container $CONTAINER" swift post $CONTAINER || die $LINENO "Failure creating container $CONTAINER"
# add some files into it. # add some files into it.
swift upload $CONTAINER /etc/issue || die "Failure uploading file to container $CONTAINER" swift upload $CONTAINER /etc/issue || die $LINENO "Failure uploading file to container $CONTAINER"
# list them # list them
swift list $CONTAINER || die "Failure listing contents of container $CONTAINER" swift list $CONTAINER || die $LINENO "Failure listing contents of container $CONTAINER"
# And we may want to delete them now that we have tested that # And we may want to delete them now that we have tested that
# everything works. # everything works.
swift delete $CONTAINER || die "Failure deleting container $CONTAINER" swift delete $CONTAINER || die $LINENO "Failure deleting container $CONTAINER"
set +o xtrace set +o xtrace
echo "*********************************************************************" echo "*********************************************************************"

View File

@ -70,7 +70,7 @@ glance image-list
# Grab the id of the image to launch # Grab the id of the image to launch
IMAGE=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1) IMAGE=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1)
die_if_not_set IMAGE "Failure getting image $DEFAULT_IMAGE_NAME" die_if_not_set $LINENO IMAGE "Failure getting image $DEFAULT_IMAGE_NAME"
# Security Groups # Security Groups
# --------------- # ---------------
@ -114,25 +114,23 @@ fi
# Clean-up from previous runs # Clean-up from previous runs
nova delete $VM_NAME || true nova delete $VM_NAME || true
if ! timeout $ACTIVE_TIMEOUT sh -c "while nova show $VM_NAME; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while nova show $VM_NAME; do sleep 1; done"; then
echo "server didn't terminate!" die $LINENO "server didn't terminate!"
exit 1
fi fi
# Boot instance # Boot instance
# ------------- # -------------
VM_UUID=$(nova boot --flavor $INSTANCE_TYPE --image $IMAGE --security_groups=$SECGROUP $VM_NAME | grep ' id ' | get_field 2) VM_UUID=$(nova boot --flavor $INSTANCE_TYPE --image $IMAGE --security_groups=$SECGROUP $VM_NAME | grep ' id ' | get_field 2)
die_if_not_set VM_UUID "Failure launching $VM_NAME" die_if_not_set $LINENO VM_UUID "Failure launching $VM_NAME"
# Check that the status is active within ACTIVE_TIMEOUT seconds # Check that the status is active within ACTIVE_TIMEOUT seconds
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then
echo "server didn't become active!" die $LINENO "server didn't become active!"
exit 1
fi fi
# Get the instance IP # Get the instance IP
IP=$(nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2) IP=$(nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2)
die_if_not_set IP "Failure retrieving IP address" die_if_not_set $LINENO IP "Failure retrieving IP address"
# Private IPs can be pinged in single node deployments # Private IPs can be pinged in single node deployments
ping_check "$PRIVATE_NETWORK_NAME" $IP $BOOT_TIMEOUT ping_check "$PRIVATE_NETWORK_NAME" $IP $BOOT_TIMEOUT
@ -142,42 +140,38 @@ ping_check "$PRIVATE_NETWORK_NAME" $IP $BOOT_TIMEOUT
# Verify it doesn't exist # Verify it doesn't exist
if [[ -n $(cinder list | grep $VOL_NAME | head -1 | get_field 2) ]]; then if [[ -n $(cinder list | grep $VOL_NAME | head -1 | get_field 2) ]]; then
echo "Volume $VOL_NAME already exists" die $LINENO "Volume $VOL_NAME already exists"
exit 1
fi fi
# Create a new volume # Create a new volume
start_time=$(date +%s) start_time=$(date +%s)
cinder create --display_name $VOL_NAME --display_description "test volume: $VOL_NAME" $DEFAULT_VOLUME_SIZE || \ cinder create --display_name $VOL_NAME --display_description "test volume: $VOL_NAME" $DEFAULT_VOLUME_SIZE || \
die "Failure creating volume $VOL_NAME" die $LINENO "Failure creating volume $VOL_NAME"
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! cinder list | grep $VOL_NAME | grep available; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while ! cinder list | grep $VOL_NAME | grep available; do sleep 1; done"; then
echo "Volume $VOL_NAME not created" die $LINENO "Volume $VOL_NAME not created"
exit 1
fi fi
end_time=$(date +%s) end_time=$(date +%s)
echo "Completed cinder create in $((end_time - start_time)) seconds" echo "Completed cinder create in $((end_time - start_time)) seconds"
# Get volume ID # Get volume ID
VOL_ID=$(cinder list | grep $VOL_NAME | head -1 | get_field 1) VOL_ID=$(cinder list | grep $VOL_NAME | head -1 | get_field 1)
die_if_not_set VOL_ID "Failure retrieving volume ID for $VOL_NAME" die_if_not_set $LINENO VOL_ID "Failure retrieving volume ID for $VOL_NAME"
# Attach to server # Attach to server
DEVICE=/dev/vdb DEVICE=/dev/vdb
start_time=$(date +%s) start_time=$(date +%s)
nova volume-attach $VM_UUID $VOL_ID $DEVICE || \ nova volume-attach $VM_UUID $VOL_ID $DEVICE || \
die "Failure attaching volume $VOL_NAME to $VM_NAME" die $LINENO "Failure attaching volume $VOL_NAME to $VM_NAME"
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! cinder list | grep $VOL_NAME | grep in-use; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while ! cinder list | grep $VOL_NAME | grep in-use; do sleep 1; done"; then
echo "Volume $VOL_NAME not attached to $VM_NAME" die $LINENO "Volume $VOL_NAME not attached to $VM_NAME"
exit 1
fi fi
end_time=$(date +%s) end_time=$(date +%s)
echo "Completed volume-attach in $((end_time - start_time)) seconds" echo "Completed volume-attach in $((end_time - start_time)) seconds"
VOL_ATTACH=$(cinder list | grep $VOL_NAME | head -1 | get_field -1) VOL_ATTACH=$(cinder list | grep $VOL_NAME | head -1 | get_field -1)
die_if_not_set VOL_ATTACH "Failure retrieving $VOL_NAME status" die_if_not_set $LINENO VOL_ATTACH "Failure retrieving $VOL_NAME status"
if [[ "$VOL_ATTACH" != $VM_UUID ]]; then if [[ "$VOL_ATTACH" != $VM_UUID ]]; then
echo "Volume not attached to correct instance" die $LINENO "Volume not attached to correct instance"
exit 1
fi fi
# Clean up # Clean up
@ -185,33 +179,30 @@ fi
# Detach volume # Detach volume
start_time=$(date +%s) start_time=$(date +%s)
nova volume-detach $VM_UUID $VOL_ID || die "Failure detaching volume $VOL_NAME from $VM_NAME" nova volume-detach $VM_UUID $VOL_ID || die $LINENO "Failure detaching volume $VOL_NAME from $VM_NAME"
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! cinder list | grep $VOL_NAME | grep available; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while ! cinder list | grep $VOL_NAME | grep available; do sleep 1; done"; then
echo "Volume $VOL_NAME not detached from $VM_NAME" die $LINENO "Volume $VOL_NAME not detached from $VM_NAME"
exit 1
fi fi
end_time=$(date +%s) end_time=$(date +%s)
echo "Completed volume-detach in $((end_time - start_time)) seconds" echo "Completed volume-detach in $((end_time - start_time)) seconds"
# Delete volume # Delete volume
start_time=$(date +%s) start_time=$(date +%s)
cinder delete $VOL_ID || die "Failure deleting volume $VOL_NAME" cinder delete $VOL_ID || die $LINENO "Failure deleting volume $VOL_NAME"
if ! timeout $ACTIVE_TIMEOUT sh -c "while cinder list | grep $VOL_NAME; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while cinder list | grep $VOL_NAME; do sleep 1; done"; then
echo "Volume $VOL_NAME not deleted" die $LINENO "Volume $VOL_NAME not deleted"
exit 1
fi fi
end_time=$(date +%s) end_time=$(date +%s)
echo "Completed cinder delete in $((end_time - start_time)) seconds" echo "Completed cinder delete in $((end_time - start_time)) seconds"
# Delete instance # Delete instance
nova delete $VM_UUID || die "Failure deleting instance $VM_NAME" nova delete $VM_UUID || die $LINENO "Failure deleting instance $VM_NAME"
if ! timeout $TERMINATE_TIMEOUT sh -c "while nova list | grep -q $VM_UUID; do sleep 1; done"; then if ! timeout $TERMINATE_TIMEOUT sh -c "while nova list | grep -q $VM_UUID; do sleep 1; done"; then
echo "Server $VM_NAME not deleted" die $LINENO "Server $VM_NAME not deleted"
exit 1
fi fi
# Delete secgroup # Delete secgroup
nova secgroup-delete $SECGROUP || die "Failure deleting security group $SECGROUP" nova secgroup-delete $SECGROUP || die $LINENO "Failure deleting security group $SECGROUP"
set +o xtrace set +o xtrace
echo "*********************************************************************" echo "*********************************************************************"

View File

@ -57,8 +57,15 @@ function cp_it {
# die "message" # die "message"
function die() { function die() {
local exitcode=$? local exitcode=$?
if [ $exitcode == 0 ]; then
exitcode=1
fi
set +o xtrace set +o xtrace
echo $@ local msg="[ERROR] $0:$1 $2"
echo $msg 1>&2;
if [[ -n ${SCREEN_LOGDIR} ]]; then
echo $msg >> "${SCREEN_LOGDIR}/error.log"
fi
exit $exitcode exit $exitcode
} }
@ -71,10 +78,9 @@ function die_if_not_set() {
( (
local exitcode=$? local exitcode=$?
set +o xtrace set +o xtrace
local evar=$1; shift local evar=$2; shift
if ! is_set $evar || [ $exitcode != 0 ]; then if ! is_set $evar || [ $exitcode != 0 ]; then
echo $@ die $@
exit -1
fi fi
) )
} }
@ -406,12 +412,10 @@ function exit_distro_not_supported {
fi fi
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
echo "Support for $DISTRO is incomplete: no support for $@" die $LINENO "Support for $DISTRO is incomplete: no support for $@"
else else
echo "Support for $DISTRO is incomplete." die $LINENO "Support for $DISTRO is incomplete."
fi fi
exit 1
} }
@ -1087,9 +1091,9 @@ function _ping_check_novanet() {
fi fi
if ! timeout $boot_timeout sh -c "$check_command"; then if ! timeout $boot_timeout sh -c "$check_command"; then
if [[ "$expected" = "True" ]]; then if [[ "$expected" = "True" ]]; then
echo "[Fail] Couldn't ping server" die $LINENO "[Fail] Couldn't ping server"
else else
echo "[Fail] Could ping server" die $LINENO "[Fail] Could ping server"
fi fi
exit 1 exit 1
fi fi
@ -1113,8 +1117,7 @@ function _ssh_check_novanet() {
local ACTIVE_TIMEOUT=$5 local ACTIVE_TIMEOUT=$5
local probe_cmd="" local probe_cmd=""
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! ssh -o StrictHostKeyChecking=no -i $KEY_FILE ${DEFAULT_INSTANCE_USER}@$FLOATING_IP echo success ; do sleep 1; done"; then if ! timeout $ACTIVE_TIMEOUT sh -c "while ! ssh -o StrictHostKeyChecking=no -i $KEY_FILE ${DEFAULT_INSTANCE_USER}@$FLOATING_IP echo success ; do sleep 1; done"; then
echo "server didn't become ssh-able!" die $LINENO "server didn't become ssh-able!"
exit 1
fi fi
} }

View File

@ -187,8 +187,7 @@ function start_glance() {
screen_it g-api "cd $GLANCE_DIR; $GLANCE_BIN_DIR/glance-api --config-file=$GLANCE_CONF_DIR/glance-api.conf" screen_it g-api "cd $GLANCE_DIR; $GLANCE_BIN_DIR/glance-api --config-file=$GLANCE_CONF_DIR/glance-api.conf"
echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..." echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..."
if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://$GLANCE_HOSTPORT; do sleep 1; done"; then if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://$GLANCE_HOSTPORT; do sleep 1; done"; then
echo "g-api did not start" die $LINENO "g-api did not start"
exit 1
fi fi
} }

View File

@ -323,8 +323,7 @@ function start_keystone() {
screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone-all --config-file $KEYSTONE_CONF $KEYSTONE_LOG_CONFIG -d --debug" screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone-all --config-file $KEYSTONE_CONF $KEYSTONE_LOG_CONFIG -d --debug"
echo "Waiting for keystone to start..." echo "Waiting for keystone to start..."
if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= curl -s http://$SERVICE_HOST:$service_port/v2.0/ >/dev/null; do sleep 1; done"; then if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= curl -s http://$SERVICE_HOST:$service_port/v2.0/ >/dev/null; do sleep 1; done"; then
echo "keystone did not start" die $LINENO "keystone did not start"
exit 1
fi fi
# Start proxies if enabled # Start proxies if enabled

View File

@ -542,8 +542,7 @@ function start_nova_api() {
screen_it n-api "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-api" screen_it n-api "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-api"
echo "Waiting for nova-api to start..." echo "Waiting for nova-api to start..."
if ! wait_for_service $SERVICE_TIMEOUT http://$SERVICE_HOST:$service_port; then if ! wait_for_service $SERVICE_TIMEOUT http://$SERVICE_HOST:$service_port; then
echo "nova-api did not start" die $LINENO "nova-api did not start"
exit 1
fi fi
# Start proxies if enabled # Start proxies if enabled

View File

@ -351,8 +351,7 @@ function start_quantum_service_and_check() {
screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server --config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE" screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server --config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE"
echo "Waiting for Quantum to start..." echo "Waiting for Quantum to start..."
if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://$Q_HOST:$Q_PORT; do sleep 1; done"; then if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://$Q_HOST:$Q_PORT; do sleep 1; done"; then
echo "Quantum did not start" die $LINENO "Quantum did not start"
exit 1
fi fi
} }
@ -396,8 +395,7 @@ function _configure_quantum_common() {
quantum_plugin_configure_common quantum_plugin_configure_common
if [[ $Q_PLUGIN_CONF_PATH == '' || $Q_PLUGIN_CONF_FILENAME == '' || $Q_PLUGIN_CLASS == '' ]]; then if [[ $Q_PLUGIN_CONF_PATH == '' || $Q_PLUGIN_CONF_FILENAME == '' || $Q_PLUGIN_CLASS == '' ]]; then
echo "Quantum plugin not set.. exiting" die $LINENO "Quantum plugin not set.. exiting"
exit 1
fi fi
# If needed, move config file from ``$QUANTUM_DIR/etc/quantum`` to ``QUANTUM_CONF_DIR`` # If needed, move config file from ``$QUANTUM_DIR/etc/quantum`` to ``QUANTUM_CONF_DIR``
@ -511,8 +509,7 @@ function _configure_quantum_service() {
if is_service_enabled $DATABASE_BACKENDS; then if is_service_enabled $DATABASE_BACKENDS; then
recreate_database $Q_DB_NAME utf8 recreate_database $Q_DB_NAME utf8
else else
echo "A database must be enabled in order to use the $Q_PLUGIN Quantum plugin." die $LINENO "A database must be enabled in order to use the $Q_PLUGIN Quantum plugin."
exit 1
fi fi
# Update either configuration file with plugin # Update either configuration file with plugin
@ -661,11 +658,10 @@ function _ping_check_quantum() {
fi fi
if ! timeout $timeout_sec sh -c "$check_command"; then if ! timeout $timeout_sec sh -c "$check_command"; then
if [[ "$expected" = "True" ]]; then if [[ "$expected" = "True" ]]; then
echo "[Fail] Couldn't ping server" die $LINENO "[Fail] Couldn't ping server"
else else
echo "[Fail] Could ping server" die $LINENO "[Fail] Could ping server"
fi fi
exit 1
fi fi
} }
@ -679,8 +675,7 @@ function _ssh_check_quantum() {
local probe_cmd = "" local probe_cmd = ""
probe_cmd=`_get_probe_cmd_prefix $from_net` probe_cmd=`_get_probe_cmd_prefix $from_net`
if ! timeout $timeout_sec sh -c "while ! $probe_cmd ssh -o StrictHostKeyChecking=no -i $key_file ${user}@$ip echo success ; do sleep 1; done"; then if ! timeout $timeout_sec sh -c "while ! $probe_cmd ssh -o StrictHostKeyChecking=no -i $key_file ${user}@$ip echo success ; do sleep 1; done"; then
echo "server didn't become ssh-able!" die $LINENO "server didn't become ssh-able!"
exit 1
fi fi
} }

View File

@ -19,8 +19,7 @@ function setup_integration_bridge() {
conn=(${NVP_CONTROLLER_CONNECTION//\:/ }) conn=(${NVP_CONTROLLER_CONNECTION//\:/ })
OVS_MGR_IP=${conn[0]} OVS_MGR_IP=${conn[0]}
else else
echo "Error - No controller specified. Unable to set a manager for OVS" die $LINENO "Error - No controller specified. Unable to set a manager for OVS"
exit 1
fi fi
sudo ovs-vsctl set-manager ssl:$OVS_MGR_IP sudo ovs-vsctl set-manager ssl:$OVS_MGR_IP
} }
@ -63,14 +62,12 @@ function quantum_plugin_configure_dhcp_agent() {
function quantum_plugin_configure_l3_agent() { function quantum_plugin_configure_l3_agent() {
# Nicira plugin does not run L3 agent # Nicira plugin does not run L3 agent
echo "ERROR - q-l3 should must not be executed with Nicira plugin!" die $LINENO "q-l3 should must not be executed with Nicira plugin!"
exit 1
} }
function quantum_plugin_configure_plugin_agent() { function quantum_plugin_configure_plugin_agent() {
# Nicira plugin does not run L2 agent # Nicira plugin does not run L2 agent
echo "ERROR - q-agt must not be executed with Nicira plugin!" die $LINENO "q-agt must not be executed with Nicira plugin!"
exit 1
} }
function quantum_plugin_configure_service() { function quantum_plugin_configure_service() {
@ -93,8 +90,7 @@ function quantum_plugin_configure_service() {
if [[ "$DEFAULT_TZ_UUID" != "" ]]; then if [[ "$DEFAULT_TZ_UUID" != "" ]]; then
iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" default_tz_uuid $DEFAULT_TZ_UUID iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" default_tz_uuid $DEFAULT_TZ_UUID
else else
echo "ERROR - The nicira plugin won't work without a default transport zone." die $LINENO "The nicira plugin won't work without a default transport zone."
exit 1
fi fi
if [[ "$DEFAULT_L3_GW_SVC_UUID" != "" ]]; then if [[ "$DEFAULT_L3_GW_SVC_UUID" != "" ]]; then
iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" default_l3_gw_service_uuid $DEFAULT_L3_GW_SVC_UUID iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" default_l3_gw_service_uuid $DEFAULT_L3_GW_SVC_UUID
@ -114,8 +110,7 @@ function quantum_plugin_configure_service() {
# Only 1 controller can be specified in this case # Only 1 controller can be specified in this case
iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" nvp_controller_connection $NVP_CONTROLLER_CONNECTION iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" nvp_controller_connection $NVP_CONTROLLER_CONNECTION
else else
echo "ERROR - The nicira plugin needs at least an NVP controller." die $LINENO "The nicira plugin needs at least an NVP controller."
exit 1
fi fi
if [[ "$NVP_USER" != "" ]]; then if [[ "$NVP_USER" != "" ]]; then
iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" nvp_user $NVP_USER iniset /$Q_PLUGIN_CONF_FILE "CLUSTER:$DC" nvp_user $NVP_USER

View File

@ -49,9 +49,7 @@ function quantum_plugin_configure_plugin_agent() {
# REVISIT - also check kernel module support for GRE and patch ports # REVISIT - also check kernel module support for GRE and patch ports
OVS_VERSION=`ovs-vsctl --version | head -n 1 | awk '{print $4;}'` OVS_VERSION=`ovs-vsctl --version | head -n 1 | awk '{print $4;}'`
if [ $OVS_VERSION \< "1.4" ] && ! is_service_enabled q-svc ; then if [ $OVS_VERSION \< "1.4" ] && ! is_service_enabled q-svc ; then
echo "You are running OVS version $OVS_VERSION." die $LINENO "You are running OVS version $OVS_VERSION. OVS 1.4+ is required for tunneling between multiple hosts."
echo "OVS 1.4+ is required for tunneling between multiple hosts."
exit 1
fi fi
iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP

View File

@ -39,8 +39,7 @@ function check_rpc_backend() {
fi fi
if is_service_enabled qpid && ! qpid_is_supported; then if is_service_enabled qpid && ! qpid_is_supported; then
echo "Qpid support is not available for this version of your distribution." die $LINENO "Qpid support is not available for this version of your distribution."
exit 1
fi fi
} }

View File

@ -55,8 +55,7 @@ GetDistro
# allow you to safely override those settings. # allow you to safely override those settings.
if [[ ! -r $TOP_DIR/stackrc ]]; then if [[ ! -r $TOP_DIR/stackrc ]]; then
echo "ERROR: missing $TOP_DIR/stackrc - did you grab more than just stack.sh?" log_error $LINENO "missing $TOP_DIR/stackrc - did you grab more than just stack.sh?"
exit 1
fi fi
source $TOP_DIR/stackrc source $TOP_DIR/stackrc
@ -93,8 +92,7 @@ disable_negated_services
if [[ ! ${DISTRO} =~ (oneiric|precise|quantal|raring|f16|f17|f18|opensuse-12.2) ]]; then if [[ ! ${DISTRO} =~ (oneiric|precise|quantal|raring|f16|f17|f18|opensuse-12.2) ]]; then
echo "WARNING: this script has not been tested on $DISTRO" echo "WARNING: this script has not been tested on $DISTRO"
if [[ "$FORCE" != "yes" ]]; then if [[ "$FORCE" != "yes" ]]; then
echo "If you wish to run this script anyway run with FORCE=yes" die $LINENO "If you wish to run this script anyway run with FORCE=yes"
exit 1
fi fi
fi fi
@ -105,16 +103,14 @@ check_rpc_backend
# ``stack.sh`` keeps function libraries here # ``stack.sh`` keeps function libraries here
# Make sure ``$TOP_DIR/lib`` directory is present # Make sure ``$TOP_DIR/lib`` directory is present
if [ ! -d $TOP_DIR/lib ]; then if [ ! -d $TOP_DIR/lib ]; then
echo "ERROR: missing devstack/lib" log_error $LINENO "missing devstack/lib"
exit 1
fi fi
# ``stack.sh`` keeps the list of ``apt`` and ``rpm`` dependencies and config # ``stack.sh`` keeps the list of ``apt`` and ``rpm`` dependencies and config
# templates and other useful files in the ``files`` subdirectory # templates and other useful files in the ``files`` subdirectory
FILES=$TOP_DIR/files FILES=$TOP_DIR/files
if [ ! -d $FILES ]; then if [ ! -d $FILES ]; then
echo "ERROR: missing devstack/files" log_error $LINENO "missing devstack/files"
exit 1
fi fi
SCREEN_NAME=${SCREEN_NAME:-stack} SCREEN_NAME=${SCREEN_NAME:-stack}
@ -248,9 +244,7 @@ if [ -z "$HOST_IP" -o "$HOST_IP" == "dhcp" ]; then
fi fi
done done
if [ "$HOST_IP" == "" ]; then if [ "$HOST_IP" == "" ]; then
echo "Could not determine host ip address." die $LINENO "Could not determine host ip address. Either localrc specified dhcp on ${HOST_IP_IFACE} or defaulted"
echo "Either localrc specified dhcp on ${HOST_IP_IFACE} or defaulted"
exit 1
fi fi
fi fi