Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Jesse Andrews | 6f3baaf | 2011-09-12 11:59:38 -0700 | [diff] [blame] | 3 | # **stack.sh** is rackspace cloudbuilder's opinionated openstack dev installation. |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 4 | |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 5 | # Settings/Options |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 6 | # ================ |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 7 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 8 | # 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 Young | 963d2eb | 2011-09-13 17:29:02 -0700 | [diff] [blame] | 15 | # or simply ``./stack.sh`` |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 16 | |
| 17 | # This script exits on an error so that errors don't compound and you see |
| 18 | # only the first error that occured. |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 19 | set -o errexit |
| 20 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 21 | # 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 Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 23 | set -o xtrace |
| 24 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 25 | # Important paths: ``DIR`` is where we are executing from and ``DEST`` is |
| 26 | # where we are installing openstack. |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 27 | DIR=`pwd` |
| 28 | DEST=/opt |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 29 | |
Jesse Andrews | 6f3baaf | 2011-09-12 11:59:38 -0700 | [diff] [blame] | 30 | # Set the destination directories for openstack projects |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 31 | NOVA_DIR=$DEST/nova |
| 32 | DASH_DIR=$DEST/dash |
| 33 | GLANCE_DIR=$DEST/glance |
| 34 | KEYSTONE_DIR=$DEST/keystone |
| 35 | NOVACLIENT_DIR=$DEST/python-novaclient |
| 36 | API_DIR=$DEST/openstackx |
| 37 | NOVNC_DIR=$DEST/noVNC |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 38 | |
| 39 | # Specify which services to launch. These generally correspond to screen tabs |
Anthony Young | 927a656 | 2011-09-14 01:58:01 -0700 | [diff] [blame] | 40 | ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,dash} |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 41 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 42 | # Use the first IP unless an explicit is set by ``HOST_IP`` environment variable |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 43 | if [ ! -n "$HOST_IP" ]; then |
| 44 | HOST_IP=`LC_ALL=C ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'` |
| 45 | fi |
| 46 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 47 | # Nova network configuration |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 48 | INTERFACE=${INTERFACE:-eth0} |
| 49 | FLOATING_RANGE=${FLOATING_RANGE:-10.6.0.0/27} |
| 50 | FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24} |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 51 | NET_MAN=${NET_MAN:-VlanManager} |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 52 | EC2_DMZ_HOST=${EC2_DMZ_HOST:-$HOST_IP} |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 53 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 54 | # If you are using FlatDHCP on multiple hosts, set the ``FLAT_INTERFACE`` |
| 55 | # variable but make sure that the interface doesn't already have an |
| 56 | # ip or you risk breaking things. |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 57 | # FLAT_INTERFACE=eth0 |
| 58 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 59 | # Nova hypervisor configuration |
| 60 | LIBVIRT_TYPE=${LIBVIRT_TYPE:-qemu} |
| 61 | |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 62 | # Mysql connection info |
Anthony Young | 3859f73 | 2011-09-14 02:33:43 -0700 | [diff] [blame^] | 63 | MYSQL_USER=${MYSQL_USER:-nova} |
Anthony Young | 1c36464 | 2011-09-13 20:21:42 -0700 | [diff] [blame] | 64 | MYSQL_PASS=${MYSQL_PASS:-nova} |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 65 | MYSQL_HOST=${MYSQL_HOST:-localhost} |
| 66 | # don't specify /db in this string, so we can use it for multiple services |
Anthony Young | fdaf21a | 2011-09-13 20:11:42 -0700 | [diff] [blame] | 67 | BASE_SQL_CONN=${BASE_SQL_CONN:-mysql://$MYSQL_USER:$MYSQL_PASS@$MYSQL_HOST} |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 68 | |
| 69 | # Rabbit connection info |
| 70 | RABBIT_HOST=${RABBIT_HOST:-localhost} |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 71 | |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 72 | # Install Packages |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 73 | # ================ |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 74 | # |
| 75 | # Openstack uses a fair number of other projects. |
| 76 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 77 | # Seed configuration with mysql password so that apt-get install doesn't |
| 78 | # prompt us for a password upon install. |
Jesse Andrews | 18d350d | 2011-09-12 21:46:12 -0700 | [diff] [blame] | 79 | cat <<MYSQL_PRESEED | sudo debconf-set-selections |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 80 | mysql-server-5.1 mysql-server/root_password password $MYSQL_PASS |
| 81 | mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASS |
| 82 | mysql-server-5.1 mysql-server/start_on_boot boolean true |
| 83 | MYSQL_PRESEED |
Jesse Andrews | 2caf8fd | 2011-09-12 16:15:11 -0700 | [diff] [blame] | 84 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 85 | # install apt requirements |
Jesse Andrews | 18d350d | 2011-09-12 21:46:12 -0700 | [diff] [blame] | 86 | sudo apt-get install -y -q `cat $DIR/apts/* | cut -d\# -f1` |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 87 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 88 | # install python requirements |
Anthony Young | 1bbd9e0 | 2011-09-12 23:59:19 -0700 | [diff] [blame] | 89 | sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $DIR/pips/*` |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 90 | |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 91 | # git clone only if directory doesn't exist already |
| 92 | function git_clone { |
| 93 | if [ ! -d $2 ]; then |
| 94 | git clone $1 $2 |
| 95 | fi |
| 96 | } |
| 97 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 98 | # compute service |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 99 | git_clone https://github.com/cloudbuilders/nova.git $NOVA_DIR |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 100 | # image catalog service |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 101 | git_clone https://github.com/cloudbuilders/glance.git $GLANCE_DIR |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 102 | # unified auth system (manages accounts/tokens) |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 103 | git_clone https://github.com/cloudbuilders/keystone.git $KEYSTONE_DIR |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 104 | # a websockets/html5 or flash powered VNC console for vm instances |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 105 | git_clone https://github.com/cloudbuilders/noVNC.git $NOVNC_DIR |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 106 | # django powered web control panel for openstack |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 107 | git_clone https://github.com/cloudbuilders/openstack-dashboard.git $DASH_DIR |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 108 | # python client library to nova that dashboard (and others) use |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 109 | git_clone https://github.com/cloudbuilders/python-novaclient.git $NOVACLIENT_DIR |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 110 | # openstackx is a collection of extensions to openstack.compute & nova |
| 111 | # that is *deprecated*. The code is being moved into python-novaclient & nova. |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 112 | git_clone https://github.com/cloudbuilders/openstackx.git $API_DIR |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 113 | |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 114 | # Initialization |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 115 | # ============== |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 116 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 117 | # setup our checkouts so they are installed into python path |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 118 | # allowing ``import nova`` or ``import glance.client`` |
Jesse Andrews | 18d350d | 2011-09-12 21:46:12 -0700 | [diff] [blame] | 119 | cd $NOVACLIENT_DIR; sudo python setup.py develop |
| 120 | cd $KEYSTONE_DIR; sudo python setup.py develop |
| 121 | cd $GLANCE_DIR; sudo python setup.py develop |
| 122 | cd $API_DIR; sudo python setup.py develop |
| 123 | cd $DASH_DIR/django-openstack; sudo python setup.py develop |
| 124 | cd $DASH_DIR/openstack-dashboard; sudo python setup.py develop |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 125 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 126 | # attempt to load modules: kvm (hardware virt) and nbd (network block |
| 127 | # device - used to manage qcow images) |
Jesse Andrews | 18d350d | 2011-09-12 21:46:12 -0700 | [diff] [blame] | 128 | sudo modprobe nbd || true |
| 129 | sudo modprobe kvm || true |
Jesse Andrews | 4d6cb14 | 2011-09-12 23:48:30 -0700 | [diff] [blame] | 130 | # user needs to be member of libvirtd group for nova-compute to use libvirt |
| 131 | sudo usermod -a -G libvirtd `whoami` |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 132 | # if kvm wasn't running before we need to restart libvirt to enable it |
Jesse Andrews | 18d350d | 2011-09-12 21:46:12 -0700 | [diff] [blame] | 133 | sudo /etc/init.d/libvirt-bin restart |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 134 | |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 135 | ## FIXME(ja): should LIBVIRT_TYPE be kvm if kvm module is loaded? |
Jesse Andrews | be395c1 | 2011-09-12 19:11:30 -0700 | [diff] [blame] | 136 | |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 137 | # add useful screenrc |
| 138 | cp $DIR/files/screenrc ~/.screenrc |
Jesse Andrews | 6f3baaf | 2011-09-12 11:59:38 -0700 | [diff] [blame] | 139 | |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 140 | # TODO: update current user to allow sudo for all commands in files/sudo/* |
| 141 | |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 142 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 143 | # Dashboard |
| 144 | # --------- |
| 145 | # |
| 146 | # Setup the django application to serve via apache/wsgi |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 147 | |
| 148 | # Dash currently imports quantum even if you aren't using it. Instead |
| 149 | # of installing quantum we can create a simple module that will pass the |
| 150 | # initial imports |
Anthony Young | 5d4843c | 2011-09-13 17:22:18 -0700 | [diff] [blame] | 151 | sudo mkdir -p $DASH_DIR/openstack-dashboard/quantum || true |
| 152 | sudo touch $DASH_DIR/openstack-dashboard/quantum/__init__.py |
| 153 | sudo touch $DASH_DIR/openstack-dashboard/quantum/client.py |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 154 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 155 | cd $DASH_DIR/openstack-dashboard |
Anthony Young | 5d4843c | 2011-09-13 17:22:18 -0700 | [diff] [blame] | 156 | sudo cp local/local_settings.py.example local/local_settings.py |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 157 | dashboard/manage.py syncdb |
| 158 | |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 159 | # create an empty directory that apache uses as docroot |
Anthony Young | 5d4843c | 2011-09-13 17:22:18 -0700 | [diff] [blame] | 160 | sudo mkdir -p $DASH_DIR/.blackhole |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 161 | |
Anthony Young | 76d5dc7 | 2011-09-13 17:00:00 -0700 | [diff] [blame] | 162 | ## Configure apache's 000-default to run dashboard |
| 163 | sudo cp $DIR/files/000-default.template /etc/apache2/sites-enabled/000-default |
Anthony Young | 4da6686 | 2011-09-13 17:08:12 -0700 | [diff] [blame] | 164 | sudo sed -e "s,%DASH_DIR%,$DASH_DIR,g" -i /etc/apache2/sites-enabled/000-default |
Jesse Andrews | 18d350d | 2011-09-12 21:46:12 -0700 | [diff] [blame] | 165 | |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 166 | # ``python setup.py develop`` left some files owned by root in ``DASH_DIR`` and |
Jesse Andrews | 18d350d | 2011-09-12 21:46:12 -0700 | [diff] [blame] | 167 | # others by the original owner. We need to change the owner to apache so |
| 168 | # dashboard can run |
| 169 | sudo chown -R www-data:www-data $DASH_DIR |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 170 | |
Anthony Young | 3859f73 | 2011-09-14 02:33:43 -0700 | [diff] [blame^] | 171 | # Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases: |
| 172 | sudo mysql -uroot -p$MYSQL_PASS -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' WITH GRANT OPTION;" |
| 173 | |
Anthony Young | 80638e5 | 2011-09-14 01:29:05 -0700 | [diff] [blame] | 174 | # 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: |
| 175 | sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf |
| 176 | sudo service mysql restart |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 177 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 178 | # Glance |
| 179 | # ------ |
| 180 | |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 181 | # Glance uses ``/var/lib/glance`` and ``/var/log/glance`` by default, so |
| 182 | # we need to insure that our user has permissions to use them. |
Jesse Andrews | 9053d6a | 2011-09-12 22:13:11 -0700 | [diff] [blame] | 183 | sudo mkdir -p /var/log/glance |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 184 | sudo chown -R `whoami` /var/log/glance |
| 185 | sudo mkdir -p /var/lib/glance |
| 186 | sudo chown -R `whoami` /var/lib/glance |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 187 | |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 188 | # Delete existing images/database as glance will recreate the db on startup |
| 189 | rm -rf /var/lib/glance/images/* |
Anthony Young | b6838a1 | 2011-09-13 17:13:32 -0700 | [diff] [blame] | 190 | # (re)create glance database |
Anthony Young | fdaf21a | 2011-09-13 20:11:42 -0700 | [diff] [blame] | 191 | mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE glance;' || true |
| 192 | mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE glance;' |
Anthony Young | b6838a1 | 2011-09-13 17:13:32 -0700 | [diff] [blame] | 193 | # Copy over our glance-registry.conf |
Anthony Young | af9de3d | 2011-09-13 19:45:18 -0700 | [diff] [blame] | 194 | GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf |
Anthony Young | 79918c5 | 2011-09-13 19:43:14 -0700 | [diff] [blame] | 195 | cp $DIR/files/glance-registry.conf $GLANCE_CONF |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 196 | sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/glance,g" -i $GLANCE_CONF |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 197 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 198 | # Nova |
| 199 | # ---- |
| 200 | |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 201 | function add_nova_flag { |
| 202 | echo "$1" >> $NOVA_DIR/bin/nova.conf |
| 203 | } |
| 204 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 205 | # (re)create nova.conf |
| 206 | rm -f $NOVA_DIR/bin/nova.conf |
| 207 | add_nova_flag "--verbose" |
| 208 | add_nova_flag "--nodaemon" |
| 209 | add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf" |
| 210 | add_nova_flag "--network_manager=nova.network.manager.$NET_MAN" |
| 211 | add_nova_flag "--my_ip=$HOST_IP" |
| 212 | add_nova_flag "--public_interface=$INTERFACE" |
| 213 | add_nova_flag "--vlan_interface=$INTERFACE" |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 214 | add_nova_flag "--sql_connection=$BASE_SQL_CONN/nova" |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 215 | add_nova_flag "--libvirt_type=$LIBVIRT_TYPE" |
| 216 | add_nova_flag "--osapi_extensions_path=$API_DIR/extensions" |
| 217 | add_nova_flag "--vncproxy_url=http://$HOST_IP:6080" |
Anthony Young | 1f81db6 | 2011-09-13 03:35:00 -0700 | [diff] [blame] | 218 | add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/" |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 219 | add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini" |
| 220 | add_nova_flag "--image_service=nova.image.glance.GlanceImageService" |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 221 | add_nova_flag "--image_service=nova.image.glance.GlanceImageService" |
| 222 | add_nova_flag "--ec2_dmz_host=$EC2_DMZ_HOST" |
| 223 | add_nova_flag "--rabbit_host=$RABBIT_HOST" |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 224 | if [ -n "$FLAT_INTERFACE" ]; then |
| 225 | add_nova_flag "--flat_interface=$FLAT_INTERFACE" |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 226 | fi |
| 227 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 228 | # create a new named screen to store things in |
| 229 | screen -d -m -S nova -t nova |
| 230 | sleep 1 |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 231 | |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 232 | # setup nova instance directory |
| 233 | mkdir -p $NOVA_DIR/instances |
| 234 | |
| 235 | # if there is a partition labeled nova-instances use it (ext filesystems |
| 236 | # can be labeled via e2label) |
| 237 | ## FIXME: if already mounted this blows up... |
| 238 | if [ -L /dev/disk/by-label/nova-instances ]; then |
| 239 | sudo mount -L nova-instances $NOVA_DIR/instances |
| 240 | sudo chown -R `whoami` $NOVA_DIR/instances |
| 241 | fi |
| 242 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 243 | # Clean out the instances directory |
| 244 | rm -rf $NOVA_DIR/instances/* |
| 245 | |
| 246 | # delete traces of nova networks from prior runs |
| 247 | killall dnsmasq || true |
| 248 | rm -rf $NOVA_DIR/networks |
| 249 | mkdir -p $NOVA_DIR/networks |
| 250 | |
| 251 | # (re)create nova database |
Anthony Young | fdaf21a | 2011-09-13 20:11:42 -0700 | [diff] [blame] | 252 | mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE nova;' || true |
| 253 | mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE nova;' |
Jesse Andrews | e8d9cd8 | 2011-09-13 15:16:26 -0700 | [diff] [blame] | 254 | $NOVA_DIR/bin/nova-manage db sync |
| 255 | |
| 256 | # create a small network |
| 257 | $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 32 |
| 258 | |
| 259 | # create some floating ips |
| 260 | $NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE |
| 261 | |
| 262 | # Keystone |
| 263 | # -------- |
| 264 | |
| 265 | # (re)create keystone database |
Anthony Young | fdaf21a | 2011-09-13 20:11:42 -0700 | [diff] [blame] | 266 | mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE keystone;' || true |
| 267 | mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE keystone;' |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 268 | |
Anthony Young | 3a09312 | 2011-09-13 19:01:45 +0000 | [diff] [blame] | 269 | # FIXME (anthony) keystone should use keystone.conf.example |
| 270 | KEYSTONE_CONF=$KEYSTONE_DIR/etc/keystone.conf |
| 271 | cp $DIR/files/keystone.conf $KEYSTONE_CONF |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 272 | sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/keystone,g" -i $KEYSTONE_CONF |
Anthony Young | 3a09312 | 2011-09-13 19:01:45 +0000 | [diff] [blame] | 273 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 274 | # initialize keystone with default users/endpoints |
Jesse Andrews | 73e27b8 | 2011-09-12 17:55:00 -0700 | [diff] [blame] | 275 | BIN_DIR=$KEYSTONE_DIR/bin bash $DIR/files/keystone_data.sh |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 276 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 277 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 278 | # Launch Services |
| 279 | # =============== |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 280 | |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 281 | # nova api crashes if we start it with a regular screen command, |
| 282 | # so send the start command by forcing text into the window. |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 283 | # Only run the services specified in ``ENABLED_SERVICES`` |
| 284 | |
| 285 | NL=`echo -ne '\015'` |
| 286 | |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 287 | function screen_it { |
Anthony Young | 292e46d | 2011-09-13 11:28:56 -0700 | [diff] [blame] | 288 | if [[ "$ENABLED_SERVICES" =~ "$1" ]]; then |
| 289 | screen -S nova -X screen -t $1 |
| 290 | screen -S nova -p $1 -X stuff "$2$NL" |
| 291 | fi |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 292 | } |
| 293 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 294 | screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf" |
| 295 | screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf" |
Jesse Andrews | 4d6cb14 | 2011-09-12 23:48:30 -0700 | [diff] [blame] | 296 | # keystone drops a keystone.log where if it is run, so change the path to |
| 297 | # where it can write |
Anthony Young | 3a09312 | 2011-09-13 19:01:45 +0000 | [diff] [blame] | 298 | screen_it key "cd /tmp; $KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF" |
Jesse Andrews | 55508d6 | 2011-09-12 19:00:28 -0700 | [diff] [blame] | 299 | screen_it n-api "$NOVA_DIR/bin/nova-api" |
| 300 | screen_it n-cpu "$NOVA_DIR/bin/nova-compute" |
| 301 | screen_it n-net "$NOVA_DIR/bin/nova-network" |
| 302 | screen_it n-sch "$NOVA_DIR/bin/nova-scheduler" |
Anthony Young | 1f81db6 | 2011-09-13 03:35:00 -0700 | [diff] [blame] | 303 | # nova-vncproxy binds a privileged port, and so needs sudo |
| 304 | screen_it n-vnc "sudo $NOVA_DIR/bin/nova-vncproxy" |
Anthony Young | 8fbba91 | 2011-09-13 09:20:58 -0700 | [diff] [blame] | 305 | screen_it dash "sudo /etc/init.d/apache2 restart; sudo tail -f /var/log/apache2/error.log" |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 306 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 307 | # Install Images |
| 308 | # ============== |
Jesse Andrews | e49b8bd | 2011-09-12 18:08:04 -0700 | [diff] [blame] | 309 | |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 310 | # Downloads a tty image (ami/aki/ari style), then extracts it. Upon extraction |
| 311 | # we upload to glance with the glance cli tool. |
Jesse Andrews | e49b8bd | 2011-09-12 18:08:04 -0700 | [diff] [blame] | 312 | |
| 313 | mkdir -p $DEST/images |
| 314 | cd $DEST/images |
Jesse Andrews | e49b8bd | 2011-09-12 18:08:04 -0700 | [diff] [blame] | 315 | if [ ! -f $DEST/tty.tgz ]; then |
Jesse Andrews | be395c1 | 2011-09-12 19:11:30 -0700 | [diff] [blame] | 316 | wget -c http://images.ansolabs.com/tty.tgz -O $DEST/tty.tgz |
Jesse Andrews | e49b8bd | 2011-09-12 18:08:04 -0700 | [diff] [blame] | 317 | fi |
| 318 | |
| 319 | # extract ami-tty/image, aki-tty/image & ari-tty/image |
Jesse Andrews | be395c1 | 2011-09-12 19:11:30 -0700 | [diff] [blame] | 320 | tar -zxf $DEST/tty.tgz |
Jesse Andrews | e49b8bd | 2011-09-12 18:08:04 -0700 | [diff] [blame] | 321 | |
Jesse Andrews | be395c1 | 2011-09-12 19:11:30 -0700 | [diff] [blame] | 322 | # add images to glance |
| 323 | # FIXME: kernel/ramdisk is hardcoded - use return result from add |
Jesse Andrews | e49b8bd | 2011-09-12 18:08:04 -0700 | [diff] [blame] | 324 | glance add name="tty-kernel" is_public=true container_format=aki disk_format=aki < aki-tty/image |
| 325 | glance add name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < ari-tty/image |
| 326 | glance add name="tty" is_public=true container_format=ami disk_format=ami kernel_id=1 ramdisk_id=2 < ami-tty/image |