blob: 2c069343b2c0e37e4c22adb098d8fd116d86cece [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...
Sean Dague0f5da002012-05-03 11:52:55 -040070# ... Also ensure we only take active images, so we don't get snapshots in process
Jay Pipesa1c87382012-04-27 17:46:58 -040071IMAGE_LINES=`glance image-list`
Jay Pipes678a1882012-04-23 10:56:15 -040072IFS="$(echo -e "\n\r")"
73IMAGES=""
74for line in $IMAGE_LINES; do
Sean Dague0f5da002012-05-03 11:52:55 -040075 IMAGES="$IMAGES `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | grep 'active' | cut -d' ' -f2`"
Dean Troyer3320c552011-11-23 23:19:10 -060076done
Jay Pipes678a1882012-04-23 10:56:15 -040077# Create array of image UUIDs...
78IFS=" "
79IMAGES=($IMAGES)
80NUM_IMAGES=${#IMAGES[*]}
81echo "Found $NUM_IMAGES images"
82if [[ $NUM_IMAGES -eq 0 ]]; then
83 echo "Found no valid images to use!"
84 exit 1
85fi
86IMAGE_UUID=${IMAGES[0]}
87IMAGE_UUID_ALT=$IMAGE_UUID
88if [[ $NUM_IMAGES -gt 1 ]]; then
89 IMAGE_UUID_ALT=${IMAGES[1]}
Dean Troyer608bb122012-01-10 14:43:17 -060090fi
Dean Troyer3320c552011-11-23 23:19:10 -060091
Jay Pipesd01325f2012-04-04 16:21:33 -040092# Create tempest.conf from tempest.conf.tpl
Sean Dague0f5da002012-05-03 11:52:55 -040093# copy every time, because the image UUIDS are going to change
94cp $TEMPEST_CONF.tpl $TEMPEST_CONF
Jesse Andrewsd7326d22011-11-20 10:02:26 -080095
Jay Pipesb297d2d2012-05-10 11:21:22 -040096ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
97ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete}
98ADMIN_TENANT_NAME=${ADMIN_TENANT:-admin}
99
Jay Pipesd01325f2012-04-04 16:21:33 -0400100IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False}
Jay Pipes678a1882012-04-23 10:56:15 -0400101IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1}
102IDENTITY_PORT=${IDENTITY_PORT:-5000}
103IDENTITY_API_VERSION="v2.0" # Note: need v for now...
Jay Pipesd01325f2012-04-04 16:21:33 -0400104# TODO(jaypipes): This is dumb and needs to be removed
105# from the Tempest configuration file entirely...
106IDENTITY_PATH=${IDENTITY_PATH:-tokens}
107IDENTITY_STRATEGY=${IDENTITY_STRATEGY:-keystone}
108
109# We use regular, non-admin users in Tempest for the USERNAME
110# substitutions and use ADMIN_USERNAME et al for the admin stuff.
111# OS_USERNAME et all should be defined in openrc.
112OS_USERNAME=${OS_USERNAME:-demo}
113OS_TENANT_NAME=${OS_TENANT_NAME:-demo}
Jay Pipesb297d2d2012-05-10 11:21:22 -0400114OS_PASSWORD=${OS_PASSWORD:$ADMIN_PASSWORD}
Jay Pipesd01325f2012-04-04 16:21:33 -0400115
Jay Pipesb297d2d2012-05-10 11:21:22 -0400116# See files/keystone_data.sh where alt_demo user
117# and tenant are set up...
118ALT_USERNAME=${ALT_USERNAME:-alt_demo}
119ALT_TENANT_NAME=${ALT_TENANT_NAME:-alt_demo}
Jay Pipesd01325f2012-04-04 16:21:33 -0400120ALT_PASSWORD=$OS_PASSWORD
Jay Pipesd01325f2012-04-04 16:21:33 -0400121
Jay Pipesd01325f2012-04-04 16:21:33 -0400122# TODO(jaypipes): Support configurable flavor refs here...
123FLAVOR_REF=1
124FLAVOR_REF_ALT=2
125
Jay Pipesd01325f2012-04-04 16:21:33 -0400126# 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 "**************************************************"