blob: f6ef0d3b95455ad4ab0eaea764f13d7db74b8d20 [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 Troyer6563a3c2012-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
Dean Troyer608bb122012-01-10 14:43:17 -0600128# Create tempest.conf from tempest.conf.sample
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800129
Dean Troyer608bb122012-01-10 14:43:17 -0600130if [[ ! -r $TEMPEST_CONF ]]; then
131 cp $TEMPEST_CONF.sample $TEMPEST_CONF
132fi
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800133
Dean Troyer608bb122012-01-10 14:43:17 -0600134sed -e "
135 /^api_key=/s|=.*\$|=$ADMIN_PASSWORD|;
136 /^auth_url=/s|=.*\$|=${OS_AUTH_URL%/}/tokens/|;
137 /^host=/s|=.*\$|=$HOST_IP|;
138 /^image_ref=/s|=.*\$|=$IMAGE_UUID|;
139 /^password=/s|=.*\$|=$ADMIN_PASSWORD|;
140 /^tenant=/s|=.*\$|=$TENANT|;
141 /^tenant_name=/s|=.*\$|=$TENANT|;
142 /^user=/s|=.*\$|=$USERNAME|;
143 /^username=/s|=.*\$|=$USERNAME|;
144" -i $TEMPEST_CONF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800145
146# Create config.ini
147
148CONFIG_INI_TMP=$(mktemp $CONFIG_INI.XXXXXX)
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500149if [ "$UPLOAD_LEGACY_TTY" ]; then
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800150 cat >$CONFIG_INI_TMP <<EOF
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500151[environment]
Dean Troyer3320c552011-11-23 23:19:10 -0600152aki_location = $TOP_DIR/files/images/aki-tty/image
153ari_location = $TOP_DIR/files/images/ari-tty/image
154ami_location = $TOP_DIR/files/images/ami-tty/image
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800155image_ref = 3
156image_ref_alt = 3
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500157flavor_ref = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800158flavor_ref_alt = 2
159
160[glance]
161host = $GLANCE_HOST
162apiver = v1
163port = $GLANCE_PORT
164image_id = 3
165image_id_alt = 3
166tenant_id = 1
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500167EOF
168else
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800169 cat >$CONFIG_INI_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -0500170[environment]
Dean Troyer3320c552011-11-23 23:19:10 -0600171aki_location = $IMAGE_DIR/kernel
172ami_location = $IMAGE_DIR/disk
173$IMAGE_RAMDISK
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800174image_ref = 2
175image_ref_alt = 2
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500176flavor_ref = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800177flavor_ref_alt = 2
Dean Troyerfda65b82011-11-02 12:13:33 -0500178
179[glance]
180host = $GLANCE_HOST
Dean Troyera0e29482011-11-04 19:44:06 -0500181apiver = v1
Dean Troyerfda65b82011-11-02 12:13:33 -0500182port = $GLANCE_PORT
Dean Troyer3320c552011-11-23 23:19:10 -0600183image_id = 2
184image_id_alt = 2
Dean Troyera0e29482011-11-04 19:44:06 -0500185tenant_id = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800186EOF
187fi
188
189cat >>$CONFIG_INI_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -0500190
191[keystone]
192service_host = $HOST_IP
193service_port = 5000
Dean Troyer5db287c2011-11-02 21:21:36 -0500194apiver = v2.0
Dean Troyerfda65b82011-11-02 12:13:33 -0500195user = admin
196password = $ADMIN_PASSWORD
Dolph Mathews50e32292011-12-15 16:04:49 -0600197tenant_name = admin
Dean Troyerfda65b82011-11-02 12:13:33 -0500198
199[nova]
200host = $HOST_IP
201port = 8774
202apiver = v1.1
203project = admin
204user = admin
Dean Troyerb0e57cf2011-11-04 12:13:43 -0500205key = $ADMIN_PASSWORD
Dean Troyerfda65b82011-11-02 12:13:33 -0500206ssh_timeout = 300
207build_timeout = 300
208flavor_ref = 1
209flavor_ref_alt = 2
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800210multi_node = no
Dean Troyerfda65b82011-11-02 12:13:33 -0500211
212[rabbitmq]
213host = $RABBIT_HOST
214user = guest
215password = $RABBIT_PASSWORD
216
217[swift]
218auth_host = $HOST_IP
219auth_port = 443
220auth_prefix = /auth/
221auth_ssl = yes
222account = system
223username = root
224password = password
225
226EOF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800227mv $CONFIG_INI_TMP $CONFIG_INI
228CONFIG_INI_TMP=""
229
230trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT