blob: 6ba301f7047ece07a70cd48958eaf03a204a02be [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
5function usage {
Dean Troyer608bb122012-01-10 14:43:17 -06006 echo "$0 - Build tempest.conf"
Dean Troyerfda65b82011-11-02 12:13:33 -05007 echo ""
Dean Troyer44d8f8f2011-11-23 23:21:06 -06008 echo "Usage: $0 [configdir]"
Dean Troyerfda65b82011-11-02 12:13:33 -05009 exit 1
10}
11
Dean Troyer44d8f8f2011-11-23 23:21:06 -060012if [ "$1" = "-h" ]; then
Dean Troyerfda65b82011-11-02 12:13:33 -050013 usage
14fi
15
Dean Troyerfda65b82011-11-02 12:13:33 -050016# Clean up any resources that may be in use
17cleanup() {
18 set +o errexit
19
20 # Mop up temporary files
Jesse Andrewsd7326d22011-11-20 10:02:26 -080021 if [ -n "$CONFIG_INI_TMP" -a -e "$CONFIG_INI_TMP" ]; then
22 rm -f $CONFIG_INI_TMP
Dean Troyerfda65b82011-11-02 12:13:33 -050023 fi
24
25 # Kill ourselves to signal any calling process
26 trap 2; kill -2 $$
27}
28
Jesse Andrewsd7326d22011-11-20 10:02:26 -080029trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
Dean Troyerfda65b82011-11-02 12:13:33 -050030
31# Keep track of the current directory
32TOOLS_DIR=$(cd $(dirname "$0") && pwd)
Dean Troyer7f9aa712012-01-31 12:11:56 -060033TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
34
35# Import common functions
36. $TOP_DIR/functions
Dean Troyerfda65b82011-11-02 12:13:33 -050037
38# Abort if localrc is not set
39if [ ! -e $TOP_DIR/localrc ]; then
Jay Pipes58d34ea2012-04-05 17:19:02 -040040 echo "You must have a localrc with necessary basic configuration defined before proceeding."
Dean Troyerfda65b82011-11-02 12:13:33 -050041 exit 1
42fi
43
Jay Pipes58d34ea2012-04-05 17:19:02 -040044# Abort if openrc is not set
45if [ ! -e $TOP_DIR/openrc ]; then
46 echo "You must have an openrc with ALL necessary passwords and credentials defined before proceeding."
47 exit 1
48fi
49
50# Source params. openrc sources stackrc which sources localrc
51source $TOP_DIR/openrc
Dean Troyerfda65b82011-11-02 12:13:33 -050052
Dean Troyer608bb122012-01-10 14:43:17 -060053# Set defaults not configured by stackrc
54TENANT=${TENANT:-admin}
55USERNAME=${USERNAME:-admin}
56IDENTITY_HOST=${IDENTITY_HOST:-$HOST_IP}
57IDENTITY_PORT=${IDENTITY_PORT:-5000}
58IDENTITY_API_VERSION=${IDENTITY_API_VERSION:-2.0}
59
Dean Troyerfda65b82011-11-02 12:13:33 -050060# Where Openstack code lives
61DEST=${DEST:-/opt/stack}
62
Dean Troyer608bb122012-01-10 14:43:17 -060063TEMPEST_DIR=$DEST/tempest
Dean Troyer44d8f8f2011-11-23 23:21:06 -060064
Dean Troyer608bb122012-01-10 14:43:17 -060065CONFIG_DIR=${1:-$TEMPEST_DIR/etc}
Dean Troyer44d8f8f2011-11-23 23:21:06 -060066CONFIG_INI=$CONFIG_DIR/config.ini
Dean Troyer608bb122012-01-10 14:43:17 -060067TEMPEST_CONF=$CONFIG_DIR/tempest.conf
Dean Troyer44d8f8f2011-11-23 23:21:06 -060068
Jesse Andrewsd7326d22011-11-20 10:02:26 -080069if [ ! -f $DEST/.ramdisk ]; then
70 # Process network configuration vars
71 GUEST_NETWORK=${GUEST_NETWORK:-1}
72 GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes}
Dean Troyerfda65b82011-11-02 12:13:33 -050073
Jesse Andrewsd7326d22011-11-20 10:02:26 -080074 GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50}
75 GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24}
76 GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0}
77 GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1}
78 GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"}
79 GUEST_RAM=${GUEST_RAM:-1524288}
80 GUEST_CORES=${GUEST_CORES:-1}
81fi
Dean Troyerfda65b82011-11-02 12:13:33 -050082
83# Use the GUEST_IP unless an explicit IP is set by ``HOST_IP``
84HOST_IP=${HOST_IP:-$GUEST_IP}
85# Use the first IP if HOST_IP still is not set
86if [ ! -n "$HOST_IP" ]; then
87 HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
88fi
89
90RABBIT_HOST=${RABBIT_HOST:-localhost}
91
92# Glance connection info. Note the port must be specified.
93GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
94set `echo $GLANCE_HOSTPORT | tr ':' ' '`
95GLANCE_HOST=$1
96GLANCE_PORT=$2
97
Dean Troyer3320c552011-11-23 23:19:10 -060098# Set up downloaded images
99# Defaults to use first image
100
101IMAGE_DIR=""
Dean Troyer608bb122012-01-10 14:43:17 -0600102IMAGE_NAME=""
Dean Troyer3320c552011-11-23 23:19:10 -0600103for imagedir in $TOP_DIR/files/images/*; do
104 KERNEL=""
105 RAMDISK=""
106 IMAGE=""
107 IMAGE_RAMDISK=""
108 KERNEL=$(for f in "$imagedir/"*-vmlinuz*; do
109 [ -f "$f" ] && echo "$f" && break; done; true)
110 [ -n "$KERNEL" ] && ln -sf $KERNEL $imagedir/kernel
111 RAMDISK=$(for f in "$imagedir/"*-initrd*; do
112 [ -f "$f" ] && echo "$f" && break; done; true)
113 [ -n "$RAMDISK" ] && ln -sf $RAMDISK $imagedir/ramdisk && \
114 IMAGE_RAMDISK="ari_location = $imagedir/ramdisk"
115 IMAGE=$(for f in "$imagedir/"*.img; do
116 [ -f "$f" ] && echo "$f" && break; done; true)
117 if [ -n "$IMAGE" ]; then
118 ln -sf $IMAGE $imagedir/disk
119 # Save the first image directory that contains a disk image link
120 if [ -z "$IMAGE_DIR" ]; then
121 IMAGE_DIR=$imagedir
Dean Troyer608bb122012-01-10 14:43:17 -0600122 IMAGE_NAME=$(basename ${IMAGE%.img})
Dean Troyer3320c552011-11-23 23:19:10 -0600123 fi
124 fi
125done
Dean Troyer608bb122012-01-10 14:43:17 -0600126if [[ -n "$IMAGE_NAME" ]]; then
127 # Get the image UUID
128 IMAGE_UUID=$(nova image-list | grep " $IMAGE_NAME " | cut -d'|' -f2)
129 # Strip spaces off
130 IMAGE_UUID=$(echo $IMAGE_UUID)
131fi
Dean Troyer3320c552011-11-23 23:19:10 -0600132
Jay Pipesd01325f2012-04-04 16:21:33 -0400133# Create tempest.conf from tempest.conf.tpl
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800134
Dean Troyer608bb122012-01-10 14:43:17 -0600135if [[ ! -r $TEMPEST_CONF ]]; then
Jay Pipesd01325f2012-04-04 16:21:33 -0400136 cp $TEMPEST_CONF.tpl $TEMPEST_CONF
Dean Troyer608bb122012-01-10 14:43:17 -0600137fi
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800138
Jay Pipesd01325f2012-04-04 16:21:33 -0400139IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False}
Jay Pipes58d34ea2012-04-05 17:19:02 -0400140TEMPEST_IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1}
141TEMPEST_IDENTITY_API_VERSION="v2.0" # Note: need v for now...
Jay Pipesd01325f2012-04-04 16:21:33 -0400142# TODO(jaypipes): This is dumb and needs to be removed
143# from the Tempest configuration file entirely...
144IDENTITY_PATH=${IDENTITY_PATH:-tokens}
145IDENTITY_STRATEGY=${IDENTITY_STRATEGY:-keystone}
146
147# We use regular, non-admin users in Tempest for the USERNAME
148# substitutions and use ADMIN_USERNAME et al for the admin stuff.
149# OS_USERNAME et all should be defined in openrc.
150OS_USERNAME=${OS_USERNAME:-demo}
151OS_TENANT_NAME=${OS_TENANT_NAME:-demo}
152OS_PASSWORD=${OS_PASSWORD:-secrete}
153
154# TODO(jaypipes): Support multiple regular user accounts instead
155# of using the same regular user account for the alternate user...
156ALT_USERNAME=$OS_USERNAME
157ALT_PASSWORD=$OS_PASSWORD
158ALT_TENANT_NAME=$OS_TENANT_NAME
159
160# TODO(jaypipes): Support multiple images instead of plopping
161# the IMAGE_UUID into both the image_ref and image_ref_alt slots
162IMAGE_UUID_ALT=$IMAGE_UUID
163
164# TODO(jaypipes): Support configurable flavor refs here...
165FLAVOR_REF=1
166FLAVOR_REF_ALT=2
167
168ADMIN_USERNAME={$ADMIN_USERNAME:-admin}
169ADMIN_PASSWORD={$ADMIN_PASSWORD:-secrete}
170ADMIN_TENANT_NAME={$ADMIN_TENANT:-admin}
171
172# Do any of the following need to be configurable?
173COMPUTE_CATALOG_TYPE=compute
174COMPUTE_CREATE_IMAGE_ENABLED=True
Jay Pipes58d34ea2012-04-05 17:19:02 -0400175COMPUTE_RESIZE_AVAILABLE=False # not supported with QEMU...
Jay Pipesd01325f2012-04-04 16:21:33 -0400176COMPUTE_LOG_LEVEL=ERROR
Jay Pipes58d34ea2012-04-05 17:19:02 -0400177BUILD_INTERVAL=10
178BUILD_TIMEOUT=600
Jay Pipesd01325f2012-04-04 16:21:33 -0400179
Dean Troyer608bb122012-01-10 14:43:17 -0600180sed -e "
Jay Pipesd01325f2012-04-04 16:21:33 -0400181 s,%IDENTITY_USE_SSL%,$IDENTITY_USE_SSL,g;
Jay Pipes58d34ea2012-04-05 17:19:02 -0400182 s,%IDENTITY_HOST%,$TEMPEST_IDENTITY_HOST,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400183 s,%IDENTITY_PORT%,$IDENTITY_PORT,g;
Jay Pipes58d34ea2012-04-05 17:19:02 -0400184 s,%IDENTITY_API_VERSION%,$TEMPEST_IDENTITY_API_VERSION,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400185 s,%IDENTITY_PATH%,$IDENTITY_PATH,g;
186 s,%IDENTITY_STRATEGY%,$IDENTITY_STRATEGY,g;
187 s,%USERNAME%,$OS_USERNAME,g;
188 s,%PASSWORD%,$OS_PASSWORD,g;
189 s,%TENANT_NAME%,$OS_TENANT_NAME,g;
190 s,%ALT_USERNAME%,$ALT_USERNAME,g;
191 s,%ALT_PASSWORD%,$ALT_PASSWORD,g;
192 s,%ALT_TENANT_NAME%,$ALT_TENANT_NAME,g;
193 s,%COMPUTE_CATALOG_TYPE%,$COMPUTE_CATALOG_TYPE,g;
194 s,%COMPUTE_CREATE_IMAGE_ENABLED%,$COMPUTE_CREATE_IMAGE_ENABLED,g;
195 s,%COMPUTE_RESIZE_AVAILABLE%,$COMPUTE_RESIZE_AVAILABLE,g;
196 s,%COMPUTE_LOG_LEVEL%,$COMPUTE_LOG_LEVEL,g;
Jay Pipes58d34ea2012-04-05 17:19:02 -0400197 s,%BUILD_INTERVAL%,$BUILD_INTERVAL,g;
198 s,%BUILD_TIMEOUT%,$BUILD_TIMEOUT,g;
Jay Pipesd01325f2012-04-04 16:21:33 -0400199 s,%IMAGE_ID%,$IMAGE_UUID,g;
200 s,%IMAGE_ID_ALT%,$IMAGE_UUID_ALT,g;
201 s,%FLAVOR_REF%,$FLAVOR_REF,g;
202 s,%FLAVOR_REF_ALT%,$FLAVOR_REF_ALT,g;
203 s,%ADMIN_USERNAME%,$ADMIN_USERNAME,g;
204 s,%ADMIN_PASSWORD%,$ADMIN_PASSWORD,g;
205 s,%ADMIN_TENANT_NAME%,$ADMIN_TENANT_NAME,g;
Dean Troyer608bb122012-01-10 14:43:17 -0600206" -i $TEMPEST_CONF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800207
Jay Pipes58d34ea2012-04-05 17:19:02 -0400208echo "Created tempest configuration file:"
209cat $TEMPEST_CONF
210echo "\n\n"
211
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800212# Create config.ini
213
214CONFIG_INI_TMP=$(mktemp $CONFIG_INI.XXXXXX)
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500215if [ "$UPLOAD_LEGACY_TTY" ]; then
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800216 cat >$CONFIG_INI_TMP <<EOF
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500217[environment]
Dean Troyer3320c552011-11-23 23:19:10 -0600218aki_location = $TOP_DIR/files/images/aki-tty/image
219ari_location = $TOP_DIR/files/images/ari-tty/image
220ami_location = $TOP_DIR/files/images/ami-tty/image
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800221image_ref = 3
222image_ref_alt = 3
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500223flavor_ref = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800224flavor_ref_alt = 2
225
226[glance]
227host = $GLANCE_HOST
228apiver = v1
229port = $GLANCE_PORT
230image_id = 3
231image_id_alt = 3
232tenant_id = 1
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500233EOF
234else
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800235 cat >$CONFIG_INI_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -0500236[environment]
Dean Troyer3320c552011-11-23 23:19:10 -0600237aki_location = $IMAGE_DIR/kernel
238ami_location = $IMAGE_DIR/disk
239$IMAGE_RAMDISK
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800240image_ref = 2
241image_ref_alt = 2
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500242flavor_ref = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800243flavor_ref_alt = 2
Dean Troyerfda65b82011-11-02 12:13:33 -0500244
245[glance]
246host = $GLANCE_HOST
Dean Troyera0e29482011-11-04 19:44:06 -0500247apiver = v1
Dean Troyerfda65b82011-11-02 12:13:33 -0500248port = $GLANCE_PORT
Dean Troyer3320c552011-11-23 23:19:10 -0600249image_id = 2
250image_id_alt = 2
Dean Troyera0e29482011-11-04 19:44:06 -0500251tenant_id = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800252EOF
253fi
254
255cat >>$CONFIG_INI_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -0500256
257[keystone]
258service_host = $HOST_IP
259service_port = 5000
Dean Troyer5db287c2011-11-02 21:21:36 -0500260apiver = v2.0
Dean Troyerfda65b82011-11-02 12:13:33 -0500261user = admin
262password = $ADMIN_PASSWORD
Dolph Mathews50e32292011-12-15 16:04:49 -0600263tenant_name = admin
Dean Troyerfda65b82011-11-02 12:13:33 -0500264
265[nova]
266host = $HOST_IP
267port = 8774
268apiver = v1.1
269project = admin
270user = admin
Dean Troyerb0e57cf2011-11-04 12:13:43 -0500271key = $ADMIN_PASSWORD
Dean Troyerfda65b82011-11-02 12:13:33 -0500272ssh_timeout = 300
273build_timeout = 300
274flavor_ref = 1
275flavor_ref_alt = 2
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800276multi_node = no
Dean Troyerfda65b82011-11-02 12:13:33 -0500277
278[rabbitmq]
279host = $RABBIT_HOST
280user = guest
281password = $RABBIT_PASSWORD
282
283[swift]
284auth_host = $HOST_IP
285auth_port = 443
286auth_prefix = /auth/
287auth_ssl = yes
288account = system
289username = root
290password = password
291
292EOF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800293mv $CONFIG_INI_TMP $CONFIG_INI
294CONFIG_INI_TMP=""
295
296trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT