blob: 3758f59ae0abfe4dd5f0e7b4c983f1b49e42fa0e [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 Andrews24859062011-09-15 21:28:23 -07005# To keep this script simple we assume you are running on an **Ubuntu 11.04 i
6# Natty** machine. It should work in a VM or physical server. Additionally we
7# put the list of *apt* and *pip* dependencies and other configuration files in
8# this repo. So start by grabbing this script and the dependencies.
9
Jesse Andrews30f68e92011-09-13 00:59:54 -070010# Settings/Options
Jesse Andrewsd74257d2011-09-13 01:24:50 -070011# ================
Jesse Andrews30f68e92011-09-13 00:59:54 -070012
Jesse Andrewsd74257d2011-09-13 01:24:50 -070013# This script is customizable through setting environment variables. If you
14# want to override a setting you can either::
15#
16# export MYSQL_PASS=anothersecret
17# ./stack.sh
18#
19# or run on a single line ``MYSQL_PASS=simple ./stack.sh``
Anthony Young963d2eb2011-09-13 17:29:02 -070020# or simply ``./stack.sh``
Jesse Andrewsd74257d2011-09-13 01:24:50 -070021
22# This script exits on an error so that errors don't compound and you see
23# only the first error that occured.
Jesse Andrewsba23cc72011-09-11 03:22:13 -070024set -o errexit
25
Jesse Andrewsd74257d2011-09-13 01:24:50 -070026# Print the commands being run so that we can see the command that triggers
27# an error. It is also useful for following allowing as the install occurs.
Jesse Andrewsba23cc72011-09-11 03:22:13 -070028set -o xtrace
29
Anthony Younge7335c22011-09-15 20:58:31 -070030# Warn users who aren't on natty
Jesse Andrews24859062011-09-15 21:28:23 -070031## TODO: alter flow to exit unless the user sets environment FORCE=true
Jesse Andrews7dd13d02011-09-15 21:29:15 -070032## TODO: warn user if apts, pips and other files don't exist that they
33## need more than just this script
Anthony Younge7335c22011-09-15 20:58:31 -070034if ! grep -q natty /etc/lsb-release; then
35 echo "WARNING: this script has only been tested on natty"
36fi
37
Jesse Andrewsd74257d2011-09-13 01:24:50 -070038# Important paths: ``DIR`` is where we are executing from and ``DEST`` is
39# where we are installing openstack.
Jesse Andrewsba23cc72011-09-11 03:22:13 -070040DIR=`pwd`
41DEST=/opt
Jesse Andrewsba23cc72011-09-11 03:22:13 -070042
Jesse Andrews6f3baaf2011-09-12 11:59:38 -070043# Set the destination directories for openstack projects
Jesse Andrewsba23cc72011-09-11 03:22:13 -070044NOVA_DIR=$DEST/nova
45DASH_DIR=$DEST/dash
Jake Dahn9337b332011-09-15 21:46:20 -070046NIXON_DIR=$DEST/dash/openstack-dashboard/dashboard/nixon
Jesse Andrewsba23cc72011-09-11 03:22:13 -070047GLANCE_DIR=$DEST/glance
48KEYSTONE_DIR=$DEST/keystone
49NOVACLIENT_DIR=$DEST/python-novaclient
50API_DIR=$DEST/openstackx
51NOVNC_DIR=$DEST/noVNC
Dean Troyer0017c8f2011-09-13 15:37:50 -050052MUNIN_DIR=$DEST/openstack-munin
Anthony Younga8416442011-09-13 20:07:44 -070053
54# Specify which services to launch. These generally correspond to screen tabs
Anthony Young70dc5e02011-09-15 16:52:43 -070055ENABLED_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 -070056
Jesse Andrewsd74257d2011-09-13 01:24:50 -070057# Use the first IP unless an explicit is set by ``HOST_IP`` environment variable
Jesse Andrewsba23cc72011-09-11 03:22:13 -070058if [ ! -n "$HOST_IP" ]; then
Dean Troyer2a15a7c2011-09-13 13:22:14 -050059 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 -070060fi
61
Jesse Andrewsd74257d2011-09-13 01:24:50 -070062# Nova network configuration
Jesse Andrewsba23cc72011-09-11 03:22:13 -070063INTERFACE=${INTERFACE:-eth0}
64FLOATING_RANGE=${FLOATING_RANGE:-10.6.0.0/27}
65FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
Jesse Andrewsba23cc72011-09-11 03:22:13 -070066NET_MAN=${NET_MAN:-VlanManager}
Anthony Younga8416442011-09-13 20:07:44 -070067EC2_DMZ_HOST=${EC2_DMZ_HOST:-$HOST_IP}
Jesse Andrews30f68e92011-09-13 00:59:54 -070068
Jesse Andrewsd74257d2011-09-13 01:24:50 -070069# If you are using FlatDHCP on multiple hosts, set the ``FLAT_INTERFACE``
70# variable but make sure that the interface doesn't already have an
71# ip or you risk breaking things.
Jesse Andrewsba23cc72011-09-11 03:22:13 -070072# FLAT_INTERFACE=eth0
73
Jesse Andrewsd74257d2011-09-13 01:24:50 -070074# Nova hypervisor configuration
75LIBVIRT_TYPE=${LIBVIRT_TYPE:-qemu}
76
Anthony Younga8416442011-09-13 20:07:44 -070077# Mysql connection info
Anthony Young320412b2011-09-14 02:39:10 -070078MYSQL_USER=${MYSQL_USER:-root}
Anthony Young1c364642011-09-13 20:21:42 -070079MYSQL_PASS=${MYSQL_PASS:-nova}
Anthony Younga8416442011-09-13 20:07:44 -070080MYSQL_HOST=${MYSQL_HOST:-localhost}
81# don't specify /db in this string, so we can use it for multiple services
Anthony Youngfdaf21a2011-09-13 20:11:42 -070082BASE_SQL_CONN=${BASE_SQL_CONN:-mysql://$MYSQL_USER:$MYSQL_PASS@$MYSQL_HOST}
Anthony Younga8416442011-09-13 20:07:44 -070083
84# Rabbit connection info
85RABBIT_HOST=${RABBIT_HOST:-localhost}
Jesse Andrewsba23cc72011-09-11 03:22:13 -070086
Anthony Young377aae62011-09-14 09:55:31 -070087# Glance connection info. Note the port must be specified.
88GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-0.0.0.0:9292}
89
Jesse Andrews30f68e92011-09-13 00:59:54 -070090# Install Packages
Jesse Andrewsd74257d2011-09-13 01:24:50 -070091# ================
Jesse Andrews30f68e92011-09-13 00:59:54 -070092#
93# Openstack uses a fair number of other projects.
94
Jesse Andrewsd74257d2011-09-13 01:24:50 -070095# Seed configuration with mysql password so that apt-get install doesn't
96# prompt us for a password upon install.
Jesse Andrews18d350d2011-09-12 21:46:12 -070097cat <<MYSQL_PRESEED | sudo debconf-set-selections
Jesse Andrews1c1d1502011-09-12 19:29:56 -070098mysql-server-5.1 mysql-server/root_password password $MYSQL_PASS
99mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASS
100mysql-server-5.1 mysql-server/start_on_boot boolean true
101MYSQL_PRESEED
Jesse Andrews2caf8fd2011-09-12 16:15:11 -0700102
Jesse Andrews75a37652011-09-12 17:09:08 -0700103# install apt requirements
Jesse Andrews18d350d2011-09-12 21:46:12 -0700104sudo apt-get install -y -q `cat $DIR/apts/* | cut -d\# -f1`
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700105
Jesse Andrews75a37652011-09-12 17:09:08 -0700106# install python requirements
Anthony Young1bbd9e02011-09-12 23:59:19 -0700107sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $DIR/pips/*`
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700108
Jesse Andrews61632572011-09-12 17:40:00 -0700109# git clone only if directory doesn't exist already
110function git_clone {
111 if [ ! -d $2 ]; then
112 git clone $1 $2
113 fi
114}
115
Jesse Andrews75a37652011-09-12 17:09:08 -0700116# compute service
Jesse Andrews61632572011-09-12 17:40:00 -0700117git_clone https://github.com/cloudbuilders/nova.git $NOVA_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700118# image catalog service
Jesse Andrews61632572011-09-12 17:40:00 -0700119git_clone https://github.com/cloudbuilders/glance.git $GLANCE_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700120# unified auth system (manages accounts/tokens)
Jesse Andrews61632572011-09-12 17:40:00 -0700121git_clone https://github.com/cloudbuilders/keystone.git $KEYSTONE_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700122# a websockets/html5 or flash powered VNC console for vm instances
Jesse Andrews61632572011-09-12 17:40:00 -0700123git_clone https://github.com/cloudbuilders/noVNC.git $NOVNC_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700124# django powered web control panel for openstack
Jesse Andrews61632572011-09-12 17:40:00 -0700125git_clone https://github.com/cloudbuilders/openstack-dashboard.git $DASH_DIR
Jake Dahn9337b332011-09-15 21:46:20 -0700126# add nixon, the iframing dashboard extension
127git clone https://github.com/jakedahn/nixon.git $NIXON_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700128# python client library to nova that dashboard (and others) use
Jesse Andrews61632572011-09-12 17:40:00 -0700129git_clone https://github.com/cloudbuilders/python-novaclient.git $NOVACLIENT_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700130# openstackx is a collection of extensions to openstack.compute & nova
131# that is *deprecated*. The code is being moved into python-novaclient & nova.
Jesse Andrews61632572011-09-12 17:40:00 -0700132git_clone https://github.com/cloudbuilders/openstackx.git $API_DIR
Dean Troyer0017c8f2011-09-13 15:37:50 -0500133# openstack-munin is a collection of munin plugins for monitoring the stack
134git_clone https://github.com/cloudbuilders/openstack-munin.git $MUNIN_DIR
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700135
Jesse Andrews30f68e92011-09-13 00:59:54 -0700136# Initialization
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700137# ==============
Jesse Andrews30f68e92011-09-13 00:59:54 -0700138
Jesse Andrews75a37652011-09-12 17:09:08 -0700139# setup our checkouts so they are installed into python path
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700140# allowing ``import nova`` or ``import glance.client``
Dean Troyer0017c8f2011-09-13 15:37:50 -0500141cd $NOVA_DIR; sudo python setup.py develop
Jesse Andrews18d350d2011-09-12 21:46:12 -0700142cd $NOVACLIENT_DIR; sudo python setup.py develop
143cd $KEYSTONE_DIR; sudo python setup.py develop
144cd $GLANCE_DIR; sudo python setup.py develop
145cd $API_DIR; sudo python setup.py develop
146cd $DASH_DIR/django-openstack; sudo python setup.py develop
147cd $DASH_DIR/openstack-dashboard; sudo python setup.py develop
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700148
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700149# add useful screenrc
150cp $DIR/files/screenrc ~/.screenrc
Jesse Andrews6f3baaf2011-09-12 11:59:38 -0700151
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700152# TODO: update current user to allow sudo for all commands in files/sudo/*
153
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700154
Jesse Andrews24859062011-09-15 21:28:23 -0700155# Mysql
156# ---------
157#
158if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
159 # Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases:
160 sudo mysql -uroot -p$MYSQL_PASS -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' identified by '$MYSQL_PASS';"
161
162 # 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:
163 sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
164 sudo service mysql restart
165fi
166
167
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700168# Dashboard
169# ---------
170#
171# Setup the django application to serve via apache/wsgi
Jesse Andrews75a37652011-09-12 17:09:08 -0700172
Anthony Young70dc5e02011-09-15 16:52:43 -0700173if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
Jesse Andrews24859062011-09-15 21:28:23 -0700174
175 # Dash currently imports quantum even if you aren't using it. Instead
176 # of installing quantum we can create a simple module that will pass the
177 # initial imports
Anthony Young70dc5e02011-09-15 16:52:43 -0700178 sudo mkdir -p $DASH_DIR/openstack-dashboard/quantum || true
179 sudo touch $DASH_DIR/openstack-dashboard/quantum/__init__.py
180 sudo touch $DASH_DIR/openstack-dashboard/quantum/client.py
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700181
Anthony Young70dc5e02011-09-15 16:52:43 -0700182 cd $DASH_DIR/openstack-dashboard
Jake Dahn9337b332011-09-15 21:46:20 -0700183 sudo cp $DIR/files/dash_settings.py local/local_settings.py
184
Anthony Young70dc5e02011-09-15 16:52:43 -0700185 dashboard/manage.py syncdb
Jesse Andrews75a37652011-09-12 17:09:08 -0700186
Anthony Young70dc5e02011-09-15 16:52:43 -0700187 # create an empty directory that apache uses as docroot
188 sudo mkdir -p $DASH_DIR/.blackhole
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700189
Anthony Young70dc5e02011-09-15 16:52:43 -0700190 ## Configure apache's 000-default to run dashboard
191 sudo cp $DIR/files/000-default.template /etc/apache2/sites-enabled/000-default
192 sudo sed -e "s,%DASH_DIR%,$DASH_DIR,g" -i /etc/apache2/sites-enabled/000-default
Jesse Andrews18d350d2011-09-12 21:46:12 -0700193
Anthony Young70dc5e02011-09-15 16:52:43 -0700194 # ``python setup.py develop`` left some files owned by root in ``DASH_DIR`` and
195 # others by the original owner. We need to change the owner to apache so
196 # dashboard can run
197 sudo chown -R www-data:www-data $DASH_DIR
198fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700199
Anthony Young3859f732011-09-14 02:33:43 -0700200
Dean Troyer0017c8f2011-09-13 15:37:50 -0500201# Munin
202# -----
203
Jesse Andrews24859062011-09-15 21:28:23 -0700204# Munin is accessable via apache and was configured in the dashboard section.
Dean Troyer0017c8f2011-09-13 15:37:50 -0500205
Anthony Young70dc5e02011-09-15 16:52:43 -0700206if [[ "$ENABLED_SERVICES" =~ "munin" ]]; then
207 # allow connections from other hosts
208 sudo sed -i -e '/Allow from localhost/s/localhost.*$/all/' /etc/munin/apache.conf
209
210 cat >/tmp/nova <<EOF
Dean Troyer0017c8f2011-09-13 15:37:50 -0500211[keystone_*]
Dean Troyer925df4c2011-09-14 10:20:57 -0500212user `whoami`
Dean Troyer0017c8f2011-09-13 15:37:50 -0500213
214[nova_*]
Dean Troyer925df4c2011-09-14 10:20:57 -0500215user `whoami`
Dean Troyer0017c8f2011-09-13 15:37:50 -0500216EOF
Anthony Young70dc5e02011-09-15 16:52:43 -0700217 sudo mv /tmp/nova /etc/munin/plugin-conf.d/nova
218 # configure Munin for Nova plugins
219 PLUGINS="keystone_stats nova_floating_ips nova_instance_launched nova_instance_ nova_instance_timing nova_services"
220 for i in $PLUGINS; do
221 sudo cp -p $MUNIN_DIR/$i /usr/share/munin/plugins
222 sudo ln -sf /usr/share/munin/plugins/$i /etc/munin/plugins
223 done
224 sudo mv /etc/munin/plugins/nova_instance_ /etc/munin/plugins/nova_instance_launched
225 sudo restart munin-node
226fi
Dean Troyer0017c8f2011-09-13 15:37:50 -0500227
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700228# Glance
229# ------
230
Anthony Young70dc5e02011-09-15 16:52:43 -0700231if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
232 # Glance uses ``/var/lib/glance`` and ``/var/log/glance`` by default, so
233 # we need to insure that our user has permissions to use them.
234 sudo mkdir -p /var/log/glance
235 sudo chown -R `whoami` /var/log/glance
236 sudo mkdir -p /var/lib/glance
237 sudo chown -R `whoami` /var/lib/glance
Jesse Andrews75a37652011-09-12 17:09:08 -0700238
Anthony Young70dc5e02011-09-15 16:52:43 -0700239 # Delete existing images/database as glance will recreate the db on startup
240 rm -rf /var/lib/glance/images/*
241 # (re)create glance database
242 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE glance;' || true
243 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE glance;'
244 # Copy over our glance-registry.conf
245 GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf
246 cp $DIR/files/glance-registry.conf $GLANCE_CONF
247 sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/glance,g" -i $GLANCE_CONF
248fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700249
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700250# Nova
251# ----
252
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700253function add_nova_flag {
254 echo "$1" >> $NOVA_DIR/bin/nova.conf
255}
256
Jesse Andrews75a37652011-09-12 17:09:08 -0700257# (re)create nova.conf
258rm -f $NOVA_DIR/bin/nova.conf
259add_nova_flag "--verbose"
260add_nova_flag "--nodaemon"
261add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf"
262add_nova_flag "--network_manager=nova.network.manager.$NET_MAN"
263add_nova_flag "--my_ip=$HOST_IP"
264add_nova_flag "--public_interface=$INTERFACE"
265add_nova_flag "--vlan_interface=$INTERFACE"
Anthony Younga8416442011-09-13 20:07:44 -0700266add_nova_flag "--sql_connection=$BASE_SQL_CONN/nova"
Jesse Andrews75a37652011-09-12 17:09:08 -0700267add_nova_flag "--libvirt_type=$LIBVIRT_TYPE"
268add_nova_flag "--osapi_extensions_path=$API_DIR/extensions"
269add_nova_flag "--vncproxy_url=http://$HOST_IP:6080"
Anthony Young1f81db62011-09-13 03:35:00 -0700270add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/"
Jesse Andrews75a37652011-09-12 17:09:08 -0700271add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini"
272add_nova_flag "--image_service=nova.image.glance.GlanceImageService"
Anthony Younga8416442011-09-13 20:07:44 -0700273add_nova_flag "--ec2_dmz_host=$EC2_DMZ_HOST"
274add_nova_flag "--rabbit_host=$RABBIT_HOST"
Anthony Young377aae62011-09-14 09:55:31 -0700275add_nova_flag "--glance_api_servers=$GLANCE_HOSTPORT"
Jesse Andrews75a37652011-09-12 17:09:08 -0700276if [ -n "$FLAT_INTERFACE" ]; then
277 add_nova_flag "--flat_interface=$FLAT_INTERFACE"
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700278fi
279
Jesse Andrews75a37652011-09-12 17:09:08 -0700280# create a new named screen to store things in
281screen -d -m -S nova -t nova
282sleep 1
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700283
Anthony Young70dc5e02011-09-15 16:52:43 -0700284if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700285
Anthony Young70dc5e02011-09-15 16:52:43 -0700286 # attempt to load modules: kvm (hardware virt) and nbd (network block
287 # device - used to manage qcow images)
288 sudo modprobe nbd || true
289 sudo modprobe kvm || true
290 # user needs to be member of libvirtd group for nova-compute to use libvirt
291 sudo usermod -a -G libvirtd `whoami`
292 # if kvm wasn't running before we need to restart libvirt to enable it
293 sudo /etc/init.d/libvirt-bin restart
294
295 ## FIXME(ja): should LIBVIRT_TYPE be kvm if kvm module is loaded?
296
297 # setup nova instance directory
298 mkdir -p $NOVA_DIR/instances
299
300 # if there is a partition labeled nova-instances use it (ext filesystems
301 # can be labeled via e2label)
302 ## FIXME: if already mounted this blows up...
303 if [ -L /dev/disk/by-label/nova-instances ]; then
304 sudo mount -L nova-instances $NOVA_DIR/instances
305 sudo chown -R `whoami` $NOVA_DIR/instances
306 fi
307
308 # Clean out the instances directory
309 rm -rf $NOVA_DIR/instances/*
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700310fi
311
Anthony Young70dc5e02011-09-15 16:52:43 -0700312if [[ "$ENABLED_SERVICES" =~ "n-net" ]]; then
313 # delete traces of nova networks from prior runs
314 killall dnsmasq || true
315 rm -rf $NOVA_DIR/networks
316 mkdir -p $NOVA_DIR/networks
317fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700318
Anthony Young70dc5e02011-09-15 16:52:43 -0700319if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
320 # (re)create nova database
321 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE nova;' || true
322 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE nova;'
323 $NOVA_DIR/bin/nova-manage db sync
Jesse Andrews75a37652011-09-12 17:09:08 -0700324
Anthony Young70dc5e02011-09-15 16:52:43 -0700325 # create a small network
326 $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 32
Jesse Andrewse8d9cd82011-09-13 15:16:26 -0700327
Anthony Young70dc5e02011-09-15 16:52:43 -0700328 # create some floating ips
329 $NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE
330fi
Jesse Andrewse8d9cd82011-09-13 15:16:26 -0700331
332# Keystone
333# --------
334
Anthony Young70dc5e02011-09-15 16:52:43 -0700335if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
336 # (re)create keystone database
337 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE keystone;' || true
338 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE keystone;'
Jesse Andrews75a37652011-09-12 17:09:08 -0700339
Anthony Young70dc5e02011-09-15 16:52:43 -0700340 # FIXME (anthony) keystone should use keystone.conf.example
341 KEYSTONE_CONF=$KEYSTONE_DIR/etc/keystone.conf
342 cp $DIR/files/keystone.conf $KEYSTONE_CONF
343 sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/keystone,g" -i $KEYSTONE_CONF
Anthony Young3a093122011-09-13 19:01:45 +0000344
Anthony Young70dc5e02011-09-15 16:52:43 -0700345 # initialize keystone with default users/endpoints
346 BIN_DIR=$KEYSTONE_DIR/bin bash $DIR/files/keystone_data.sh
347fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700348
Jesse Andrews75a37652011-09-12 17:09:08 -0700349
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700350# Launch Services
351# ===============
Jesse Andrews30f68e92011-09-13 00:59:54 -0700352
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700353# nova api crashes if we start it with a regular screen command,
354# so send the start command by forcing text into the window.
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700355# Only run the services specified in ``ENABLED_SERVICES``
356
357NL=`echo -ne '\015'`
358
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700359function screen_it {
Anthony Young292e46d2011-09-13 11:28:56 -0700360 if [[ "$ENABLED_SERVICES" =~ "$1" ]]; then
361 screen -S nova -X screen -t $1
362 screen -S nova -p $1 -X stuff "$2$NL"
363 fi
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700364}
365
Jesse Andrews75a37652011-09-12 17:09:08 -0700366screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf"
367screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf"
Anthony Young70dc5e02011-09-15 16:52:43 -0700368screen_it key "$KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF"
Jesse Andrews55508d62011-09-12 19:00:28 -0700369screen_it n-api "$NOVA_DIR/bin/nova-api"
370screen_it n-cpu "$NOVA_DIR/bin/nova-compute"
371screen_it n-net "$NOVA_DIR/bin/nova-network"
372screen_it n-sch "$NOVA_DIR/bin/nova-scheduler"
Anthony Young1f81db62011-09-13 03:35:00 -0700373# nova-vncproxy binds a privileged port, and so needs sudo
374screen_it n-vnc "sudo $NOVA_DIR/bin/nova-vncproxy"
Anthony Young8fbba912011-09-13 09:20:58 -0700375screen_it dash "sudo /etc/init.d/apache2 restart; sudo tail -f /var/log/apache2/error.log"
Jesse Andrews75a37652011-09-12 17:09:08 -0700376
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700377# Install Images
378# ==============
Jesse Andrewse49b8bd2011-09-12 18:08:04 -0700379
Anthony Young70dc5e02011-09-15 16:52:43 -0700380if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
381 # Downloads a tty image (ami/aki/ari style), then extracts it. Upon extraction
382 # we upload to glance with the glance cli tool.
383 mkdir -p $DEST/images
384 cd $DEST/images
385 if [ ! -f $DEST/tty.tgz ]; then
386 wget -c http://images.ansolabs.com/tty.tgz -O $DEST/tty.tgz
387 fi
Jesse Andrewse49b8bd2011-09-12 18:08:04 -0700388
Anthony Young70dc5e02011-09-15 16:52:43 -0700389 # extract ami-tty/image, aki-tty/image & ari-tty/image
390 tar -zxf $DEST/tty.tgz
391
392 # add images to glance
393 # FIXME: kernel/ramdisk is hardcoded - use return result from add
394 glance add name="tty-kernel" is_public=true container_format=aki disk_format=aki < aki-tty/image
395 glance add name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < ari-tty/image
396 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 -0700397fi
Jesse Andrews24859062011-09-15 21:28:23 -0700398
399# Using the cloud
400# ===============
401
402# If you installed the dashboard on this server, then you should be able
403# to access the site using your browser.
404if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
405 echo "dashboard is now available at http://$HOST_IP/"
406fi
407
408# If keystone is present, you can point nova cli to this server
409if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
410 echo "keystone is serving at http://$HOST_IP:5000/v2.0/"
411 echo "examples on using novaclient command line is in exercise.sh"
412fi