blob: 99c501289778ce34c6deb108168aaf44c6dc4397 [file] [log] [blame]
Dean Troyerfda65b82011-11-02 12:13:33 -05001#!/usr/bin/env bash
2#
Dean Troyer608bb122012-01-10 14:43:17 -06003# configure_tempest.sh - Build a tempest configuration file from devstack
Dean Troyerfda65b82011-11-02 12:13:33 -05004
Jay Pipes678a1882012-04-23 10:56:15 -04005echo "**************************************************"
6echo "Configuring Tempest"
7echo "**************************************************"
8
9# This script exits on an error so that errors don't compound and you see
10# only the first error that occured.
11set -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.
15set -o xtrace
16
Dean Troyerfda65b82011-11-02 12:13:33 -050017function usage {
Dean Troyer608bb122012-01-10 14:43:17 -060018 echo "$0 - Build tempest.conf"
Dean Troyerfda65b82011-11-02 12:13:33 -050019 echo ""
Jay Pipes678a1882012-04-23 10:56:15 -040020 echo "Usage: $0"
Dean Troyerfda65b82011-11-02 12:13:33 -050021 exit 1
22}
23
Dean Troyer44d8f8f2011-11-23 23:21:06 -060024if [ "$1" = "-h" ]; then
Dean Troyerfda65b82011-11-02 12:13:33 -050025 usage
26fi
27
Dean Troyerfda65b82011-11-02 12:13:33 -050028# Keep track of the current directory
29TOOLS_DIR=$(cd $(dirname "$0") && pwd)
Dean Troyer7f9aa712012-01-31 12:11:56 -060030TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
31
32# Import common functions
33. $TOP_DIR/functions
Dean Troyerfda65b82011-11-02 12:13:33 -050034
35# Abort if localrc is not set
36if [ ! -e $TOP_DIR/localrc ]; then
Jay Pipes58d34ea2012-04-05 17:19:02 -040037 echo "You must have a localrc with necessary basic configuration defined before proceeding."
Dean Troyerfda65b82011-11-02 12:13:33 -050038 exit 1
39fi
40
Jay Pipes58d34ea2012-04-05 17:19:02 -040041# Abort if openrc is not set
42if [ ! -e $TOP_DIR/openrc ]; then
43 echo "You must have an openrc with ALL necessary passwords and credentials defined before proceeding."
44 exit 1
45fi
46
Jay Pipes678a1882012-04-23 10:56:15 -040047# Source params
Jay Pipes58d34ea2012-04-05 17:19:02 -040048source $TOP_DIR/openrc
Dean Troyerfda65b82011-11-02 12:13:33 -050049
50# Where Openstack code lives
51DEST=${DEST:-/opt/stack}
52
Dean Troyer608bb122012-01-10 14:43:17 -060053TEMPEST_DIR=$DEST/tempest
Jay Pipes678a1882012-04-23 10:56:15 -040054CONFIG_DIR=$TEMPEST_DIR/etc
Dean Troyer608bb122012-01-10 14:43:17 -060055TEMPEST_CONF=$CONFIG_DIR/tempest.conf
Dean Troyer44d8f8f2011-11-23 23:21:06 -060056
Dean Troyerfda65b82011-11-02 12:13:33 -050057# Use the GUEST_IP unless an explicit IP is set by ``HOST_IP``
58HOST_IP=${HOST_IP:-$GUEST_IP}
59# Use the first IP if HOST_IP still is not set
60if [ ! -n "$HOST_IP" ]; then
61 HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
62fi
63
Jay Pipes678a1882012-04-23 10:56:15 -040064# 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 Pipesa1c87382012-04-27 17:46:58 -040070IMAGE_LINES=`glance image-list`
Jay Pipes678a1882012-04-23 10:56:15 -040071IFS="$(echo -e "\n\r")"
72IMAGES=""
73for line in $IMAGE_LINES; do
Jay Pipesa1c87382012-04-27 17:46:58 -040074 IMAGES="$IMAGES `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | cut -d' ' -f2`"
Dean Troyer3320c552011-11-23 23:19:10 -060075done
Jay Pipes678a1882012-04-23 10:56:15 -040076# Create array of image UUIDs...
77IFS=" "
78IMAGES=($IMAGES)
79NUM_IMAGES=${#IMAGES[*]}
80echo "Found $NUM_IMAGES images"
81if [[ $NUM_IMAGES -eq 0 ]]; then
82 echo "Found no valid images to use!"
83 exit 1
84fi
85IMAGE_UUID=${IMAGES[0]}
86IMAGE_UUID_ALT=$IMAGE_UUID
87if [[ $NUM_IMAGES -gt 1 ]]; then
88 IMAGE_UUID_ALT=${IMAGES[1]}
Dean Troyer608bb122012-01-10 14:43:17 -060089fi
Dean Troyer3320c552011-11-23 23:19:10 -060090
Jay Pipesd01325f2012-04-04 16:21:33 -040091# Create tempest.conf from tempest.conf.tpl
Dean Troyer608bb122012-01-10 14:43:17 -060092if [[ ! -r $TEMPEST_CONF ]]; then
Jay Pipesd01325f2012-04-04 16:21:33 -040093 cp $TEMPEST_CONF.tpl $TEMPEST_CONF
Dean Troyer608bb122012-01-10 14:43:17 -060094fi
Jesse Andrewsd7326d22011-11-20 10:02:26 -080095
Jay Pipesd01325f2012-04-04 16:21:33 -040096IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False}
Jay Pipes678a1882012-04-23 10:56:15 -040097IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1}
98IDENTITY_PORT=${IDENTITY_PORT:-5000}
99IDENTITY_API_VERSION="v2.0" # Note: need v for now...
Jay Pipesd01325f2012-04-04 16:21:33 -0400100# TODO(jaypipes): This is dumb and needs to be removed
101# from the Tempest configuration file entirely...
102IDENTITY_PATH=${IDENTITY_PATH:-tokens}
103IDENTITY_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.
108OS_USERNAME=${OS_USERNAME:-demo}
109OS_TENANT_NAME=${OS_TENANT_NAME:-demo}
110OS_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...
114ALT_USERNAME=$OS_USERNAME
115ALT_PASSWORD=$OS_PASSWORD
116ALT_TENANT_NAME=$OS_TENANT_NAME
117
Jay Pipesd01325f2012-04-04 16:21:33 -0400118# TODO(jaypipes): Support configurable flavor refs here...
119FLAVOR_REF=1
120FLAVOR_REF_ALT=2
121
122ADMIN_USERNAME={$ADMIN_USERNAME:-admin}
123ADMIN_PASSWORD={$ADMIN_PASSWORD:-secrete}
124ADMIN_TENANT_NAME={$ADMIN_TENANT:-admin}
125
126# Do any of the following need to be configurable?
127COMPUTE_CATALOG_TYPE=compute
128COMPUTE_CREATE_IMAGE_ENABLED=True
Jay Pipes58d34ea2012-04-05 17:19:02 -0400129COMPUTE_RESIZE_AVAILABLE=False # not supported with QEMU...
Jay Pipesd01325f2012-04-04 16:21:33 -0400130COMPUTE_LOG_LEVEL=ERROR
Jay Pipes58d34ea2012-04-05 17:19:02 -0400131BUILD_INTERVAL=10
132BUILD_TIMEOUT=600
Jay Pipesd01325f2012-04-04 16:21:33 -0400133
Jay Pipesc0e1ef52012-04-30 15:56:13 -0400134# Image test configuration options...
135IMAGE_HOST=${IMAGE_HOST:-127.0.0.1}
136IMAGE_PORT=${IMAGE_PORT:-9292}
137IMAGE_API_VERSION="1"
138
Dean Troyer608bb122012-01-10 14:43:17 -0600139sed -e "
Jay Pipesd01325f2012-04-04 16:21:33 -0400140 s,%IDENTITY_USE_SSL%,$IDENTITY_USE_SSL,g;
Jay Pipes678a1882012-04-23 10:56:15 -0400141 s,%IDENTITY_HOST%,$IDENTITY_HOST,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400142 s,%IDENTITY_PORT%,$IDENTITY_PORT,g;
Jay Pipes678a1882012-04-23 10:56:15 -0400143 s,%IDENTITY_API_VERSION%,$IDENTITY_API_VERSION,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400144 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 Pipes58d34ea2012-04-05 17:19:02 -0400156 s,%BUILD_INTERVAL%,$BUILD_INTERVAL,g;
157 s,%BUILD_TIMEOUT%,$BUILD_TIMEOUT,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400158 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 Pipesc0e1ef52012-04-30 15:56:13 -0400162 s,%IMAGE_HOST%,$IMAGE_HOST,g;
163 s,%IMAGE_PORT%,$IMAGE_PORT,g;
164 s,%IMAGE_API_VERSION%,$IMAGE_API_VERSION,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400165 s,%ADMIN_USERNAME%,$ADMIN_USERNAME,g;
166 s,%ADMIN_PASSWORD%,$ADMIN_PASSWORD,g;
167 s,%ADMIN_TENANT_NAME%,$ADMIN_TENANT_NAME,g;
Dean Troyer608bb122012-01-10 14:43:17 -0600168" -i $TEMPEST_CONF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800169
Jay Pipes58d34ea2012-04-05 17:19:02 -0400170echo "Created tempest configuration file:"
171cat $TEMPEST_CONF
Jay Pipes58d34ea2012-04-05 17:19:02 -0400172
Jay Pipes678a1882012-04-23 10:56:15 -0400173echo "\n"
174echo "**************************************************"
175echo "Finished Configuring Tempest"
176echo "**************************************************"