blob: bfb552dc95cd9f8daddc00cc660798c4a84891a0 [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
Jay Pipes58d34ea2012-04-05 17:19:02 -040050source $TOP_DIR/openrc
Dean Troyerfda65b82011-11-02 12:13:33 -050051
52# Where Openstack code lives
53DEST=${DEST:-/opt/stack}
54
Dean Troyer608bb122012-01-10 14:43:17 -060055TEMPEST_DIR=$DEST/tempest
Jay Pipes678a1882012-04-23 10:56:15 -040056CONFIG_DIR=$TEMPEST_DIR/etc
Dean Troyer608bb122012-01-10 14:43:17 -060057TEMPEST_CONF=$CONFIG_DIR/tempest.conf
Dean Troyer44d8f8f2011-11-23 23:21:06 -060058
Dean Troyerfda65b82011-11-02 12:13:33 -050059# Use the GUEST_IP unless an explicit IP is set by ``HOST_IP``
60HOST_IP=${HOST_IP:-$GUEST_IP}
61# Use the first IP if HOST_IP still is not set
62if [ ! -n "$HOST_IP" ]; then
63 HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
64fi
65
Jay Pipes678a1882012-04-23 10:56:15 -040066# Glance should already contain images to be used in tempest
67# testing. Here we simply look for images stored in Glance
68# and set the appropriate variables for use in the tempest config
69# We ignore ramdisk and kernel images and set the IMAGE_UUID to
70# the first image returned and set IMAGE_UUID_ALT to the second,
71# if there is more than one returned...
Sean Dague0f5da002012-05-03 11:52:55 -040072# ... Also ensure we only take active images, so we don't get snapshots in process
Jay Pipesa1c87382012-04-27 17:46:58 -040073IMAGE_LINES=`glance image-list`
Jay Pipes678a1882012-04-23 10:56:15 -040074IFS="$(echo -e "\n\r")"
75IMAGES=""
76for line in $IMAGE_LINES; do
Sean Dague0f5da002012-05-03 11:52:55 -040077 IMAGES="$IMAGES `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | cut -d' ' -f2`"
Dean Troyer3320c552011-11-23 23:19:10 -060078done
Jay Pipes678a1882012-04-23 10:56:15 -040079# Create array of image UUIDs...
80IFS=" "
81IMAGES=($IMAGES)
82NUM_IMAGES=${#IMAGES[*]}
83echo "Found $NUM_IMAGES images"
84if [[ $NUM_IMAGES -eq 0 ]]; then
85 echo "Found no valid images to use!"
86 exit 1
87fi
88IMAGE_UUID=${IMAGES[0]}
89IMAGE_UUID_ALT=$IMAGE_UUID
90if [[ $NUM_IMAGES -gt 1 ]]; then
91 IMAGE_UUID_ALT=${IMAGES[1]}
Dean Troyer608bb122012-01-10 14:43:17 -060092fi
Dean Troyer3320c552011-11-23 23:19:10 -060093
Jay Pipesd01325f2012-04-04 16:21:33 -040094# Create tempest.conf from tempest.conf.tpl
Sean Dague0f5da002012-05-03 11:52:55 -040095# copy every time, because the image UUIDS are going to change
96cp $TEMPEST_CONF.tpl $TEMPEST_CONF
Jesse Andrewsd7326d22011-11-20 10:02:26 -080097
Jay Pipesb297d2d2012-05-10 11:21:22 -040098ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
99ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete}
100ADMIN_TENANT_NAME=${ADMIN_TENANT:-admin}
101
Jay Pipesd01325f2012-04-04 16:21:33 -0400102IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False}
Jay Pipes678a1882012-04-23 10:56:15 -0400103IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1}
104IDENTITY_PORT=${IDENTITY_PORT:-5000}
105IDENTITY_API_VERSION="v2.0" # Note: need v for now...
Jay Pipesd01325f2012-04-04 16:21:33 -0400106# TODO(jaypipes): This is dumb and needs to be removed
107# from the Tempest configuration file entirely...
108IDENTITY_PATH=${IDENTITY_PATH:-tokens}
109IDENTITY_STRATEGY=${IDENTITY_STRATEGY:-keystone}
110
111# We use regular, non-admin users in Tempest for the USERNAME
112# substitutions and use ADMIN_USERNAME et al for the admin stuff.
113# OS_USERNAME et all should be defined in openrc.
114OS_USERNAME=${OS_USERNAME:-demo}
115OS_TENANT_NAME=${OS_TENANT_NAME:-demo}
Jay Pipesb297d2d2012-05-10 11:21:22 -0400116OS_PASSWORD=${OS_PASSWORD:$ADMIN_PASSWORD}
Jay Pipesd01325f2012-04-04 16:21:33 -0400117
Jay Pipesb297d2d2012-05-10 11:21:22 -0400118# See files/keystone_data.sh where alt_demo user
119# and tenant are set up...
120ALT_USERNAME=${ALT_USERNAME:-alt_demo}
121ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo}
Jay Pipesd01325f2012-04-04 16:21:33 -0400122ALT_PASSWORD=$OS_PASSWORD
Jay Pipesd01325f2012-04-04 16:21:33 -0400123
Jay Pipesd01325f2012-04-04 16:21:33 -0400124# TODO(jaypipes): Support configurable flavor refs here...
125FLAVOR_REF=1
126FLAVOR_REF_ALT=2
127
Jay Pipesd01325f2012-04-04 16:21:33 -0400128# Do any of the following need to be configurable?
129COMPUTE_CATALOG_TYPE=compute
130COMPUTE_CREATE_IMAGE_ENABLED=True
Jay Pipes58d34ea2012-04-05 17:19:02 -0400131COMPUTE_RESIZE_AVAILABLE=False # not supported with QEMU...
Jay Pipesd01325f2012-04-04 16:21:33 -0400132COMPUTE_LOG_LEVEL=ERROR
Jay Pipes58d34ea2012-04-05 17:19:02 -0400133BUILD_INTERVAL=10
134BUILD_TIMEOUT=600
Jay Pipesd01325f2012-04-04 16:21:33 -0400135
Jay Pipesc0e1ef52012-04-30 15:56:13 -0400136# Image test configuration options...
137IMAGE_HOST=${IMAGE_HOST:-127.0.0.1}
138IMAGE_PORT=${IMAGE_PORT:-9292}
139IMAGE_API_VERSION="1"
140
Dean Troyer608bb122012-01-10 14:43:17 -0600141sed -e "
Jay Pipesd01325f2012-04-04 16:21:33 -0400142 s,%IDENTITY_USE_SSL%,$IDENTITY_USE_SSL,g;
Jay Pipes678a1882012-04-23 10:56:15 -0400143 s,%IDENTITY_HOST%,$IDENTITY_HOST,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400144 s,%IDENTITY_PORT%,$IDENTITY_PORT,g;
Jay Pipes678a1882012-04-23 10:56:15 -0400145 s,%IDENTITY_API_VERSION%,$IDENTITY_API_VERSION,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400146 s,%IDENTITY_PATH%,$IDENTITY_PATH,g;
147 s,%IDENTITY_STRATEGY%,$IDENTITY_STRATEGY,g;
148 s,%USERNAME%,$OS_USERNAME,g;
149 s,%PASSWORD%,$OS_PASSWORD,g;
150 s,%TENANT_NAME%,$OS_TENANT_NAME,g;
151 s,%ALT_USERNAME%,$ALT_USERNAME,g;
152 s,%ALT_PASSWORD%,$ALT_PASSWORD,g;
153 s,%ALT_TENANT_NAME%,$ALT_TENANT_NAME,g;
154 s,%COMPUTE_CATALOG_TYPE%,$COMPUTE_CATALOG_TYPE,g;
155 s,%COMPUTE_CREATE_IMAGE_ENABLED%,$COMPUTE_CREATE_IMAGE_ENABLED,g;
156 s,%COMPUTE_RESIZE_AVAILABLE%,$COMPUTE_RESIZE_AVAILABLE,g;
157 s,%COMPUTE_LOG_LEVEL%,$COMPUTE_LOG_LEVEL,g;
Jay Pipes58d34ea2012-04-05 17:19:02 -0400158 s,%BUILD_INTERVAL%,$BUILD_INTERVAL,g;
159 s,%BUILD_TIMEOUT%,$BUILD_TIMEOUT,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400160 s,%IMAGE_ID%,$IMAGE_UUID,g;
161 s,%IMAGE_ID_ALT%,$IMAGE_UUID_ALT,g;
162 s,%FLAVOR_REF%,$FLAVOR_REF,g;
163 s,%FLAVOR_REF_ALT%,$FLAVOR_REF_ALT,g;
Jay Pipesc0e1ef52012-04-30 15:56:13 -0400164 s,%IMAGE_HOST%,$IMAGE_HOST,g;
165 s,%IMAGE_PORT%,$IMAGE_PORT,g;
166 s,%IMAGE_API_VERSION%,$IMAGE_API_VERSION,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400167 s,%ADMIN_USERNAME%,$ADMIN_USERNAME,g;
168 s,%ADMIN_PASSWORD%,$ADMIN_PASSWORD,g;
169 s,%ADMIN_TENANT_NAME%,$ADMIN_TENANT_NAME,g;
Dean Troyer608bb122012-01-10 14:43:17 -0600170" -i $TEMPEST_CONF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800171
Jay Pipes58d34ea2012-04-05 17:19:02 -0400172echo "Created tempest configuration file:"
173cat $TEMPEST_CONF
Jay Pipes58d34ea2012-04-05 17:19:02 -0400174
Jay Pipes678a1882012-04-23 10:56:15 -0400175echo "\n"
176echo "**************************************************"
177echo "Finished Configuring Tempest"
178echo "**************************************************"