Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Jesse Andrews | 5e2fc41 | 2011-09-18 21:16:42 -0700 | [diff] [blame] | 3 | # **stack.sh** is an opinionated openstack dev installation. |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 4 | |
Jesse Andrews | c4b3aab | 2011-09-15 22:54:52 -0700 | [diff] [blame] | 5 | # To keep this script simple we assume you are running on an **Ubuntu 11.04 |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 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 | |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 10 | # You can grab the most recent version of this script and files from Rackspace |
Jesse Andrews | 5e2fc41 | 2011-09-18 21:16:42 -0700 | [diff] [blame] | 11 | # Cloud Builders at https://github.com/cloudbuilders/devstack |
Jesse Andrews | 6edd17f | 2011-09-15 22:19:42 -0700 | [diff] [blame] | 12 | |
| 13 | # Sanity Check |
| 14 | # ============ |
| 15 | |
Jesse Andrews | c4b3aab | 2011-09-15 22:54:52 -0700 | [diff] [blame] | 16 | # Warn users who aren't on natty, but allow them to override check and attempt |
Jesse Andrews | 6edd17f | 2011-09-15 22:19:42 -0700 | [diff] [blame] | 17 | # installation with ``FORCE=yes ./stack`` |
Jesse Andrews | 6edd17f | 2011-09-15 22:19:42 -0700 | [diff] [blame] | 18 | if ! grep -q natty /etc/lsb-release; then |
| 19 | echo "WARNING: this script has only been tested on natty" |
| 20 | if [[ "$FORCE" != "yes" ]]; then |
| 21 | echo "If you wish to run this script anyway run with FORCE=yes" |
| 22 | exit 1 |
| 23 | fi |
| 24 | fi |
| 25 | |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 26 | #The following makes fresh mininmal installs (i.e. LXCs) happy |
| 27 | apt-get update |
| 28 | apt-get install -y sudo |
| 29 | |
| 30 | # stack.sh keeps the list of **apt** and **pip** dependencies in external |
Jesse Andrews | 4d28218 | 2011-09-16 11:27:43 -0700 | [diff] [blame] | 31 | # files, along with config templates and other useful files. You can find these |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 32 | # in the ``files`` directory (next to this script). We will reference this |
Jesse Andrews | bf3868d | 2011-09-16 11:31:16 -0700 | [diff] [blame] | 33 | # directory using the ``FILES`` variable in this script. |
| 34 | FILES=`pwd`/files |
| 35 | if [ ! -d $FILES ]; then |
| 36 | echo "ERROR: missing devstack/files - did you grab more than just stack.sh?" |
Jesse Andrews | 6edd17f | 2011-09-15 22:19:42 -0700 | [diff] [blame] | 37 | exit 1 |
| 38 | fi |
| 39 | |
| 40 | # Settings |
| 41 | # ======== |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 42 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 43 | # This script is customizable through setting environment variables. If you |
| 44 | # want to override a setting you can either:: |
| 45 | # |
| 46 | # export MYSQL_PASS=anothersecret |
| 47 | # ./stack.sh |
| 48 | # |
Jesse Andrews | 6edd17f | 2011-09-15 22:19:42 -0700 | [diff] [blame] | 49 | # You can also pass options on a single line ``MYSQL_PASS=simple ./stack.sh`` |
| 50 | # |
| 51 | # We try to have sensible defaults, so you should be able to run ``./stack.sh`` |
| 52 | # in most cases. |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 53 | |
Jesse Andrews | 6edd17f | 2011-09-15 22:19:42 -0700 | [diff] [blame] | 54 | # So that errors don't compound we exit on any errors so you see only the |
| 55 | # first error that occured. |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 56 | set -o errexit |
| 57 | |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 58 | # Print the commands being run so that we can see the command that triggers |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 59 | # 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] | 60 | set -o xtrace |
| 61 | |
Jesse Andrews | 6edd17f | 2011-09-15 22:19:42 -0700 | [diff] [blame] | 62 | # Destination path for installation ``DEST`` |
| 63 | DEST=${DEST:-/opt} |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 64 | |
Jesse Andrews | 6f3baaf | 2011-09-12 11:59:38 -0700 | [diff] [blame] | 65 | # Set the destination directories for openstack projects |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 66 | NOVA_DIR=$DEST/nova |
| 67 | DASH_DIR=$DEST/dash |
Jake Dahn | 9337b33 | 2011-09-15 21:46:20 -0700 | [diff] [blame] | 68 | NIXON_DIR=$DEST/dash/openstack-dashboard/dashboard/nixon |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 69 | GLANCE_DIR=$DEST/glance |
| 70 | KEYSTONE_DIR=$DEST/keystone |
| 71 | NOVACLIENT_DIR=$DEST/python-novaclient |
| 72 | API_DIR=$DEST/openstackx |
| 73 | NOVNC_DIR=$DEST/noVNC |
Dean Troyer | 0017c8f | 2011-09-13 15:37:50 -0500 | [diff] [blame] | 74 | MUNIN_DIR=$DEST/openstack-munin |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 75 | |
| 76 | # Specify which services to launch. These generally correspond to screen tabs |
Dean Troyer | 0d6de09 | 2011-09-21 13:44:08 -0500 | [diff] [blame] | 77 | ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,dash,mysql,rabbit,munin} |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 78 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 79 | # 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] | 80 | if [ ! -n "$HOST_IP" ]; then |
Dean Troyer | 2a15a7c | 2011-09-13 13:22:14 -0500 | [diff] [blame] | 81 | HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'` |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 82 | fi |
| 83 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 84 | # Nova network configuration |
Anthony Young | b1bdd5e | 2011-09-20 09:39:50 -0700 | [diff] [blame] | 85 | PUBLIC_INTERFACE=${PUBLIC_INTERFACE:-eth0} |
Jesse Andrews | 8ff5dbc | 2011-09-25 22:28:08 -0700 | [diff] [blame^] | 86 | VLAN_INTERFACE=${VLAN_INTERFACE:-$PUBLIC_INTERFACE} |
Jesse Andrews | a72f7ad | 2011-09-25 13:41:22 -0700 | [diff] [blame] | 87 | FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.1/28} |
| 88 | FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/16} |
| 89 | NET_MAN=${NET_MAN:-FlatDHCPManager} |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 90 | EC2_DMZ_HOST=${EC2_DMZ_HOST:-$HOST_IP} |
Anthony Young | b1bdd5e | 2011-09-20 09:39:50 -0700 | [diff] [blame] | 91 | FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-br100} |
Jesse Andrews | 8ff5dbc | 2011-09-25 22:28:08 -0700 | [diff] [blame^] | 92 | SCHEDULER=${SCHEDULER:-nova.scheduler.simple.SimpleScheduler} |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 93 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 94 | # If you are using FlatDHCP on multiple hosts, set the ``FLAT_INTERFACE`` |
| 95 | # variable but make sure that the interface doesn't already have an |
| 96 | # ip or you risk breaking things. |
Jesse Andrews | 8ff5dbc | 2011-09-25 22:28:08 -0700 | [diff] [blame^] | 97 | FLAT_INTERFACE=${FLAT_INTERFACE:-eth0} |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 98 | |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 99 | # Nova hypervisor configuration. We default to **kvm** but will drop back to |
Jesse Andrews | d1879c5 | 2011-09-16 16:28:13 -0700 | [diff] [blame] | 100 | # **qemu** if we are unable to load the kvm module. |
| 101 | LIBVIRT_TYPE=${LIBVIRT_TYPE:-kvm} |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 102 | |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 103 | # Mysql connection info |
Anthony Young | 320412b | 2011-09-14 02:39:10 -0700 | [diff] [blame] | 104 | MYSQL_USER=${MYSQL_USER:-root} |
Anthony Young | 1c36464 | 2011-09-13 20:21:42 -0700 | [diff] [blame] | 105 | MYSQL_PASS=${MYSQL_PASS:-nova} |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 106 | MYSQL_HOST=${MYSQL_HOST:-localhost} |
| 107 | # 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] | 108 | 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] | 109 | |
| 110 | # Rabbit connection info |
| 111 | RABBIT_HOST=${RABBIT_HOST:-localhost} |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 112 | |
Anthony Young | 377aae6 | 2011-09-14 09:55:31 -0700 | [diff] [blame] | 113 | # Glance connection info. Note the port must be specified. |
Anthony Young | b1bdd5e | 2011-09-20 09:39:50 -0700 | [diff] [blame] | 114 | GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} |
Anthony Young | 377aae6 | 2011-09-14 09:55:31 -0700 | [diff] [blame] | 115 | |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 116 | # Install Packages |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 117 | # ================ |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 118 | # |
| 119 | # Openstack uses a fair number of other projects. |
| 120 | |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 121 | # Seed configuration with mysql password so that apt-get install doesn't |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 122 | # prompt us for a password upon install. |
Jesse Andrews | 18d350d | 2011-09-12 21:46:12 -0700 | [diff] [blame] | 123 | cat <<MYSQL_PRESEED | sudo debconf-set-selections |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 124 | mysql-server-5.1 mysql-server/root_password password $MYSQL_PASS |
| 125 | mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASS |
| 126 | mysql-server-5.1 mysql-server/start_on_boot boolean true |
| 127 | MYSQL_PRESEED |
Jesse Andrews | 2caf8fd | 2011-09-12 16:15:11 -0700 | [diff] [blame] | 128 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 129 | # install apt requirements |
Jesse Andrews | bf3868d | 2011-09-16 11:31:16 -0700 | [diff] [blame] | 130 | sudo apt-get install -y -q `cat $FILES/apts/* | cut -d\# -f1 | grep -Ev "mysql-server|rabbitmq-server"` |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 131 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 132 | # install python requirements |
Jesse Andrews | bf3868d | 2011-09-16 11:31:16 -0700 | [diff] [blame] | 133 | sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*` |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 134 | |
Jesse Andrews | d61db85 | 2011-09-16 14:13:17 -0700 | [diff] [blame] | 135 | # git clone only if directory doesn't exist already. Since ``DEST`` might not |
| 136 | # be owned by the installation user, we create the directory and change the |
| 137 | # ownership to the proper user. |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 138 | function git_clone { |
| 139 | if [ ! -d $2 ]; then |
Jesse Andrews | d61db85 | 2011-09-16 14:13:17 -0700 | [diff] [blame] | 140 | sudo mkdir $2 |
| 141 | sudo chown `whoami` $2 |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 142 | git clone $1 $2 |
| 143 | fi |
| 144 | } |
| 145 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 146 | # compute service |
Anthony Young | 8530928 | 2011-09-23 07:23:31 +0000 | [diff] [blame] | 147 | # FIXME - need to factor out these repositories |
| 148 | # git_clone https://github.com/cloudbuilders/nova.git $NOVA_DIR |
| 149 | if [ ! -d $NOVA_DIR ]; then |
| 150 | bzr clone lp:~hudson-openstack/nova/milestone-proposed/ $NOVA_DIR |
| 151 | fi |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 152 | # image catalog service |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 153 | git_clone https://github.com/cloudbuilders/glance.git $GLANCE_DIR |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 154 | # unified auth system (manages accounts/tokens) |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 155 | git_clone https://github.com/cloudbuilders/keystone.git $KEYSTONE_DIR |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 156 | # a websockets/html5 or flash powered VNC console for vm instances |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 157 | git_clone https://github.com/cloudbuilders/noVNC.git $NOVNC_DIR |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 158 | # django powered web control panel for openstack |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 159 | git_clone https://github.com/cloudbuilders/openstack-dashboard.git $DASH_DIR |
Anthony Young | 8530928 | 2011-09-23 07:23:31 +0000 | [diff] [blame] | 160 | # FIXME - need to factor out logic like this |
Anthony Young | 36d2527 | 2011-09-23 07:34:38 +0000 | [diff] [blame] | 161 | cd $DASH_DIR && sudo git fetch && sudo git checkout origin/keystone_diablo |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 162 | # add nixon, will use this to show munin graphs in dashboard |
Jake Dahn | 38fc665 | 2011-09-15 22:58:06 -0700 | [diff] [blame] | 163 | git_clone https://github.com/cloudbuilders/nixon.git $NIXON_DIR |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 164 | # python client library to nova that dashboard (and others) use |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 165 | git_clone https://github.com/cloudbuilders/python-novaclient.git $NOVACLIENT_DIR |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 166 | # openstackx is a collection of extensions to openstack.compute & nova |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 167 | # that is *deprecated*. The code is being moved into python-novaclient & nova. |
Jesse Andrews | 6163257 | 2011-09-12 17:40:00 -0700 | [diff] [blame] | 168 | git_clone https://github.com/cloudbuilders/openstackx.git $API_DIR |
Dean Troyer | 0017c8f | 2011-09-13 15:37:50 -0500 | [diff] [blame] | 169 | # openstack-munin is a collection of munin plugins for monitoring the stack |
| 170 | git_clone https://github.com/cloudbuilders/openstack-munin.git $MUNIN_DIR |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 171 | |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 172 | # Initialization |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 173 | # ============== |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 174 | |
Jesse Andrews | d1879c5 | 2011-09-16 16:28:13 -0700 | [diff] [blame] | 175 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 176 | # setup our checkouts so they are installed into python path |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 177 | # allowing ``import nova`` or ``import glance.client`` |
Dean Troyer | 0017c8f | 2011-09-13 15:37:50 -0500 | [diff] [blame] | 178 | cd $NOVA_DIR; sudo python setup.py develop |
Jesse Andrews | 18d350d | 2011-09-12 21:46:12 -0700 | [diff] [blame] | 179 | cd $NOVACLIENT_DIR; sudo python setup.py develop |
| 180 | cd $KEYSTONE_DIR; sudo python setup.py develop |
| 181 | cd $GLANCE_DIR; sudo python setup.py develop |
| 182 | cd $API_DIR; sudo python setup.py develop |
| 183 | cd $DASH_DIR/django-openstack; sudo python setup.py develop |
| 184 | cd $DASH_DIR/openstack-dashboard; sudo python setup.py develop |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 185 | |
Jesse Andrews | 6edd17f | 2011-09-15 22:19:42 -0700 | [diff] [blame] | 186 | # Add a useful screenrc. This isn't required to run openstack but is we do |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 187 | # it since we are going to run the services in screen for simple |
Jesse Andrews | bf3868d | 2011-09-16 11:31:16 -0700 | [diff] [blame] | 188 | cp $FILES/screenrc ~/.screenrc |
Jesse Andrews | 6f3baaf | 2011-09-12 11:59:38 -0700 | [diff] [blame] | 189 | |
Jesse Andrews | 6edd17f | 2011-09-15 22:19:42 -0700 | [diff] [blame] | 190 | ## TODO: update current user to allow sudo for all commands in files/sudo/* |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 191 | |
Anthony Young | a09ae2f | 2011-09-15 23:11:29 -0700 | [diff] [blame] | 192 | # Rabbit |
| 193 | # --------- |
| 194 | # |
| 195 | if [[ "$ENABLED_SERVICES" =~ "rabbit" ]]; then |
| 196 | # Install and start rabbitmq-server |
Anthony Young | 093eeb0 | 2011-09-15 23:17:44 -0700 | [diff] [blame] | 197 | sudo apt-get install -y -q rabbitmq-server |
Anthony Young | a09ae2f | 2011-09-15 23:11:29 -0700 | [diff] [blame] | 198 | fi |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 199 | |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 200 | # Mysql |
| 201 | # --------- |
| 202 | # |
| 203 | if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then |
Anthony Young | a09ae2f | 2011-09-15 23:11:29 -0700 | [diff] [blame] | 204 | # Install and start mysql-server |
Anthony Young | 093eeb0 | 2011-09-15 23:17:44 -0700 | [diff] [blame] | 205 | sudo apt-get -y -q install mysql-server |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 206 | # Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases: |
| 207 | sudo mysql -uroot -p$MYSQL_PASS -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' identified by '$MYSQL_PASS';" |
| 208 | |
| 209 | # 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: |
| 210 | sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf |
| 211 | sudo service mysql restart |
| 212 | fi |
| 213 | |
| 214 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 215 | # Dashboard |
| 216 | # --------- |
| 217 | # |
| 218 | # Setup the django application to serve via apache/wsgi |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 219 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 220 | if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 221 | |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 222 | # Dash currently imports quantum even if you aren't using it. Instead |
| 223 | # of installing quantum we can create a simple module that will pass the |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 224 | # initial imports |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 225 | sudo mkdir -p $DASH_DIR/openstack-dashboard/quantum || true |
| 226 | sudo touch $DASH_DIR/openstack-dashboard/quantum/__init__.py |
| 227 | sudo touch $DASH_DIR/openstack-dashboard/quantum/client.py |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 228 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 229 | cd $DASH_DIR/openstack-dashboard |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 230 | |
Jake Dahn | a3492ed | 2011-09-15 22:42:43 -0700 | [diff] [blame] | 231 | # Includes settings for Nixon, to expose munin charts. |
Jesse Andrews | bf3868d | 2011-09-16 11:31:16 -0700 | [diff] [blame] | 232 | sudo cp $FILES/dash_settings.py local/local_settings.py |
Jake Dahn | 9337b33 | 2011-09-15 21:46:20 -0700 | [diff] [blame] | 233 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 234 | dashboard/manage.py syncdb |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 235 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 236 | # create an empty directory that apache uses as docroot |
| 237 | sudo mkdir -p $DASH_DIR/.blackhole |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 238 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 239 | ## Configure apache's 000-default to run dashboard |
Jesse Andrews | bf3868d | 2011-09-16 11:31:16 -0700 | [diff] [blame] | 240 | sudo cp $FILES/000-default.template /etc/apache2/sites-enabled/000-default |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 241 | 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] | 242 | |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 243 | # ``python setup.py develop`` left some files owned by root in ``DASH_DIR`` |
| 244 | # and others are owned by the user you are using to run this script. |
Jesse Andrews | 4d28218 | 2011-09-16 11:27:43 -0700 | [diff] [blame] | 245 | # We need to change the owner to apache for dashboard to run. |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 246 | sudo chown -R www-data:www-data $DASH_DIR |
| 247 | fi |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 248 | |
Anthony Young | 3859f73 | 2011-09-14 02:33:43 -0700 | [diff] [blame] | 249 | |
Dean Troyer | 0017c8f | 2011-09-13 15:37:50 -0500 | [diff] [blame] | 250 | # Munin |
| 251 | # ----- |
| 252 | |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 253 | # Munin is accessable via apache and was configured in the dashboard section. |
Dean Troyer | 0017c8f | 2011-09-13 15:37:50 -0500 | [diff] [blame] | 254 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 255 | if [[ "$ENABLED_SERVICES" =~ "munin" ]]; then |
| 256 | # allow connections from other hosts |
Jake Dahn | 3568125 | 2011-09-16 16:53:22 -0700 | [diff] [blame] | 257 | sudo sed -i -e 's/Allow from localhost/Allow from all/g' /etc/munin/apache.conf |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 258 | |
| 259 | cat >/tmp/nova <<EOF |
Dean Troyer | 0017c8f | 2011-09-13 15:37:50 -0500 | [diff] [blame] | 260 | [keystone_*] |
Dean Troyer | 925df4c | 2011-09-14 10:20:57 -0500 | [diff] [blame] | 261 | user `whoami` |
Dean Troyer | 0017c8f | 2011-09-13 15:37:50 -0500 | [diff] [blame] | 262 | |
| 263 | [nova_*] |
Dean Troyer | 925df4c | 2011-09-14 10:20:57 -0500 | [diff] [blame] | 264 | user `whoami` |
Dean Troyer | 0017c8f | 2011-09-13 15:37:50 -0500 | [diff] [blame] | 265 | EOF |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 266 | sudo mv /tmp/nova /etc/munin/plugin-conf.d/nova |
| 267 | # configure Munin for Nova plugins |
| 268 | PLUGINS="keystone_stats nova_floating_ips nova_instance_launched nova_instance_ nova_instance_timing nova_services" |
| 269 | for i in $PLUGINS; do |
| 270 | sudo cp -p $MUNIN_DIR/$i /usr/share/munin/plugins |
| 271 | sudo ln -sf /usr/share/munin/plugins/$i /etc/munin/plugins |
| 272 | done |
| 273 | sudo mv /etc/munin/plugins/nova_instance_ /etc/munin/plugins/nova_instance_launched |
| 274 | sudo restart munin-node |
| 275 | fi |
Dean Troyer | 0017c8f | 2011-09-13 15:37:50 -0500 | [diff] [blame] | 276 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 277 | # Glance |
| 278 | # ------ |
| 279 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 280 | if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then |
Anthony Young | c835762 | 2011-09-20 10:38:06 -0700 | [diff] [blame] | 281 | GLANCE_IMAGE_DIR=$DEST/glance/images |
Anthony Young | a531b77 | 2011-09-20 09:59:54 -0700 | [diff] [blame] | 282 | # Delete existing images |
| 283 | rm -rf $GLANCE_IMAGE_DIR |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 284 | |
Anthony Young | a531b77 | 2011-09-20 09:59:54 -0700 | [diff] [blame] | 285 | # Use local glance directories |
| 286 | mkdir -p $GLANCE_IMAGE_DIR |
| 287 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 288 | # (re)create glance database |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 289 | mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE IF EXISTS glance;' |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 290 | mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE glance;' |
| 291 | # Copy over our glance-registry.conf |
| 292 | GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf |
Jesse Andrews | bf3868d | 2011-09-16 11:31:16 -0700 | [diff] [blame] | 293 | cp $FILES/glance-registry.conf $GLANCE_CONF |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 294 | sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/glance,g" -i $GLANCE_CONF |
Anthony Young | a531b77 | 2011-09-20 09:59:54 -0700 | [diff] [blame] | 295 | sudo sed -e "s,%DEST%,$DEST,g" -i $GLANCE_CONF |
Anthony Young | f12d3ab | 2011-09-20 00:33:51 -0700 | [diff] [blame] | 296 | |
| 297 | GLANCE_API_CONF=$GLANCE_DIR/etc/glance-api.conf |
| 298 | cp $FILES/glance-api.conf $GLANCE_API_CONF |
Anthony Young | a531b77 | 2011-09-20 09:59:54 -0700 | [diff] [blame] | 299 | sudo sed -e "s,%DEST%,$DEST,g" -i $GLANCE_API_CONF |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 300 | fi |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 301 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 302 | # Nova |
| 303 | # ---- |
| 304 | |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 305 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 306 | if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 307 | |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 308 | # attempt to load modules: nbd (network block device - used to manage |
| 309 | # qcow images) and kvm (hardware based virtualization). If unable to |
Jesse Andrews | d1879c5 | 2011-09-16 16:28:13 -0700 | [diff] [blame] | 310 | # load kvm, set the libvirt type to qemu. |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 311 | sudo modprobe nbd || true |
Dean Troyer | 0d6de09 | 2011-09-21 13:44:08 -0500 | [diff] [blame] | 312 | if [ ! -e /dev/kvm ]; then |
Jesse Andrews | d1879c5 | 2011-09-16 16:28:13 -0700 | [diff] [blame] | 313 | LIBVIRT_TYPE=qemu |
| 314 | fi |
Jesse Andrews | e30432f | 2011-09-16 14:54:48 -0700 | [diff] [blame] | 315 | # User needs to be member of libvirtd group for nova-compute to use libvirt. |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 316 | sudo usermod -a -G libvirtd `whoami` |
| 317 | # if kvm wasn't running before we need to restart libvirt to enable it |
| 318 | sudo /etc/init.d/libvirt-bin restart |
| 319 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 320 | # setup nova instance directory |
| 321 | mkdir -p $NOVA_DIR/instances |
| 322 | |
| 323 | # if there is a partition labeled nova-instances use it (ext filesystems |
| 324 | # can be labeled via e2label) |
| 325 | ## FIXME: if already mounted this blows up... |
| 326 | if [ -L /dev/disk/by-label/nova-instances ]; then |
| 327 | sudo mount -L nova-instances $NOVA_DIR/instances |
| 328 | sudo chown -R `whoami` $NOVA_DIR/instances |
| 329 | fi |
| 330 | |
| 331 | # Clean out the instances directory |
| 332 | rm -rf $NOVA_DIR/instances/* |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 333 | fi |
| 334 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 335 | if [[ "$ENABLED_SERVICES" =~ "n-net" ]]; then |
| 336 | # delete traces of nova networks from prior runs |
Anthony Young | 09fde81 | 2011-09-20 02:23:54 -0700 | [diff] [blame] | 337 | sudo killall dnsmasq || true |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 338 | rm -rf $NOVA_DIR/networks |
| 339 | mkdir -p $NOVA_DIR/networks |
| 340 | fi |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 341 | |
Jesse Andrews | d1879c5 | 2011-09-16 16:28:13 -0700 | [diff] [blame] | 342 | function add_nova_flag { |
| 343 | echo "$1" >> $NOVA_DIR/bin/nova.conf |
| 344 | } |
| 345 | |
| 346 | # (re)create nova.conf |
| 347 | rm -f $NOVA_DIR/bin/nova.conf |
| 348 | add_nova_flag "--verbose" |
| 349 | add_nova_flag "--nodaemon" |
Jesse Andrews | 8ff5dbc | 2011-09-25 22:28:08 -0700 | [diff] [blame^] | 350 | add_nova_flag "--scheduler_driver=$SCHEDULER" |
Jesse Andrews | d1879c5 | 2011-09-16 16:28:13 -0700 | [diff] [blame] | 351 | add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf" |
| 352 | add_nova_flag "--network_manager=nova.network.manager.$NET_MAN" |
| 353 | add_nova_flag "--my_ip=$HOST_IP" |
Anthony Young | b1bdd5e | 2011-09-20 09:39:50 -0700 | [diff] [blame] | 354 | add_nova_flag "--public_interface=$PUBLIC_INTERFACE" |
| 355 | add_nova_flag "--vlan_interface=$VLAN_INTERFACE" |
Jesse Andrews | d1879c5 | 2011-09-16 16:28:13 -0700 | [diff] [blame] | 356 | add_nova_flag "--sql_connection=$BASE_SQL_CONN/nova" |
| 357 | add_nova_flag "--libvirt_type=$LIBVIRT_TYPE" |
| 358 | add_nova_flag "--osapi_extensions_path=$API_DIR/extensions" |
| 359 | add_nova_flag "--vncproxy_url=http://$HOST_IP:6080" |
| 360 | add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/" |
| 361 | add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini" |
| 362 | add_nova_flag "--image_service=nova.image.glance.GlanceImageService" |
| 363 | add_nova_flag "--ec2_dmz_host=$EC2_DMZ_HOST" |
| 364 | add_nova_flag "--rabbit_host=$RABBIT_HOST" |
| 365 | add_nova_flag "--glance_api_servers=$GLANCE_HOSTPORT" |
Anthony Young | b1bdd5e | 2011-09-20 09:39:50 -0700 | [diff] [blame] | 366 | add_nova_flag "--flat_network_bridge=$FLAT_NETWORK_BRIDGE" |
Jesse Andrews | d1879c5 | 2011-09-16 16:28:13 -0700 | [diff] [blame] | 367 | if [ -n "$FLAT_INTERFACE" ]; then |
| 368 | add_nova_flag "--flat_interface=$FLAT_INTERFACE" |
| 369 | fi |
| 370 | if [ -n "$MULTI_HOST" ]; then |
| 371 | add_nova_flag "--multi_host=$MULTI_HOST" |
| 372 | fi |
| 373 | |
Anthony Young | a074800 | 2011-09-16 21:37:36 -0700 | [diff] [blame] | 374 | if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then |
| 375 | # (re)create nova database |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 376 | mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE IF EXISTS nova;' |
Anthony Young | a074800 | 2011-09-16 21:37:36 -0700 | [diff] [blame] | 377 | mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE nova;' |
| 378 | $NOVA_DIR/bin/nova-manage db sync |
| 379 | |
| 380 | # create a small network |
| 381 | $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 32 |
| 382 | |
| 383 | # create some floating ips |
| 384 | $NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE |
| 385 | fi |
| 386 | |
| 387 | |
Jesse Andrews | e8d9cd8 | 2011-09-13 15:16:26 -0700 | [diff] [blame] | 388 | # Keystone |
| 389 | # -------- |
| 390 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 391 | if [[ "$ENABLED_SERVICES" =~ "key" ]]; then |
| 392 | # (re)create keystone database |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 393 | mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE IF EXISTS keystone;' |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 394 | mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE keystone;' |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 395 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 396 | # FIXME (anthony) keystone should use keystone.conf.example |
| 397 | KEYSTONE_CONF=$KEYSTONE_DIR/etc/keystone.conf |
Jesse Andrews | bf3868d | 2011-09-16 11:31:16 -0700 | [diff] [blame] | 398 | cp $FILES/keystone.conf $KEYSTONE_CONF |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 399 | 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] | 400 | |
Anthony Young | ec21d93 | 2011-09-16 16:05:55 -0700 | [diff] [blame] | 401 | KEYSTONE_DATA=$KEYSTONE_DIR/bin/keystone_data.sh |
| 402 | cp $FILES/keystone_data.sh $KEYSTONE_DATA |
| 403 | sudo sed -e "s,%HOST_IP%,$HOST_IP,g" -i $KEYSTONE_DATA |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 404 | # initialize keystone with default users/endpoints |
Anthony Young | ec21d93 | 2011-09-16 16:05:55 -0700 | [diff] [blame] | 405 | BIN_DIR=$KEYSTONE_DIR/bin bash $KEYSTONE_DATA |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 406 | fi |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 407 | |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 408 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 409 | # Launch Services |
| 410 | # =============== |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 411 | |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 412 | # nova api crashes if we start it with a regular screen command, |
| 413 | # so send the start command by forcing text into the window. |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 414 | # Only run the services specified in ``ENABLED_SERVICES`` |
| 415 | |
Jesse Andrews | 1f71760 | 2011-09-16 15:18:53 -0700 | [diff] [blame] | 416 | # our screen helper to launch a service in a hidden named screen |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 417 | function screen_it { |
Jesse Andrews | 1f71760 | 2011-09-16 15:18:53 -0700 | [diff] [blame] | 418 | NL=`echo -ne '\015'` |
Anthony Young | 292e46d | 2011-09-13 11:28:56 -0700 | [diff] [blame] | 419 | if [[ "$ENABLED_SERVICES" =~ "$1" ]]; then |
| 420 | screen -S nova -X screen -t $1 |
| 421 | screen -S nova -p $1 -X stuff "$2$NL" |
| 422 | fi |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 423 | } |
| 424 | |
Jesse Andrews | a16e5e9 | 2011-09-16 16:30:55 -0700 | [diff] [blame] | 425 | # create a new named screen to run processes in |
| 426 | screen -d -m -S nova -t nova |
| 427 | sleep 1 |
| 428 | |
Anthony Young | d000b22 | 2011-09-19 14:46:53 -0700 | [diff] [blame] | 429 | if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then |
| 430 | screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf" |
| 431 | fi |
| 432 | |
| 433 | if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then |
| 434 | screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf" |
| 435 | while ! wget -q -O- http://$GLANCE_HOSTPORT; do |
| 436 | echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..." |
| 437 | sleep 1 |
| 438 | done |
| 439 | fi |
| 440 | |
| 441 | if [[ "$ENABLED_SERVICES" =~ "key" ]]; then |
Anthony Young | f33796e | 2011-09-22 00:14:12 -0700 | [diff] [blame] | 442 | screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF -d" |
Anthony Young | d000b22 | 2011-09-19 14:46:53 -0700 | [diff] [blame] | 443 | while ! wget -q -O- http://127.0.0.1:5000; do |
| 444 | echo "Waiting for keystone to start..." |
| 445 | sleep 1 |
| 446 | done |
| 447 | fi |
| 448 | |
| 449 | if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then |
Anthony Young | 9bf3d76 | 2011-09-20 09:51:16 -0700 | [diff] [blame] | 450 | screen_it n-api "cd $NOVA_DIR && $NOVA_DIR/bin/nova-api" |
Anthony Young | d000b22 | 2011-09-19 14:46:53 -0700 | [diff] [blame] | 451 | while ! wget -q -O- http://127.0.0.1:8774; do |
| 452 | echo "Waiting for nova-api to start..." |
| 453 | sleep 1 |
| 454 | done |
| 455 | fi |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 456 | # Launching nova-compute should be as simple as running ``nova-compute`` but |
| 457 | # have to do a little more than that in our script. Since we add the group |
Jesse Andrews | 1f71760 | 2011-09-16 15:18:53 -0700 | [diff] [blame] | 458 | # ``libvirtd`` to our user in this script, when nova-compute is run it is |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 459 | # within the context of our original shell (so our groups won't be updated). |
Jesse Andrews | 1f71760 | 2011-09-16 15:18:53 -0700 | [diff] [blame] | 460 | # We can send the command nova-compute to the ``newgrp`` command to execute |
| 461 | # in a specific context. |
Anthony Young | 9bf3d76 | 2011-09-20 09:51:16 -0700 | [diff] [blame] | 462 | screen_it n-cpu "cd $NOVA_DIR && echo $NOVA_DIR/bin/nova-compute | newgrp libvirtd" |
| 463 | screen_it n-net "cd $NOVA_DIR && $NOVA_DIR/bin/nova-network" |
| 464 | screen_it n-sch "cd $NOVA_DIR && $NOVA_DIR/bin/nova-scheduler" |
Anthony Young | 1f81db6 | 2011-09-13 03:35:00 -0700 | [diff] [blame] | 465 | # nova-vncproxy binds a privileged port, and so needs sudo |
Anthony Young | 9bf3d76 | 2011-09-20 09:51:16 -0700 | [diff] [blame] | 466 | screen_it n-vnc "cd $NOVA_DIR && sudo $NOVA_DIR/bin/nova-vncproxy" |
| 467 | screen_it dash "cd $DASH_DIR && 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] | 468 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 469 | # Install Images |
| 470 | # ============== |
Jesse Andrews | e49b8bd | 2011-09-12 18:08:04 -0700 | [diff] [blame] | 471 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 472 | if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 473 | # Downloads a tty image (ami/aki/ari style), then extracts it. Upon extraction |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 474 | # we upload to glance with the glance cli tool. |
Jesse Andrews | 543d7d4 | 2011-09-16 14:16:36 -0700 | [diff] [blame] | 475 | if [ ! -f $FILES/tty.tgz ]; then |
| 476 | wget -c http://images.ansolabs.com/tty.tgz -O $FILES/tty.tgz |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 477 | fi |
Jesse Andrews | e49b8bd | 2011-09-12 18:08:04 -0700 | [diff] [blame] | 478 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 479 | # extract ami-tty/image, aki-tty/image & ari-tty/image |
Jesse Andrews | 543d7d4 | 2011-09-16 14:16:36 -0700 | [diff] [blame] | 480 | mkdir -p $FILES/images |
Jesse Andrews | 74e965f | 2011-09-16 14:19:46 -0700 | [diff] [blame] | 481 | tar -zxf $FILES/tty.tgz -C $FILES/images |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 482 | |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 483 | # add images to glance |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 484 | # FIXME: kernel/ramdisk is hardcoded - use return result from add |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 485 | glance add -A 999888777666 name="tty-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/aki-tty/image |
| 486 | glance add -A 999888777666 name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < $FILES/images/ari-tty/image |
Anthony Young | d02d715 | 2011-09-20 01:31:41 -0700 | [diff] [blame] | 487 | glance add -A 999888777666 name="tty" is_public=true container_format=ami disk_format=ami kernel_id=1 ramdisk_id=2 < $FILES/images/ami-tty/image |
Jesse Andrews | e49b8bd | 2011-09-12 18:08:04 -0700 | [diff] [blame] | 488 | fi |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 489 | |
| 490 | # Using the cloud |
| 491 | # =============== |
| 492 | |
| 493 | # If you installed the dashboard on this server, then you should be able |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 494 | # to access the site using your browser. |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 495 | if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then |
| 496 | echo "dashboard is now available at http://$HOST_IP/" |
| 497 | fi |
| 498 | |
| 499 | # If keystone is present, you can point nova cli to this server |
| 500 | if [[ "$ENABLED_SERVICES" =~ "key" ]]; then |
| 501 | echo "keystone is serving at http://$HOST_IP:5000/v2.0/" |
| 502 | echo "examples on using novaclient command line is in exercise.sh" |
| 503 | fi |