blob: 90b8abf8bc4c6707a96b4c3d0531f9145935e033 [file] [log] [blame]
Dean Troyerfda65b82011-11-02 12:13:33 -05001#!/usr/bin/env bash
2#
Dean Troyerf79cc422011-12-01 10:21:42 -06003# build_ci_config.sh - Build a config.ini for tempest (openstack-integration-tests)
4# (https://github.com/openstack/tempest.git)
Dean Troyerfda65b82011-11-02 12:13:33 -05005
6function usage {
Dean Troyerf79cc422011-12-01 10:21:42 -06007 echo "$0 - Build config.ini for tempest"
Dean Troyerfda65b82011-11-02 12:13:33 -05008 echo ""
Dean Troyer44d8f8f2011-11-23 23:21:06 -06009 echo "Usage: $0 [configdir]"
Dean Troyerfda65b82011-11-02 12:13:33 -050010 exit 1
11}
12
Dean Troyer44d8f8f2011-11-23 23:21:06 -060013if [ "$1" = "-h" ]; then
Dean Troyerfda65b82011-11-02 12:13:33 -050014 usage
15fi
16
Dean Troyerfda65b82011-11-02 12:13:33 -050017# Clean up any resources that may be in use
18cleanup() {
19 set +o errexit
20
21 # Mop up temporary files
Jesse Andrewsd7326d22011-11-20 10:02:26 -080022 if [ -n "$CONFIG_CONF_TMP" -a -e "$CONFIG_CONF_TMP" ]; then
23 rm -f $CONFIG_CONF_TMP
24 fi
25 if [ -n "$CONFIG_INI_TMP" -a -e "$CONFIG_INI_TMP" ]; then
26 rm -f $CONFIG_INI_TMP
Dean Troyerfda65b82011-11-02 12:13:33 -050027 fi
28
29 # Kill ourselves to signal any calling process
30 trap 2; kill -2 $$
31}
32
Jesse Andrewsd7326d22011-11-20 10:02:26 -080033trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
Dean Troyerfda65b82011-11-02 12:13:33 -050034
35# Keep track of the current directory
36TOOLS_DIR=$(cd $(dirname "$0") && pwd)
37TOP_DIR=`cd $TOOLS_DIR/..; pwd`
38
39# Abort if localrc is not set
40if [ ! -e $TOP_DIR/localrc ]; then
41 echo "You must have a localrc with ALL necessary passwords and configuration defined before proceeding."
42 echo "See stack.sh for required passwords."
43 exit 1
44fi
45
46# Source params
47source ./stackrc
48
49# Where Openstack code lives
50DEST=${DEST:-/opt/stack}
51
Dean Troyerf79cc422011-12-01 10:21:42 -060052CITEST_DIR=$DEST/tempest
Dean Troyer44d8f8f2011-11-23 23:21:06 -060053
54CONFIG_DIR=${1:-$CITEST_DIR/etc}
55CONFIG_CONF=$CONFIG_DIR/storm.conf
56CONFIG_INI=$CONFIG_DIR/config.ini
57
Dean Troyer39c2efc2011-11-07 16:40:35 -060058DIST_NAME=${DIST_NAME:-oneiric}
Dean Troyerb0e57cf2011-11-04 12:13:43 -050059
Dean Troyer44d8f8f2011-11-23 23:21:06 -060060# git clone only if directory doesn't exist already. Since ``DEST`` might not
61# be owned by the installation user, we create the directory and change the
62# ownership to the proper user.
63function git_clone {
64
65 GIT_REMOTE=$1
66 GIT_DEST=$2
67 GIT_BRANCH=$3
68
69 # do a full clone only if the directory doesn't exist
70 if [ ! -d $GIT_DEST ]; then
71 git clone $GIT_REMOTE $GIT_DEST
72 cd $2
73 # This checkout syntax works for both branches and tags
74 git checkout $GIT_BRANCH
75 elif [[ "$RECLONE" == "yes" ]]; then
76 # if it does exist then simulate what clone does if asked to RECLONE
77 cd $GIT_DEST
78 # set the url to pull from and fetch
79 git remote set-url origin $GIT_REMOTE
80 git fetch origin
81 # remove the existing ignored files (like pyc) as they cause breakage
82 # (due to the py files having older timestamps than our pyc, so python
83 # thinks the pyc files are correct using them)
84 find $GIT_DEST -name '*.pyc' -delete
85 git checkout -f origin/$GIT_BRANCH
86 # a local branch might not exist
87 git branch -D $GIT_BRANCH || true
88 git checkout -b $GIT_BRANCH
89 fi
90}
91
92# Install tests and prerequisites
Dean Troyerf79cc422011-12-01 10:21:42 -060093sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install --use-mirrors `cat $TOP_DIR/files/pips/tempest`
Dean Troyer44d8f8f2011-11-23 23:21:06 -060094
95git_clone $CITEST_REPO $CITEST_DIR $CITEST_BRANCH
96
Jesse Andrewsd7326d22011-11-20 10:02:26 -080097if [ ! -f $DEST/.ramdisk ]; then
98 # Process network configuration vars
99 GUEST_NETWORK=${GUEST_NETWORK:-1}
100 GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes}
Dean Troyerfda65b82011-11-02 12:13:33 -0500101
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800102 GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50}
103 GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24}
104 GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0}
105 GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1}
106 GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"}
107 GUEST_RAM=${GUEST_RAM:-1524288}
108 GUEST_CORES=${GUEST_CORES:-1}
109fi
Dean Troyerfda65b82011-11-02 12:13:33 -0500110
111# Use the GUEST_IP unless an explicit IP is set by ``HOST_IP``
112HOST_IP=${HOST_IP:-$GUEST_IP}
113# Use the first IP if HOST_IP still is not set
114if [ ! -n "$HOST_IP" ]; then
115 HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
116fi
117
118RABBIT_HOST=${RABBIT_HOST:-localhost}
119
120# Glance connection info. Note the port must be specified.
121GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
122set `echo $GLANCE_HOSTPORT | tr ':' ' '`
123GLANCE_HOST=$1
124GLANCE_PORT=$2
125
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800126# Create storm.conf
127
128CONFIG_CONF_TMP=$(mktemp $CONFIG_CONF.XXXXXX)
129 cat >$CONFIG_CONF_TMP <<EOF
130[nova]
131auth_url=http://$HOST_IP:5000/v2.0/tokens
132user=admin
133api_key=$ADMIN_PASSWORD
134tenant_name=admin
135ssh_timeout=300
136build_interval=10
137build_timeout=600
138
139[environment]
140image_ref=3
141image_ref_alt=4
142flavor_ref=1
143flavor_ref_alt=2
144create_image_enabled=true
145resize_available=true
146authentication=keystone_v2
147EOF
148mv $CONFIG_CONF_TMP $CONFIG_CONF
149CONFIG_CONF_TMP=""
150
151# Create config.ini
152
153CONFIG_INI_TMP=$(mktemp $CONFIG_INI.XXXXXX)
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500154if [ "$UPLOAD_LEGACY_TTY" ]; then
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800155 cat >$CONFIG_INI_TMP <<EOF
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500156[environment]
157aki_location = $DEST/devstack/files/images/aki-tty/image
158ari_location = $DEST/devstack/files/images/ari-tty/image
159ami_location = $DEST/devstack/files/images/ami-tty/image
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800160image_ref = 3
161image_ref_alt = 3
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500162flavor_ref = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800163flavor_ref_alt = 2
164
165[glance]
166host = $GLANCE_HOST
167apiver = v1
168port = $GLANCE_PORT
169image_id = 3
170image_id_alt = 3
171tenant_id = 1
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500172EOF
173else
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800174 cat >$CONFIG_INI_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -0500175[environment]
Dean Troyerb0e57cf2011-11-04 12:13:43 -0500176aki_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-vmlinuz-virtual
177#ari_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-loader
178ami_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64.img
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800179image_ref = 2
180image_ref_alt = 2
Dean Troyerff0ed1d2011-11-05 16:15:11 -0500181flavor_ref = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800182flavor_ref_alt = 2
Dean Troyerfda65b82011-11-02 12:13:33 -0500183
184[glance]
185host = $GLANCE_HOST
Dean Troyera0e29482011-11-04 19:44:06 -0500186apiver = v1
Dean Troyerfda65b82011-11-02 12:13:33 -0500187port = $GLANCE_PORT
188image_id = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800189image_id_alt = 1
Dean Troyera0e29482011-11-04 19:44:06 -0500190tenant_id = 1
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800191EOF
192fi
193
194cat >>$CONFIG_INI_TMP <<EOF
Dean Troyerfda65b82011-11-02 12:13:33 -0500195
196[keystone]
197service_host = $HOST_IP
198service_port = 5000
Dean Troyer5db287c2011-11-02 21:21:36 -0500199apiver = v2.0
Dean Troyerfda65b82011-11-02 12:13:33 -0500200user = admin
201password = $ADMIN_PASSWORD
Dolph Mathews50e32292011-12-15 16:04:49 -0600202tenant_name = admin
Dean Troyerfda65b82011-11-02 12:13:33 -0500203
204[nova]
205host = $HOST_IP
206port = 8774
207apiver = v1.1
208project = admin
209user = admin
Dean Troyerb0e57cf2011-11-04 12:13:43 -0500210key = $ADMIN_PASSWORD
Dean Troyerfda65b82011-11-02 12:13:33 -0500211ssh_timeout = 300
212build_timeout = 300
213flavor_ref = 1
214flavor_ref_alt = 2
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800215multi_node = no
Dean Troyerfda65b82011-11-02 12:13:33 -0500216
217[rabbitmq]
218host = $RABBIT_HOST
219user = guest
220password = $RABBIT_PASSWORD
221
222[swift]
223auth_host = $HOST_IP
224auth_port = 443
225auth_prefix = /auth/
226auth_ssl = yes
227account = system
228username = root
229password = password
230
231EOF
Jesse Andrewsd7326d22011-11-20 10:02:26 -0800232mv $CONFIG_INI_TMP $CONFIG_INI
233CONFIG_INI_TMP=""
234
235trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT