blob: 22a8c43bdc728bf5bf8ac63296e1211b7b4103f2 [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 Pipes3edd5b42012-07-08 21:04:12 -040098COMPUTE_ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
99COMPUTE_ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete}
100COMPUTE_ADMIN_TENANT_NAME=${ADMIN_TENANT:-admin}
101
102IDENTITY_ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
103IDENTITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete}
104IDENTITY_ADMIN_TENANT_NAME=${ADMIN_TENANT:-admin}
Jay Pipesb297d2d2012-05-10 11:21:22 -0400105
Jay Pipesd01325f2012-04-04 16:21:33 -0400106IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False}
Jay Pipes678a1882012-04-23 10:56:15 -0400107IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1}
108IDENTITY_PORT=${IDENTITY_PORT:-5000}
109IDENTITY_API_VERSION="v2.0" # Note: need v for now...
Jay Pipesd01325f2012-04-04 16:21:33 -0400110# TODO(jaypipes): This is dumb and needs to be removed
111# from the Tempest configuration file entirely...
112IDENTITY_PATH=${IDENTITY_PATH:-tokens}
113IDENTITY_STRATEGY=${IDENTITY_STRATEGY:-keystone}
Jay Pipes3edd5b42012-07-08 21:04:12 -0400114IDENTITY_CATALOG_TYPE=identity
Jay Pipesd01325f2012-04-04 16:21:33 -0400115
116# We use regular, non-admin users in Tempest for the USERNAME
117# substitutions and use ADMIN_USERNAME et al for the admin stuff.
118# OS_USERNAME et all should be defined in openrc.
119OS_USERNAME=${OS_USERNAME:-demo}
120OS_TENANT_NAME=${OS_TENANT_NAME:-demo}
Jay Pipesb297d2d2012-05-10 11:21:22 -0400121OS_PASSWORD=${OS_PASSWORD:$ADMIN_PASSWORD}
Jay Pipesd01325f2012-04-04 16:21:33 -0400122
Jay Pipesb297d2d2012-05-10 11:21:22 -0400123# See files/keystone_data.sh where alt_demo user
124# and tenant are set up...
125ALT_USERNAME=${ALT_USERNAME:-alt_demo}
126ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo}
Jay Pipesd01325f2012-04-04 16:21:33 -0400127ALT_PASSWORD=$OS_PASSWORD
Jay Pipesd01325f2012-04-04 16:21:33 -0400128
Jay Pipesd01325f2012-04-04 16:21:33 -0400129# TODO(jaypipes): Support configurable flavor refs here...
130FLAVOR_REF=1
131FLAVOR_REF_ALT=2
132
Jay Pipesd01325f2012-04-04 16:21:33 -0400133# Do any of the following need to be configurable?
134COMPUTE_CATALOG_TYPE=compute
135COMPUTE_CREATE_IMAGE_ENABLED=True
Jay Pipes3edd5b42012-07-08 21:04:12 -0400136COMPUTE_ALLOW_TENANT_ISOLATION=True
Jay Pipes58d34ea2012-04-05 17:19:02 -0400137COMPUTE_RESIZE_AVAILABLE=False # not supported with QEMU...
Jay Pipesd01325f2012-04-04 16:21:33 -0400138COMPUTE_LOG_LEVEL=ERROR
Jay Pipes3edd5b42012-07-08 21:04:12 -0400139BUILD_INTERVAL=3
140BUILD_TIMEOUT=400
141RUN_SSH=True
142SSH_USER=$OS_USERNAME
143NETWORK_FOR_SSH=private
144IP_VERSION_FOR_SSH=4
145SSH_TIMEOUT=4
Jay Pipesd01325f2012-04-04 16:21:33 -0400146
Jay Pipesc0e1ef52012-04-30 15:56:13 -0400147# Image test configuration options...
148IMAGE_HOST=${IMAGE_HOST:-127.0.0.1}
149IMAGE_PORT=${IMAGE_PORT:-9292}
Jay Pipes3edd5b42012-07-08 21:04:12 -0400150IMAGE_API_VERSION=1
151IMAGE_CATALOG_TYPE=image
152
153# Network API test configuration
154NETWORK_CATALOG_TYPE=network
155NETWORK_API_VERSION=2.0
Jay Pipesc0e1ef52012-04-30 15:56:13 -0400156
Dean Troyer608bb122012-01-10 14:43:17 -0600157sed -e "
Jay Pipesd01325f2012-04-04 16:21:33 -0400158 s,%IDENTITY_USE_SSL%,$IDENTITY_USE_SSL,g;
Jay Pipes678a1882012-04-23 10:56:15 -0400159 s,%IDENTITY_HOST%,$IDENTITY_HOST,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400160 s,%IDENTITY_PORT%,$IDENTITY_PORT,g;
Jay Pipes678a1882012-04-23 10:56:15 -0400161 s,%IDENTITY_API_VERSION%,$IDENTITY_API_VERSION,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400162 s,%IDENTITY_PATH%,$IDENTITY_PATH,g;
163 s,%IDENTITY_STRATEGY%,$IDENTITY_STRATEGY,g;
Jay Pipes3edd5b42012-07-08 21:04:12 -0400164 s,%IDENTITY_CATALOG_TYPE%,$IDENTITY_CATALOG_TYPE,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400165 s,%USERNAME%,$OS_USERNAME,g;
166 s,%PASSWORD%,$OS_PASSWORD,g;
167 s,%TENANT_NAME%,$OS_TENANT_NAME,g;
168 s,%ALT_USERNAME%,$ALT_USERNAME,g;
169 s,%ALT_PASSWORD%,$ALT_PASSWORD,g;
170 s,%ALT_TENANT_NAME%,$ALT_TENANT_NAME,g;
171 s,%COMPUTE_CATALOG_TYPE%,$COMPUTE_CATALOG_TYPE,g;
Jay Pipes3edd5b42012-07-08 21:04:12 -0400172 s,%COMPUTE_ALLOW_TENANT_ISOLATION%,$COMPUTE_ALLOW_TENANT_ISOLATION,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400173 s,%COMPUTE_CREATE_IMAGE_ENABLED%,$COMPUTE_CREATE_IMAGE_ENABLED,g;
174 s,%COMPUTE_RESIZE_AVAILABLE%,$COMPUTE_RESIZE_AVAILABLE,g;
175 s,%COMPUTE_LOG_LEVEL%,$COMPUTE_LOG_LEVEL,g;
Jay Pipes58d34ea2012-04-05 17:19:02 -0400176 s,%BUILD_INTERVAL%,$BUILD_INTERVAL,g;
177 s,%BUILD_TIMEOUT%,$BUILD_TIMEOUT,g;
Jay Pipes3edd5b42012-07-08 21:04:12 -0400178 s,%RUN_SSH%,$RUN_SSH,g;
179 s,%SSH_USER%,$SSH_USER,g;
180 s,%NETWORK_FOR_SSH%,$NETWORK_FOR_SSH,g;
181 s,%IP_VERSION_FOR_SSH%,$IP_VERSION_FOR_SSH,g;
182 s,%SSH_TIMEOUT%,$SSH_TIMEOUT,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400183 s,%IMAGE_ID%,$IMAGE_UUID,g;
184 s,%IMAGE_ID_ALT%,$IMAGE_UUID_ALT,g;
185 s,%FLAVOR_REF%,$FLAVOR_REF,g;
186 s,%FLAVOR_REF_ALT%,$FLAVOR_REF_ALT,g;
Jay Pipesc0e1ef52012-04-30 15:56:13 -0400187 s,%IMAGE_HOST%,$IMAGE_HOST,g;
188 s,%IMAGE_PORT%,$IMAGE_PORT,g;
189 s,%IMAGE_API_VERSION%,$IMAGE_API_VERSION,g;
Jay Pipes3edd5b42012-07-08 21:04:12 -0400190 s,%IMAGE_CATALOG_TYPE%,$IMAGE_CATALOG_TYPE,g;
191 s,%COMPUTE_ADMIN_USERNAME%,$COMPUTE_ADMIN_USERNAME,g;
192 s,%COMPUTE_ADMIN_PASSWORD%,$COMPUTE_ADMIN_PASSWORD,g;
193 s,%COMPUTE_ADMIN_TENANT_NAME%,$COMPUTE_ADMIN_TENANT_NAME,g;
194 s,%IDENTITY_ADMIN_USERNAME%,$IDENTITY_ADMIN_USERNAME,g;
195 s,%IDENTITY_ADMIN_PASSWORD%,$IDENTITY_ADMIN_PASSWORD,g;
196 s,%IDENTITY_ADMIN_TENANT_NAME%,$IDENTITY_ADMIN_TENANT_NAME,g;
197 s,%NETWORK_CATALOG_TYPE%,$NETWORK_CATALOG_TYPE,g;
198 s,%NETWORK_API_VERSION%,$NETWORK_API_VERSION,g;
Dean Troyer608bb122012-01-10 14:43:17 -0600199" -i $TEMPEST_CONF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800200
Jay Pipes58d34ea2012-04-05 17:19:02 -0400201echo "Created tempest configuration file:"
202cat $TEMPEST_CONF
Jay Pipes58d34ea2012-04-05 17:19:02 -0400203
Jay Pipes678a1882012-04-23 10:56:15 -0400204echo "\n"
205echo "**************************************************"
206echo "Finished Configuring Tempest"
207echo "**************************************************"