Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | # |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 3 | # configure_tempest.sh - Build a tempest configuration file from devstack |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 4 | |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 5 | echo "**************************************************" |
| 6 | echo "Configuring Tempest" |
| 7 | echo "**************************************************" |
| 8 | |
| 9 | # This script exits on an error so that errors don't compound and you see |
| 10 | # only the first error that occured. |
| 11 | set -o errexit |
| 12 | |
| 13 | # Print the commands being run so that we can see the command that triggers |
| 14 | # an error. It is also useful for following allowing as the install occurs. |
| 15 | set -o xtrace |
| 16 | |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 17 | function usage { |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 18 | echo "$0 - Build tempest.conf" |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 19 | echo "" |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 20 | echo "Usage: $0" |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 21 | exit 1 |
| 22 | } |
| 23 | |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 24 | if [ "$1" = "-h" ]; then |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 25 | usage |
| 26 | fi |
| 27 | |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 28 | # Keep track of the current directory |
| 29 | TOOLS_DIR=$(cd $(dirname "$0") && pwd) |
Dean Troyer | 7f9aa71 | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 30 | TOP_DIR=$(cd $TOOLS_DIR/..; pwd) |
| 31 | |
| 32 | # Import common functions |
| 33 | . $TOP_DIR/functions |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 34 | |
| 35 | # Abort if localrc is not set |
| 36 | if [ ! -e $TOP_DIR/localrc ]; then |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 37 | echo "You must have a localrc with necessary basic configuration defined before proceeding." |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 38 | exit 1 |
| 39 | fi |
| 40 | |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 41 | # Abort if openrc is not set |
| 42 | if [ ! -e $TOP_DIR/openrc ]; then |
| 43 | echo "You must have an openrc with ALL necessary passwords and credentials defined before proceeding." |
| 44 | exit 1 |
| 45 | fi |
| 46 | |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 47 | # Source params |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 48 | source $TOP_DIR/openrc |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 49 | |
| 50 | # Where Openstack code lives |
| 51 | DEST=${DEST:-/opt/stack} |
| 52 | |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 53 | TEMPEST_DIR=$DEST/tempest |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 54 | CONFIG_DIR=$TEMPEST_DIR/etc |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 55 | TEMPEST_CONF=$CONFIG_DIR/tempest.conf |
Dean Troyer | 44d8f8f | 2011-11-23 23:21:06 -0600 | [diff] [blame] | 56 | |
Dean Troyer | fda65b8 | 2011-11-02 12:13:33 -0500 | [diff] [blame] | 57 | # Use the GUEST_IP unless an explicit IP is set by ``HOST_IP`` |
| 58 | HOST_IP=${HOST_IP:-$GUEST_IP} |
| 59 | # Use the first IP if HOST_IP still is not set |
| 60 | if [ ! -n "$HOST_IP" ]; then |
| 61 | HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'` |
| 62 | fi |
| 63 | |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 64 | # Glance should already contain images to be used in tempest |
| 65 | # testing. Here we simply look for images stored in Glance |
| 66 | # and set the appropriate variables for use in the tempest config |
| 67 | # We ignore ramdisk and kernel images and set the IMAGE_UUID to |
| 68 | # the first image returned and set IMAGE_UUID_ALT to the second, |
| 69 | # if there is more than one returned... |
Jay Pipes | a1c8738 | 2012-04-27 17:46:58 -0400 | [diff] [blame] | 70 | IMAGE_LINES=`glance image-list` |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 71 | IFS="$(echo -e "\n\r")" |
| 72 | IMAGES="" |
| 73 | for line in $IMAGE_LINES; do |
Jay Pipes | a1c8738 | 2012-04-27 17:46:58 -0400 | [diff] [blame] | 74 | IMAGES="$IMAGES `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | cut -d' ' -f2`" |
Dean Troyer | 3320c55 | 2011-11-23 23:19:10 -0600 | [diff] [blame] | 75 | done |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 76 | # Create array of image UUIDs... |
| 77 | IFS=" " |
| 78 | IMAGES=($IMAGES) |
| 79 | NUM_IMAGES=${#IMAGES[*]} |
| 80 | echo "Found $NUM_IMAGES images" |
| 81 | if [[ $NUM_IMAGES -eq 0 ]]; then |
| 82 | echo "Found no valid images to use!" |
| 83 | exit 1 |
| 84 | fi |
| 85 | IMAGE_UUID=${IMAGES[0]} |
| 86 | IMAGE_UUID_ALT=$IMAGE_UUID |
| 87 | if [[ $NUM_IMAGES -gt 1 ]]; then |
| 88 | IMAGE_UUID_ALT=${IMAGES[1]} |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 89 | fi |
Dean Troyer | 3320c55 | 2011-11-23 23:19:10 -0600 | [diff] [blame] | 90 | |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 91 | # Create tempest.conf from tempest.conf.tpl |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 92 | if [[ ! -r $TEMPEST_CONF ]]; then |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 93 | cp $TEMPEST_CONF.tpl $TEMPEST_CONF |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 94 | fi |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 95 | |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 96 | IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False} |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 97 | IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1} |
| 98 | IDENTITY_PORT=${IDENTITY_PORT:-5000} |
| 99 | IDENTITY_API_VERSION="v2.0" # Note: need v for now... |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 100 | # TODO(jaypipes): This is dumb and needs to be removed |
| 101 | # from the Tempest configuration file entirely... |
| 102 | IDENTITY_PATH=${IDENTITY_PATH:-tokens} |
| 103 | IDENTITY_STRATEGY=${IDENTITY_STRATEGY:-keystone} |
| 104 | |
| 105 | # We use regular, non-admin users in Tempest for the USERNAME |
| 106 | # substitutions and use ADMIN_USERNAME et al for the admin stuff. |
| 107 | # OS_USERNAME et all should be defined in openrc. |
| 108 | OS_USERNAME=${OS_USERNAME:-demo} |
| 109 | OS_TENANT_NAME=${OS_TENANT_NAME:-demo} |
| 110 | OS_PASSWORD=${OS_PASSWORD:-secrete} |
| 111 | |
| 112 | # TODO(jaypipes): Support multiple regular user accounts instead |
| 113 | # of using the same regular user account for the alternate user... |
| 114 | ALT_USERNAME=$OS_USERNAME |
| 115 | ALT_PASSWORD=$OS_PASSWORD |
| 116 | ALT_TENANT_NAME=$OS_TENANT_NAME |
| 117 | |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 118 | # TODO(jaypipes): Support configurable flavor refs here... |
| 119 | FLAVOR_REF=1 |
| 120 | FLAVOR_REF_ALT=2 |
| 121 | |
| 122 | ADMIN_USERNAME={$ADMIN_USERNAME:-admin} |
| 123 | ADMIN_PASSWORD={$ADMIN_PASSWORD:-secrete} |
| 124 | ADMIN_TENANT_NAME={$ADMIN_TENANT:-admin} |
| 125 | |
| 126 | # Do any of the following need to be configurable? |
| 127 | COMPUTE_CATALOG_TYPE=compute |
| 128 | COMPUTE_CREATE_IMAGE_ENABLED=True |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 129 | COMPUTE_RESIZE_AVAILABLE=False # not supported with QEMU... |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 130 | COMPUTE_LOG_LEVEL=ERROR |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 131 | BUILD_INTERVAL=10 |
| 132 | BUILD_TIMEOUT=600 |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 133 | |
Jay Pipes | c0e1ef5 | 2012-04-30 15:56:13 -0400 | [diff] [blame^] | 134 | # Image test configuration options... |
| 135 | IMAGE_HOST=${IMAGE_HOST:-127.0.0.1} |
| 136 | IMAGE_PORT=${IMAGE_PORT:-9292} |
| 137 | IMAGE_API_VERSION="1" |
| 138 | |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 139 | sed -e " |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 140 | s,%IDENTITY_USE_SSL%,$IDENTITY_USE_SSL,g; |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 141 | s,%IDENTITY_HOST%,$IDENTITY_HOST,g; |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 142 | s,%IDENTITY_PORT%,$IDENTITY_PORT,g; |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 143 | s,%IDENTITY_API_VERSION%,$IDENTITY_API_VERSION,g; |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 144 | s,%IDENTITY_PATH%,$IDENTITY_PATH,g; |
| 145 | s,%IDENTITY_STRATEGY%,$IDENTITY_STRATEGY,g; |
| 146 | s,%USERNAME%,$OS_USERNAME,g; |
| 147 | s,%PASSWORD%,$OS_PASSWORD,g; |
| 148 | s,%TENANT_NAME%,$OS_TENANT_NAME,g; |
| 149 | s,%ALT_USERNAME%,$ALT_USERNAME,g; |
| 150 | s,%ALT_PASSWORD%,$ALT_PASSWORD,g; |
| 151 | s,%ALT_TENANT_NAME%,$ALT_TENANT_NAME,g; |
| 152 | s,%COMPUTE_CATALOG_TYPE%,$COMPUTE_CATALOG_TYPE,g; |
| 153 | s,%COMPUTE_CREATE_IMAGE_ENABLED%,$COMPUTE_CREATE_IMAGE_ENABLED,g; |
| 154 | s,%COMPUTE_RESIZE_AVAILABLE%,$COMPUTE_RESIZE_AVAILABLE,g; |
| 155 | s,%COMPUTE_LOG_LEVEL%,$COMPUTE_LOG_LEVEL,g; |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 156 | s,%BUILD_INTERVAL%,$BUILD_INTERVAL,g; |
| 157 | s,%BUILD_TIMEOUT%,$BUILD_TIMEOUT,g; |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 158 | s,%IMAGE_ID%,$IMAGE_UUID,g; |
| 159 | s,%IMAGE_ID_ALT%,$IMAGE_UUID_ALT,g; |
| 160 | s,%FLAVOR_REF%,$FLAVOR_REF,g; |
| 161 | s,%FLAVOR_REF_ALT%,$FLAVOR_REF_ALT,g; |
Jay Pipes | c0e1ef5 | 2012-04-30 15:56:13 -0400 | [diff] [blame^] | 162 | s,%IMAGE_HOST%,$IMAGE_HOST,g; |
| 163 | s,%IMAGE_PORT%,$IMAGE_PORT,g; |
| 164 | s,%IMAGE_API_VERSION%,$IMAGE_API_VERSION,g; |
Jay Pipes | d01325f | 2012-04-04 16:21:33 -0400 | [diff] [blame] | 165 | s,%ADMIN_USERNAME%,$ADMIN_USERNAME,g; |
| 166 | s,%ADMIN_PASSWORD%,$ADMIN_PASSWORD,g; |
| 167 | s,%ADMIN_TENANT_NAME%,$ADMIN_TENANT_NAME,g; |
Dean Troyer | 608bb12 | 2012-01-10 14:43:17 -0600 | [diff] [blame] | 168 | " -i $TEMPEST_CONF |
Jesse Andrews | d7326d2 | 2011-11-20 10:02:26 -0800 | [diff] [blame] | 169 | |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 170 | echo "Created tempest configuration file:" |
| 171 | cat $TEMPEST_CONF |
Jay Pipes | 58d34ea | 2012-04-05 17:19:02 -0400 | [diff] [blame] | 172 | |
Jay Pipes | 678a188 | 2012-04-23 10:56:15 -0400 | [diff] [blame] | 173 | echo "\n" |
| 174 | echo "**************************************************" |
| 175 | echo "Finished Configuring Tempest" |
| 176 | echo "**************************************************" |