blob: 01849ad3b75e41c0f9f46868591595e0c090fffe [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
40 echo "You must have a localrc with ALL necessary passwords and configuration defined before proceeding."
41 echo "See stack.sh for required passwords."
42 exit 1
43fi
44
45# Source params
46source ./stackrc
47
Dean Troyer608bb122012-01-10 14:43:17 -060048# Set defaults not configured by stackrc
49TENANT=${TENANT:-admin}
50USERNAME=${USERNAME:-admin}
51IDENTITY_HOST=${IDENTITY_HOST:-$HOST_IP}
52IDENTITY_PORT=${IDENTITY_PORT:-5000}
53IDENTITY_API_VERSION=${IDENTITY_API_VERSION:-2.0}
54
Dean Troyerfda65b82011-11-02 12:13:33 -050055# Where Openstack code lives
56DEST=${DEST:-/opt/stack}
57
Dean Troyer608bb122012-01-10 14:43:17 -060058TEMPEST_DIR=$DEST/tempest
Dean Troyer44d8f8f2011-11-23 23:21:06 -060059
Dean Troyer608bb122012-01-10 14:43:17 -060060CONFIG_DIR=${1:-$TEMPEST_DIR/etc}
Dean Troyer44d8f8f2011-11-23 23:21:06 -060061CONFIG_INI=$CONFIG_DIR/config.ini
Dean Troyer608bb122012-01-10 14:43:17 -060062TEMPEST_CONF=$CONFIG_DIR/tempest.conf
Dean Troyer44d8f8f2011-11-23 23:21:06 -060063
Jesse Andrewsd7326d22011-11-20 10:02:26 -080064if [ ! -f $DEST/.ramdisk ]; then
65 # Process network configuration vars
66 GUEST_NETWORK=${GUEST_NETWORK:-1}
67 GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes}
Dean Troyerfda65b82011-11-02 12:13:33 -050068
Jesse Andrewsd7326d22011-11-20 10:02:26 -080069 GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50}
70 GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24}
71 GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0}
72 GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1}
73 GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"}
74 GUEST_RAM=${GUEST_RAM:-1524288}
75 GUEST_CORES=${GUEST_CORES:-1}
76fi
Dean Troyerfda65b82011-11-02 12:13:33 -050077
78# Use the GUEST_IP unless an explicit IP is set by ``HOST_IP``
79HOST_IP=${HOST_IP:-$GUEST_IP}
80# Use the first IP if HOST_IP still is not set
81if [ ! -n "$HOST_IP" ]; then
82 HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
83fi
84
85RABBIT_HOST=${RABBIT_HOST:-localhost}
86
87# Glance connection info. Note the port must be specified.
88GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
89set `echo $GLANCE_HOSTPORT | tr ':' ' '`
90GLANCE_HOST=$1
91GLANCE_PORT=$2
92
Dean Troyer3320c552011-11-23 23:19:10 -060093# Set up downloaded images
94# Defaults to use first image
95
96IMAGE_DIR=""
Dean Troyer608bb122012-01-10 14:43:17 -060097IMAGE_NAME=""
Dean Troyer3320c552011-11-23 23:19:10 -060098for imagedir in $TOP_DIR/files/images/*; do
99 KERNEL=""
100 RAMDISK=""
101 IMAGE=""
102 IMAGE_RAMDISK=""
103 KERNEL=$(for f in "$imagedir/"*-vmlinuz*; do
104 [ -f "$f" ] && echo "$f" && break; done; true)
105 [ -n "$KERNEL" ] && ln -sf $KERNEL $imagedir/kernel
106 RAMDISK=$(for f in "$imagedir/"*-initrd*; do
107 [ -f "$f" ] && echo "$f" && break; done; true)
108 [ -n "$RAMDISK" ] && ln -sf $RAMDISK $imagedir/ramdisk && \
109 IMAGE_RAMDISK="ari_location = $imagedir/ramdisk"
110 IMAGE=$(for f in "$imagedir/"*.img; do
111 [ -f "$f" ] && echo "$f" && break; done; true)
112 if [ -n "$IMAGE" ]; then
113 ln -sf $IMAGE $imagedir/disk
114 # Save the first image directory that contains a disk image link
115 if [ -z "$IMAGE_DIR" ]; then
116 IMAGE_DIR=$imagedir
Dean Troyer608bb122012-01-10 14:43:17 -0600117 IMAGE_NAME=$(basename ${IMAGE%.img})
Dean Troyer3320c552011-11-23 23:19:10 -0600118 fi
119 fi
120done
Dean Troyer608bb122012-01-10 14:43:17 -0600121if [[ -n "$IMAGE_NAME" ]]; then
122 # Get the image UUID
123 IMAGE_UUID=$(nova image-list | grep " $IMAGE_NAME " | cut -d'|' -f2)
124 # Strip spaces off
125 IMAGE_UUID=$(echo $IMAGE_UUID)
126fi
Dean Troyer3320c552011-11-23 23:19:10 -0600127
Jay Pipesd01325f2012-04-04 16:21:33 -0400128# Create tempest.conf from tempest.conf.tpl
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800129
Dean Troyer608bb122012-01-10 14:43:17 -0600130if [[ ! -r $TEMPEST_CONF ]]; then
Jay Pipesd01325f2012-04-04 16:21:33 -0400131 cp $TEMPEST_CONF.tpl $TEMPEST_CONF
Dean Troyer608bb122012-01-10 14:43:17 -0600132fi
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800133
Jay Pipesd01325f2012-04-04 16:21:33 -0400134IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False}
135IDENTITY_PORT=${IDENTITY_PORT:-5000}
136IDENTITY_API_VERSION={$IDENTITY_API_VERSION:-v2.0} # Note: need v for now...
137# TODO(jaypipes): This is dumb and needs to be removed
138# from the Tempest configuration file entirely...
139IDENTITY_PATH=${IDENTITY_PATH:-tokens}
140IDENTITY_STRATEGY=${IDENTITY_STRATEGY:-keystone}
141
142# We use regular, non-admin users in Tempest for the USERNAME
143# substitutions and use ADMIN_USERNAME et al for the admin stuff.
144# OS_USERNAME et all should be defined in openrc.
145OS_USERNAME=${OS_USERNAME:-demo}
146OS_TENANT_NAME=${OS_TENANT_NAME:-demo}
147OS_PASSWORD=${OS_PASSWORD:-secrete}
148
149# TODO(jaypipes): Support multiple regular user accounts instead
150# of using the same regular user account for the alternate user...
151ALT_USERNAME=$OS_USERNAME
152ALT_PASSWORD=$OS_PASSWORD
153ALT_TENANT_NAME=$OS_TENANT_NAME
154
155# TODO(jaypipes): Support multiple images instead of plopping
156# the IMAGE_UUID into both the image_ref and image_ref_alt slots
157IMAGE_UUID_ALT=$IMAGE_UUID
158
159# TODO(jaypipes): Support configurable flavor refs here...
160FLAVOR_REF=1
161FLAVOR_REF_ALT=2
162
163ADMIN_USERNAME={$ADMIN_USERNAME:-admin}
164ADMIN_PASSWORD={$ADMIN_PASSWORD:-secrete}
165ADMIN_TENANT_NAME={$ADMIN_TENANT:-admin}
166
167# Do any of the following need to be configurable?
168COMPUTE_CATALOG_TYPE=compute
169COMPUTE_CREATE_IMAGE_ENABLED=True
170COMPUTE_RESIZE_AVAILABLE=True
171COMPUTE_LOG_LEVEL=ERROR
172
Dean Troyer608bb122012-01-10 14:43:17 -0600173sed -e "
Jay Pipesd01325f2012-04-04 16:21:33 -0400174 s,%IDENTITY_USE_SSL%,$IDENTITY_USE_SSL,g;
175 s,%IDENTITY_HOST%,$HOST_IP,g;
176 s,%IDENTITY_PORT%,$IDENTITY_PORT,g;
177 s,%IDENTITY_API_VERSION%,$IDENTITY_API_VERSION,g;
178 s,%IDENTITY_PATH%,$IDENTITY_PATH,g;
179 s,%IDENTITY_STRATEGY%,$IDENTITY_STRATEGY,g;
180 s,%USERNAME%,$OS_USERNAME,g;
181 s,%PASSWORD%,$OS_PASSWORD,g;
182 s,%TENANT_NAME%,$OS_TENANT_NAME,g;
183 s,%ALT_USERNAME%,$ALT_USERNAME,g;
184 s,%ALT_PASSWORD%,$ALT_PASSWORD,g;
185 s,%ALT_TENANT_NAME%,$ALT_TENANT_NAME,g;
186 s,%COMPUTE_CATALOG_TYPE%,$COMPUTE_CATALOG_TYPE,g;
187 s,%COMPUTE_CREATE_IMAGE_ENABLED%,$COMPUTE_CREATE_IMAGE_ENABLED,g;
188 s,%COMPUTE_RESIZE_AVAILABLE%,$COMPUTE_RESIZE_AVAILABLE,g;
189 s,%COMPUTE_LOG_LEVEL%,$COMPUTE_LOG_LEVEL,g;
190 s,%IMAGE_ID%,$IMAGE_UUID,g;
191 s,%IMAGE_ID_ALT%,$IMAGE_UUID_ALT,g;
192 s,%FLAVOR_REF%,$FLAVOR_REF,g;
193 s,%FLAVOR_REF_ALT%,$FLAVOR_REF_ALT,g;
194 s,%ADMIN_USERNAME%,$ADMIN_USERNAME,g;
195 s,%ADMIN_PASSWORD%,$ADMIN_PASSWORD,g;
196 s,%ADMIN_TENANT_NAME%,$ADMIN_TENANT_NAME,g;
Dean Troyer608bb122012-01-10 14:43:17 -0600197" -i $TEMPEST_CONF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800198
199# Create config.ini
200
201CONFIG_INI_TMP=$(mktemp $CONFIG_INI.XXXXXX)
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500202if [ "$UPLOAD_LEGACY_TTY" ]; then
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800203 cat >$CONFIG_INI_TMP <<EOF
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500204[environment]
Dean Troyer3320c552011-11-23 23:19:10 -0600205aki_location = $TOP_DIR/files/images/aki-tty/image
206ari_location = $TOP_DIR/files/images/ari-tty/image
207ami_location = $TOP_DIR/files/images/ami-tty/image
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800208image_ref = 3
209image_ref_alt = 3
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500210flavor_ref = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800211flavor_ref_alt = 2
212
213[glance]
214host = $GLANCE_HOST
215apiver = v1
216port = $GLANCE_PORT
217image_id = 3
218image_id_alt = 3
219tenant_id = 1
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500220EOF
221else
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800222 cat >$CONFIG_INI_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -0500223[environment]
Dean Troyer3320c552011-11-23 23:19:10 -0600224aki_location = $IMAGE_DIR/kernel
225ami_location = $IMAGE_DIR/disk
226$IMAGE_RAMDISK
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800227image_ref = 2
228image_ref_alt = 2
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500229flavor_ref = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800230flavor_ref_alt = 2
Dean Troyerfda65b82011-11-02 12:13:33 -0500231
232[glance]
233host = $GLANCE_HOST
Dean Troyera0e29482011-11-04 19:44:06 -0500234apiver = v1
Dean Troyerfda65b82011-11-02 12:13:33 -0500235port = $GLANCE_PORT
Dean Troyer3320c552011-11-23 23:19:10 -0600236image_id = 2
237image_id_alt = 2
Dean Troyera0e29482011-11-04 19:44:06 -0500238tenant_id = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800239EOF
240fi
241
242cat >>$CONFIG_INI_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -0500243
244[keystone]
245service_host = $HOST_IP
246service_port = 5000
Dean Troyer5db287c2011-11-02 21:21:36 -0500247apiver = v2.0
Dean Troyerfda65b82011-11-02 12:13:33 -0500248user = admin
249password = $ADMIN_PASSWORD
Dolph Mathews50e32292011-12-15 16:04:49 -0600250tenant_name = admin
Dean Troyerfda65b82011-11-02 12:13:33 -0500251
252[nova]
253host = $HOST_IP
254port = 8774
255apiver = v1.1
256project = admin
257user = admin
Dean Troyerb0e57cf2011-11-04 12:13:43 -0500258key = $ADMIN_PASSWORD
Dean Troyerfda65b82011-11-02 12:13:33 -0500259ssh_timeout = 300
260build_timeout = 300
261flavor_ref = 1
262flavor_ref_alt = 2
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800263multi_node = no
Dean Troyerfda65b82011-11-02 12:13:33 -0500264
265[rabbitmq]
266host = $RABBIT_HOST
267user = guest
268password = $RABBIT_PASSWORD
269
270[swift]
271auth_host = $HOST_IP
272auth_port = 443
273auth_prefix = /auth/
274auth_ssl = yes
275account = system
276username = root
277password = password
278
279EOF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800280mv $CONFIG_INI_TMP $CONFIG_INI
281CONFIG_INI_TMP=""
282
283trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT