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