blob: 8eed8eca599be2b970babdbebb7131ae8c820490 [file] [log] [blame]
Dean Troyerfda65b82011-11-02 12:13:33 -05001#!/usr/bin/env bash
2#
3# build_ci_config.sh - Build a config.ini for openstack-integration-tests
4# (https://github.com/openstack/openstack-integration-tests)
5
6function usage {
7 echo "$0 - Build config.ini for openstack-integration-tests"
8 echo ""
Jesse Andrewsd7326d22011-11-20 10:02:26 -08009 echo "Usage: $0 configdir"
Dean Troyerfda65b82011-11-02 12:13:33 -050010 exit 1
11}
12
13if [ ! "$#" -eq "1" ]; then
14 usage
15fi
16
Jesse Andrewsd7326d22011-11-20 10:02:26 -080017CONFIG_DIR=$1
18CONFIG_CONF=$CONFIG_DIR/storm.conf
19CONFIG_INI=$CONFIG_DIR/config.ini
Dean Troyerfda65b82011-11-02 12:13:33 -050020
21# Clean up any resources that may be in use
22cleanup() {
23 set +o errexit
24
25 # Mop up temporary files
Jesse Andrewsd7326d22011-11-20 10:02:26 -080026 if [ -n "$CONFIG_CONF_TMP" -a -e "$CONFIG_CONF_TMP" ]; then
27 rm -f $CONFIG_CONF_TMP
28 fi
29 if [ -n "$CONFIG_INI_TMP" -a -e "$CONFIG_INI_TMP" ]; then
30 rm -f $CONFIG_INI_TMP
Dean Troyerfda65b82011-11-02 12:13:33 -050031 fi
32
33 # Kill ourselves to signal any calling process
34 trap 2; kill -2 $$
35}
36
Jesse Andrewsd7326d22011-11-20 10:02:26 -080037trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
Dean Troyerfda65b82011-11-02 12:13:33 -050038
39# Keep track of the current directory
40TOOLS_DIR=$(cd $(dirname "$0") && pwd)
41TOP_DIR=`cd $TOOLS_DIR/..; pwd`
42
43# Abort if localrc is not set
44if [ ! -e $TOP_DIR/localrc ]; then
45 echo "You must have a localrc with ALL necessary passwords and configuration defined before proceeding."
46 echo "See stack.sh for required passwords."
47 exit 1
48fi
49
50# Source params
51source ./stackrc
52
53# Where Openstack code lives
54DEST=${DEST:-/opt/stack}
55
Dean Troyer39c2efc2011-11-07 16:40:35 -060056DIST_NAME=${DIST_NAME:-oneiric}
Dean Troyerb0e57cf2011-11-04 12:13:43 -050057
Jesse Andrewsd7326d22011-11-20 10:02:26 -080058if [ ! -f $DEST/.ramdisk ]; then
59 # Process network configuration vars
60 GUEST_NETWORK=${GUEST_NETWORK:-1}
61 GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes}
Dean Troyerfda65b82011-11-02 12:13:33 -050062
Jesse Andrewsd7326d22011-11-20 10:02:26 -080063 GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50}
64 GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24}
65 GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0}
66 GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1}
67 GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"}
68 GUEST_RAM=${GUEST_RAM:-1524288}
69 GUEST_CORES=${GUEST_CORES:-1}
70fi
Dean Troyerfda65b82011-11-02 12:13:33 -050071
72# Use the GUEST_IP unless an explicit IP is set by ``HOST_IP``
73HOST_IP=${HOST_IP:-$GUEST_IP}
74# Use the first IP if HOST_IP still is not set
75if [ ! -n "$HOST_IP" ]; then
76 HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
77fi
78
79RABBIT_HOST=${RABBIT_HOST:-localhost}
80
81# Glance connection info. Note the port must be specified.
82GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
83set `echo $GLANCE_HOSTPORT | tr ':' ' '`
84GLANCE_HOST=$1
85GLANCE_PORT=$2
86
Jesse Andrewsd7326d22011-11-20 10:02:26 -080087# Create storm.conf
88
89CONFIG_CONF_TMP=$(mktemp $CONFIG_CONF.XXXXXX)
90 cat >$CONFIG_CONF_TMP <<EOF
91[nova]
92auth_url=http://$HOST_IP:5000/v2.0/tokens
93user=admin
94api_key=$ADMIN_PASSWORD
95tenant_name=admin
96ssh_timeout=300
97build_interval=10
98build_timeout=600
99
100[environment]
101image_ref=3
102image_ref_alt=4
103flavor_ref=1
104flavor_ref_alt=2
105create_image_enabled=true
106resize_available=true
107authentication=keystone_v2
108EOF
109mv $CONFIG_CONF_TMP $CONFIG_CONF
110CONFIG_CONF_TMP=""
111
112# Create config.ini
113
114CONFIG_INI_TMP=$(mktemp $CONFIG_INI.XXXXXX)
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500115if [ "$UPLOAD_LEGACY_TTY" ]; then
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800116 cat >$CONFIG_INI_TMP <<EOF
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500117[environment]
118aki_location = $DEST/devstack/files/images/aki-tty/image
119ari_location = $DEST/devstack/files/images/ari-tty/image
120ami_location = $DEST/devstack/files/images/ami-tty/image
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800121image_ref = 3
122image_ref_alt = 3
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500123flavor_ref = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800124flavor_ref_alt = 2
125
126[glance]
127host = $GLANCE_HOST
128apiver = v1
129port = $GLANCE_PORT
130image_id = 3
131image_id_alt = 3
132tenant_id = 1
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500133EOF
134else
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800135 cat >$CONFIG_INI_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -0500136[environment]
Dean Troyerb0e57cf2011-11-04 12:13:43 -0500137aki_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-vmlinuz-virtual
138#ari_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-loader
139ami_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64.img
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800140image_ref = 2
141image_ref_alt = 2
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500142flavor_ref = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800143flavor_ref_alt = 2
Dean Troyerfda65b82011-11-02 12:13:33 -0500144
145[glance]
146host = $GLANCE_HOST
Dean Troyera0e29482011-11-04 19:44:06 -0500147apiver = v1
Dean Troyerfda65b82011-11-02 12:13:33 -0500148port = $GLANCE_PORT
149image_id = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800150image_id_alt = 1
Dean Troyera0e29482011-11-04 19:44:06 -0500151tenant_id = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800152EOF
153fi
154
155cat >>$CONFIG_INI_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -0500156
157[keystone]
158service_host = $HOST_IP
159service_port = 5000
Dean Troyer5db287c2011-11-02 21:21:36 -0500160apiver = v2.0
Dean Troyerfda65b82011-11-02 12:13:33 -0500161user = admin
162password = $ADMIN_PASSWORD
163tenant_id = 1
164
165[nova]
166host = $HOST_IP
167port = 8774
168apiver = v1.1
169project = admin
170user = admin
Dean Troyerb0e57cf2011-11-04 12:13:43 -0500171key = $ADMIN_PASSWORD
Dean Troyerfda65b82011-11-02 12:13:33 -0500172ssh_timeout = 300
173build_timeout = 300
174flavor_ref = 1
175flavor_ref_alt = 2
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800176multi_node = no
Dean Troyerfda65b82011-11-02 12:13:33 -0500177
178[rabbitmq]
179host = $RABBIT_HOST
180user = guest
181password = $RABBIT_PASSWORD
182
183[swift]
184auth_host = $HOST_IP
185auth_port = 443
186auth_prefix = /auth/
187auth_ssl = yes
188account = system
189username = root
190password = password
191
192EOF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800193mv $CONFIG_INI_TMP $CONFIG_INI
194CONFIG_INI_TMP=""
195
196trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT