No other hypervisor has a dedicated exercise, docker should be
tested just by testing the nova APIs, not on it's own.
Change-Id: Ifc788815380e8502449171410dea8260786a1e79
| 1 | 1 |
deleted file mode 100755 |
| ... | ... |
@@ -1,104 +0,0 @@ |
| 1 |
-#!/usr/bin/env bash |
|
| 2 |
- |
|
| 3 |
-# **docker** |
|
| 4 |
- |
|
| 5 |
-# Test Docker hypervisor |
|
| 6 |
- |
|
| 7 |
-echo "*********************************************************************" |
|
| 8 |
-echo "Begin DevStack Exercise: $0" |
|
| 9 |
-echo "*********************************************************************" |
|
| 10 |
- |
|
| 11 |
-# This script exits on an error so that errors don't compound and you see |
|
| 12 |
-# only the first error that occurred. |
|
| 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 |
- |
|
| 23 |
-# Keep track of the current directory |
|
| 24 |
-EXERCISE_DIR=$(cd $(dirname "$0") && pwd) |
|
| 25 |
-TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) |
|
| 26 |
- |
|
| 27 |
-# Import common functions |
|
| 28 |
-source $TOP_DIR/functions |
|
| 29 |
- |
|
| 30 |
-# Import configuration |
|
| 31 |
-source $TOP_DIR/openrc |
|
| 32 |
- |
|
| 33 |
-# Import exercise configuration |
|
| 34 |
-source $TOP_DIR/exerciserc |
|
| 35 |
- |
|
| 36 |
-# Skip if the hypervisor is not Docker |
|
| 37 |
-[[ "$VIRT_DRIVER" == "docker" ]] || exit 55 |
|
| 38 |
- |
|
| 39 |
-# Import docker functions and declarations |
|
| 40 |
-source $TOP_DIR/lib/nova_plugins/hypervisor-docker |
|
| 41 |
- |
|
| 42 |
-# Image and flavor are ignored but the CLI requires them... |
|
| 43 |
- |
|
| 44 |
-# Instance type to create |
|
| 45 |
-DEFAULT_INSTANCE_TYPE=${DEFAULT_INSTANCE_TYPE:-m1.tiny}
|
|
| 46 |
- |
|
| 47 |
-# Boot this image, use first AMI image if unset |
|
| 48 |
-DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-ami}
|
|
| 49 |
- |
|
| 50 |
-# Instance name |
|
| 51 |
-VM_NAME=ex-docker |
|
| 52 |
- |
|
| 53 |
- |
|
| 54 |
-# Launching a server |
|
| 55 |
-# ================== |
|
| 56 |
- |
|
| 57 |
-# Grab the id of the image to launch |
|
| 58 |
-IMAGE=$(glance image-list | egrep " $DOCKER_IMAGE_NAME:latest " | get_field 1) |
|
| 59 |
-die_if_not_set $LINENO IMAGE "Failure getting image $DOCKER_IMAGE_NAME" |
|
| 60 |
- |
|
| 61 |
-# Select a flavor |
|
| 62 |
-INSTANCE_TYPE=$(nova flavor-list | grep $DEFAULT_INSTANCE_TYPE | get_field 1) |
|
| 63 |
-if [[ -z "$INSTANCE_TYPE" ]]; then |
|
| 64 |
- # grab the first flavor in the list to launch if default doesn't exist |
|
| 65 |
- INSTANCE_TYPE=$(nova flavor-list | head -n 4 | tail -n 1 | get_field 1) |
|
| 66 |
-fi |
|
| 67 |
- |
|
| 68 |
-# Clean-up from previous runs |
|
| 69 |
-nova delete $VM_NAME || true |
|
| 70 |
-if ! timeout $ACTIVE_TIMEOUT sh -c "while nova show $VM_NAME; do sleep 1; done"; then |
|
| 71 |
- die $LINENO "server didn't terminate!" |
|
| 72 |
-fi |
|
| 73 |
- |
|
| 74 |
-# Boot instance |
|
| 75 |
-# ------------- |
|
| 76 |
- |
|
| 77 |
-VM_UUID=$(nova boot --flavor $INSTANCE_TYPE --image $IMAGE $VM_NAME | grep ' id ' | get_field 2) |
|
| 78 |
-die_if_not_set $LINENO VM_UUID "Failure launching $VM_NAME" |
|
| 79 |
- |
|
| 80 |
-# Check that the status is active within ACTIVE_TIMEOUT seconds |
|
| 81 |
-if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then |
|
| 82 |
- die $LINENO "server didn't become active!" |
|
| 83 |
-fi |
|
| 84 |
- |
|
| 85 |
-# Get the instance IP |
|
| 86 |
-IP=$(nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2) |
|
| 87 |
-die_if_not_set $LINENO IP "Failure retrieving IP address" |
|
| 88 |
- |
|
| 89 |
-# Private IPs can be pinged in single node deployments |
|
| 90 |
-ping_check "$PRIVATE_NETWORK_NAME" $IP $BOOT_TIMEOUT |
|
| 91 |
- |
|
| 92 |
-# Clean up |
|
| 93 |
-# -------- |
|
| 94 |
- |
|
| 95 |
-# Delete instance |
|
| 96 |
-nova delete $VM_UUID || die $LINENO "Failure deleting instance $VM_NAME" |
|
| 97 |
-if ! timeout $TERMINATE_TIMEOUT sh -c "while nova list | grep -q $VM_UUID; do sleep 1; done"; then |
|
| 98 |
- die $LINENO "Server $VM_NAME not deleted" |
|
| 99 |
-fi |
|
| 100 |
- |
|
| 101 |
-set +o xtrace |
|
| 102 |
-echo "*********************************************************************" |
|
| 103 |
-echo "SUCCESS: End DevStack Exercise: $0" |
|
| 104 |
-echo "*********************************************************************" |