| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 1 | #!/usr/bin/env bash | 
|  | 2 |  | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 3 | # **volumes.sh** | 
|  | 4 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 5 | # Test cinder volumes with the ``cinder`` command from ``python-cinderclient`` | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 6 |  | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 7 | echo "*********************************************************************" | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 8 | echo "Begin DevStack Exercise: $0" | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 9 | echo "*********************************************************************" | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 10 |  | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 11 | # This script exits on an error so that errors don't compound and you see | 
| Joe Gordon | 6fd2811 | 2012-11-13 16:55:41 -0800 | [diff] [blame] | 12 | # only the first error that occurred. | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 13 | set -o errexit | 
|  | 14 |  | 
|  | 15 | # Print the commands being run so that we can see the command that triggers | 
|  | 16 | # an error.  It is also useful for following allowing as the install occurs. | 
|  | 17 | set -o xtrace | 
|  | 18 |  | 
|  | 19 |  | 
|  | 20 | # Settings | 
|  | 21 | # ======== | 
|  | 22 |  | 
| Dean Troyer | 51fb454 | 2012-03-09 22:21:59 -0600 | [diff] [blame] | 23 | # Keep track of the current directory | 
|  | 24 | EXERCISE_DIR=$(cd $(dirname "$0") && pwd) | 
|  | 25 | TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 26 |  | 
|  | 27 | # Import common functions | 
| Dean Troyer | 51fb454 | 2012-03-09 22:21:59 -0600 | [diff] [blame] | 28 | source $TOP_DIR/functions | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 29 |  | 
|  | 30 | # Import configuration | 
| Dean Troyer | 51fb454 | 2012-03-09 22:21:59 -0600 | [diff] [blame] | 31 | source $TOP_DIR/openrc | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 32 |  | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 33 | # Import project functions | 
|  | 34 | source $TOP_DIR/lib/cinder | 
| Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 35 | source $TOP_DIR/lib/neutron | 
| Dean Troyer | 5a9739a | 2015-03-25 11:33:51 -0500 | [diff] [blame] | 36 | source $TOP_DIR/lib/neutron-legacy | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 37 |  | 
| Dean Troyer | 51fb454 | 2012-03-09 22:21:59 -0600 | [diff] [blame] | 38 | # Import exercise configuration | 
|  | 39 | source $TOP_DIR/exerciserc | 
| Dean Troyer | 751c152 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 40 |  | 
| Joe Gordon | 6fd2811 | 2012-11-13 16:55:41 -0800 | [diff] [blame] | 41 | # If cinder is not enabled we exit with exitcode 55 which mean | 
| Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 42 | # exercise is skipped. | 
| Joe Gordon | 6fd2811 | 2012-11-13 16:55:41 -0800 | [diff] [blame] | 43 | is_service_enabled cinder || exit 55 | 
| Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 44 |  | 
| Adam Gandelman | b875d01 | 2014-03-17 19:47:14 -0700 | [diff] [blame] | 45 | # Ironic does not currently support volume attachment. | 
|  | 46 | [ "$VIRT_DRIVER" == "ironic" ] && exit 55 | 
|  | 47 |  | 
| Dean Troyer | 751c152 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 48 | # Instance type to create | 
|  | 49 | DEFAULT_INSTANCE_TYPE=${DEFAULT_INSTANCE_TYPE:-m1.tiny} | 
|  | 50 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 51 | # Boot this image, use first AMI image if unset | 
| Dean Troyer | 751c152 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 52 | DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-ami} | 
|  | 53 |  | 
| Dean Troyer | 96288ba | 2012-08-17 14:11:55 -0500 | [diff] [blame] | 54 | # Security group name | 
|  | 55 | SECGROUP=${SECGROUP:-vol_secgroup} | 
|  | 56 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 57 | # Instance and volume names | 
|  | 58 | VM_NAME=${VM_NAME:-ex-vol-inst} | 
|  | 59 | VOL_NAME="ex-vol-$(openssl rand -hex 4)" | 
|  | 60 |  | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 61 |  | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 62 | # Launching a server | 
|  | 63 | # ================== | 
|  | 64 |  | 
|  | 65 | # List servers for tenant: | 
|  | 66 | nova list | 
|  | 67 |  | 
|  | 68 | # Images | 
|  | 69 | # ------ | 
|  | 70 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 71 | # List the images available | 
| Steve Martinelli | 5c206c2 | 2014-08-02 20:32:31 -0400 | [diff] [blame] | 72 | openstack image list | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 73 |  | 
| Dean Troyer | 751c152 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 74 | # Grab the id of the image to launch | 
| Steve Martinelli | 5c206c2 | 2014-08-02 20:32:31 -0400 | [diff] [blame] | 75 | IMAGE=$(openstack image list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1) | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 76 | die_if_not_set $LINENO IMAGE "Failure getting image $DEFAULT_IMAGE_NAME" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 77 |  | 
| Dean Troyer | 96288ba | 2012-08-17 14:11:55 -0500 | [diff] [blame] | 78 | # Security Groups | 
|  | 79 | # --------------- | 
|  | 80 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 81 | # List security groups | 
| Dean Troyer | 96288ba | 2012-08-17 14:11:55 -0500 | [diff] [blame] | 82 | nova secgroup-list | 
|  | 83 |  | 
| Chris Behrens | c62c2b9 | 2013-07-24 03:56:13 -0700 | [diff] [blame] | 84 | if is_service_enabled n-cell; then | 
|  | 85 | # Cells does not support security groups, so force the use of "default" | 
|  | 86 | SECGROUP="default" | 
|  | 87 | echo "Using the default security group because of Cells." | 
|  | 88 | else | 
|  | 89 | # Create a secgroup | 
|  | 90 | if ! nova secgroup-list | grep -q $SECGROUP; then | 
|  | 91 | nova secgroup-create $SECGROUP "$SECGROUP description" | 
|  | 92 | if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova secgroup-list | grep -q $SECGROUP; do sleep 1; done"; then | 
|  | 93 | echo "Security group not created" | 
|  | 94 | exit 1 | 
|  | 95 | fi | 
| Dean Troyer | 96288ba | 2012-08-17 14:11:55 -0500 | [diff] [blame] | 96 | fi | 
|  | 97 | fi | 
|  | 98 |  | 
|  | 99 | # Configure Security Group Rules | 
| Dean Troyer | 15bda3e | 2013-01-11 15:07:53 -0600 | [diff] [blame] | 100 | if ! nova secgroup-list-rules $SECGROUP | grep -q icmp; then | 
|  | 101 | nova secgroup-add-rule $SECGROUP icmp -1 -1 0.0.0.0/0 | 
|  | 102 | fi | 
|  | 103 | if ! nova secgroup-list-rules $SECGROUP | grep -q " tcp .* 22 "; then | 
|  | 104 | nova secgroup-add-rule $SECGROUP tcp 22 22 0.0.0.0/0 | 
|  | 105 | fi | 
| Dean Troyer | 96288ba | 2012-08-17 14:11:55 -0500 | [diff] [blame] | 106 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 107 | # List secgroup rules | 
|  | 108 | nova secgroup-list-rules $SECGROUP | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 109 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 110 | # Set up instance | 
|  | 111 | # --------------- | 
|  | 112 |  | 
|  | 113 | # List flavors | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 114 | nova flavor-list | 
|  | 115 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 116 | # Select a flavor | 
|  | 117 | INSTANCE_TYPE=$(nova flavor-list | grep $DEFAULT_INSTANCE_TYPE | get_field 1) | 
| Dean Troyer | 1d6e0e1 | 2011-12-23 12:45:13 -0600 | [diff] [blame] | 118 | if [[ -z "$INSTANCE_TYPE" ]]; then | 
|  | 119 | # grab the first flavor in the list to launch if default doesn't exist | 
| Sean Dague | 922c8ae | 2013-10-22 10:06:06 -0400 | [diff] [blame] | 120 | INSTANCE_TYPE=$(nova flavor-list | head -n 4 | tail -n 1 | get_field 1) | 
| DennyZhang | 23178a9 | 2013-10-22 17:07:32 -0500 | [diff] [blame] | 121 | die_if_not_set $LINENO INSTANCE_TYPE "Failure retrieving INSTANCE_TYPE" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 122 | fi | 
|  | 123 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 124 | # Clean-up from previous runs | 
|  | 125 | nova delete $VM_NAME || true | 
|  | 126 | if ! timeout $ACTIVE_TIMEOUT sh -c "while nova show $VM_NAME; do sleep 1; done"; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 127 | die $LINENO "server didn't terminate!" | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 128 | fi | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 129 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 130 | # Boot instance | 
|  | 131 | # ------------- | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 132 |  | 
| Dean Troyer | 526b79f | 2013-11-22 11:30:44 -0600 | [diff] [blame] | 133 | VM_UUID=$(nova boot --flavor $INSTANCE_TYPE --image $IMAGE --security-groups=$SECGROUP $VM_NAME | grep ' id ' | get_field 2) | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 134 | die_if_not_set $LINENO VM_UUID "Failure launching $VM_NAME" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 135 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 136 | # Check that the status is active within ACTIVE_TIMEOUT seconds | 
| Dean Troyer | 751c152 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 137 | if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 138 | die $LINENO "server didn't become active!" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 139 | fi | 
|  | 140 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 141 | # Get the instance IP | 
| Nachi Ueno | 6769b16 | 2013-08-12 18:18:56 -0700 | [diff] [blame] | 142 | IP=$(get_instance_ip $VM_UUID $PRIVATE_NETWORK_NAME) | 
|  | 143 |  | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 144 | die_if_not_set $LINENO IP "Failure retrieving IP address" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 145 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 146 | # Private IPs can be pinged in single node deployments | 
| Sean Dague | af9bf86 | 2015-04-16 08:58:32 -0400 | [diff] [blame] | 147 | ping_check $IP $BOOT_TIMEOUT "$PRIVATE_NETWORK_NAME" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 148 |  | 
|  | 149 | # Volumes | 
|  | 150 | # ------- | 
|  | 151 |  | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 152 | # Verify it doesn't exist | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 153 | if [[ -n $(cinder list | grep $VOL_NAME | head -1 | get_field 2) ]]; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 154 | die $LINENO "Volume $VOL_NAME already exists" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 155 | fi | 
|  | 156 |  | 
|  | 157 | # Create a new volume | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 158 | start_time=$(date +%s) | 
| Dean Troyer | 526b79f | 2013-11-22 11:30:44 -0600 | [diff] [blame] | 159 | cinder create --display-name $VOL_NAME --display-description "test volume: $VOL_NAME" $DEFAULT_VOLUME_SIZE || \ | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 160 | die $LINENO "Failure creating volume $VOL_NAME" | 
| John Griffith | 161e280 | 2012-11-05 13:59:49 -0700 | [diff] [blame] | 161 | if ! timeout $ACTIVE_TIMEOUT sh -c "while ! cinder list | grep $VOL_NAME | grep available; do sleep 1; done"; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 162 | die $LINENO "Volume $VOL_NAME not created" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 163 | fi | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 164 | end_time=$(date +%s) | 
| John Griffith | 161e280 | 2012-11-05 13:59:49 -0700 | [diff] [blame] | 165 | echo "Completed cinder create in $((end_time - start_time)) seconds" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 166 |  | 
|  | 167 | # Get volume ID | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 168 | VOL_ID=$(cinder list | grep $VOL_NAME | head -1 | get_field 1) | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 169 | die_if_not_set $LINENO VOL_ID "Failure retrieving volume ID for $VOL_NAME" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 170 |  | 
|  | 171 | # Attach to server | 
|  | 172 | DEVICE=/dev/vdb | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 173 | start_time=$(date +%s) | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 174 | nova volume-attach $VM_UUID $VOL_ID $DEVICE || \ | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 175 | die $LINENO "Failure attaching volume $VOL_NAME to $VM_NAME" | 
| John Griffith | 161e280 | 2012-11-05 13:59:49 -0700 | [diff] [blame] | 176 | if ! timeout $ACTIVE_TIMEOUT sh -c "while ! cinder list | grep $VOL_NAME | grep in-use; do sleep 1; done"; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 177 | die $LINENO "Volume $VOL_NAME not attached to $VM_NAME" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 178 | fi | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 179 | end_time=$(date +%s) | 
| John Griffith | 496ffc7 | 2012-09-26 15:09:52 -0600 | [diff] [blame] | 180 | echo "Completed volume-attach in $((end_time - start_time)) seconds" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 181 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 182 | VOL_ATTACH=$(cinder list | grep $VOL_NAME | head -1 | get_field -1) | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 183 | die_if_not_set $LINENO VOL_ATTACH "Failure retrieving $VOL_NAME status" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 184 | if [[ "$VOL_ATTACH" != $VM_UUID ]]; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 185 | die $LINENO "Volume not attached to correct instance" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 186 | fi | 
|  | 187 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 188 | # Clean up | 
|  | 189 | # -------- | 
|  | 190 |  | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 191 | # Detach volume | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 192 | start_time=$(date +%s) | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 193 | nova volume-detach $VM_UUID $VOL_ID || die $LINENO "Failure detaching volume $VOL_NAME from $VM_NAME" | 
| John Griffith | 161e280 | 2012-11-05 13:59:49 -0700 | [diff] [blame] | 194 | if ! timeout $ACTIVE_TIMEOUT sh -c "while ! cinder list | grep $VOL_NAME | grep available; do sleep 1; done"; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 195 | die $LINENO "Volume $VOL_NAME not detached from $VM_NAME" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 196 | fi | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 197 | end_time=$(date +%s) | 
| John Griffith | 496ffc7 | 2012-09-26 15:09:52 -0600 | [diff] [blame] | 198 | echo "Completed volume-detach in $((end_time - start_time)) seconds" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 199 |  | 
|  | 200 | # Delete volume | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 201 | start_time=$(date +%s) | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 202 | cinder delete $VOL_ID || die $LINENO "Failure deleting volume $VOL_NAME" | 
| Adam Gandelman | 756c842 | 2013-01-04 13:37:22 -0800 | [diff] [blame] | 203 | if ! timeout $ACTIVE_TIMEOUT sh -c "while cinder list | grep $VOL_NAME; do sleep 1; done"; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 204 | die $LINENO "Volume $VOL_NAME not deleted" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 205 | fi | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 206 | end_time=$(date +%s) | 
| John Griffith | 161e280 | 2012-11-05 13:59:49 -0700 | [diff] [blame] | 207 | echo "Completed cinder delete in $((end_time - start_time)) seconds" | 
| Dean Troyer | a8dda17 | 2011-12-16 12:22:02 -0600 | [diff] [blame] | 208 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 209 | # Delete instance | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 210 | nova delete $VM_UUID || die $LINENO "Failure deleting instance $VM_NAME" | 
| Dean Troyer | 96288ba | 2012-08-17 14:11:55 -0500 | [diff] [blame] | 211 | if ! timeout $TERMINATE_TIMEOUT sh -c "while nova list | grep -q $VM_UUID; do sleep 1; done"; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 212 | die $LINENO "Server $VM_NAME not deleted" | 
| Dean Troyer | 96288ba | 2012-08-17 14:11:55 -0500 | [diff] [blame] | 213 | fi | 
|  | 214 |  | 
| Chris Behrens | c62c2b9 | 2013-07-24 03:56:13 -0700 | [diff] [blame] | 215 | if [[ $SECGROUP = "default" ]] ; then | 
|  | 216 | echo "Skipping deleting default security group" | 
|  | 217 | else | 
|  | 218 | # Delete secgroup | 
|  | 219 | nova secgroup-delete $SECGROUP || die $LINENO "Failure deleting security group $SECGROUP" | 
|  | 220 | fi | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 221 |  | 
|  | 222 | set +o xtrace | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 223 | echo "*********************************************************************" | 
|  | 224 | echo "SUCCESS: End DevStack Exercise: $0" | 
|  | 225 | echo "*********************************************************************" |