blob: 070bc0bd9aa93d7f18673f4acd5eba959760ca17 [file] [log] [blame]
Dean Troyerfda65b82011-11-02 12:13:33 -05001#!/usr/bin/env bash
2#
Dean Troyere62ba4d2012-06-27 22:07:34 -05003# **configure_tempest.sh**
4
5# Build a tempest configuration file from devstack
Dean Troyerfda65b82011-11-02 12:13:33 -05006
Jay Pipes678a1882012-04-23 10:56:15 -04007echo "**************************************************"
8echo "Configuring Tempest"
9echo "**************************************************"
10
11# This script exits on an error so that errors don't compound and you see
12# only the first error that occured.
13set -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.
17set -o xtrace
18
Dean Troyerfda65b82011-11-02 12:13:33 -050019function usage {
Dean Troyer608bb122012-01-10 14:43:17 -060020 echo "$0 - Build tempest.conf"
Dean Troyerfda65b82011-11-02 12:13:33 -050021 echo ""
Jay Pipes678a1882012-04-23 10:56:15 -040022 echo "Usage: $0"
Dean Troyerfda65b82011-11-02 12:13:33 -050023 exit 1
24}
25
Dean Troyer44d8f8f2011-11-23 23:21:06 -060026if [ "$1" = "-h" ]; then
Dean Troyerfda65b82011-11-02 12:13:33 -050027 usage
28fi
29
Dean Troyerfda65b82011-11-02 12:13:33 -050030# Keep track of the current directory
31TOOLS_DIR=$(cd $(dirname "$0") && pwd)
Dean Troyer7f9aa712012-01-31 12:11:56 -060032TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
33
34# Import common functions
35. $TOP_DIR/functions
Dean Troyerfda65b82011-11-02 12:13:33 -050036
37# Abort if localrc is not set
38if [ ! -e $TOP_DIR/localrc ]; then
Jay Pipes58d34ea2012-04-05 17:19:02 -040039 echo "You must have a localrc with necessary basic configuration defined before proceeding."
Dean Troyerfda65b82011-11-02 12:13:33 -050040 exit 1
41fi
42
Jay Pipes58d34ea2012-04-05 17:19:02 -040043# Abort if openrc is not set
44if [ ! -e $TOP_DIR/openrc ]; then
45 echo "You must have an openrc with ALL necessary passwords and credentials defined before proceeding."
46 exit 1
47fi
48
Jay Pipes678a1882012-04-23 10:56:15 -040049# Source params
Matthew Treinish52330642012-11-07 15:00:01 -050050source $TOP_DIR/lib/database
Jay Pipes58d34ea2012-04-05 17:19:02 -040051source $TOP_DIR/openrc
Dean Troyerfda65b82011-11-02 12:13:33 -050052
53# Where Openstack code lives
54DEST=${DEST:-/opt/stack}
55
Jay Pipes4ba6eeb2012-08-01 11:55:12 -040056NOVA_SOURCE_DIR=$DEST/nova
Dean Troyer608bb122012-01-10 14:43:17 -060057TEMPEST_DIR=$DEST/tempest
Jay Pipes678a1882012-04-23 10:56:15 -040058CONFIG_DIR=$TEMPEST_DIR/etc
Dean Troyer608bb122012-01-10 14:43:17 -060059TEMPEST_CONF=$CONFIG_DIR/tempest.conf
Dean Troyer44d8f8f2011-11-23 23:21:06 -060060
Dean Troyerfda65b82011-11-02 12:13:33 -050061# Use the GUEST_IP unless an explicit IP is set by ``HOST_IP``
62HOST_IP=${HOST_IP:-$GUEST_IP}
63# Use the first IP if HOST_IP still is not set
64if [ ! -n "$HOST_IP" ]; then
65 HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
66fi
67
Jay Pipes678a1882012-04-23 10:56:15 -040068# Glance should already contain images to be used in tempest
69# testing. Here we simply look for images stored in Glance
70# and set the appropriate variables for use in the tempest config
Devananda van der Veenc0c6f002012-07-06 17:49:12 -070071# We ignore ramdisk and kernel images, look for the default image
72# DEFAULT_IMAGE_NAME. If not found, we set the IMAGE_UUID to the
73# first image returned and set IMAGE_UUID_ALT to the second,
Jay Pipes678a1882012-04-23 10:56:15 -040074# if there is more than one returned...
Sean Dague0f5da002012-05-03 11:52:55 -040075# ... Also ensure we only take active images, so we don't get snapshots in process
Jay Pipesa1c87382012-04-27 17:46:58 -040076IMAGE_LINES=`glance image-list`
Jay Pipes678a1882012-04-23 10:56:15 -040077IFS="$(echo -e "\n\r")"
78IMAGES=""
79for line in $IMAGE_LINES; do
Devananda van der Veenc0c6f002012-07-06 17:49:12 -070080 if [ -z $DEFAULT_IMAGE_NAME ]; then
81 IMAGES="$IMAGES `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | cut -d' ' -f2`"
82 else
83 IMAGES="$IMAGES `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | grep "$DEFAULT_IMAGE_NAME" | cut -d' ' -f2`"
84 fi
Dean Troyer3320c552011-11-23 23:19:10 -060085done
Jay Pipes678a1882012-04-23 10:56:15 -040086# Create array of image UUIDs...
87IFS=" "
88IMAGES=($IMAGES)
89NUM_IMAGES=${#IMAGES[*]}
90echo "Found $NUM_IMAGES images"
91if [[ $NUM_IMAGES -eq 0 ]]; then
92 echo "Found no valid images to use!"
93 exit 1
94fi
95IMAGE_UUID=${IMAGES[0]}
96IMAGE_UUID_ALT=$IMAGE_UUID
97if [[ $NUM_IMAGES -gt 1 ]]; then
98 IMAGE_UUID_ALT=${IMAGES[1]}
Dean Troyer608bb122012-01-10 14:43:17 -060099fi
Dean Troyer3320c552011-11-23 23:19:10 -0600100
Jay Pipesd01325f2012-04-04 16:21:33 -0400101# Create tempest.conf from tempest.conf.tpl
Sean Dague0f5da002012-05-03 11:52:55 -0400102# copy every time, because the image UUIDS are going to change
103cp $TEMPEST_CONF.tpl $TEMPEST_CONF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800104
Jay Pipes3edd5b42012-07-08 21:04:12 -0400105COMPUTE_ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
106COMPUTE_ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete}
107COMPUTE_ADMIN_TENANT_NAME=${ADMIN_TENANT:-admin}
108
109IDENTITY_ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
110IDENTITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete}
111IDENTITY_ADMIN_TENANT_NAME=${ADMIN_TENANT:-admin}
Jay Pipesb297d2d2012-05-10 11:21:22 -0400112
Jay Pipesd01325f2012-04-04 16:21:33 -0400113IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False}
Jay Pipes678a1882012-04-23 10:56:15 -0400114IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1}
115IDENTITY_PORT=${IDENTITY_PORT:-5000}
116IDENTITY_API_VERSION="v2.0" # Note: need v for now...
Jay Pipesd01325f2012-04-04 16:21:33 -0400117# TODO(jaypipes): This is dumb and needs to be removed
118# from the Tempest configuration file entirely...
119IDENTITY_PATH=${IDENTITY_PATH:-tokens}
120IDENTITY_STRATEGY=${IDENTITY_STRATEGY:-keystone}
Jay Pipes3edd5b42012-07-08 21:04:12 -0400121IDENTITY_CATALOG_TYPE=identity
Jay Pipesd01325f2012-04-04 16:21:33 -0400122
123# We use regular, non-admin users in Tempest for the USERNAME
124# substitutions and use ADMIN_USERNAME et al for the admin stuff.
125# OS_USERNAME et all should be defined in openrc.
126OS_USERNAME=${OS_USERNAME:-demo}
127OS_TENANT_NAME=${OS_TENANT_NAME:-demo}
Jay Pipesb297d2d2012-05-10 11:21:22 -0400128OS_PASSWORD=${OS_PASSWORD:$ADMIN_PASSWORD}
Jay Pipesd01325f2012-04-04 16:21:33 -0400129
Jay Pipesb297d2d2012-05-10 11:21:22 -0400130# See files/keystone_data.sh where alt_demo user
131# and tenant are set up...
132ALT_USERNAME=${ALT_USERNAME:-alt_demo}
133ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo}
Jay Pipesd01325f2012-04-04 16:21:33 -0400134ALT_PASSWORD=$OS_PASSWORD
Jay Pipesd01325f2012-04-04 16:21:33 -0400135
Devananda van der Veenc0c6f002012-07-06 17:49:12 -0700136# Check Nova for existing flavors and, if set, look for the
137# DEFAULT_INSTANCE_TYPE and use that. Otherwise, just use the first flavor.
138FLAVOR_LINES=`nova flavor-list`
139IFS="$(echo -e "\n\r")"
140FLAVORS=""
141for line in $FLAVOR_LINES; do
142 if [ -z $DEFAULT_INSTANCE_TYPE ]; then
Devananda van der Veen27004922012-08-15 16:38:29 -0700143 FLAVORS="$FLAVORS `echo $line | grep -v "^\(|\s*ID\|+--\)" | cut -d' ' -f2`"
Devananda van der Veenc0c6f002012-07-06 17:49:12 -0700144 else
Devananda van der Veen27004922012-08-15 16:38:29 -0700145 FLAVORS="$FLAVORS `echo $line | grep -v "^\(|\s*ID\|+--\)" | grep "$DEFAULT_INSTANCE_TYPE" | cut -d' ' -f2`"
Devananda van der Veenc0c6f002012-07-06 17:49:12 -0700146 fi
147done
148IFS=" "
149FLAVORS=($FLAVORS)
150NUM_FLAVORS=${#FLAVORS[*]}
151echo "Found $NUM_FLAVORS flavors"
152if [[ $NUM_FLAVORS -eq 0 ]]; then
153 echo "Found no valid flavors to use!"
154 exit 1
155fi
156FLAVOR_REF=${FLAVORS[0]}
157FLAVOR_REF_ALT=$FLAVOR_REF
158if [[ $NUM_FLAVORS -gt 1 ]]; then
159 FLAVOR_REF_ALT=${FLAVORS[1]}
160fi
Jay Pipesd01325f2012-04-04 16:21:33 -0400161
Jay Pipesd01325f2012-04-04 16:21:33 -0400162# Do any of the following need to be configurable?
163COMPUTE_CATALOG_TYPE=compute
164COMPUTE_CREATE_IMAGE_ENABLED=True
Jay Pipes3edd5b42012-07-08 21:04:12 -0400165COMPUTE_ALLOW_TENANT_ISOLATION=True
Dan Smith88ae3762012-09-04 10:18:18 -0700166COMPUTE_ALLOW_TENANT_REUSE=True
Jay Pipes4ba6eeb2012-08-01 11:55:12 -0400167COMPUTE_RESIZE_AVAILABLE=False
David Kranz686f98e2012-07-24 09:15:44 -0400168COMPUTE_CHANGE_PASSWORD_AVAILABLE=False # not supported with QEMU...
Jay Pipesd01325f2012-04-04 16:21:33 -0400169COMPUTE_LOG_LEVEL=ERROR
Jay Pipes3edd5b42012-07-08 21:04:12 -0400170BUILD_INTERVAL=3
171BUILD_TIMEOUT=400
Rohit Karajgi2eb9a132012-08-08 02:34:51 -0700172COMPUTE_BUILD_INTERVAL=3
173COMPUTE_BUILD_TIMEOUT=400
174VOLUME_BUILD_INTERVAL=3
175VOLUME_BUILD_TIMEOUT=300
Jay Pipes3edd5b42012-07-08 21:04:12 -0400176RUN_SSH=True
Devananda van der Veenc0c6f002012-07-06 17:49:12 -0700177# Check for DEFAULT_INSTANCE_USER and try to connect with that account
178SSH_USER=${DEFAULT_INSTANCE_USER:-$OS_USERNAME}
Jay Pipes3edd5b42012-07-08 21:04:12 -0400179NETWORK_FOR_SSH=private
180IP_VERSION_FOR_SSH=4
181SSH_TIMEOUT=4
Jay Pipes4ba6eeb2012-08-01 11:55:12 -0400182# Whitebox testing configuration for Compute...
183COMPUTE_WHITEBOX_ENABLED=True
184COMPUTE_SOURCE_DIR=$NOVA_SOURCE_DIR
185COMPUTE_BIN_DIR=/usr/bin/nova
186COMPUTE_CONFIG_PATH=/etc/nova/nova.conf
187# TODO(jaypipes): Create the key file here... right now, no whitebox
188# tests actually use a key.
189COMPUTE_PATH_TO_PRIVATE_KEY=$TEMPEST_DIR/id_rsa
Matthew Treinish52330642012-11-07 15:00:01 -0500190COMPUTE_DB_URI=$BASE_SQL_CONN/nova
Jay Pipesd01325f2012-04-04 16:21:33 -0400191
Jay Pipesc0e1ef52012-04-30 15:56:13 -0400192# Image test configuration options...
193IMAGE_HOST=${IMAGE_HOST:-127.0.0.1}
194IMAGE_PORT=${IMAGE_PORT:-9292}
Jay Pipes3edd5b42012-07-08 21:04:12 -0400195IMAGE_API_VERSION=1
196IMAGE_CATALOG_TYPE=image
197
198# Network API test configuration
199NETWORK_CATALOG_TYPE=network
200NETWORK_API_VERSION=2.0
Jay Pipesc0e1ef52012-04-30 15:56:13 -0400201
Rohit Karajgi5ef90472012-07-31 06:20:35 -0700202# Volume API test configuration
203VOLUME_CATALOG_TYPE=volume
204
Mate Lakat32cce9e2012-10-05 12:27:51 +0100205# Live migration
206LIVE_MIGRATION_AVAILABLE=${LIVE_MIGRATION_AVAILABLE:-False}
207USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION=${USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION:-False}
208
Dean Troyer608bb122012-01-10 14:43:17 -0600209sed -e "
Jay Pipesd01325f2012-04-04 16:21:33 -0400210 s,%IDENTITY_USE_SSL%,$IDENTITY_USE_SSL,g;
Jay Pipes678a1882012-04-23 10:56:15 -0400211 s,%IDENTITY_HOST%,$IDENTITY_HOST,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400212 s,%IDENTITY_PORT%,$IDENTITY_PORT,g;
Jay Pipes678a1882012-04-23 10:56:15 -0400213 s,%IDENTITY_API_VERSION%,$IDENTITY_API_VERSION,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400214 s,%IDENTITY_PATH%,$IDENTITY_PATH,g;
215 s,%IDENTITY_STRATEGY%,$IDENTITY_STRATEGY,g;
Jay Pipes3edd5b42012-07-08 21:04:12 -0400216 s,%IDENTITY_CATALOG_TYPE%,$IDENTITY_CATALOG_TYPE,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400217 s,%USERNAME%,$OS_USERNAME,g;
218 s,%PASSWORD%,$OS_PASSWORD,g;
219 s,%TENANT_NAME%,$OS_TENANT_NAME,g;
220 s,%ALT_USERNAME%,$ALT_USERNAME,g;
221 s,%ALT_PASSWORD%,$ALT_PASSWORD,g;
222 s,%ALT_TENANT_NAME%,$ALT_TENANT_NAME,g;
223 s,%COMPUTE_CATALOG_TYPE%,$COMPUTE_CATALOG_TYPE,g;
Jay Pipes3edd5b42012-07-08 21:04:12 -0400224 s,%COMPUTE_ALLOW_TENANT_ISOLATION%,$COMPUTE_ALLOW_TENANT_ISOLATION,g;
Dan Smith88ae3762012-09-04 10:18:18 -0700225 s,%COMPUTE_ALLOW_TENANT_REUSE%,$COMPUTE_ALLOW_TENANT_REUSE,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400226 s,%COMPUTE_CREATE_IMAGE_ENABLED%,$COMPUTE_CREATE_IMAGE_ENABLED,g;
227 s,%COMPUTE_RESIZE_AVAILABLE%,$COMPUTE_RESIZE_AVAILABLE,g;
David Kranz686f98e2012-07-24 09:15:44 -0400228 s,%COMPUTE_CHANGE_PASSWORD_AVAILABLE%,$COMPUTE_CHANGE_PASSWORD_AVAILABLE,g;
Jay Pipes4ba6eeb2012-08-01 11:55:12 -0400229 s,%COMPUTE_WHITEBOX_ENABLED%,$COMPUTE_WHITEBOX_ENABLED,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400230 s,%COMPUTE_LOG_LEVEL%,$COMPUTE_LOG_LEVEL,g;
Jay Pipes58d34ea2012-04-05 17:19:02 -0400231 s,%BUILD_INTERVAL%,$BUILD_INTERVAL,g;
232 s,%BUILD_TIMEOUT%,$BUILD_TIMEOUT,g;
Rohit Karajgi2eb9a132012-08-08 02:34:51 -0700233 s,%COMPUTE_BUILD_INTERVAL%,$COMPUTE_BUILD_INTERVAL,g;
234 s,%COMPUTE_BUILD_TIMEOUT%,$COMPUTE_BUILD_TIMEOUT,g;
Jay Pipes3edd5b42012-07-08 21:04:12 -0400235 s,%RUN_SSH%,$RUN_SSH,g;
236 s,%SSH_USER%,$SSH_USER,g;
237 s,%NETWORK_FOR_SSH%,$NETWORK_FOR_SSH,g;
238 s,%IP_VERSION_FOR_SSH%,$IP_VERSION_FOR_SSH,g;
239 s,%SSH_TIMEOUT%,$SSH_TIMEOUT,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400240 s,%IMAGE_ID%,$IMAGE_UUID,g;
241 s,%IMAGE_ID_ALT%,$IMAGE_UUID_ALT,g;
242 s,%FLAVOR_REF%,$FLAVOR_REF,g;
243 s,%FLAVOR_REF_ALT%,$FLAVOR_REF_ALT,g;
Jay Pipes4ba6eeb2012-08-01 11:55:12 -0400244 s,%COMPUTE_CONFIG_PATH%,$COMPUTE_CONFIG_PATH,g;
245 s,%COMPUTE_SOURCE_DIR%,$COMPUTE_SOURCE_DIR,g;
246 s,%COMPUTE_BIN_DIR%,$COMPUTE_BIN_DIR,g;
247 s,%COMPUTE_PATH_TO_PRIVATE_KEY%,$COMPUTE_PATH_TO_PRIVATE_KEY,g;
248 s,%COMPUTE_DB_URI%,$COMPUTE_DB_URI,g;
Jay Pipesc0e1ef52012-04-30 15:56:13 -0400249 s,%IMAGE_HOST%,$IMAGE_HOST,g;
250 s,%IMAGE_PORT%,$IMAGE_PORT,g;
251 s,%IMAGE_API_VERSION%,$IMAGE_API_VERSION,g;
Jay Pipes3edd5b42012-07-08 21:04:12 -0400252 s,%IMAGE_CATALOG_TYPE%,$IMAGE_CATALOG_TYPE,g;
253 s,%COMPUTE_ADMIN_USERNAME%,$COMPUTE_ADMIN_USERNAME,g;
254 s,%COMPUTE_ADMIN_PASSWORD%,$COMPUTE_ADMIN_PASSWORD,g;
255 s,%COMPUTE_ADMIN_TENANT_NAME%,$COMPUTE_ADMIN_TENANT_NAME,g;
256 s,%IDENTITY_ADMIN_USERNAME%,$IDENTITY_ADMIN_USERNAME,g;
257 s,%IDENTITY_ADMIN_PASSWORD%,$IDENTITY_ADMIN_PASSWORD,g;
258 s,%IDENTITY_ADMIN_TENANT_NAME%,$IDENTITY_ADMIN_TENANT_NAME,g;
259 s,%NETWORK_CATALOG_TYPE%,$NETWORK_CATALOG_TYPE,g;
260 s,%NETWORK_API_VERSION%,$NETWORK_API_VERSION,g;
Rohit Karajgi5ef90472012-07-31 06:20:35 -0700261 s,%VOLUME_CATALOG_TYPE%,$VOLUME_CATALOG_TYPE,g;
Rohit Karajgi2eb9a132012-08-08 02:34:51 -0700262 s,%VOLUME_BUILD_INTERVAL%,$VOLUME_BUILD_INTERVAL,g;
263 s,%VOLUME_BUILD_TIMEOUT%,$VOLUME_BUILD_TIMEOUT,g;
Mate Lakat32cce9e2012-10-05 12:27:51 +0100264 s,%LIVE_MIGRATION_AVAILABLE%,$LIVE_MIGRATION_AVAILABLE,g;
265 s,%USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION%,$USE_BLOCK_MIGRATION_FOR_LIVE_MIGRATION,g;
Dean Troyer608bb122012-01-10 14:43:17 -0600266" -i $TEMPEST_CONF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800267
Jay Pipes58d34ea2012-04-05 17:19:02 -0400268echo "Created tempest configuration file:"
269cat $TEMPEST_CONF
Jay Pipes58d34ea2012-04-05 17:19:02 -0400270
Jay Pipes678a1882012-04-23 10:56:15 -0400271echo "\n"
272echo "**************************************************"
273echo "Finished Configuring Tempest"
274echo "**************************************************"