blob: 0519fbc02f2702874fc0eb05db99bf22d997d930 [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
46GLANCE_DIR=$DEST/glance
47KEYSTONE_DIR=$DEST/keystone
48NOVACLIENT_DIR=$DEST/python-novaclient
49API_DIR=$DEST/openstackx
50NOVNC_DIR=$DEST/noVNC
Dean Troyer0017c8f2011-09-13 15:37:50 -050051MUNIN_DIR=$DEST/openstack-munin
Anthony Younga8416442011-09-13 20:07:44 -070052
53# Specify which services to launch. These generally correspond to screen tabs
Anthony Young70dc5e02011-09-15 16:52:43 -070054ENABLED_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 -070055
Jesse Andrewsd74257d2011-09-13 01:24:50 -070056# Use the first IP unless an explicit is set by ``HOST_IP`` environment variable
Jesse Andrewsba23cc72011-09-11 03:22:13 -070057if [ ! -n "$HOST_IP" ]; then
Dean Troyer2a15a7c2011-09-13 13:22:14 -050058 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 -070059fi
60
Jesse Andrewsd74257d2011-09-13 01:24:50 -070061# Nova network configuration
Jesse Andrewsba23cc72011-09-11 03:22:13 -070062INTERFACE=${INTERFACE:-eth0}
63FLOATING_RANGE=${FLOATING_RANGE:-10.6.0.0/27}
64FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
Jesse Andrewsba23cc72011-09-11 03:22:13 -070065NET_MAN=${NET_MAN:-VlanManager}
Anthony Younga8416442011-09-13 20:07:44 -070066EC2_DMZ_HOST=${EC2_DMZ_HOST:-$HOST_IP}
Jesse Andrews30f68e92011-09-13 00:59:54 -070067
Jesse Andrewsd74257d2011-09-13 01:24:50 -070068# If you are using FlatDHCP on multiple hosts, set the ``FLAT_INTERFACE``
69# variable but make sure that the interface doesn't already have an
70# ip or you risk breaking things.
Jesse Andrewsba23cc72011-09-11 03:22:13 -070071# FLAT_INTERFACE=eth0
72
Jesse Andrewsd74257d2011-09-13 01:24:50 -070073# Nova hypervisor configuration
74LIBVIRT_TYPE=${LIBVIRT_TYPE:-qemu}
75
Anthony Younga8416442011-09-13 20:07:44 -070076# Mysql connection info
Anthony Young320412b2011-09-14 02:39:10 -070077MYSQL_USER=${MYSQL_USER:-root}
Anthony Young1c364642011-09-13 20:21:42 -070078MYSQL_PASS=${MYSQL_PASS:-nova}
Anthony Younga8416442011-09-13 20:07:44 -070079MYSQL_HOST=${MYSQL_HOST:-localhost}
80# don't specify /db in this string, so we can use it for multiple services
Anthony Youngfdaf21a2011-09-13 20:11:42 -070081BASE_SQL_CONN=${BASE_SQL_CONN:-mysql://$MYSQL_USER:$MYSQL_PASS@$MYSQL_HOST}
Anthony Younga8416442011-09-13 20:07:44 -070082
83# Rabbit connection info
84RABBIT_HOST=${RABBIT_HOST:-localhost}
Jesse Andrewsba23cc72011-09-11 03:22:13 -070085
Anthony Young377aae62011-09-14 09:55:31 -070086# Glance connection info. Note the port must be specified.
87GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-0.0.0.0:9292}
88
Jesse Andrews30f68e92011-09-13 00:59:54 -070089# Install Packages
Jesse Andrewsd74257d2011-09-13 01:24:50 -070090# ================
Jesse Andrews30f68e92011-09-13 00:59:54 -070091#
92# Openstack uses a fair number of other projects.
93
Jesse Andrewsd74257d2011-09-13 01:24:50 -070094# Seed configuration with mysql password so that apt-get install doesn't
95# prompt us for a password upon install.
Jesse Andrews18d350d2011-09-12 21:46:12 -070096cat <<MYSQL_PRESEED | sudo debconf-set-selections
Jesse Andrews1c1d1502011-09-12 19:29:56 -070097mysql-server-5.1 mysql-server/root_password password $MYSQL_PASS
98mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASS
99mysql-server-5.1 mysql-server/start_on_boot boolean true
100MYSQL_PRESEED
Jesse Andrews2caf8fd2011-09-12 16:15:11 -0700101
Jesse Andrews75a37652011-09-12 17:09:08 -0700102# install apt requirements
Jesse Andrews18d350d2011-09-12 21:46:12 -0700103sudo apt-get install -y -q `cat $DIR/apts/* | cut -d\# -f1`
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700104
Jesse Andrews75a37652011-09-12 17:09:08 -0700105# install python requirements
Anthony Young1bbd9e02011-09-12 23:59:19 -0700106sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $DIR/pips/*`
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700107
Jesse Andrews61632572011-09-12 17:40:00 -0700108# git clone only if directory doesn't exist already
109function git_clone {
110 if [ ! -d $2 ]; then
111 git clone $1 $2
112 fi
113}
114
Jesse Andrews75a37652011-09-12 17:09:08 -0700115# compute service
Jesse Andrews61632572011-09-12 17:40:00 -0700116git_clone https://github.com/cloudbuilders/nova.git $NOVA_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700117# image catalog service
Jesse Andrews61632572011-09-12 17:40:00 -0700118git_clone https://github.com/cloudbuilders/glance.git $GLANCE_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700119# unified auth system (manages accounts/tokens)
Jesse Andrews61632572011-09-12 17:40:00 -0700120git_clone https://github.com/cloudbuilders/keystone.git $KEYSTONE_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700121# a websockets/html5 or flash powered VNC console for vm instances
Jesse Andrews61632572011-09-12 17:40:00 -0700122git_clone https://github.com/cloudbuilders/noVNC.git $NOVNC_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700123# django powered web control panel for openstack
Jesse Andrews61632572011-09-12 17:40:00 -0700124git_clone https://github.com/cloudbuilders/openstack-dashboard.git $DASH_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700125# python client library to nova that dashboard (and others) use
Jesse Andrews61632572011-09-12 17:40:00 -0700126git_clone https://github.com/cloudbuilders/python-novaclient.git $NOVACLIENT_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700127# openstackx is a collection of extensions to openstack.compute & nova
128# that is *deprecated*. The code is being moved into python-novaclient & nova.
Jesse Andrews61632572011-09-12 17:40:00 -0700129git_clone https://github.com/cloudbuilders/openstackx.git $API_DIR
Dean Troyer0017c8f2011-09-13 15:37:50 -0500130# openstack-munin is a collection of munin plugins for monitoring the stack
131git_clone https://github.com/cloudbuilders/openstack-munin.git $MUNIN_DIR
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700132
Jesse Andrews30f68e92011-09-13 00:59:54 -0700133# Initialization
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700134# ==============
Jesse Andrews30f68e92011-09-13 00:59:54 -0700135
Jesse Andrews75a37652011-09-12 17:09:08 -0700136# setup our checkouts so they are installed into python path
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700137# allowing ``import nova`` or ``import glance.client``
Dean Troyer0017c8f2011-09-13 15:37:50 -0500138cd $NOVA_DIR; sudo python setup.py develop
Jesse Andrews18d350d2011-09-12 21:46:12 -0700139cd $NOVACLIENT_DIR; sudo python setup.py develop
140cd $KEYSTONE_DIR; sudo python setup.py develop
141cd $GLANCE_DIR; sudo python setup.py develop
142cd $API_DIR; sudo python setup.py develop
143cd $DASH_DIR/django-openstack; sudo python setup.py develop
144cd $DASH_DIR/openstack-dashboard; sudo python setup.py develop
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700145
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700146# add useful screenrc
147cp $DIR/files/screenrc ~/.screenrc
Jesse Andrews6f3baaf2011-09-12 11:59:38 -0700148
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700149# TODO: update current user to allow sudo for all commands in files/sudo/*
150
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700151
Jesse Andrews24859062011-09-15 21:28:23 -0700152# Mysql
153# ---------
154#
155if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
156 # Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases:
157 sudo mysql -uroot -p$MYSQL_PASS -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' identified by '$MYSQL_PASS';"
158
159 # 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:
160 sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
161 sudo service mysql restart
162fi
163
164
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700165# Dashboard
166# ---------
167#
168# Setup the django application to serve via apache/wsgi
Jesse Andrews75a37652011-09-12 17:09:08 -0700169
Anthony Young70dc5e02011-09-15 16:52:43 -0700170if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
Jesse Andrews24859062011-09-15 21:28:23 -0700171
172 # Dash currently imports quantum even if you aren't using it. Instead
173 # of installing quantum we can create a simple module that will pass the
174 # initial imports
Anthony Young70dc5e02011-09-15 16:52:43 -0700175 sudo mkdir -p $DASH_DIR/openstack-dashboard/quantum || true
176 sudo touch $DASH_DIR/openstack-dashboard/quantum/__init__.py
177 sudo touch $DASH_DIR/openstack-dashboard/quantum/client.py
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700178
Anthony Young70dc5e02011-09-15 16:52:43 -0700179 cd $DASH_DIR/openstack-dashboard
180 sudo cp local/local_settings.py.example local/local_settings.py
181 dashboard/manage.py syncdb
Jesse Andrews75a37652011-09-12 17:09:08 -0700182
Anthony Young70dc5e02011-09-15 16:52:43 -0700183 # create an empty directory that apache uses as docroot
184 sudo mkdir -p $DASH_DIR/.blackhole
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700185
Anthony Young70dc5e02011-09-15 16:52:43 -0700186 ## Configure apache's 000-default to run dashboard
187 sudo cp $DIR/files/000-default.template /etc/apache2/sites-enabled/000-default
188 sudo sed -e "s,%DASH_DIR%,$DASH_DIR,g" -i /etc/apache2/sites-enabled/000-default
Jesse Andrews18d350d2011-09-12 21:46:12 -0700189
Anthony Young70dc5e02011-09-15 16:52:43 -0700190 # ``python setup.py develop`` left some files owned by root in ``DASH_DIR`` and
191 # others by the original owner. We need to change the owner to apache so
192 # dashboard can run
193 sudo chown -R www-data:www-data $DASH_DIR
194fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700195
Anthony Young3859f732011-09-14 02:33:43 -0700196
Dean Troyer0017c8f2011-09-13 15:37:50 -0500197# Munin
198# -----
199
Jesse Andrews24859062011-09-15 21:28:23 -0700200# Munin is accessable via apache and was configured in the dashboard section.
Dean Troyer0017c8f2011-09-13 15:37:50 -0500201
Anthony Young70dc5e02011-09-15 16:52:43 -0700202if [[ "$ENABLED_SERVICES" =~ "munin" ]]; then
203 # allow connections from other hosts
204 sudo sed -i -e '/Allow from localhost/s/localhost.*$/all/' /etc/munin/apache.conf
205
206 cat >/tmp/nova <<EOF
Dean Troyer0017c8f2011-09-13 15:37:50 -0500207[keystone_*]
Dean Troyer925df4c2011-09-14 10:20:57 -0500208user `whoami`
Dean Troyer0017c8f2011-09-13 15:37:50 -0500209
210[nova_*]
Dean Troyer925df4c2011-09-14 10:20:57 -0500211user `whoami`
Dean Troyer0017c8f2011-09-13 15:37:50 -0500212EOF
Anthony Young70dc5e02011-09-15 16:52:43 -0700213 sudo mv /tmp/nova /etc/munin/plugin-conf.d/nova
214 # configure Munin for Nova plugins
215 PLUGINS="keystone_stats nova_floating_ips nova_instance_launched nova_instance_ nova_instance_timing nova_services"
216 for i in $PLUGINS; do
217 sudo cp -p $MUNIN_DIR/$i /usr/share/munin/plugins
218 sudo ln -sf /usr/share/munin/plugins/$i /etc/munin/plugins
219 done
220 sudo mv /etc/munin/plugins/nova_instance_ /etc/munin/plugins/nova_instance_launched
221 sudo restart munin-node
222fi
Dean Troyer0017c8f2011-09-13 15:37:50 -0500223
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700224# Glance
225# ------
226
Anthony Young70dc5e02011-09-15 16:52:43 -0700227if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
228 # Glance uses ``/var/lib/glance`` and ``/var/log/glance`` by default, so
229 # we need to insure that our user has permissions to use them.
230 sudo mkdir -p /var/log/glance
231 sudo chown -R `whoami` /var/log/glance
232 sudo mkdir -p /var/lib/glance
233 sudo chown -R `whoami` /var/lib/glance
Jesse Andrews75a37652011-09-12 17:09:08 -0700234
Anthony Young70dc5e02011-09-15 16:52:43 -0700235 # Delete existing images/database as glance will recreate the db on startup
236 rm -rf /var/lib/glance/images/*
237 # (re)create glance database
238 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE glance;' || true
239 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE glance;'
240 # Copy over our glance-registry.conf
241 GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf
242 cp $DIR/files/glance-registry.conf $GLANCE_CONF
243 sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/glance,g" -i $GLANCE_CONF
244fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700245
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700246# Nova
247# ----
248
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700249function add_nova_flag {
250 echo "$1" >> $NOVA_DIR/bin/nova.conf
251}
252
Jesse Andrews75a37652011-09-12 17:09:08 -0700253# (re)create nova.conf
254rm -f $NOVA_DIR/bin/nova.conf
255add_nova_flag "--verbose"
256add_nova_flag "--nodaemon"
257add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf"
258add_nova_flag "--network_manager=nova.network.manager.$NET_MAN"
259add_nova_flag "--my_ip=$HOST_IP"
260add_nova_flag "--public_interface=$INTERFACE"
261add_nova_flag "--vlan_interface=$INTERFACE"
Anthony Younga8416442011-09-13 20:07:44 -0700262add_nova_flag "--sql_connection=$BASE_SQL_CONN/nova"
Jesse Andrews75a37652011-09-12 17:09:08 -0700263add_nova_flag "--libvirt_type=$LIBVIRT_TYPE"
264add_nova_flag "--osapi_extensions_path=$API_DIR/extensions"
265add_nova_flag "--vncproxy_url=http://$HOST_IP:6080"
Anthony Young1f81db62011-09-13 03:35:00 -0700266add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/"
Jesse Andrews75a37652011-09-12 17:09:08 -0700267add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini"
268add_nova_flag "--image_service=nova.image.glance.GlanceImageService"
Anthony Younga8416442011-09-13 20:07:44 -0700269add_nova_flag "--ec2_dmz_host=$EC2_DMZ_HOST"
270add_nova_flag "--rabbit_host=$RABBIT_HOST"
Anthony Young377aae62011-09-14 09:55:31 -0700271add_nova_flag "--glance_api_servers=$GLANCE_HOSTPORT"
Jesse Andrews75a37652011-09-12 17:09:08 -0700272if [ -n "$FLAT_INTERFACE" ]; then
273 add_nova_flag "--flat_interface=$FLAT_INTERFACE"
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700274fi
275
Jesse Andrews75a37652011-09-12 17:09:08 -0700276# create a new named screen to store things in
277screen -d -m -S nova -t nova
278sleep 1
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700279
Anthony Young70dc5e02011-09-15 16:52:43 -0700280if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700281
Anthony Young70dc5e02011-09-15 16:52:43 -0700282 # attempt to load modules: kvm (hardware virt) and nbd (network block
283 # device - used to manage qcow images)
284 sudo modprobe nbd || true
285 sudo modprobe kvm || true
286 # user needs to be member of libvirtd group for nova-compute to use libvirt
287 sudo usermod -a -G libvirtd `whoami`
288 # if kvm wasn't running before we need to restart libvirt to enable it
289 sudo /etc/init.d/libvirt-bin restart
290
291 ## FIXME(ja): should LIBVIRT_TYPE be kvm if kvm module is loaded?
292
293 # setup nova instance directory
294 mkdir -p $NOVA_DIR/instances
295
296 # if there is a partition labeled nova-instances use it (ext filesystems
297 # can be labeled via e2label)
298 ## FIXME: if already mounted this blows up...
299 if [ -L /dev/disk/by-label/nova-instances ]; then
300 sudo mount -L nova-instances $NOVA_DIR/instances
301 sudo chown -R `whoami` $NOVA_DIR/instances
302 fi
303
304 # Clean out the instances directory
305 rm -rf $NOVA_DIR/instances/*
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700306fi
307
Anthony Young70dc5e02011-09-15 16:52:43 -0700308if [[ "$ENABLED_SERVICES" =~ "n-net" ]]; then
309 # delete traces of nova networks from prior runs
310 killall dnsmasq || true
311 rm -rf $NOVA_DIR/networks
312 mkdir -p $NOVA_DIR/networks
313fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700314
Anthony Young70dc5e02011-09-15 16:52:43 -0700315if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
316 # (re)create nova database
317 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE nova;' || true
318 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE nova;'
319 $NOVA_DIR/bin/nova-manage db sync
Jesse Andrews75a37652011-09-12 17:09:08 -0700320
Anthony Young70dc5e02011-09-15 16:52:43 -0700321 # create a small network
322 $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 32
Jesse Andrewse8d9cd82011-09-13 15:16:26 -0700323
Anthony Young70dc5e02011-09-15 16:52:43 -0700324 # create some floating ips
325 $NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE
326fi
Jesse Andrewse8d9cd82011-09-13 15:16:26 -0700327
328# Keystone
329# --------
330
Anthony Young70dc5e02011-09-15 16:52:43 -0700331if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
332 # (re)create keystone database
333 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE keystone;' || true
334 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE keystone;'
Jesse Andrews75a37652011-09-12 17:09:08 -0700335
Anthony Young70dc5e02011-09-15 16:52:43 -0700336 # FIXME (anthony) keystone should use keystone.conf.example
337 KEYSTONE_CONF=$KEYSTONE_DIR/etc/keystone.conf
338 cp $DIR/files/keystone.conf $KEYSTONE_CONF
339 sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/keystone,g" -i $KEYSTONE_CONF
Anthony Young3a093122011-09-13 19:01:45 +0000340
Anthony Young70dc5e02011-09-15 16:52:43 -0700341 # initialize keystone with default users/endpoints
342 BIN_DIR=$KEYSTONE_DIR/bin bash $DIR/files/keystone_data.sh
343fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700344
Jesse Andrews75a37652011-09-12 17:09:08 -0700345
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700346# Launch Services
347# ===============
Jesse Andrews30f68e92011-09-13 00:59:54 -0700348
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700349# nova api crashes if we start it with a regular screen command,
350# so send the start command by forcing text into the window.
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700351# Only run the services specified in ``ENABLED_SERVICES``
352
353NL=`echo -ne '\015'`
354
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700355function screen_it {
Anthony Young292e46d2011-09-13 11:28:56 -0700356 if [[ "$ENABLED_SERVICES" =~ "$1" ]]; then
357 screen -S nova -X screen -t $1
358 screen -S nova -p $1 -X stuff "$2$NL"
359 fi
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700360}
361
Jesse Andrews75a37652011-09-12 17:09:08 -0700362screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf"
363screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf"
Anthony Young70dc5e02011-09-15 16:52:43 -0700364screen_it key "$KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF"
Jesse Andrews55508d62011-09-12 19:00:28 -0700365screen_it n-api "$NOVA_DIR/bin/nova-api"
366screen_it n-cpu "$NOVA_DIR/bin/nova-compute"
367screen_it n-net "$NOVA_DIR/bin/nova-network"
368screen_it n-sch "$NOVA_DIR/bin/nova-scheduler"
Anthony Young1f81db62011-09-13 03:35:00 -0700369# nova-vncproxy binds a privileged port, and so needs sudo
370screen_it n-vnc "sudo $NOVA_DIR/bin/nova-vncproxy"
Anthony Young8fbba912011-09-13 09:20:58 -0700371screen_it dash "sudo /etc/init.d/apache2 restart; sudo tail -f /var/log/apache2/error.log"
Jesse Andrews75a37652011-09-12 17:09:08 -0700372
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700373# Install Images
374# ==============
Jesse Andrewse49b8bd2011-09-12 18:08:04 -0700375
Anthony Young70dc5e02011-09-15 16:52:43 -0700376if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
377 # Downloads a tty image (ami/aki/ari style), then extracts it. Upon extraction
378 # we upload to glance with the glance cli tool.
379 mkdir -p $DEST/images
380 cd $DEST/images
381 if [ ! -f $DEST/tty.tgz ]; then
382 wget -c http://images.ansolabs.com/tty.tgz -O $DEST/tty.tgz
383 fi
Jesse Andrewse49b8bd2011-09-12 18:08:04 -0700384
Anthony Young70dc5e02011-09-15 16:52:43 -0700385 # extract ami-tty/image, aki-tty/image & ari-tty/image
386 tar -zxf $DEST/tty.tgz
387
388 # add images to glance
389 # FIXME: kernel/ramdisk is hardcoded - use return result from add
390 glance add name="tty-kernel" is_public=true container_format=aki disk_format=aki < aki-tty/image
391 glance add name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < ari-tty/image
392 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 -0700393fi
Jesse Andrews24859062011-09-15 21:28:23 -0700394
395# Using the cloud
396# ===============
397
398# If you installed the dashboard on this server, then you should be able
399# to access the site using your browser.
400if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
401 echo "dashboard is now available at http://$HOST_IP/"
402fi
403
404# If keystone is present, you can point nova cli to this server
405if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
406 echo "keystone is serving at http://$HOST_IP:5000/v2.0/"
407 echo "examples on using novaclient command line is in exercise.sh"
408fi