blob: aed5615bcf7b9d02a203d8e8dd078ca30fc6e6a5 [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
Anthony Younge7335c22011-09-15 20:58:31 -070032if ! grep -q natty /etc/lsb-release; then
33 echo "WARNING: this script has only been tested on natty"
34fi
35
Jesse Andrewsd74257d2011-09-13 01:24:50 -070036# Important paths: ``DIR`` is where we are executing from and ``DEST`` is
37# where we are installing openstack.
Jesse Andrewsba23cc72011-09-11 03:22:13 -070038DIR=`pwd`
39DEST=/opt
Jesse Andrewsba23cc72011-09-11 03:22:13 -070040
Jesse Andrews6f3baaf2011-09-12 11:59:38 -070041# Set the destination directories for openstack projects
Jesse Andrewsba23cc72011-09-11 03:22:13 -070042NOVA_DIR=$DEST/nova
43DASH_DIR=$DEST/dash
44GLANCE_DIR=$DEST/glance
45KEYSTONE_DIR=$DEST/keystone
46NOVACLIENT_DIR=$DEST/python-novaclient
47API_DIR=$DEST/openstackx
48NOVNC_DIR=$DEST/noVNC
Dean Troyer0017c8f2011-09-13 15:37:50 -050049MUNIN_DIR=$DEST/openstack-munin
Anthony Younga8416442011-09-13 20:07:44 -070050
51# Specify which services to launch. These generally correspond to screen tabs
Anthony Young70dc5e02011-09-15 16:52:43 -070052ENABLED_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 -070053
Jesse Andrewsd74257d2011-09-13 01:24:50 -070054# Use the first IP unless an explicit is set by ``HOST_IP`` environment variable
Jesse Andrewsba23cc72011-09-11 03:22:13 -070055if [ ! -n "$HOST_IP" ]; then
Dean Troyer2a15a7c2011-09-13 13:22:14 -050056 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 -070057fi
58
Jesse Andrewsd74257d2011-09-13 01:24:50 -070059# Nova network configuration
Jesse Andrewsba23cc72011-09-11 03:22:13 -070060INTERFACE=${INTERFACE:-eth0}
61FLOATING_RANGE=${FLOATING_RANGE:-10.6.0.0/27}
62FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
Jesse Andrewsba23cc72011-09-11 03:22:13 -070063NET_MAN=${NET_MAN:-VlanManager}
Anthony Younga8416442011-09-13 20:07:44 -070064EC2_DMZ_HOST=${EC2_DMZ_HOST:-$HOST_IP}
Jesse Andrews30f68e92011-09-13 00:59:54 -070065
Jesse Andrewsd74257d2011-09-13 01:24:50 -070066# If you are using FlatDHCP on multiple hosts, set the ``FLAT_INTERFACE``
67# variable but make sure that the interface doesn't already have an
68# ip or you risk breaking things.
Jesse Andrewsba23cc72011-09-11 03:22:13 -070069# FLAT_INTERFACE=eth0
70
Jesse Andrewsd74257d2011-09-13 01:24:50 -070071# Nova hypervisor configuration
72LIBVIRT_TYPE=${LIBVIRT_TYPE:-qemu}
73
Anthony Younga8416442011-09-13 20:07:44 -070074# Mysql connection info
Anthony Young320412b2011-09-14 02:39:10 -070075MYSQL_USER=${MYSQL_USER:-root}
Anthony Young1c364642011-09-13 20:21:42 -070076MYSQL_PASS=${MYSQL_PASS:-nova}
Anthony Younga8416442011-09-13 20:07:44 -070077MYSQL_HOST=${MYSQL_HOST:-localhost}
78# don't specify /db in this string, so we can use it for multiple services
Anthony Youngfdaf21a2011-09-13 20:11:42 -070079BASE_SQL_CONN=${BASE_SQL_CONN:-mysql://$MYSQL_USER:$MYSQL_PASS@$MYSQL_HOST}
Anthony Younga8416442011-09-13 20:07:44 -070080
81# Rabbit connection info
82RABBIT_HOST=${RABBIT_HOST:-localhost}
Jesse Andrewsba23cc72011-09-11 03:22:13 -070083
Anthony Young377aae62011-09-14 09:55:31 -070084# Glance connection info. Note the port must be specified.
85GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-0.0.0.0:9292}
86
Jesse Andrews30f68e92011-09-13 00:59:54 -070087# Install Packages
Jesse Andrewsd74257d2011-09-13 01:24:50 -070088# ================
Jesse Andrews30f68e92011-09-13 00:59:54 -070089#
90# Openstack uses a fair number of other projects.
91
Jesse Andrewsd74257d2011-09-13 01:24:50 -070092# Seed configuration with mysql password so that apt-get install doesn't
93# prompt us for a password upon install.
Jesse Andrews18d350d2011-09-12 21:46:12 -070094cat <<MYSQL_PRESEED | sudo debconf-set-selections
Jesse Andrews1c1d1502011-09-12 19:29:56 -070095mysql-server-5.1 mysql-server/root_password password $MYSQL_PASS
96mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASS
97mysql-server-5.1 mysql-server/start_on_boot boolean true
98MYSQL_PRESEED
Jesse Andrews2caf8fd2011-09-12 16:15:11 -070099
Jesse Andrews75a37652011-09-12 17:09:08 -0700100# install apt requirements
Jesse Andrews18d350d2011-09-12 21:46:12 -0700101sudo apt-get install -y -q `cat $DIR/apts/* | cut -d\# -f1`
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700102
Jesse Andrews75a37652011-09-12 17:09:08 -0700103# install python requirements
Anthony Young1bbd9e02011-09-12 23:59:19 -0700104sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $DIR/pips/*`
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700105
Jesse Andrews61632572011-09-12 17:40:00 -0700106# git clone only if directory doesn't exist already
107function git_clone {
108 if [ ! -d $2 ]; then
109 git clone $1 $2
110 fi
111}
112
Jesse Andrews75a37652011-09-12 17:09:08 -0700113# compute service
Jesse Andrews61632572011-09-12 17:40:00 -0700114git_clone https://github.com/cloudbuilders/nova.git $NOVA_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700115# image catalog service
Jesse Andrews61632572011-09-12 17:40:00 -0700116git_clone https://github.com/cloudbuilders/glance.git $GLANCE_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700117# unified auth system (manages accounts/tokens)
Jesse Andrews61632572011-09-12 17:40:00 -0700118git_clone https://github.com/cloudbuilders/keystone.git $KEYSTONE_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700119# a websockets/html5 or flash powered VNC console for vm instances
Jesse Andrews61632572011-09-12 17:40:00 -0700120git_clone https://github.com/cloudbuilders/noVNC.git $NOVNC_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700121# django powered web control panel for openstack
Jesse Andrews61632572011-09-12 17:40:00 -0700122git_clone https://github.com/cloudbuilders/openstack-dashboard.git $DASH_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700123# python client library to nova that dashboard (and others) use
Jesse Andrews61632572011-09-12 17:40:00 -0700124git_clone https://github.com/cloudbuilders/python-novaclient.git $NOVACLIENT_DIR
Jesse Andrews75a37652011-09-12 17:09:08 -0700125# openstackx is a collection of extensions to openstack.compute & nova
126# that is *deprecated*. The code is being moved into python-novaclient & nova.
Jesse Andrews61632572011-09-12 17:40:00 -0700127git_clone https://github.com/cloudbuilders/openstackx.git $API_DIR
Dean Troyer0017c8f2011-09-13 15:37:50 -0500128# openstack-munin is a collection of munin plugins for monitoring the stack
129git_clone https://github.com/cloudbuilders/openstack-munin.git $MUNIN_DIR
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700130
Jesse Andrews30f68e92011-09-13 00:59:54 -0700131# Initialization
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700132# ==============
Jesse Andrews30f68e92011-09-13 00:59:54 -0700133
Jesse Andrews75a37652011-09-12 17:09:08 -0700134# setup our checkouts so they are installed into python path
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700135# allowing ``import nova`` or ``import glance.client``
Dean Troyer0017c8f2011-09-13 15:37:50 -0500136cd $NOVA_DIR; sudo python setup.py develop
Jesse Andrews18d350d2011-09-12 21:46:12 -0700137cd $NOVACLIENT_DIR; sudo python setup.py develop
138cd $KEYSTONE_DIR; sudo python setup.py develop
139cd $GLANCE_DIR; sudo python setup.py develop
140cd $API_DIR; sudo python setup.py develop
141cd $DASH_DIR/django-openstack; sudo python setup.py develop
142cd $DASH_DIR/openstack-dashboard; sudo python setup.py develop
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700143
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700144# add useful screenrc
145cp $DIR/files/screenrc ~/.screenrc
Jesse Andrews6f3baaf2011-09-12 11:59:38 -0700146
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700147# TODO: update current user to allow sudo for all commands in files/sudo/*
148
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700149
Jesse Andrews24859062011-09-15 21:28:23 -0700150# Mysql
151# ---------
152#
153if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
154 # Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases:
155 sudo mysql -uroot -p$MYSQL_PASS -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' identified by '$MYSQL_PASS';"
156
157 # 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:
158 sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
159 sudo service mysql restart
160fi
161
162
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700163# Dashboard
164# ---------
165#
166# Setup the django application to serve via apache/wsgi
Jesse Andrews75a37652011-09-12 17:09:08 -0700167
Anthony Young70dc5e02011-09-15 16:52:43 -0700168if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
Jesse Andrews24859062011-09-15 21:28:23 -0700169
170 # Dash currently imports quantum even if you aren't using it. Instead
171 # of installing quantum we can create a simple module that will pass the
172 # initial imports
Anthony Young70dc5e02011-09-15 16:52:43 -0700173 sudo mkdir -p $DASH_DIR/openstack-dashboard/quantum || true
174 sudo touch $DASH_DIR/openstack-dashboard/quantum/__init__.py
175 sudo touch $DASH_DIR/openstack-dashboard/quantum/client.py
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700176
Anthony Young70dc5e02011-09-15 16:52:43 -0700177 cd $DASH_DIR/openstack-dashboard
178 sudo cp local/local_settings.py.example local/local_settings.py
179 dashboard/manage.py syncdb
Jesse Andrews75a37652011-09-12 17:09:08 -0700180
Anthony Young70dc5e02011-09-15 16:52:43 -0700181 # create an empty directory that apache uses as docroot
182 sudo mkdir -p $DASH_DIR/.blackhole
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700183
Anthony Young70dc5e02011-09-15 16:52:43 -0700184 ## Configure apache's 000-default to run dashboard
185 sudo cp $DIR/files/000-default.template /etc/apache2/sites-enabled/000-default
186 sudo sed -e "s,%DASH_DIR%,$DASH_DIR,g" -i /etc/apache2/sites-enabled/000-default
Jesse Andrews18d350d2011-09-12 21:46:12 -0700187
Anthony Young70dc5e02011-09-15 16:52:43 -0700188 # ``python setup.py develop`` left some files owned by root in ``DASH_DIR`` and
189 # others by the original owner. We need to change the owner to apache so
190 # dashboard can run
191 sudo chown -R www-data:www-data $DASH_DIR
192fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700193
Anthony Young3859f732011-09-14 02:33:43 -0700194
Dean Troyer0017c8f2011-09-13 15:37:50 -0500195# Munin
196# -----
197
Jesse Andrews24859062011-09-15 21:28:23 -0700198# Munin is accessable via apache and was configured in the dashboard section.
Dean Troyer0017c8f2011-09-13 15:37:50 -0500199
Anthony Young70dc5e02011-09-15 16:52:43 -0700200if [[ "$ENABLED_SERVICES" =~ "munin" ]]; then
201 # allow connections from other hosts
202 sudo sed -i -e '/Allow from localhost/s/localhost.*$/all/' /etc/munin/apache.conf
203
204 cat >/tmp/nova <<EOF
Dean Troyer0017c8f2011-09-13 15:37:50 -0500205[keystone_*]
Dean Troyer925df4c2011-09-14 10:20:57 -0500206user `whoami`
Dean Troyer0017c8f2011-09-13 15:37:50 -0500207
208[nova_*]
Dean Troyer925df4c2011-09-14 10:20:57 -0500209user `whoami`
Dean Troyer0017c8f2011-09-13 15:37:50 -0500210EOF
Anthony Young70dc5e02011-09-15 16:52:43 -0700211 sudo mv /tmp/nova /etc/munin/plugin-conf.d/nova
212 # configure Munin for Nova plugins
213 PLUGINS="keystone_stats nova_floating_ips nova_instance_launched nova_instance_ nova_instance_timing nova_services"
214 for i in $PLUGINS; do
215 sudo cp -p $MUNIN_DIR/$i /usr/share/munin/plugins
216 sudo ln -sf /usr/share/munin/plugins/$i /etc/munin/plugins
217 done
218 sudo mv /etc/munin/plugins/nova_instance_ /etc/munin/plugins/nova_instance_launched
219 sudo restart munin-node
220fi
Dean Troyer0017c8f2011-09-13 15:37:50 -0500221
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700222# Glance
223# ------
224
Anthony Young70dc5e02011-09-15 16:52:43 -0700225if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
226 # Glance uses ``/var/lib/glance`` and ``/var/log/glance`` by default, so
227 # we need to insure that our user has permissions to use them.
228 sudo mkdir -p /var/log/glance
229 sudo chown -R `whoami` /var/log/glance
230 sudo mkdir -p /var/lib/glance
231 sudo chown -R `whoami` /var/lib/glance
Jesse Andrews75a37652011-09-12 17:09:08 -0700232
Anthony Young70dc5e02011-09-15 16:52:43 -0700233 # Delete existing images/database as glance will recreate the db on startup
234 rm -rf /var/lib/glance/images/*
235 # (re)create glance database
236 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE glance;' || true
237 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE glance;'
238 # Copy over our glance-registry.conf
239 GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf
240 cp $DIR/files/glance-registry.conf $GLANCE_CONF
241 sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/glance,g" -i $GLANCE_CONF
242fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700243
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700244# Nova
245# ----
246
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700247function add_nova_flag {
248 echo "$1" >> $NOVA_DIR/bin/nova.conf
249}
250
Jesse Andrews75a37652011-09-12 17:09:08 -0700251# (re)create nova.conf
252rm -f $NOVA_DIR/bin/nova.conf
253add_nova_flag "--verbose"
254add_nova_flag "--nodaemon"
255add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf"
256add_nova_flag "--network_manager=nova.network.manager.$NET_MAN"
257add_nova_flag "--my_ip=$HOST_IP"
258add_nova_flag "--public_interface=$INTERFACE"
259add_nova_flag "--vlan_interface=$INTERFACE"
Anthony Younga8416442011-09-13 20:07:44 -0700260add_nova_flag "--sql_connection=$BASE_SQL_CONN/nova"
Jesse Andrews75a37652011-09-12 17:09:08 -0700261add_nova_flag "--libvirt_type=$LIBVIRT_TYPE"
262add_nova_flag "--osapi_extensions_path=$API_DIR/extensions"
263add_nova_flag "--vncproxy_url=http://$HOST_IP:6080"
Anthony Young1f81db62011-09-13 03:35:00 -0700264add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/"
Jesse Andrews75a37652011-09-12 17:09:08 -0700265add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini"
266add_nova_flag "--image_service=nova.image.glance.GlanceImageService"
Anthony Younga8416442011-09-13 20:07:44 -0700267add_nova_flag "--ec2_dmz_host=$EC2_DMZ_HOST"
268add_nova_flag "--rabbit_host=$RABBIT_HOST"
Anthony Young377aae62011-09-14 09:55:31 -0700269add_nova_flag "--glance_api_servers=$GLANCE_HOSTPORT"
Jesse Andrews75a37652011-09-12 17:09:08 -0700270if [ -n "$FLAT_INTERFACE" ]; then
271 add_nova_flag "--flat_interface=$FLAT_INTERFACE"
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700272fi
273
Jesse Andrews75a37652011-09-12 17:09:08 -0700274# create a new named screen to store things in
275screen -d -m -S nova -t nova
276sleep 1
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700277
Anthony Young70dc5e02011-09-15 16:52:43 -0700278if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700279
Anthony Young70dc5e02011-09-15 16:52:43 -0700280 # attempt to load modules: kvm (hardware virt) and nbd (network block
281 # device - used to manage qcow images)
282 sudo modprobe nbd || true
283 sudo modprobe kvm || true
284 # user needs to be member of libvirtd group for nova-compute to use libvirt
285 sudo usermod -a -G libvirtd `whoami`
286 # if kvm wasn't running before we need to restart libvirt to enable it
287 sudo /etc/init.d/libvirt-bin restart
288
289 ## FIXME(ja): should LIBVIRT_TYPE be kvm if kvm module is loaded?
290
291 # setup nova instance directory
292 mkdir -p $NOVA_DIR/instances
293
294 # if there is a partition labeled nova-instances use it (ext filesystems
295 # can be labeled via e2label)
296 ## FIXME: if already mounted this blows up...
297 if [ -L /dev/disk/by-label/nova-instances ]; then
298 sudo mount -L nova-instances $NOVA_DIR/instances
299 sudo chown -R `whoami` $NOVA_DIR/instances
300 fi
301
302 # Clean out the instances directory
303 rm -rf $NOVA_DIR/instances/*
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700304fi
305
Anthony Young70dc5e02011-09-15 16:52:43 -0700306if [[ "$ENABLED_SERVICES" =~ "n-net" ]]; then
307 # delete traces of nova networks from prior runs
308 killall dnsmasq || true
309 rm -rf $NOVA_DIR/networks
310 mkdir -p $NOVA_DIR/networks
311fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700312
Anthony Young70dc5e02011-09-15 16:52:43 -0700313if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
314 # (re)create nova database
315 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE nova;' || true
316 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE nova;'
317 $NOVA_DIR/bin/nova-manage db sync
Jesse Andrews75a37652011-09-12 17:09:08 -0700318
Anthony Young70dc5e02011-09-15 16:52:43 -0700319 # create a small network
320 $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 32
Jesse Andrewse8d9cd82011-09-13 15:16:26 -0700321
Anthony Young70dc5e02011-09-15 16:52:43 -0700322 # create some floating ips
323 $NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE
324fi
Jesse Andrewse8d9cd82011-09-13 15:16:26 -0700325
326# Keystone
327# --------
328
Anthony Young70dc5e02011-09-15 16:52:43 -0700329if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
330 # (re)create keystone database
331 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE keystone;' || true
332 mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE keystone;'
Jesse Andrews75a37652011-09-12 17:09:08 -0700333
Anthony Young70dc5e02011-09-15 16:52:43 -0700334 # FIXME (anthony) keystone should use keystone.conf.example
335 KEYSTONE_CONF=$KEYSTONE_DIR/etc/keystone.conf
336 cp $DIR/files/keystone.conf $KEYSTONE_CONF
337 sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/keystone,g" -i $KEYSTONE_CONF
Anthony Young3a093122011-09-13 19:01:45 +0000338
Anthony Young70dc5e02011-09-15 16:52:43 -0700339 # initialize keystone with default users/endpoints
340 BIN_DIR=$KEYSTONE_DIR/bin bash $DIR/files/keystone_data.sh
341fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700342
Jesse Andrews75a37652011-09-12 17:09:08 -0700343
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700344# Launch Services
345# ===============
Jesse Andrews30f68e92011-09-13 00:59:54 -0700346
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700347# nova api crashes if we start it with a regular screen command,
348# so send the start command by forcing text into the window.
Jesse Andrewsdfcd2002011-09-13 13:17:22 -0700349# Only run the services specified in ``ENABLED_SERVICES``
350
351NL=`echo -ne '\015'`
352
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700353function screen_it {
Anthony Young292e46d2011-09-13 11:28:56 -0700354 if [[ "$ENABLED_SERVICES" =~ "$1" ]]; then
355 screen -S nova -X screen -t $1
356 screen -S nova -p $1 -X stuff "$2$NL"
357 fi
Jesse Andrews1c1d1502011-09-12 19:29:56 -0700358}
359
Jesse Andrews75a37652011-09-12 17:09:08 -0700360screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf"
361screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf"
Anthony Young70dc5e02011-09-15 16:52:43 -0700362screen_it key "$KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF"
Jesse Andrews55508d62011-09-12 19:00:28 -0700363screen_it n-api "$NOVA_DIR/bin/nova-api"
364screen_it n-cpu "$NOVA_DIR/bin/nova-compute"
365screen_it n-net "$NOVA_DIR/bin/nova-network"
366screen_it n-sch "$NOVA_DIR/bin/nova-scheduler"
Anthony Young1f81db62011-09-13 03:35:00 -0700367# nova-vncproxy binds a privileged port, and so needs sudo
368screen_it n-vnc "sudo $NOVA_DIR/bin/nova-vncproxy"
Anthony Young8fbba912011-09-13 09:20:58 -0700369screen_it dash "sudo /etc/init.d/apache2 restart; sudo tail -f /var/log/apache2/error.log"
Jesse Andrews75a37652011-09-12 17:09:08 -0700370
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700371# Install Images
372# ==============
Jesse Andrewse49b8bd2011-09-12 18:08:04 -0700373
Anthony Young70dc5e02011-09-15 16:52:43 -0700374if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
375 # Downloads a tty image (ami/aki/ari style), then extracts it. Upon extraction
376 # we upload to glance with the glance cli tool.
377 mkdir -p $DEST/images
378 cd $DEST/images
379 if [ ! -f $DEST/tty.tgz ]; then
380 wget -c http://images.ansolabs.com/tty.tgz -O $DEST/tty.tgz
381 fi
Jesse Andrewse49b8bd2011-09-12 18:08:04 -0700382
Anthony Young70dc5e02011-09-15 16:52:43 -0700383 # extract ami-tty/image, aki-tty/image & ari-tty/image
384 tar -zxf $DEST/tty.tgz
385
386 # add images to glance
387 # FIXME: kernel/ramdisk is hardcoded - use return result from add
388 glance add name="tty-kernel" is_public=true container_format=aki disk_format=aki < aki-tty/image
389 glance add name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < ari-tty/image
390 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 -0700391fi
Jesse Andrews24859062011-09-15 21:28:23 -0700392
393# Using the cloud
394# ===============
395
396# If you installed the dashboard on this server, then you should be able
397# to access the site using your browser.
398if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
399 echo "dashboard is now available at http://$HOST_IP/"
400fi
401
402# If keystone is present, you can point nova cli to this server
403if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
404 echo "keystone is serving at http://$HOST_IP:5000/v2.0/"
405 echo "examples on using novaclient command line is in exercise.sh"
406fi