Merge branch 'build_kvm', remote-tracking branch 'origin' into build_kvm

main
Anthony Young 13 years ago
commit 728e944d0b

@ -30,18 +30,53 @@ if ! grep -q natty /etc/lsb-release; then
fi fi
fi fi
# Keep track of the current devstack directory.
TOP_DIR=$(cd $(dirname "$0") && pwd)
# stack.sh keeps the list of **apt** and **pip** dependencies in external # stack.sh keeps the list of **apt** and **pip** dependencies in external
# files, along with config templates and other useful files. You can find these # files, along with config templates and other useful files. You can find these
# in the ``files`` directory (next to this script). We will reference this # in the ``files`` directory (next to this script). We will reference this
# directory using the ``FILES`` variable in this script. # directory using the ``FILES`` variable in this script.
FILES=`pwd`/files FILES=$TOP_DIR/files
if [ ! -d $FILES ]; then if [ ! -d $FILES ]; then
echo "ERROR: missing devstack/files - did you grab more than just stack.sh?" echo "ERROR: missing devstack/files - did you grab more than just stack.sh?"
exit 1 exit 1
fi fi
# Keep track of the current devstack directory.
TOP_DIR=$(cd $(dirname "$0") && pwd)
# Settings
# ========
# This script is customizable through setting environment variables. If you
# want to override a setting you can either::
#
# export MYSQL_PASSWORD=anothersecret
# ./stack.sh
#
# You can also pass options on a single line ``MYSQL_PASSWORD=simple ./stack.sh``
#
# Additionally, you can put any local variables into a ``localrc`` file, like::
#
# MYSQL_PASSWORD=anothersecret
# MYSQL_USER=hellaroot
#
# We try to have sensible defaults, so you should be able to run ``./stack.sh``
# in most cases.
#
# We our settings from ``stackrc``. This file is distributed with devstack and
# contains locations for what repositories to use. If you want to use other
# repositories and branches, you can add your own settings with another file
# called ``localrc``
#
# If ``localrc`` exists, then ``stackrc`` will load those settings. This is
# useful for changing a branch or repostiory to test other versions. Also you
# can store your other settings like **MYSQL_PASSWORD** or **ADMIN_PASSWORD** instead
# of letting devstack generate random ones for you.
source ./stackrc
# Destination path for installation ``DEST``
DEST=${DEST:-/opt/stack}
# OpenStack is designed to be run as a regular user (Dashboard will fail to run # OpenStack is designed to be run as a regular user (Dashboard will fail to run
# as root, since apache refused to startup serve content from root user). If # as root, since apache refused to startup serve content from root user). If
@ -60,7 +95,7 @@ if [[ $EUID -eq 0 ]]; then
if ! getent passwd stack >/dev/null; then if ! getent passwd stack >/dev/null; then
echo "Creating a user called stack" echo "Creating a user called stack"
useradd -U -G sudo -s /bin/bash -m stack useradd -U -G sudo -s /bin/bash -d $DEST -m stack
fi fi
echo "Giving stack user passwordless sudo priviledges" echo "Giving stack user passwordless sudo priviledges"
@ -71,7 +106,7 @@ if [[ $EUID -eq 0 ]]; then
> /etc/sudoers.d/50_stack_sh ) > /etc/sudoers.d/50_stack_sh )
echo "Copying files to stack user" echo "Copying files to stack user"
STACK_DIR="/home/stack/${PWD##*/}" STACK_DIR="$DEST/${PWD##*/}"
cp -r -f "$PWD" "$STACK_DIR" cp -r -f "$PWD" "$STACK_DIR"
chown -R stack "$STACK_DIR" chown -R stack "$STACK_DIR"
if [[ "$SHELL_AFTER_RUN" != "no" ]]; then if [[ "$SHELL_AFTER_RUN" != "no" ]]; then
@ -82,40 +117,6 @@ if [[ $EUID -eq 0 ]]; then
exit 1 exit 1
fi fi
# Settings
# ========
# This script is customizable through setting environment variables. If you
# want to override a setting you can either::
#
# export MYSQL_PASSWORD=anothersecret
# ./stack.sh
#
# You can also pass options on a single line ``MYSQL_PASSWORD=simple ./stack.sh``
#
# Additionally, you can put any local variables into a ``localrc`` file, like::
#
# MYSQL_PASSWORD=anothersecret
# MYSQL_USER=hellaroot
#
# We try to have sensible defaults, so you should be able to run ``./stack.sh``
# in most cases.
#
# We our settings from ``stackrc``. This file is distributed with devstack and
# contains locations for what repositories to use. If you want to use other
# repositories and branches, you can add your own settings with another file
# called ``localrc``
#
# If ``localrc`` exists, then ``stackrc`` will load those settings. This is
# useful for changing a branch or repostiory to test other versions. Also you
# can store your other settings like **MYSQL_PASSWORD** or **ADMIN_PASSWORD** instead
# of letting devstack generate random ones for you.
source ./stackrc
# Destination path for installation ``DEST``
DEST=${DEST:-/opt/stack}
# Set the destination directories for openstack projects # Set the destination directories for openstack projects
NOVA_DIR=$DEST/nova NOVA_DIR=$DEST/nova
DASH_DIR=$DEST/dash DASH_DIR=$DEST/dash
@ -229,16 +230,15 @@ FLAT_INTERFACE=${FLAT_INTERFACE:-eth0}
# use an existing server, you can pass in the user/password/host parameters. # use an existing server, you can pass in the user/password/host parameters.
# You will need to send the same ``MYSQL_PASSWORD`` to every host if you are doing # You will need to send the same ``MYSQL_PASSWORD`` to every host if you are doing
# a multi-node devstack installation. # a multi-node devstack installation.
MYSQL_HOST=${MYSQL_HOST:-localhost}
MYSQL_USER=${MYSQL_USER:-root} MYSQL_USER=${MYSQL_USER:-root}
read_password MYSQL_PASSWORD "ENTER A PASSWORD TO USE FOR MYSQL." read_password MYSQL_PASSWORD "ENTER A PASSWORD TO USE FOR MYSQL."
MYSQL_HOST=${MYSQL_HOST:-localhost}
# don't specify /db in this string, so we can use it for multiple services # don't specify /db in this string, so we can use it for multiple services
BASE_SQL_CONN=${BASE_SQL_CONN:-mysql://$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST} BASE_SQL_CONN=${BASE_SQL_CONN:-mysql://$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST}
# Rabbit connection info # Rabbit connection info
RABBIT_HOST=${RABBIT_HOST:-localhost} RABBIT_HOST=${RABBIT_HOST:-localhost}
RABBIT_PASSWORD=${RABBIT_PASSWORD:-`openssl rand -hex 12`}
read_password RABBIT_PASSWORD "ENTER A PASSWORD TO USE FOR RABBIT." read_password RABBIT_PASSWORD "ENTER A PASSWORD TO USE FOR RABBIT."
# Glance connection info. Note the port must be specified. # Glance connection info. Note the port must be specified.
@ -270,8 +270,11 @@ failed() {
# an error. It is also useful for following along as the install occurs. # an error. It is also useful for following along as the install occurs.
set -o xtrace set -o xtrace
# create the destination directory and ensure it is writable by the user
sudo mkdir -p $DEST sudo mkdir -p $DEST
sudo chown `whoami` $DEST if [ ! -w $DEST ]; then
sudo chown `whoami` $DEST
fi
# Install Packages # Install Packages
# ================ # ================
@ -292,14 +295,14 @@ sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*`
function git_clone { function git_clone {
# if there is an existing checkout, move it out of the way # if there is an existing checkout, move it out of the way
if [[ "$RECLONE" == "yes" ]]; then if [[ "$RECLONE" == "yes" ]]; then
# FIXME(ja): if we were smarter we could speed up RECLONE by
# using the old git repo as the basis of our new clone...
if [ -d $2 ]; then if [ -d $2 ]; then
mv $2 /tmp/stack.`date +%s` mv $2 /tmp/stack.`date +%s`
fi fi
fi fi
if [ ! -d $2 ]; then if [ ! -d $2 ]; then
sudo mkdir $2
sudo chown `whoami` $2
git clone $1 $2 git clone $1 $2
cd $2 cd $2
# This checkout syntax works for both branches and tags # This checkout syntax works for both branches and tags
@ -408,6 +411,8 @@ if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
# ``local_settings.py`` is used to override dashboard default settings. # ``local_settings.py`` is used to override dashboard default settings.
cp $FILES/dash_settings.py $DASH_DIR/openstack-dashboard/local/local_settings.py cp $FILES/dash_settings.py $DASH_DIR/openstack-dashboard/local/local_settings.py
# Initialize the dashboard database (it stores sessions and notices shown to
# users). The user system is external (keystone).
cd $DASH_DIR/openstack-dashboard cd $DASH_DIR/openstack-dashboard
dashboard/manage.py syncdb dashboard/manage.py syncdb
@ -435,7 +440,8 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
# (re)create glance database # (re)create glance database
mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS glance;' mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS glance;'
mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE glance;' mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE glance;'
# Copy over our glance-registry.conf
# Copy over our glance configurations and update them
GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf
cp $FILES/glance-registry.conf $GLANCE_CONF cp $FILES/glance-registry.conf $GLANCE_CONF
sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/glance,g" -i $GLANCE_CONF sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/glance,g" -i $GLANCE_CONF
@ -454,7 +460,7 @@ fi
# We are going to use the sample http middleware configuration from the keystone # We are going to use the sample http middleware configuration from the keystone
# project to launch nova. This paste config adds the configuration required # project to launch nova. This paste config adds the configuration required
# for nova to validate keystone tokens - except we need to switch the config # for nova to validate keystone tokens - except we need to switch the config
# to use our admin token instead (instead of the token from their sample data). # to use our service token instead (instead of the invalid token 999888777666).
sudo sed -e "s,999888777666,$SERVICE_TOKEN,g" -i $KEYSTONE_DIR/examples/paste/nova-api-paste.ini sudo sed -e "s,999888777666,$SERVICE_TOKEN,g" -i $KEYSTONE_DIR/examples/paste/nova-api-paste.ini
if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
@ -465,9 +471,9 @@ if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
# attempt to load modules: network block device - used to manage qcow images # attempt to load modules: network block device - used to manage qcow images
sudo modprobe nbd || true sudo modprobe nbd || true
# Check for kvm (hardware based virtualization). If unable to load kvm, # Check for kvm (hardware based virtualization). If unable to initialize
# set the libvirt type to qemu. Note: many systems come with hardware # kvm, we drop back to the slower emulation mode (qemu). Note: many systems
# virtualization disabled in BIOS. # come with hardware virtualization disabled in BIOS.
if [[ "$LIBVIRT_TYPE" == "kvm" ]]; then if [[ "$LIBVIRT_TYPE" == "kvm" ]]; then
sudo modprobe kvm || true sudo modprobe kvm || true
if [ ! -e /dev/kvm ]; then if [ ! -e /dev/kvm ]; then
@ -481,7 +487,8 @@ if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
# to simulate multiple systems. # to simulate multiple systems.
if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
sudo apt-get install lxc -y sudo apt-get install lxc -y
# lxc requires cgroups to be configured on /cgroup # lxc uses cgroups (a kernel interface via virtual filesystem) configured
# and mounted to ``/cgroup``
sudo mkdir -p /cgroup sudo mkdir -p /cgroup
if ! grep -q cgroup /etc/fstab; then if ! grep -q cgroup /etc/fstab; then
echo none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0 | sudo tee -a /etc/fstab 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
fi fi
fi fi
# User needs to be member of libvirtd group for nova-compute to use libvirt. # The user that nova runs as needs to be member of libvirtd group otherwise
# nova-compute will be unable to use libvirt.
sudo usermod -a -G libvirtd `whoami` sudo usermod -a -G libvirtd `whoami`
# if kvm wasn't running before we need to restart libvirt to enable it # libvirt detects various settings on startup, as we potentially changed
# the system configuration (modules, filesystems), we need to restart
# libvirt to detect those changes.
sudo /etc/init.d/libvirt-bin restart sudo /etc/init.d/libvirt-bin restart
@ -503,12 +513,14 @@ if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
# Nova stores each instance in its own directory. # Nova stores each instance in its own directory.
mkdir -p $NOVA_DIR/instances mkdir -p $NOVA_DIR/instances
# if there is a partition labeled nova-instances use it (ext filesystems # You can specify a different disk to be mounted and used for backing the
# can be labeled via e2label) # virtual machines. If there is a partition labeled nova-instances we
## FIXME: if already mounted this blows up... # mount it (ext filesystems can be labeled via e2label).
if [ -L /dev/disk/by-label/nova-instances ]; then if [ -L /dev/disk/by-label/nova-instances ]; then
sudo mount -L nova-instances $NOVA_DIR/instances if ! mount -n | grep -q nova-instances; then
sudo chown -R `whoami` $NOVA_DIR/instances sudo mount -L nova-instances $NOVA_DIR/instances
sudo chown -R `whoami` $NOVA_DIR/instances
fi
fi fi
# Clean out the instances directory. # Clean out the instances directory.
@ -675,10 +687,10 @@ screen_it dash "cd $DASH_DIR && sudo /etc/init.d/apache2 restart; sudo tail -f /
# TTY also uses cloud-init, supporting login via keypair and sending scripts as # TTY also uses cloud-init, supporting login via keypair and sending scripts as
# userdata. See https://help.ubuntu.com/community/CloudInit for more on cloud-init # userdata. See https://help.ubuntu.com/community/CloudInit for more on cloud-init
# #
# Override IMAGE_URLS if you would to launch a different image(s). # Override ``IMAGE_URLS`` with a comma-seperated list of uec images.
# Specify IMAGE_URLS as a comma-separated list of uec urls. Some other options include: #
# natty: http://uec-images.ubuntu.com/natty/current/natty-server-cloudimg-amd64.tar.gz # * **natty**: http://uec-images.ubuntu.com/natty/current/natty-server-cloudimg-amd64.tar.gz
# oneiric: http://uec-images.ubuntu.com/oneiric/current/oneiric-server-cloudimg-amd64.tar.gz # * **oneiric**: http://uec-images.ubuntu.com/oneiric/current/oneiric-server-cloudimg-amd64.tar.gz
if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
# Create a directory for the downloaded image tarballs. # Create a directory for the downloaded image tarballs.

@ -18,6 +18,9 @@ CWD=`pwd`
DEST=${DEST:-/opt/stack} DEST=${DEST:-/opt/stack}
# Param string to pass to stack.sh. Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova"
STACKSH_PARAMS=${STACKSH_PARAMS:-}
# Option to use the version of devstack on which we are currently working # Option to use the version of devstack on which we are currently working
USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1} USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
@ -42,7 +45,7 @@ if [ ! -d $CHROOTCACHE/natty-dev ]; then
chroot $CHROOTCACHE/natty-dev groupadd libvirtd chroot $CHROOTCACHE/natty-dev groupadd libvirtd
chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd
mkdir -p $CHROOTCACHE/natty-dev/$DEST mkdir -p $CHROOTCACHE/natty-dev/$DEST
chown stack $CHROOTCACHE/natty-dev/$DEST chroot $CHROOTCACHE/natty-dev chown stack $DEST
# a simple password - pass # a simple password - pass
echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
@ -112,6 +115,34 @@ auto eth0
iface eth0 inet dhcp iface eth0 inet dhcp
EOF EOF
# Set hostname
echo "ramstack" >$CHROOTCACHE/natty-stack/etc/hostname
echo "127.0.0.1 localhost ramstack" >$CHROOTCACHE/natty-stack/etc/hosts
# Configure the runner
RUN_SH=$CHROOTCACHE/natty-stack/$DEST/run.sh
cat > $RUN_SH <<EOF
#!/usr/bin/env bash
# Get IP range
set \`ip addr show dev eth0 | grep inet\`
PREFIX=\`echo \$2 | cut -d. -f1,2,3\`
export FLOATING_RANGE="\$PREFIX.224/27"
# Kill any existing screens
killall screen
# Run stack.sh
cd $DEST/devstack && \$STACKSH_PARAMS ./stack.sh > $DEST/run.sh.log
echo >> $DEST/run.sh.log
echo >> $DEST/run.sh.log
echo "All done! Time to start clicking." >> $DEST/run.sh.log
EOF
# Make the run.sh executable
chmod 755 $RUN_SH
chroot $CHROOTCACHE/natty-stack chown stack $DEST/run.sh
# build a new image # build a new image
BASE=$CHROOTCACHE/build.$$ BASE=$CHROOTCACHE/build.$$
IMG=$BASE.img IMG=$BASE.img

@ -21,22 +21,25 @@ if [ -b $DEST_DIR ]; then
# We have a block device, install syslinux and mount it # We have a block device, install syslinux and mount it
DEST_DEV=$DEST_DIR DEST_DEV=$DEST_DIR
DEST_DIR=`mktemp -d mntXXXXXX` DEST_DIR=`mktemp -d mntXXXXXX`
mount $DEST_DEV $DEST_DIR
if [ ! -d $DEST_DIR/syslinux ]; then
mkdir -p $DEST_DIR/syslinux
fi
# Install syslinux on the device # Install syslinux on the device
syslinux --install --directory syslinux $DEST_DEV syslinux --install --directory syslinux $DEST_DEV
mount $DEST_DEV $DEST_DIR
else else
# We have a directory (for sanity checking output) # We have a directory (for sanity checking output)
DEST_DEV="" DEST_DEV=""
if [ ! -d $DEST_DIR/syslinux ]; then if [ ! -d $DEST_DIR/syslinux ]; then
mkdir -p $DEST_DIR/syslinux mkdir -p $DEST_DIR/syslinux
fi fi
fi fi
# Get some more stuff from syslinux # Get some more stuff from syslinux
for i in memdisk menu.c32; do for i in memdisk menu.c32; do
cp -p /usr/lib/syslinux/$i $DEST_DIR/syslinux cp -p /usr/lib/syslinux/$i $DEST_DIR/syslinux
done done
CFG=$DEST_DIR/syslinux/syslinux.cfg CFG=$DEST_DIR/syslinux/syslinux.cfg

Loading…
Cancel
Save