| Jesse Andrews | b019151 | 2011-09-14 19:37:10 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash | 
|  | 2 |  | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 3 | # **floating_ips.sh** - using the cloud can be fun | 
| Jesse Andrews | b019151 | 2011-09-14 19:37:10 -0700 | [diff] [blame] | 4 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 5 | # Test instance connectivity with the ``nova`` command from ``python-novaclient`` | 
| Jesse Andrews | b019151 | 2011-09-14 19:37:10 -0700 | [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 |  | 
| Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 11 | # This script exits on an error so that errors don't compound and you see | 
| Joe Gordon | 4640026 | 2013-06-30 04:32:27 -0700 | [diff] [blame] | 12 | # only the first error that occurred. | 
| Jesse Andrews | b19424f | 2011-09-14 22:03:04 -0700 | [diff] [blame] | 13 | set -o errexit | 
|  | 14 |  | 
| Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 15 | # Print the commands being run so that we can see the command that triggers | 
| Jesse Andrews | b19424f | 2011-09-14 22:03:04 -0700 | [diff] [blame] | 16 | # an error.  It is also useful for following allowing as the install occurs. | 
|  | 17 | set -o xtrace | 
|  | 18 |  | 
|  | 19 |  | 
|  | 20 | # Settings | 
|  | 21 | # ======== | 
| Jesse Andrews | b019151 | 2011-09-14 19:37:10 -0700 | [diff] [blame] | 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 | 
| Jesse Andrews | b019151 | 2011-09-14 19:37:10 -0700 | [diff] [blame] | 32 |  | 
| Dean Troyer | e2907b4 | 2014-02-26 17:35:37 -0600 | [diff] [blame] | 33 | # Import project functions | 
|  | 34 | source $TOP_DIR/lib/neutron | 
|  | 35 |  | 
| Dean Troyer | 51fb454 | 2012-03-09 22:21:59 -0600 | [diff] [blame] | 36 | # Import exercise configuration | 
|  | 37 | source $TOP_DIR/exerciserc | 
| Dean Troyer | 751c152 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 38 |  | 
| Kiall Mac Innes | a16c821 | 2014-01-12 19:35:43 +0000 | [diff] [blame] | 39 | # If nova api is not enabled we exit with exitcode 55 so that | 
|  | 40 | # the exercise is skipped | 
|  | 41 | is_service_enabled n-api || exit 55 | 
|  | 42 |  | 
| Dean Troyer | 751c152 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 43 | # Instance type to create | 
|  | 44 | DEFAULT_INSTANCE_TYPE=${DEFAULT_INSTANCE_TYPE:-m1.tiny} | 
|  | 45 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 46 | # Boot this image, use first AMI image if unset | 
| Dean Troyer | 751c152 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 47 | DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-ami} | 
|  | 48 |  | 
|  | 49 | # Security group name | 
|  | 50 | SECGROUP=${SECGROUP:-test_secgroup} | 
|  | 51 |  | 
|  | 52 | # Default floating IP pool name | 
| Aaron Rosen | 640f1e4 | 2013-03-26 16:52:53 -0700 | [diff] [blame] | 53 | DEFAULT_FLOATING_POOL=${DEFAULT_FLOATING_POOL:-public} | 
| Dean Troyer | 751c152 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 54 |  | 
|  | 55 | # Additional floating IP pool and range | 
| Dean Troyer | 696ad33 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 56 | TEST_FLOATING_POOL=${TEST_FLOATING_POOL:-test} | 
|  | 57 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 58 | # Instance name | 
|  | 59 | VM_NAME="ex-float" | 
|  | 60 |  | 
| Chris Behrens | c62c2b9 | 2013-07-24 03:56:13 -0700 | [diff] [blame] | 61 | # Cells does not support floating ips API calls | 
|  | 62 | is_service_enabled n-cell && exit 55 | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 63 |  | 
| Jesse Andrews | 593828d | 2011-09-14 22:44:50 -0700 | [diff] [blame] | 64 | # Launching a server | 
|  | 65 | # ================== | 
| Jesse Andrews | b19424f | 2011-09-14 22:03:04 -0700 | [diff] [blame] | 66 |  | 
| Jesse Andrews | 593828d | 2011-09-14 22:44:50 -0700 | [diff] [blame] | 67 | # List servers for tenant: | 
| Jesse Andrews | b019151 | 2011-09-14 19:37:10 -0700 | [diff] [blame] | 68 | nova list | 
| Jesse Andrews | 593828d | 2011-09-14 22:44:50 -0700 | [diff] [blame] | 69 |  | 
| Jesse Andrews | 593828d | 2011-09-14 22:44:50 -0700 | [diff] [blame] | 70 | # Images | 
|  | 71 | # ------ | 
|  | 72 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 73 | # List the images available | 
| Dean Troyer | 4549525 | 2012-04-13 13:16:38 -0500 | [diff] [blame] | 74 | glance image-list | 
| Jesse Andrews | 593828d | 2011-09-14 22:44:50 -0700 | [diff] [blame] | 75 |  | 
| Dean Troyer | 751c152 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 76 | # Grab the id of the image to launch | 
| Dean Troyer | 4549525 | 2012-04-13 13:16:38 -0500 | [diff] [blame] | 77 | IMAGE=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1) | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 78 | die_if_not_set $LINENO IMAGE "Failure getting image $DEFAULT_IMAGE_NAME" | 
| Jesse Andrews | d888e1c | 2011-10-15 20:01:12 -0700 | [diff] [blame] | 79 |  | 
| Anthony Young | 20a2cae | 2011-10-17 16:02:24 -0700 | [diff] [blame] | 80 | # Security Groups | 
|  | 81 | # --------------- | 
| Anthony Young | 20a2cae | 2011-10-17 16:02:24 -0700 | [diff] [blame] | 82 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 83 | # List security groups | 
| Anthony Young | 20a2cae | 2011-10-17 16:02:24 -0700 | [diff] [blame] | 84 | nova secgroup-list | 
|  | 85 |  | 
|  | 86 | # Create a secgroup | 
| Dean Troyer | 751c152 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 87 | if ! nova secgroup-list | grep -q $SECGROUP; then | 
|  | 88 | nova secgroup-create $SECGROUP "$SECGROUP description" | 
|  | 89 | if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova secgroup-list | grep -q $SECGROUP; do sleep 1; done"; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 90 | die $LINENO "Security group not created" | 
| Dean Troyer | 751c152 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 91 | fi | 
|  | 92 | fi | 
| Jesse Andrews | d888e1c | 2011-10-15 20:01:12 -0700 | [diff] [blame] | 93 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 94 | # Configure Security Group Rules | 
|  | 95 | if ! nova secgroup-list-rules $SECGROUP | grep -q icmp; then | 
|  | 96 | nova secgroup-add-rule $SECGROUP icmp -1 -1 0.0.0.0/0 | 
|  | 97 | fi | 
|  | 98 | if ! nova secgroup-list-rules $SECGROUP | grep -q " tcp .* 22 "; then | 
|  | 99 | nova secgroup-add-rule $SECGROUP tcp 22 22 0.0.0.0/0 | 
| Dean Troyer | 1d6e0e1 | 2011-12-23 12:45:13 -0600 | [diff] [blame] | 100 | fi | 
| Jesse Andrews | d888e1c | 2011-10-15 20:01:12 -0700 | [diff] [blame] | 101 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 102 | # List secgroup rules | 
|  | 103 | nova secgroup-list-rules $SECGROUP | 
| Jesse Andrews | d888e1c | 2011-10-15 20:01:12 -0700 | [diff] [blame] | 104 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 105 | # Set up instance | 
|  | 106 | # --------------- | 
| Jesse Andrews | d888e1c | 2011-10-15 20:01:12 -0700 | [diff] [blame] | 107 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 108 | # List flavors | 
|  | 109 | nova flavor-list | 
| Dean Troyer | ad10176 | 2012-06-27 22:04:40 -0500 | [diff] [blame] | 110 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 111 | # Select a flavor | 
|  | 112 | INSTANCE_TYPE=$(nova flavor-list | grep $DEFAULT_INSTANCE_TYPE | get_field 1) | 
|  | 113 | if [[ -z "$INSTANCE_TYPE" ]]; then | 
|  | 114 | # 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] | 115 | 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] | 116 | die_if_not_set $LINENO INSTANCE_TYPE "Failure retrieving INSTANCE_TYPE" | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 117 | fi | 
| Jesse Andrews | 6fc7101 | 2011-10-24 11:29:08 -0700 | [diff] [blame] | 118 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 119 | # Clean-up from previous runs | 
|  | 120 | nova delete $VM_NAME || true | 
|  | 121 | 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] | 122 | die $LINENO "server didn't terminate!" | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 123 | exit 1 | 
|  | 124 | fi | 
| Jesse Andrews | 6fc7101 | 2011-10-24 11:29:08 -0700 | [diff] [blame] | 125 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 126 | # Boot instance | 
|  | 127 | # ------------- | 
| Jesse Andrews | 6fc7101 | 2011-10-24 11:29:08 -0700 | [diff] [blame] | 128 |  | 
| Dean Troyer | 526b79f | 2013-11-22 11:30:44 -0600 | [diff] [blame] | 129 | 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] | 130 | die_if_not_set $LINENO VM_UUID "Failure launching $VM_NAME" | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 131 |  | 
|  | 132 | # Check that the status is active within ACTIVE_TIMEOUT seconds | 
| Dean Troyer | 751c152 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 133 | 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] | 134 | die $LINENO "server didn't become active!" | 
| Jesse Andrews | 5a77483 | 2011-10-26 21:30:02 -0700 | [diff] [blame] | 135 | fi | 
| Jesse Andrews | d888e1c | 2011-10-15 20:01:12 -0700 | [diff] [blame] | 136 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 137 | # Get the instance IP | 
| Nachi Ueno | 6769b16 | 2013-08-12 18:18:56 -0700 | [diff] [blame] | 138 | IP=$(get_instance_ip $VM_UUID $PRIVATE_NETWORK_NAME) | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 139 | die_if_not_set $LINENO IP "Failure retrieving IP address" | 
| Jesse Andrews | d888e1c | 2011-10-15 20:01:12 -0700 | [diff] [blame] | 140 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 141 | # Private IPs can be pinged in single node deployments | 
| Nachi Ueno | fda946e | 2012-10-24 17:26:02 -0700 | [diff] [blame] | 142 | ping_check "$PRIVATE_NETWORK_NAME" $IP $BOOT_TIMEOUT | 
| Jesse Andrews | 6fc7101 | 2011-10-24 11:29:08 -0700 | [diff] [blame] | 143 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 144 | # Floating IPs | 
|  | 145 | # ------------ | 
| Jesse Andrews | 6fc7101 | 2011-10-24 11:29:08 -0700 | [diff] [blame] | 146 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 147 | # Allocate a floating IP from the default pool | 
|  | 148 | FLOATING_IP=$(nova floating-ip-create | grep $DEFAULT_FLOATING_POOL | get_field 1) | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 149 | die_if_not_set $LINENO FLOATING_IP "Failure creating floating IP from pool $DEFAULT_FLOATING_POOL" | 
| Anthony Young | 20a2cae | 2011-10-17 16:02:24 -0700 | [diff] [blame] | 150 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 151 | # List floating addresses | 
| Dean Troyer | 696ad33 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 152 | if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova floating-ip-list | grep -q $FLOATING_IP; do sleep 1; done"; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 153 | die $LINENO "Floating IP not allocated" | 
| Dean Troyer | 696ad33 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 154 | fi | 
| Anthony Young | 20a2cae | 2011-10-17 16:02:24 -0700 | [diff] [blame] | 155 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 156 | # Add floating IP to our server | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 157 | nova add-floating-ip $VM_UUID $FLOATING_IP || \ | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 158 | die $LINENO "Failure adding floating IP $FLOATING_IP to $VM_NAME" | 
| Anthony Young | 20a2cae | 2011-10-17 16:02:24 -0700 | [diff] [blame] | 159 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 160 | # Test we can ping our floating IP within ASSOCIATE_TIMEOUT seconds | 
| Nachi Ueno | fda946e | 2012-10-24 17:26:02 -0700 | [diff] [blame] | 161 | ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT | 
| Anthony Young | 20a2cae | 2011-10-17 16:02:24 -0700 | [diff] [blame] | 162 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 163 | if ! is_service_enabled neutron; then | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 164 | # Allocate an IP from second floating pool | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 165 | TEST_FLOATING_IP=$(nova floating-ip-create $TEST_FLOATING_POOL | grep $TEST_FLOATING_POOL | get_field 1) | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 166 | die_if_not_set $LINENO TEST_FLOATING_IP "Failure creating floating IP in $TEST_FLOATING_POOL" | 
| Dean Troyer | 696ad33 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 167 |  | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 168 | # list floating addresses | 
|  | 169 | 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 | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 170 | die $LINENO "Floating IP not allocated" | 
| Sean Dague | 922c8ae | 2013-10-22 10:06:06 -0400 | [diff] [blame] | 171 | fi | 
| Dean Troyer | 696ad33 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 172 | fi | 
|  | 173 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 174 | # Dis-allow icmp traffic (ping) | 
|  | 175 | nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0 || \ | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 176 | die $LINENO "Failure deleting security group rule from $SECGROUP" | 
| Anthony Young | 20a2cae | 2011-10-17 16:02:24 -0700 | [diff] [blame] | 177 |  | 
| Brian Haley | 9b3602c | 2014-02-28 13:52:29 -0500 | [diff] [blame] | 178 | if ! timeout $ASSOCIATE_TIMEOUT sh -c "while nova secgroup-list-rules $SECGROUP | grep -q icmp; do sleep 1; done"; then | 
|  | 179 | die $LINENO "Security group rule not deleted from $SECGROUP" | 
|  | 180 | fi | 
|  | 181 |  | 
| Anthony Young | 1de18c6 | 2011-11-01 14:19:18 -0500 | [diff] [blame] | 182 | # FIXME (anthony): make xs support security groups | 
| Adam Gandelman | b875d01 | 2014-03-17 19:47:14 -0700 | [diff] [blame] | 183 | if [ "$VIRT_DRIVER" != "ironic" -a "$VIRT_DRIVER" != "xenserver" -a "$VIRT_DRIVER" != "openvz" ]; then | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 184 | # Test we can aren't able to ping our floating ip within ASSOCIATE_TIMEOUT seconds | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 185 | ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT Fail | 
| Anthony Young | 20a2cae | 2011-10-17 16:02:24 -0700 | [diff] [blame] | 186 | fi | 
|  | 187 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 188 | # Clean up | 
|  | 189 | # -------- | 
|  | 190 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 191 | if ! is_service_enabled neutron; then | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 192 | # Delete second floating IP | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 193 | nova floating-ip-delete $TEST_FLOATING_IP || \ | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 194 | die $LINENO "Failure deleting floating IP $TEST_FLOATING_IP" | 
| Nachi Ueno | 5db5bfa | 2012-10-29 11:25:29 -0700 | [diff] [blame] | 195 | fi | 
| Nachi Ueno | fda946e | 2012-10-24 17:26:02 -0700 | [diff] [blame] | 196 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 197 | # Delete the floating ip | 
|  | 198 | nova floating-ip-delete $FLOATING_IP || \ | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 199 | die $LINENO "Failure deleting floating IP $FLOATING_IP" | 
| Nachi Ueno | fda946e | 2012-10-24 17:26:02 -0700 | [diff] [blame] | 200 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 201 | # Delete instance | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 202 | nova delete $VM_UUID || die $LINENO "Failure deleting instance $VM_NAME" | 
| Dean Troyer | 96288ba | 2012-08-17 14:11:55 -0500 | [diff] [blame] | 203 | # Wait for termination | 
|  | 204 | 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] | 205 | die $LINENO "Server $VM_NAME not deleted" | 
| Russell Bryant | 5836b15 | 2012-02-24 10:23:33 -0500 | [diff] [blame] | 206 | fi | 
|  | 207 |  | 
| Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 208 | # Delete secgroup | 
|  | 209 | nova secgroup-delete $SECGROUP || \ | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 210 | die $LINENO "Failure deleting security group $SECGROUP" | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 211 |  | 
|  | 212 | set +o xtrace | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 213 | echo "*********************************************************************" | 
|  | 214 | echo "SUCCESS: End DevStack Exercise: $0" | 
|  | 215 | echo "*********************************************************************" |