blob: ca77ccf292ed781ce18f95d6703173e0e0dcc6cc [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 ""
9 echo "Usage: $0 configfile"
10 exit 1
11}
12
13if [ ! "$#" -eq "1" ]; then
14 usage
15fi
16
17CONFIG_FILE=$1
18
19# Clean up any resources that may be in use
20cleanup() {
21 set +o errexit
22
23 # Mop up temporary files
24 if [ -n "$CONFIG_FILE_TMP" -a -e "$CONFIG_FILE_TMP" ]; then
25 rm -f $CONFIG_FILE_TMP
26 fi
27
28 # Kill ourselves to signal any calling process
29 trap 2; kill -2 $$
30}
31
32trap cleanup SIGHUP SIGINT SIGTERM
33
34# Keep track of the current directory
35TOOLS_DIR=$(cd $(dirname "$0") && pwd)
36TOP_DIR=`cd $TOOLS_DIR/..; pwd`
37
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
48# Where Openstack code lives
49DEST=${DEST:-/opt/stack}
50
Dean Troyerb0e57cf2011-11-04 12:13:43 -050051DIST_NAME=${DIST_NAME:-natty}
52
Dean Troyerfda65b82011-11-02 12:13:33 -050053# Process network configuration vars
54GUEST_NETWORK=${GUEST_NETWORK:-1}
55GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes}
56
57GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50}
58GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24}
59GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0}
60GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1}
61GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"}
62GUEST_RAM=${GUEST_RAM:-1524288}
63GUEST_CORES=${GUEST_CORES:-1}
64
65# Use the GUEST_IP unless an explicit IP is set by ``HOST_IP``
66HOST_IP=${HOST_IP:-$GUEST_IP}
67# Use the first IP if HOST_IP still is not set
68if [ ! -n "$HOST_IP" ]; then
69 HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
70fi
71
72RABBIT_HOST=${RABBIT_HOST:-localhost}
73
74# Glance connection info. Note the port must be specified.
75GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
76set `echo $GLANCE_HOSTPORT | tr ':' ' '`
77GLANCE_HOST=$1
78GLANCE_PORT=$2
79
80CONFIG_FILE_TMP=$(mktemp $CONFIG_FILE.XXXXXX)
Dean Troyerff0ed1d2011-11-05 16:15:11 -050081if [ "$UPLOAD_LEGACY_TTY" ]; then
82 cat >$CONFIG_FILE_TMP <<EOF
83[environment]
84aki_location = $DEST/devstack/files/images/aki-tty/image
85ari_location = $DEST/devstack/files/images/ari-tty/image
86ami_location = $DEST/devstack/files/images/ami-tty/image
87image_ref = 1
88flavor_ref = 1
89EOF
90else
91 cat >$CONFIG_FILE_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -050092[environment]
Dean Troyerb0e57cf2011-11-04 12:13:43 -050093aki_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-vmlinuz-virtual
94#ari_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-loader
95ami_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64.img
Dean Troyerff0ed1d2011-11-05 16:15:11 -050096image_ref = 1
97flavor_ref = 1
98EOF
99fi
Dean Troyerfda65b82011-11-02 12:13:33 -0500100
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500101cat >>$CONFIG_FILE_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -0500102[glance]
103host = $GLANCE_HOST
Dean Troyera0e29482011-11-04 19:44:06 -0500104apiver = v1
Dean Troyerfda65b82011-11-02 12:13:33 -0500105port = $GLANCE_PORT
106image_id = 1
Dean Troyera0e29482011-11-04 19:44:06 -0500107tenant_id = 1
Dean Troyerfda65b82011-11-02 12:13:33 -0500108
109[keystone]
110service_host = $HOST_IP
111service_port = 5000
Dean Troyer5db287c2011-11-02 21:21:36 -0500112apiver = v2.0
Dean Troyerfda65b82011-11-02 12:13:33 -0500113user = admin
114password = $ADMIN_PASSWORD
115tenant_id = 1
116
117[nova]
118host = $HOST_IP
119port = 8774
120apiver = v1.1
121project = admin
122user = admin
Dean Troyerb0e57cf2011-11-04 12:13:43 -0500123key = $ADMIN_PASSWORD
Dean Troyerfda65b82011-11-02 12:13:33 -0500124ssh_timeout = 300
125build_timeout = 300
126flavor_ref = 1
127flavor_ref_alt = 2
128
129[rabbitmq]
130host = $RABBIT_HOST
131user = guest
132password = $RABBIT_PASSWORD
133
134[swift]
135auth_host = $HOST_IP
136auth_port = 443
137auth_prefix = /auth/
138auth_ssl = yes
139account = system
140username = root
141password = password
142
143EOF
Dean Troyer5db287c2011-11-02 21:21:36 -0500144mv $CONFIG_FILE_TMP $CONFIG_FILE