| ... | ... |
@@ -30,18 +30,53 @@ if ! grep -q natty /etc/lsb-release; then |
| 30 | 30 |
fi |
| 31 | 31 |
fi |
| 32 | 32 |
|
| 33 |
+# Keep track of the current devstack directory. |
|
| 34 |
+TOP_DIR=$(cd $(dirname "$0") && pwd) |
|
| 35 |
+ |
|
| 33 | 36 |
# stack.sh keeps the list of **apt** and **pip** dependencies in external |
| 34 | 37 |
# files, along with config templates and other useful files. You can find these |
| 35 | 38 |
# in the ``files`` directory (next to this script). We will reference this |
| 36 | 39 |
# directory using the ``FILES`` variable in this script. |
| 37 |
-FILES=`pwd`/files |
|
| 40 |
+FILES=$TOP_DIR/files |
|
| 38 | 41 |
if [ ! -d $FILES ]; then |
| 39 | 42 |
echo "ERROR: missing devstack/files - did you grab more than just stack.sh?" |
| 40 | 43 |
exit 1 |
| 41 | 44 |
fi |
| 42 | 45 |
|
| 43 |
-# Keep track of the current devstack directory. |
|
| 44 |
-TOP_DIR=$(cd $(dirname "$0") && pwd) |
|
| 46 |
+ |
|
| 47 |
+ |
|
| 48 |
+# Settings |
|
| 49 |
+# ======== |
|
| 50 |
+ |
|
| 51 |
+# This script is customizable through setting environment variables. If you |
|
| 52 |
+# want to override a setting you can either:: |
|
| 53 |
+# |
|
| 54 |
+# export MYSQL_PASSWORD=anothersecret |
|
| 55 |
+# ./stack.sh |
|
| 56 |
+# |
|
| 57 |
+# You can also pass options on a single line ``MYSQL_PASSWORD=simple ./stack.sh`` |
|
| 58 |
+# |
|
| 59 |
+# Additionally, you can put any local variables into a ``localrc`` file, like:: |
|
| 60 |
+# |
|
| 61 |
+# MYSQL_PASSWORD=anothersecret |
|
| 62 |
+# MYSQL_USER=hellaroot |
|
| 63 |
+# |
|
| 64 |
+# We try to have sensible defaults, so you should be able to run ``./stack.sh`` |
|
| 65 |
+# in most cases. |
|
| 66 |
+# |
|
| 67 |
+# We our settings from ``stackrc``. This file is distributed with devstack and |
|
| 68 |
+# contains locations for what repositories to use. If you want to use other |
|
| 69 |
+# repositories and branches, you can add your own settings with another file |
|
| 70 |
+# called ``localrc`` |
|
| 71 |
+# |
|
| 72 |
+# If ``localrc`` exists, then ``stackrc`` will load those settings. This is |
|
| 73 |
+# useful for changing a branch or repostiory to test other versions. Also you |
|
| 74 |
+# can store your other settings like **MYSQL_PASSWORD** or **ADMIN_PASSWORD** instead |
|
| 75 |
+# of letting devstack generate random ones for you. |
|
| 76 |
+source ./stackrc |
|
| 77 |
+ |
|
| 78 |
+# Destination path for installation ``DEST`` |
|
| 79 |
+DEST=${DEST:-/opt/stack}
|
|
| 45 | 80 |
|
| 46 | 81 |
# OpenStack is designed to be run as a regular user (Dashboard will fail to run |
| 47 | 82 |
# as root, since apache refused to startup serve content from root user). If |
| ... | ... |
@@ -60,7 +95,7 @@ if [[ $EUID -eq 0 ]]; then |
| 60 | 60 |
|
| 61 | 61 |
if ! getent passwd stack >/dev/null; then |
| 62 | 62 |
echo "Creating a user called stack" |
| 63 |
- useradd -U -G sudo -s /bin/bash -m stack |
|
| 63 |
+ useradd -U -G sudo -s /bin/bash -d $DEST -m stack |
|
| 64 | 64 |
fi |
| 65 | 65 |
|
| 66 | 66 |
echo "Giving stack user passwordless sudo priviledges" |
| ... | ... |
@@ -71,7 +106,7 @@ if [[ $EUID -eq 0 ]]; then |
| 71 | 71 |
> /etc/sudoers.d/50_stack_sh ) |
| 72 | 72 |
|
| 73 | 73 |
echo "Copying files to stack user" |
| 74 |
- STACK_DIR="/home/stack/${PWD##*/}"
|
|
| 74 |
+ STACK_DIR="$DEST/${PWD##*/}"
|
|
| 75 | 75 |
cp -r -f "$PWD" "$STACK_DIR" |
| 76 | 76 |
chown -R stack "$STACK_DIR" |
| 77 | 77 |
if [[ "$SHELL_AFTER_RUN" != "no" ]]; then |
| ... | ... |
@@ -82,40 +117,6 @@ if [[ $EUID -eq 0 ]]; then |
| 82 | 82 |
exit 1 |
| 83 | 83 |
fi |
| 84 | 84 |
|
| 85 |
- |
|
| 86 |
-# Settings |
|
| 87 |
-# ======== |
|
| 88 |
- |
|
| 89 |
-# This script is customizable through setting environment variables. If you |
|
| 90 |
-# want to override a setting you can either:: |
|
| 91 |
-# |
|
| 92 |
-# export MYSQL_PASSWORD=anothersecret |
|
| 93 |
-# ./stack.sh |
|
| 94 |
-# |
|
| 95 |
-# You can also pass options on a single line ``MYSQL_PASSWORD=simple ./stack.sh`` |
|
| 96 |
-# |
|
| 97 |
-# Additionally, you can put any local variables into a ``localrc`` file, like:: |
|
| 98 |
-# |
|
| 99 |
-# MYSQL_PASSWORD=anothersecret |
|
| 100 |
-# MYSQL_USER=hellaroot |
|
| 101 |
-# |
|
| 102 |
-# We try to have sensible defaults, so you should be able to run ``./stack.sh`` |
|
| 103 |
-# in most cases. |
|
| 104 |
-# |
|
| 105 |
-# We our settings from ``stackrc``. This file is distributed with devstack and |
|
| 106 |
-# contains locations for what repositories to use. If you want to use other |
|
| 107 |
-# repositories and branches, you can add your own settings with another file |
|
| 108 |
-# called ``localrc`` |
|
| 109 |
-# |
|
| 110 |
-# If ``localrc`` exists, then ``stackrc`` will load those settings. This is |
|
| 111 |
-# useful for changing a branch or repostiory to test other versions. Also you |
|
| 112 |
-# can store your other settings like **MYSQL_PASSWORD** or **ADMIN_PASSWORD** instead |
|
| 113 |
-# of letting devstack generate random ones for you. |
|
| 114 |
-source ./stackrc |
|
| 115 |
- |
|
| 116 |
-# Destination path for installation ``DEST`` |
|
| 117 |
-DEST=${DEST:-/opt/stack}
|
|
| 118 |
- |
|
| 119 | 85 |
# Set the destination directories for openstack projects |
| 120 | 86 |
NOVA_DIR=$DEST/nova |
| 121 | 87 |
DASH_DIR=$DEST/dash |
| ... | ... |
@@ -229,16 +230,15 @@ FLAT_INTERFACE=${FLAT_INTERFACE:-eth0}
|
| 229 | 229 |
# use an existing server, you can pass in the user/password/host parameters. |
| 230 | 230 |
# You will need to send the same ``MYSQL_PASSWORD`` to every host if you are doing |
| 231 | 231 |
# a multi-node devstack installation. |
| 232 |
+MYSQL_HOST=${MYSQL_HOST:-localhost}
|
|
| 232 | 233 |
MYSQL_USER=${MYSQL_USER:-root}
|
| 233 | 234 |
read_password MYSQL_PASSWORD "ENTER A PASSWORD TO USE FOR MYSQL." |
| 234 |
-MYSQL_HOST=${MYSQL_HOST:-localhost}
|
|
| 235 | 235 |
|
| 236 | 236 |
# don't specify /db in this string, so we can use it for multiple services |
| 237 | 237 |
BASE_SQL_CONN=${BASE_SQL_CONN:-mysql://$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST}
|
| 238 | 238 |
|
| 239 | 239 |
# Rabbit connection info |
| 240 | 240 |
RABBIT_HOST=${RABBIT_HOST:-localhost}
|
| 241 |
-RABBIT_PASSWORD=${RABBIT_PASSWORD:-`openssl rand -hex 12`}
|
|
| 242 | 241 |
read_password RABBIT_PASSWORD "ENTER A PASSWORD TO USE FOR RABBIT." |
| 243 | 242 |
|
| 244 | 243 |
# Glance connection info. Note the port must be specified. |
| ... | ... |
@@ -270,8 +270,11 @@ failed() {
|
| 270 | 270 |
# an error. It is also useful for following along as the install occurs. |
| 271 | 271 |
set -o xtrace |
| 272 | 272 |
|
| 273 |
+# create the destination directory and ensure it is writable by the user |
|
| 273 | 274 |
sudo mkdir -p $DEST |
| 274 |
-sudo chown `whoami` $DEST |
|
| 275 |
+if [ ! -w $DEST ]; then |
|
| 276 |
+ sudo chown `whoami` $DEST |
|
| 277 |
+fi |
|
| 275 | 278 |
|
| 276 | 279 |
# Install Packages |
| 277 | 280 |
# ================ |
| ... | ... |
@@ -292,14 +295,14 @@ sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*` |
| 292 | 292 |
function git_clone {
|
| 293 | 293 |
# if there is an existing checkout, move it out of the way |
| 294 | 294 |
if [[ "$RECLONE" == "yes" ]]; then |
| 295 |
+ # FIXME(ja): if we were smarter we could speed up RECLONE by |
|
| 296 |
+ # using the old git repo as the basis of our new clone... |
|
| 295 | 297 |
if [ -d $2 ]; then |
| 296 | 298 |
mv $2 /tmp/stack.`date +%s` |
| 297 | 299 |
fi |
| 298 | 300 |
fi |
| 299 | 301 |
|
| 300 | 302 |
if [ ! -d $2 ]; then |
| 301 |
- sudo mkdir $2 |
|
| 302 |
- sudo chown `whoami` $2 |
|
| 303 | 303 |
git clone $1 $2 |
| 304 | 304 |
cd $2 |
| 305 | 305 |
# This checkout syntax works for both branches and tags |
| ... | ... |
@@ -408,6 +411,8 @@ if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then |
| 408 | 408 |
# ``local_settings.py`` is used to override dashboard default settings. |
| 409 | 409 |
cp $FILES/dash_settings.py $DASH_DIR/openstack-dashboard/local/local_settings.py |
| 410 | 410 |
|
| 411 |
+ # Initialize the dashboard database (it stores sessions and notices shown to |
|
| 412 |
+ # users). The user system is external (keystone). |
|
| 411 | 413 |
cd $DASH_DIR/openstack-dashboard |
| 412 | 414 |
dashboard/manage.py syncdb |
| 413 | 415 |
|
| ... | ... |
@@ -435,7 +440,8 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then |
| 435 | 435 |
# (re)create glance database |
| 436 | 436 |
mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS glance;' |
| 437 | 437 |
mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE glance;' |
| 438 |
- # Copy over our glance-registry.conf |
|
| 438 |
+ |
|
| 439 |
+ # Copy over our glance configurations and update them |
|
| 439 | 440 |
GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf |
| 440 | 441 |
cp $FILES/glance-registry.conf $GLANCE_CONF |
| 441 | 442 |
sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/glance,g" -i $GLANCE_CONF |
| ... | ... |
@@ -454,7 +460,7 @@ fi |
| 454 | 454 |
# We are going to use the sample http middleware configuration from the keystone |
| 455 | 455 |
# project to launch nova. This paste config adds the configuration required |
| 456 | 456 |
# for nova to validate keystone tokens - except we need to switch the config |
| 457 |
-# to use our admin token instead (instead of the token from their sample data). |
|
| 457 |
+# to use our service token instead (instead of the invalid token 999888777666). |
|
| 458 | 458 |
sudo sed -e "s,999888777666,$SERVICE_TOKEN,g" -i $KEYSTONE_DIR/examples/paste/nova-api-paste.ini |
| 459 | 459 |
|
| 460 | 460 |
if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then |
| ... | ... |
@@ -465,9 +471,9 @@ if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then |
| 465 | 465 |
# attempt to load modules: network block device - used to manage qcow images |
| 466 | 466 |
sudo modprobe nbd || true |
| 467 | 467 |
|
| 468 |
- # Check for kvm (hardware based virtualization). If unable to load kvm, |
|
| 469 |
- # set the libvirt type to qemu. Note: many systems come with hardware |
|
| 470 |
- # virtualization disabled in BIOS. |
|
| 468 |
+ # Check for kvm (hardware based virtualization). If unable to initialize |
|
| 469 |
+ # kvm, we drop back to the slower emulation mode (qemu). Note: many systems |
|
| 470 |
+ # come with hardware virtualization disabled in BIOS. |
|
| 471 | 471 |
if [[ "$LIBVIRT_TYPE" == "kvm" ]]; then |
| 472 | 472 |
sudo modprobe kvm || true |
| 473 | 473 |
if [ ! -e /dev/kvm ]; then |
| ... | ... |
@@ -481,7 +487,8 @@ if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then |
| 481 | 481 |
# to simulate multiple systems. |
| 482 | 482 |
if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then |
| 483 | 483 |
sudo apt-get install lxc -y |
| 484 |
- # lxc requires cgroups to be configured on /cgroup |
|
| 484 |
+ # lxc uses cgroups (a kernel interface via virtual filesystem) configured |
|
| 485 |
+ # and mounted to ``/cgroup`` |
|
| 485 | 486 |
sudo mkdir -p /cgroup |
| 486 | 487 |
if ! grep -q cgroup /etc/fstab; then |
| 487 | 488 |
echo none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0 | sudo tee -a /etc/fstab |
| ... | ... |
@@ -491,9 +498,12 @@ if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then |
| 491 | 491 |
fi |
| 492 | 492 |
fi |
| 493 | 493 |
|
| 494 |
- # User needs to be member of libvirtd group for nova-compute to use libvirt. |
|
| 494 |
+ # The user that nova runs as needs to be member of libvirtd group otherwise |
|
| 495 |
+ # nova-compute will be unable to use libvirt. |
|
| 495 | 496 |
sudo usermod -a -G libvirtd `whoami` |
| 496 |
- # if kvm wasn't running before we need to restart libvirt to enable it |
|
| 497 |
+ # libvirt detects various settings on startup, as we potentially changed |
|
| 498 |
+ # the system configuration (modules, filesystems), we need to restart |
|
| 499 |
+ # libvirt to detect those changes. |
|
| 497 | 500 |
sudo /etc/init.d/libvirt-bin restart |
| 498 | 501 |
|
| 499 | 502 |
|
| ... | ... |
@@ -503,12 +513,14 @@ if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then |
| 503 | 503 |
# Nova stores each instance in its own directory. |
| 504 | 504 |
mkdir -p $NOVA_DIR/instances |
| 505 | 505 |
|
| 506 |
- # if there is a partition labeled nova-instances use it (ext filesystems |
|
| 507 |
- # can be labeled via e2label) |
|
| 508 |
- ## FIXME: if already mounted this blows up... |
|
| 506 |
+ # You can specify a different disk to be mounted and used for backing the |
|
| 507 |
+ # virtual machines. If there is a partition labeled nova-instances we |
|
| 508 |
+ # mount it (ext filesystems can be labeled via e2label). |
|
| 509 | 509 |
if [ -L /dev/disk/by-label/nova-instances ]; then |
| 510 |
- sudo mount -L nova-instances $NOVA_DIR/instances |
|
| 511 |
- sudo chown -R `whoami` $NOVA_DIR/instances |
|
| 510 |
+ if ! mount -n | grep -q nova-instances; then |
|
| 511 |
+ sudo mount -L nova-instances $NOVA_DIR/instances |
|
| 512 |
+ sudo chown -R `whoami` $NOVA_DIR/instances |
|
| 513 |
+ fi |
|
| 512 | 514 |
fi |
| 513 | 515 |
|
| 514 | 516 |
# Clean out the instances directory. |
| ... | ... |
@@ -675,10 +687,10 @@ screen_it dash "cd $DASH_DIR && sudo /etc/init.d/apache2 restart; sudo tail -f / |
| 675 | 675 |
# TTY also uses cloud-init, supporting login via keypair and sending scripts as |
| 676 | 676 |
# userdata. See https://help.ubuntu.com/community/CloudInit for more on cloud-init |
| 677 | 677 |
# |
| 678 |
-# Override IMAGE_URLS if you would to launch a different image(s). |
|
| 679 |
-# Specify IMAGE_URLS as a comma-separated list of uec urls. Some other options include: |
|
| 680 |
-# natty: http://uec-images.ubuntu.com/natty/current/natty-server-cloudimg-amd64.tar.gz |
|
| 681 |
-# oneiric: http://uec-images.ubuntu.com/oneiric/current/oneiric-server-cloudimg-amd64.tar.gz |
|
| 678 |
+# Override ``IMAGE_URLS`` with a comma-seperated list of uec images. |
|
| 679 |
+# |
|
| 680 |
+# * **natty**: http://uec-images.ubuntu.com/natty/current/natty-server-cloudimg-amd64.tar.gz |
|
| 681 |
+# * **oneiric**: http://uec-images.ubuntu.com/oneiric/current/oneiric-server-cloudimg-amd64.tar.gz |
|
| 682 | 682 |
|
| 683 | 683 |
if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then |
| 684 | 684 |
# Create a directory for the downloaded image tarballs. |
| ... | ... |
@@ -18,6 +18,9 @@ CWD=`pwd` |
| 18 | 18 |
|
| 19 | 19 |
DEST=${DEST:-/opt/stack}
|
| 20 | 20 |
|
| 21 |
+# Param string to pass to stack.sh. Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova" |
|
| 22 |
+STACKSH_PARAMS=${STACKSH_PARAMS:-}
|
|
| 23 |
+ |
|
| 21 | 24 |
# Option to use the version of devstack on which we are currently working |
| 22 | 25 |
USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
|
| 23 | 26 |
|
| ... | ... |
@@ -42,7 +45,7 @@ if [ ! -d $CHROOTCACHE/natty-dev ]; then |
| 42 | 42 |
chroot $CHROOTCACHE/natty-dev groupadd libvirtd |
| 43 | 43 |
chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd |
| 44 | 44 |
mkdir -p $CHROOTCACHE/natty-dev/$DEST |
| 45 |
- chown stack $CHROOTCACHE/natty-dev/$DEST |
|
| 45 |
+ chroot $CHROOTCACHE/natty-dev chown stack $DEST |
|
| 46 | 46 |
|
| 47 | 47 |
# a simple password - pass |
| 48 | 48 |
echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd |
| ... | ... |
@@ -112,6 +115,34 @@ auto eth0 |
| 112 | 112 |
iface eth0 inet dhcp |
| 113 | 113 |
EOF |
| 114 | 114 |
|
| 115 |
+# Set hostname |
|
| 116 |
+echo "ramstack" >$CHROOTCACHE/natty-stack/etc/hostname |
|
| 117 |
+echo "127.0.0.1 localhost ramstack" >$CHROOTCACHE/natty-stack/etc/hosts |
|
| 118 |
+ |
|
| 119 |
+# Configure the runner |
|
| 120 |
+RUN_SH=$CHROOTCACHE/natty-stack/$DEST/run.sh |
|
| 121 |
+cat > $RUN_SH <<EOF |
|
| 122 |
+#!/usr/bin/env bash |
|
| 123 |
+ |
|
| 124 |
+# Get IP range |
|
| 125 |
+set \`ip addr show dev eth0 | grep inet\` |
|
| 126 |
+PREFIX=\`echo \$2 | cut -d. -f1,2,3\` |
|
| 127 |
+export FLOATING_RANGE="\$PREFIX.224/27" |
|
| 128 |
+ |
|
| 129 |
+# Kill any existing screens |
|
| 130 |
+killall screen |
|
| 131 |
+ |
|
| 132 |
+# Run stack.sh |
|
| 133 |
+cd $DEST/devstack && \$STACKSH_PARAMS ./stack.sh > $DEST/run.sh.log |
|
| 134 |
+echo >> $DEST/run.sh.log |
|
| 135 |
+echo >> $DEST/run.sh.log |
|
| 136 |
+echo "All done! Time to start clicking." >> $DEST/run.sh.log |
|
| 137 |
+EOF |
|
| 138 |
+ |
|
| 139 |
+# Make the run.sh executable |
|
| 140 |
+chmod 755 $RUN_SH |
|
| 141 |
+chroot $CHROOTCACHE/natty-stack chown stack $DEST/run.sh |
|
| 142 |
+ |
|
| 115 | 143 |
# build a new image |
| 116 | 144 |
BASE=$CHROOTCACHE/build.$$ |
| 117 | 145 |
IMG=$BASE.img |
| ... | ... |
@@ -21,22 +21,25 @@ if [ -b $DEST_DIR ]; then |
| 21 | 21 |
# We have a block device, install syslinux and mount it |
| 22 | 22 |
DEST_DEV=$DEST_DIR |
| 23 | 23 |
DEST_DIR=`mktemp -d mntXXXXXX` |
| 24 |
+ mount $DEST_DEV $DEST_DIR |
|
| 25 |
+ |
|
| 26 |
+ if [ ! -d $DEST_DIR/syslinux ]; then |
|
| 27 |
+ mkdir -p $DEST_DIR/syslinux |
|
| 28 |
+ fi |
|
| 24 | 29 |
|
| 25 | 30 |
# Install syslinux on the device |
| 26 | 31 |
syslinux --install --directory syslinux $DEST_DEV |
| 27 |
- |
|
| 28 |
- mount $DEST_DEV $DEST_DIR |
|
| 29 | 32 |
else |
| 30 | 33 |
# We have a directory (for sanity checking output) |
| 31 |
- DEST_DEV="" |
|
| 32 |
- if [ ! -d $DEST_DIR/syslinux ]; then |
|
| 33 |
- mkdir -p $DEST_DIR/syslinux |
|
| 34 |
- fi |
|
| 34 |
+ DEST_DEV="" |
|
| 35 |
+ if [ ! -d $DEST_DIR/syslinux ]; then |
|
| 36 |
+ mkdir -p $DEST_DIR/syslinux |
|
| 37 |
+ fi |
|
| 35 | 38 |
fi |
| 36 | 39 |
|
| 37 | 40 |
# Get some more stuff from syslinux |
| 38 | 41 |
for i in memdisk menu.c32; do |
| 39 |
- cp -p /usr/lib/syslinux/$i $DEST_DIR/syslinux |
|
| 42 |
+ cp -p /usr/lib/syslinux/$i $DEST_DIR/syslinux |
|
| 40 | 43 |
done |
| 41 | 44 |
|
| 42 | 45 |
CFG=$DEST_DIR/syslinux/syslinux.cfg |