blob: 51ddcc5580e4d9a5c0ff6e6c12892b2466a458dd [file] [log] [blame]
Jesse Andrewsba23cc72011-09-11 03:22:13 -07001#!/usr/bin/env bash
2
Jesse Andrews6f3baaf2011-09-12 11:59:38 -07003# **stack.sh** is rackspace cloudbuilder's opinionated openstack dev installation.
Jesse Andrewsba23cc72011-09-11 03:22:13 -07004
Jesse Andrews30f68e92011-09-13 00:59:54 -07005# Settings/Options
Jesse Andrewsd74257d2011-09-13 01:24:50 -07006# ================
Jesse Andrews30f68e92011-09-13 00:59:54 -07007
Jesse Andrewsd74257d2011-09-13 01:24:50 -07008# This script is customizable through setting environment variables. If you
9# want to override a setting you can either::
10#
11# export MYSQL_PASS=anothersecret
12# ./stack.sh
13#
14# or run on a single line ``MYSQL_PASS=simple ./stack.sh``
Anthony Young963d2eb2011-09-13 17:29:02 -070015# or simply ``./stack.sh``
Jesse Andrewsd74257d2011-09-13 01:24:50 -070016
17# This script exits on an error so that errors don't compound and you see
18# only the first error that occured.
Jesse Andrewsba23cc72011-09-11 03:22:13 -070019set -o errexit
20
Jesse Andrewsd74257d2011-09-13 01:24:50 -070021# Print the commands being run so that we can see the command that triggers
22# an error. It is also useful for following allowing as the install occurs.
Jesse Andrewsba23cc72011-09-11 03:22:13 -070023set -o xtrace
24
Anthony Younge7335c22011-09-15 20:58:31 -070025# Warn users who aren't on natty
26if ! grep -q natty /etc/lsb-release; then
27 echo "WARNING: this script has only been tested on natty"
28fi
29
Jesse Andrewsd74257d2011-09-13 01:24:50 -070030# Important paths: ``DIR`` is where we are executing from and ``DEST`` is
31# where we are installing openstack.
Jesse Andrewsba23cc72011-09-11 03:22:13 -070032DIR=`pwd`
33DEST=/opt
Jesse Andrewsba23cc72011-09-11 03:22:13 -070034
Jesse Andrews6f3baaf2011-09-12 11:59:38 -070035# Set the destination directories for openstack projects
Jesse Andrewsba23cc72011-09-11 03:22:13 -070036NOVA_DIR=$DEST/nova
37DASH_DIR=$DEST/dash
Jake Dahn9337b332011-09-15 21:46:20 -070038NIXON_DIR=$DEST/dash/openstack-dashboard/dashboard/nixon
Jesse Andrewsba23cc72011-09-11 03:22:13 -070039GLANCE_DIR=$DEST/glance
40KEYSTONE_DIR=$DEST/keystone
41NOVACLIENT_DIR=$DEST/python-novaclient
42API_DIR=$DEST/openstackx
43NOVNC_DIR=$DEST/noVNC
Dean Troyer0017c8f2011-09-13 15:37:50 -050044MUNIN_DIR=$DEST/openstack-munin
Anthony Younga8416442011-09-13 20:07:44 -070045
46# Specify which services to launch. These generally correspond to screen tabs
Anthony Young70dc5e02011-09-15 16:52:43 -070047ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,dash,mysql,rabbit}
Jesse Andrewsba23cc72011-09-11 03:22:13 -070048
Jesse Andrewsd74257d2011-09-13 01:24:50 -070049# Use the first IP unless an explicit is set by ``HOST_IP`` environment variable
Jesse Andrewsba23cc72011-09-11 03:22:13 -070050if [ ! -n "$HOST_IP" ]; then
Dean Troyer2a15a7c2011-09-13 13:22:14 -050051 HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
Jesse Andrewsba23cc72011-09-11 03:22:13 -070052fi
53
Jesse Andrewsd74257d2011-09-13 01:24:50 -070054# Nova network configuration
Jesse Andrewsba23cc72011-09-11 03:22:13 -070055INTERFACE=${INTERFACE:-eth0}
56FLOATING_RANGE=${FLOATING_RANGE:-10.6.0.0/27}
57FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
Jesse Andrewsba23cc72011-09-11 03:22:13 -070058NET_MAN=${NET_MAN:-VlanManager}
Anthony Younga8416442011-09-13 20:07:44 -070059EC2_DMZ_HOST=${EC2_DMZ_HOST:-$HOST_IP}
Jesse Andrews30f68e92011-09-13 00:59:54 -070060
Jesse Andrewsd74257d2011-09-13 01:24:50 -070061# If you are using FlatDHCP on multiple hosts, set the ``FLAT_INTERFACE``
62# variable but make sure that the interface doesn't already have an
63# ip or you risk breaking things.
Jesse Andrewsba23cc72011-09-11 03:22:13 -070064# FLAT_INTERFACE=eth0
65
Jesse Andrewsd74257d2011-09-13 01:24:50 -070066# Nova hypervisor configuration
67LIBVIRT_TYPE=${LIBVIRT_TYPE:-qemu}
68
Anthony Younga8416442011-09-13 20:07:44 -070069# Mysql connection info
Anthony Young320412b2011-09-14 02:39:10 -070070MYSQL_USER=${MYSQL_USER:-root}
Anthony Young1c364642011-09-13 20:21:42 -070071MYSQL_PASS=${MYSQL_PASS:-nova}
Anthony Younga8416442011-09-13 20:07:44 -070072MYSQL_HOST=${MYSQL_HOST:-localhost}
73# don't specify /db in this string, so we can use it for multiple services
Anthony Youngfdaf21a2011-09-13 20:11:42 -070074BASE_SQL_CONN=${BASE_SQL_CONN:-mysql://$MYSQL_USER:$MYSQL_PASS@$MYSQL_HOST}
Anthony Younga8416442011-09-13 20:07:44 -070075
76# Rabbit connection info
77RABBIT_HOST=${RABBIT_HOST:-localhost}
Jesse Andrewsba23cc72011-09-11 03:22:13 -070078
Anthony Young377aae62011-09-14 09:55:31 -070079# Glance connection info. Note the port must be specified.
80GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-0.0.0.0:9292}
81
Jesse Andrews30f68e92011-09-13 00:59:54 -070082# Install Packages
Jesse Andrewsd74257d2011-09-13 01:24:50 -070083# ================
Jesse Andrews30f68e92011-09-13 00:59:54 -070084#
85# Openstack uses a fair number of other projects.
86
Jesse Andrewsd74257d2011-09-13 01:24:50 -070087# Seed configuration with mysql password so that apt-get install doesn't
88# prompt us for a password upon install.
Jesse Andrews18d350d2011-09-12 21:46:12 -070089cat <<MYSQL_PRESEED | sudo debconf-set-selections
Jesse Andrews1c1d1502011-09-12 19:29:56 -070090mysql-server-5.1 mysql-server/root_password password $MYSQL_PASS
91mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASS
92mysql-server-5.1 mysql-server/start_on_boot boolean true
93MYSQL_PRESEED
Jesse Andrews2caf8fd2011-09-12 16:15:11 -070094
Jesse Andrews75a37652011-09-12 17:09:08 -070095# install apt requirements
Jesse Andrews18d350d2011-09-12 21:46:12 -070096sudo apt-get install -y -q `cat $DIR/apts/* | cut -d\# -f1`
Jesse Andrewsba23cc72011-09-11 03:22:13 -070097
Jesse Andrews75a37652011-09-12 17:09:08 -070098# install python requirements
Anthony Young1bbd9e02011-09-12 23:59:19 -070099sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $DIR/pips/*`
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700100
Jesse Andrews61632572011-09-12 17:40:00 -0700101# git clone only if directory doesn't exist already
102function git_clone {
103 if [ ! -d $2 ]; then
104 git clone $1 $2
105 fi
106}
107
Jesse Andrews75a37652011-09-12 17:09:08 -0700108# compute service
Jesse Andrews61632572011-09-12 17:40:00 -0700109git_clone https://github.com/cloudbuilders/nova.git $NOVA_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700110# image catalog service
Jesse Andrews61632572011-09-12 17:40:00 -0700111git_clone https://github.com/cloudbuilders/glance.git $GLANCE_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700112# unified auth system (manages accounts/tokens)
Jesse Andrews61632572011-09-12 17:40:00 -0700113git_clone https://github.com/cloudbuilders/keystone.git $KEYSTONE_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700114# a websockets/html5 or flash powered VNC console for vm instances
Jesse Andrews61632572011-09-12 17:40:00 -0700115git_clone https://github.com/cloudbuilders/noVNC.git $NOVNC_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700116# django powered web control panel for openstack
Jesse Andrews61632572011-09-12 17:40:00 -0700117git_clone https://github.com/cloudbuilders/openstack-dashboard.git $DASH_DIR
Jake Dahn9337b332011-09-15 21:46:20 -0700118# add nixon, the iframing dashboard extension
119git clone https://github.com/jakedahn/nixon.git $NIXON_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700120# python client library to nova that dashboard (and others) use
Jesse Andrews61632572011-09-12 17:40:00 -0700121git_clone https://github.com/cloudbuilders/python-novaclient.git $NOVACLIENT_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700122# openstackx is a collection of extensions to openstack.compute & nova
123# that is *deprecated*. The code is being moved into python-novaclient & nova.
Jesse Andrews61632572011-09-12 17:40:00 -0700124git_clone https://github.com/cloudbuilders/openstackx.git $API_DIR
Dean Troyer0017c8f2011-09-13 15:37:50 -0500125# openstack-munin is a collection of munin plugins for monitoring the stack
126git_clone https://github.com/cloudbuilders/openstack-munin.git $MUNIN_DIR
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700127
Jesse Andrews30f68e92011-09-13 00:59:54 -0700128# Initialization
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700129# ==============
Jesse Andrews30f68e92011-09-13 00:59:54 -0700130
Jesse Andrews75a37652011-09-12 17:09:08 -0700131# setup our checkouts so they are installed into python path
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700132# allowing ``import nova`` or ``import glance.client``
Dean Troyer0017c8f2011-09-13 15:37:50 -0500133cd $NOVA_DIR; sudo python setup.py develop
Jesse Andrews18d350d2011-09-12 21:46:12 -0700134cd $NOVACLIENT_DIR; sudo python setup.py develop
135cd $KEYSTONE_DIR; sudo python setup.py develop
136cd $GLANCE_DIR; sudo python setup.py develop
137cd $API_DIR; sudo python setup.py develop
138cd $DASH_DIR/django-openstack; sudo python setup.py develop
139cd $DASH_DIR/openstack-dashboard; sudo python setup.py develop
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700140
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700141# add useful screenrc
142cp $DIR/files/screenrc ~/.screenrc
Jesse Andrews6f3baaf2011-09-12 11:59:38 -0700143
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700144# TODO: update current user to allow sudo for all commands in files/sudo/*
145
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700146
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700147# Dashboard
148# ---------
149#
150# Setup the django application to serve via apache/wsgi
Jesse Andrews75a37652011-09-12 17:09:08 -0700151
152# Dash currently imports quantum even if you aren't using it. Instead
153# of installing quantum we can create a simple module that will pass the
154# initial imports
Anthony Young70dc5e02011-09-15 16:52:43 -0700155if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
156 sudo mkdir -p $DASH_DIR/openstack-dashboard/quantum || true
157 sudo touch $DASH_DIR/openstack-dashboard/quantum/__init__.py
158 sudo touch $DASH_DIR/openstack-dashboard/quantum/client.py
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700159
Anthony Young70dc5e02011-09-15 16:52:43 -0700160 cd $DASH_DIR/openstack-dashboard
Jake Dahn9337b332011-09-15 21:46:20 -0700161 sudo cp $DIR/files/dash_settings.py local/local_settings.py
162
Anthony Young70dc5e02011-09-15 16:52:43 -0700163 dashboard/manage.py syncdb
Jesse Andrews75a37652011-09-12 17:09:08 -0700164
Anthony Young70dc5e02011-09-15 16:52:43 -0700165 # create an empty directory that apache uses as docroot
166 sudo mkdir -p $DASH_DIR/.blackhole
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700167
Anthony Young70dc5e02011-09-15 16:52:43 -0700168 ## Configure apache's 000-default to run dashboard
169 sudo cp $DIR/files/000-default.template /etc/apache2/sites-enabled/000-default
170 sudo sed -e "s,%DASH_DIR%,$DASH_DIR,g" -i /etc/apache2/sites-enabled/000-default
Jesse Andrews18d350d2011-09-12 21:46:12 -0700171
Anthony Young70dc5e02011-09-15 16:52:43 -0700172 # ``python setup.py develop`` left some files owned by root in ``DASH_DIR`` and
173 # others by the original owner. We need to change the owner to apache so
174 # dashboard can run
175 sudo chown -R www-data:www-data $DASH_DIR
176fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700177
Anthony Young3859f732011-09-14 02:33:43 -0700178
Anthony Young70dc5e02011-09-15 16:52:43 -0700179# Mysql
180# ---------
181#
182if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
183 # Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases:
184 sudo mysql -uroot -p$MYSQL_PASS -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' identified by '$MYSQL_PASS';"
185
186 # Edit /etc/mysql/my.cnf to change ‘bind-address’ from localhost (127.0.0.1) to any (0.0.0.0) and restart the mysql service:
187 sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
188 sudo service mysql restart
189fi
190
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700191
Dean Troyer0017c8f2011-09-13 15:37:50 -0500192# Munin
193# -----
194
Dean Troyer0017c8f2011-09-13 15:37:50 -0500195
Anthony Young70dc5e02011-09-15 16:52:43 -0700196if [[ "$ENABLED_SERVICES" =~ "munin" ]]; then
197 # allow connections from other hosts
198 sudo sed -i -e '/Allow from localhost/s/localhost.*$/all/' /etc/munin/apache.conf
199
200 cat >/tmp/nova <<EOF
Dean Troyer0017c8f2011-09-13 15:37:50 -0500201[keystone_*]
Dean Troyer925df4c2011-09-14 10:20:57 -0500202user `whoami`
Dean Troyer0017c8f2011-09-13 15:37:50 -0500203
204[nova_*]
Dean Troyer925df4c2011-09-14 10:20:57 -0500205user `whoami`
Dean Troyer0017c8f2011-09-13 15:37:50 -0500206EOF
Anthony Young70dc5e02011-09-15 16:52:43 -0700207 sudo mv /tmp/nova /etc/munin/plugin-conf.d/nova
208 # configure Munin for Nova plugins
209 PLUGINS="keystone_stats nova_floating_ips nova_instance_launched nova_instance_ nova_instance_timing nova_services"
210 for i in $PLUGINS; do
211 sudo cp -p $MUNIN_DIR/$i /usr/share/munin/plugins
212 sudo ln -sf /usr/share/munin/plugins/$i /etc/munin/plugins
213 done
214 sudo mv /etc/munin/plugins/nova_instance_ /etc/munin/plugins/nova_instance_launched
215 sudo restart munin-node
216fi
Dean Troyer0017c8f2011-09-13 15:37:50 -0500217
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700218# Glance
219# ------
220
Anthony Young70dc5e02011-09-15 16:52:43 -0700221if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
222 # Glance uses ``/var/lib/glance`` and ``/var/log/glance`` by default, so
223 # we need to insure that our user has permissions to use them.
224 sudo mkdir -p /var/log/glance
225 sudo chown -R `whoami` /var/log/glance
226 sudo mkdir -p /var/lib/glance
227 sudo chown -R `whoami` /var/lib/glance
Jesse Andrews75a37652011-09-12 17:09:08 -0700228
Anthony Young70dc5e02011-09-15 16:52:43 -0700229 # Delete existing images/database as glance will recreate the db on startup
230 rm -rf /var/lib/glance/images/*
231 # (re)create glance database
232 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE glance;' || true
233 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE glance;'
234 # Copy over our glance-registry.conf
235 GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf
236 cp $DIR/files/glance-registry.conf $GLANCE_CONF
237 sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/glance,g" -i $GLANCE_CONF
238fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700239
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700240# Nova
241# ----
242
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700243function add_nova_flag {
244 echo "$1" >> $NOVA_DIR/bin/nova.conf
245}
246
Jesse Andrews75a37652011-09-12 17:09:08 -0700247# (re)create nova.conf
248rm -f $NOVA_DIR/bin/nova.conf
249add_nova_flag "--verbose"
250add_nova_flag "--nodaemon"
251add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf"
252add_nova_flag "--network_manager=nova.network.manager.$NET_MAN"
253add_nova_flag "--my_ip=$HOST_IP"
254add_nova_flag "--public_interface=$INTERFACE"
255add_nova_flag "--vlan_interface=$INTERFACE"
Anthony Younga8416442011-09-13 20:07:44 -0700256add_nova_flag "--sql_connection=$BASE_SQL_CONN/nova"
Jesse Andrews75a37652011-09-12 17:09:08 -0700257add_nova_flag "--libvirt_type=$LIBVIRT_TYPE"
258add_nova_flag "--osapi_extensions_path=$API_DIR/extensions"
259add_nova_flag "--vncproxy_url=http://$HOST_IP:6080"
Anthony Young1f81db62011-09-13 03:35:00 -0700260add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/"
Jesse Andrews75a37652011-09-12 17:09:08 -0700261add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini"
262add_nova_flag "--image_service=nova.image.glance.GlanceImageService"
Anthony Younga8416442011-09-13 20:07:44 -0700263add_nova_flag "--ec2_dmz_host=$EC2_DMZ_HOST"
264add_nova_flag "--rabbit_host=$RABBIT_HOST"
Anthony Young377aae62011-09-14 09:55:31 -0700265add_nova_flag "--glance_api_servers=$GLANCE_HOSTPORT"
Jesse Andrews75a37652011-09-12 17:09:08 -0700266if [ -n "$FLAT_INTERFACE" ]; then
267 add_nova_flag "--flat_interface=$FLAT_INTERFACE"
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700268fi
269
Jesse Andrews75a37652011-09-12 17:09:08 -0700270# create a new named screen to store things in
271screen -d -m -S nova -t nova
272sleep 1
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700273
Anthony Young70dc5e02011-09-15 16:52:43 -0700274if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700275
Anthony Young70dc5e02011-09-15 16:52:43 -0700276 # attempt to load modules: kvm (hardware virt) and nbd (network block
277 # device - used to manage qcow images)
278 sudo modprobe nbd || true
279 sudo modprobe kvm || true
280 # user needs to be member of libvirtd group for nova-compute to use libvirt
281 sudo usermod -a -G libvirtd `whoami`
282 # if kvm wasn't running before we need to restart libvirt to enable it
283 sudo /etc/init.d/libvirt-bin restart
284
285 ## FIXME(ja): should LIBVIRT_TYPE be kvm if kvm module is loaded?
286
287 # setup nova instance directory
288 mkdir -p $NOVA_DIR/instances
289
290 # if there is a partition labeled nova-instances use it (ext filesystems
291 # can be labeled via e2label)
292 ## FIXME: if already mounted this blows up...
293 if [ -L /dev/disk/by-label/nova-instances ]; then
294 sudo mount -L nova-instances $NOVA_DIR/instances
295 sudo chown -R `whoami` $NOVA_DIR/instances
296 fi
297
298 # Clean out the instances directory
299 rm -rf $NOVA_DIR/instances/*
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700300fi
301
Anthony Young70dc5e02011-09-15 16:52:43 -0700302if [[ "$ENABLED_SERVICES" =~ "n-net" ]]; then
303 # delete traces of nova networks from prior runs
304 killall dnsmasq || true
305 rm -rf $NOVA_DIR/networks
306 mkdir -p $NOVA_DIR/networks
307fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700308
Anthony Young70dc5e02011-09-15 16:52:43 -0700309if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
310 # (re)create nova database
311 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE nova;' || true
312 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE nova;'
313 $NOVA_DIR/bin/nova-manage db sync
Jesse Andrews75a37652011-09-12 17:09:08 -0700314
Anthony Young70dc5e02011-09-15 16:52:43 -0700315 # create a small network
316 $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 32
Jesse Andrewse8d9cd82011-09-13 15:16:26 -0700317
Anthony Young70dc5e02011-09-15 16:52:43 -0700318 # create some floating ips
319 $NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE
320fi
Jesse Andrewse8d9cd82011-09-13 15:16:26 -0700321
322# Keystone
323# --------
324
Anthony Young70dc5e02011-09-15 16:52:43 -0700325if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
326 # (re)create keystone database
327 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE keystone;' || true
328 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE keystone;'
Jesse Andrews75a37652011-09-12 17:09:08 -0700329
Anthony Young70dc5e02011-09-15 16:52:43 -0700330 # FIXME (anthony) keystone should use keystone.conf.example
331 KEYSTONE_CONF=$KEYSTONE_DIR/etc/keystone.conf
332 cp $DIR/files/keystone.conf $KEYSTONE_CONF
333 sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/keystone,g" -i $KEYSTONE_CONF
Anthony Young3a093122011-09-13 19:01:45 +0000334
Anthony Young70dc5e02011-09-15 16:52:43 -0700335 # initialize keystone with default users/endpoints
336 BIN_DIR=$KEYSTONE_DIR/bin bash $DIR/files/keystone_data.sh
337fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700338
Jesse Andrews75a37652011-09-12 17:09:08 -0700339
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700340# Launch Services
341# ===============
Jesse Andrews30f68e92011-09-13 00:59:54 -0700342
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700343# nova api crashes if we start it with a regular screen command,
344# so send the start command by forcing text into the window.
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700345# Only run the services specified in ``ENABLED_SERVICES``
346
347NL=`echo -ne '\015'`
348
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700349function screen_it {
Anthony Young292e46d2011-09-13 11:28:56 -0700350 if [[ "$ENABLED_SERVICES" =~ "$1" ]]; then
351 screen -S nova -X screen -t $1
352 screen -S nova -p $1 -X stuff "$2$NL"
353 fi
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700354}
355
Jesse Andrews75a37652011-09-12 17:09:08 -0700356screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf"
357screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf"
Anthony Young70dc5e02011-09-15 16:52:43 -0700358screen_it key "$KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF"
Jesse Andrews55508d62011-09-12 19:00:28 -0700359screen_it n-api "$NOVA_DIR/bin/nova-api"
360screen_it n-cpu "$NOVA_DIR/bin/nova-compute"
361screen_it n-net "$NOVA_DIR/bin/nova-network"
362screen_it n-sch "$NOVA_DIR/bin/nova-scheduler"
Anthony Young1f81db62011-09-13 03:35:00 -0700363# nova-vncproxy binds a privileged port, and so needs sudo
364screen_it n-vnc "sudo $NOVA_DIR/bin/nova-vncproxy"
Anthony Young8fbba912011-09-13 09:20:58 -0700365screen_it dash "sudo /etc/init.d/apache2 restart; sudo tail -f /var/log/apache2/error.log"
Jesse Andrews75a37652011-09-12 17:09:08 -0700366
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700367# Install Images
368# ==============
Jesse Andrewse49b8bd2011-09-12 18:08:04 -0700369
Anthony Young70dc5e02011-09-15 16:52:43 -0700370if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
371 # Downloads a tty image (ami/aki/ari style), then extracts it. Upon extraction
372 # we upload to glance with the glance cli tool.
373 mkdir -p $DEST/images
374 cd $DEST/images
375 if [ ! -f $DEST/tty.tgz ]; then
376 wget -c http://images.ansolabs.com/tty.tgz -O $DEST/tty.tgz
377 fi
Jesse Andrewse49b8bd2011-09-12 18:08:04 -0700378
Anthony Young70dc5e02011-09-15 16:52:43 -0700379 # extract ami-tty/image, aki-tty/image & ari-tty/image
380 tar -zxf $DEST/tty.tgz
381
382 # add images to glance
383 # FIXME: kernel/ramdisk is hardcoded - use return result from add
384 glance add name="tty-kernel" is_public=true container_format=aki disk_format=aki < aki-tty/image
385 glance add name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < ari-tty/image
386 glance add name="tty" is_public=true container_format=ami disk_format=ami kernel_id=1 ramdisk_id=2 < ami-tty/image
Jesse Andrewse49b8bd2011-09-12 18:08:04 -0700387fi