blob: 00add9a33632fa1fc30fb84ad4ad37552bd61e0c [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)
33TOP_DIR=`cd $TOOLS_DIR/..; pwd`
34
35# Abort if localrc is not set
36if [ ! -e $TOP_DIR/localrc ]; then
37 echo "You must have a localrc with ALL necessary passwords and configuration defined before proceeding."
38 echo "See stack.sh for required passwords."
39 exit 1
40fi
41
42# Source params
43source ./stackrc
44
Dean Troyer608bb122012-01-10 14:43:17 -060045# Set defaults not configured by stackrc
46TENANT=${TENANT:-admin}
47USERNAME=${USERNAME:-admin}
48IDENTITY_HOST=${IDENTITY_HOST:-$HOST_IP}
49IDENTITY_PORT=${IDENTITY_PORT:-5000}
50IDENTITY_API_VERSION=${IDENTITY_API_VERSION:-2.0}
51
Dean Troyerfda65b82011-11-02 12:13:33 -050052# Where Openstack code lives
53DEST=${DEST:-/opt/stack}
54
Dean Troyer608bb122012-01-10 14:43:17 -060055TEMPEST_DIR=$DEST/tempest
Dean Troyer44d8f8f2011-11-23 23:21:06 -060056
Dean Troyer608bb122012-01-10 14:43:17 -060057CONFIG_DIR=${1:-$TEMPEST_DIR/etc}
Dean Troyer44d8f8f2011-11-23 23:21:06 -060058CONFIG_INI=$CONFIG_DIR/config.ini
Dean Troyer608bb122012-01-10 14:43:17 -060059TEMPEST_CONF=$CONFIG_DIR/tempest.conf
Dean Troyer44d8f8f2011-11-23 23:21:06 -060060
Jesse Andrewsd7326d22011-11-20 10:02:26 -080061if [ ! -f $DEST/.ramdisk ]; then
62 # Process network configuration vars
63 GUEST_NETWORK=${GUEST_NETWORK:-1}
64 GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes}
Dean Troyerfda65b82011-11-02 12:13:33 -050065
Jesse Andrewsd7326d22011-11-20 10:02:26 -080066 GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50}
67 GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24}
68 GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0}
69 GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1}
70 GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"}
71 GUEST_RAM=${GUEST_RAM:-1524288}
72 GUEST_CORES=${GUEST_CORES:-1}
73fi
Dean Troyerfda65b82011-11-02 12:13:33 -050074
75# Use the GUEST_IP unless an explicit IP is set by ``HOST_IP``
76HOST_IP=${HOST_IP:-$GUEST_IP}
77# Use the first IP if HOST_IP still is not set
78if [ ! -n "$HOST_IP" ]; then
79 HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
80fi
81
82RABBIT_HOST=${RABBIT_HOST:-localhost}
83
84# Glance connection info. Note the port must be specified.
85GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
86set `echo $GLANCE_HOSTPORT | tr ':' ' '`
87GLANCE_HOST=$1
88GLANCE_PORT=$2
89
Dean Troyer3320c552011-11-23 23:19:10 -060090# Set up downloaded images
91# Defaults to use first image
92
93IMAGE_DIR=""
Dean Troyer608bb122012-01-10 14:43:17 -060094IMAGE_NAME=""
Dean Troyer3320c552011-11-23 23:19:10 -060095for imagedir in $TOP_DIR/files/images/*; do
96 KERNEL=""
97 RAMDISK=""
98 IMAGE=""
99 IMAGE_RAMDISK=""
100 KERNEL=$(for f in "$imagedir/"*-vmlinuz*; do
101 [ -f "$f" ] && echo "$f" && break; done; true)
102 [ -n "$KERNEL" ] && ln -sf $KERNEL $imagedir/kernel
103 RAMDISK=$(for f in "$imagedir/"*-initrd*; do
104 [ -f "$f" ] && echo "$f" && break; done; true)
105 [ -n "$RAMDISK" ] && ln -sf $RAMDISK $imagedir/ramdisk && \
106 IMAGE_RAMDISK="ari_location = $imagedir/ramdisk"
107 IMAGE=$(for f in "$imagedir/"*.img; do
108 [ -f "$f" ] && echo "$f" && break; done; true)
109 if [ -n "$IMAGE" ]; then
110 ln -sf $IMAGE $imagedir/disk
111 # Save the first image directory that contains a disk image link
112 if [ -z "$IMAGE_DIR" ]; then
113 IMAGE_DIR=$imagedir
Dean Troyer608bb122012-01-10 14:43:17 -0600114 IMAGE_NAME=$(basename ${IMAGE%.img})
Dean Troyer3320c552011-11-23 23:19:10 -0600115 fi
116 fi
117done
Dean Troyer608bb122012-01-10 14:43:17 -0600118if [[ -n "$IMAGE_NAME" ]]; then
119 # Get the image UUID
120 IMAGE_UUID=$(nova image-list | grep " $IMAGE_NAME " | cut -d'|' -f2)
121 # Strip spaces off
122 IMAGE_UUID=$(echo $IMAGE_UUID)
123fi
Dean Troyer3320c552011-11-23 23:19:10 -0600124
Dean Troyer608bb122012-01-10 14:43:17 -0600125# Create tempest.conf from tempest.conf.sample
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800126
Dean Troyer608bb122012-01-10 14:43:17 -0600127if [[ ! -r $TEMPEST_CONF ]]; then
128 cp $TEMPEST_CONF.sample $TEMPEST_CONF
129fi
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800130
Dean Troyer608bb122012-01-10 14:43:17 -0600131sed -e "
132 /^api_key=/s|=.*\$|=$ADMIN_PASSWORD|;
133 /^auth_url=/s|=.*\$|=${OS_AUTH_URL%/}/tokens/|;
134 /^host=/s|=.*\$|=$HOST_IP|;
135 /^image_ref=/s|=.*\$|=$IMAGE_UUID|;
136 /^password=/s|=.*\$|=$ADMIN_PASSWORD|;
137 /^tenant=/s|=.*\$|=$TENANT|;
138 /^tenant_name=/s|=.*\$|=$TENANT|;
139 /^user=/s|=.*\$|=$USERNAME|;
140 /^username=/s|=.*\$|=$USERNAME|;
141" -i $TEMPEST_CONF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800142
143# Create config.ini
144
145CONFIG_INI_TMP=$(mktemp $CONFIG_INI.XXXXXX)
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500146if [ "$UPLOAD_LEGACY_TTY" ]; then
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800147 cat >$CONFIG_INI_TMP <<EOF
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500148[environment]
Dean Troyer3320c552011-11-23 23:19:10 -0600149aki_location = $TOP_DIR/files/images/aki-tty/image
150ari_location = $TOP_DIR/files/images/ari-tty/image
151ami_location = $TOP_DIR/files/images/ami-tty/image
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800152image_ref = 3
153image_ref_alt = 3
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500154flavor_ref = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800155flavor_ref_alt = 2
156
157[glance]
158host = $GLANCE_HOST
159apiver = v1
160port = $GLANCE_PORT
161image_id = 3
162image_id_alt = 3
163tenant_id = 1
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500164EOF
165else
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800166 cat >$CONFIG_INI_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -0500167[environment]
Dean Troyer3320c552011-11-23 23:19:10 -0600168aki_location = $IMAGE_DIR/kernel
169ami_location = $IMAGE_DIR/disk
170$IMAGE_RAMDISK
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800171image_ref = 2
172image_ref_alt = 2
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500173flavor_ref = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800174flavor_ref_alt = 2
Dean Troyerfda65b82011-11-02 12:13:33 -0500175
176[glance]
177host = $GLANCE_HOST
Dean Troyera0e29482011-11-04 19:44:06 -0500178apiver = v1
Dean Troyerfda65b82011-11-02 12:13:33 -0500179port = $GLANCE_PORT
Dean Troyer3320c552011-11-23 23:19:10 -0600180image_id = 2
181image_id_alt = 2
Dean Troyera0e29482011-11-04 19:44:06 -0500182tenant_id = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800183EOF
184fi
185
186cat >>$CONFIG_INI_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -0500187
188[keystone]
189service_host = $HOST_IP
190service_port = 5000
Dean Troyer5db287c2011-11-02 21:21:36 -0500191apiver = v2.0
Dean Troyerfda65b82011-11-02 12:13:33 -0500192user = admin
193password = $ADMIN_PASSWORD
Dolph Mathews50e32292011-12-15 16:04:49 -0600194tenant_name = admin
Dean Troyerfda65b82011-11-02 12:13:33 -0500195
196[nova]
197host = $HOST_IP
198port = 8774
199apiver = v1.1
200project = admin
201user = admin
Dean Troyerb0e57cf2011-11-04 12:13:43 -0500202key = $ADMIN_PASSWORD
Dean Troyerfda65b82011-11-02 12:13:33 -0500203ssh_timeout = 300
204build_timeout = 300
205flavor_ref = 1
206flavor_ref_alt = 2
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800207multi_node = no
Dean Troyerfda65b82011-11-02 12:13:33 -0500208
209[rabbitmq]
210host = $RABBIT_HOST
211user = guest
212password = $RABBIT_PASSWORD
213
214[swift]
215auth_host = $HOST_IP
216auth_port = 443
217auth_prefix = /auth/
218auth_ssl = yes
219account = system
220username = root
221password = password
222
223EOF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800224mv $CONFIG_INI_TMP $CONFIG_INI
225CONFIG_INI_TMP=""
226
227trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT