From 1bfa3d53c1ee74525932b721c2dddd42fc129b8e Mon Sep 17 00:00:00 2001 From: Brad Hall Date: Thu, 27 Oct 2011 18:18:20 -0700 Subject: [PATCH 001/112] Add Quantum support --- files/apts/quantum | 2 ++ stack.sh | 83 ++++++++++++++++++++++++++++++++++++++++++---- stackrc | 4 +++ 3 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 files/apts/quantum diff --git a/files/apts/quantum b/files/apts/quantum new file mode 100644 index 0000000..f5008ad --- /dev/null +++ b/files/apts/quantum @@ -0,0 +1,2 @@ +openvswitch-switch +openvswitch-datapath-dkms diff --git a/stack.sh b/stack.sh index e7f36e8..e7c383b 100755 --- a/stack.sh +++ b/stack.sh @@ -150,6 +150,10 @@ KEYSTONE_DIR=$DEST/keystone NOVACLIENT_DIR=$DEST/python-novaclient OPENSTACKX_DIR=$DEST/openstackx NOVNC_DIR=$DEST/noVNC +QUANTUM_DIR=$DEST/quantum + +# Default Quantum Plugin +Q_PLUGIN=${Q_PLUGIN:-openvswitch} # Specify which services to launch. These generally correspond to screen tabs ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit} @@ -244,6 +248,17 @@ FLAT_INTERFACE=${FLAT_INTERFACE:-eth0} ## FIXME(ja): should/can we check that FLAT_INTERFACE is sane? +# Using Quantum networking: +# +# Make sure that q-svc is enabled in ENABLED_SERVICES. If it is the network +# manager will be set to the QuantumManager. +# +# If you're planning to use the Quantum openvswitch plugin, set Q_PLUGIN to +# "openvswitch" and make sure the q-agt service is enabled in +# ENABLED_SERVICES. +# +# With Quantum networking the NET_MAN variable is ignored. + # MySQL & RabbitMQ # ---------------- @@ -362,6 +377,8 @@ git_clone $NOVACLIENT_REPO $NOVACLIENT_DIR $NOVACLIENT_BRANCH # openstackx is a collection of extensions to openstack.compute & nova # that is *deprecated*. The code is being moved into python-novaclient & nova. git_clone $OPENSTACKX_REPO $OPENSTACKX_DIR $OPENSTACKX_BRANCH +# quantum +git_clone $QUANTUM_REPO $QUANTUM_DIR $QUANTUM_BRANCH # Initialization # ============== @@ -376,6 +393,7 @@ cd $NOVA_DIR; sudo python setup.py develop cd $OPENSTACKX_DIR; sudo python setup.py develop cd $HORIZON_DIR/django-openstack; sudo python setup.py develop cd $HORIZON_DIR/openstack-dashboard; sudo python setup.py develop +cd $QUANTUM_DIR; sudo python setup.py develop # Add a useful screenrc. This isn't required to run openstack but is we do # it since we are going to run the services in screen for simple @@ -616,8 +634,16 @@ add_nova_flag "--nodaemon" add_nova_flag "--allow_admin_api" add_nova_flag "--scheduler_driver=$SCHEDULER" add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf" -add_nova_flag "--network_manager=nova.network.manager.$NET_MAN" add_nova_flag "--fixed_range=$FIXED_RANGE" +if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then + add_nova_flag "--network_manager=nova.network.quantum.manager.QuantumManager" + if [[ "$Q_PLUGIN" = "openvswitch" ]]; then + add_nova_flag "--libvirt_vif_type=ethernet" + add_nova_flag "--libvirt_vif_driver=nova.virt.libvirt.vif.LibvirtOpenVswitchDriver" + fi +else + add_nova_flag "--network_manager=nova.network.manager.$NET_MAN" +fi add_nova_flag "--my_ip=$HOST_IP" add_nova_flag "--public_interface=$PUBLIC_INTERFACE" add_nova_flag "--vlan_interface=$VLAN_INTERFACE" @@ -676,12 +702,6 @@ if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then # (re)create nova database $NOVA_DIR/bin/nova-manage db sync - - # create a small network - $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 $FIXED_NETWORK_SIZE - - # create some floating ips - $NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE fi @@ -764,6 +784,55 @@ if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then exit 1 fi fi + +# Quantum +if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then + # Create database for the plugin/agent + if [[ "$Q_PLUGIN" = "openvswitch" ]]; then + if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then + mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE IF NOT EXISTS ovs_quantum;' + else + echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin." + exit 1 + fi + fi + + QUANTUM_PLUGIN_INI_FILE=$QUANTUM_DIR/quantum/plugins.ini + # Make sure we're using the openvswitch plugin + sed -i -e "s/^provider =.*$/provider = quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPlugin/g" $QUANTUM_PLUGIN_INI_FILE + screen_it q-svc "cd $QUANTUM_DIR && export PYTHONPATH=.:$PYTHONPATH; python $QUANTUM_DIR/bin/quantum $QUANTUM_DIR/etc/quantum.conf" +fi + +# Quantum agent (for compute nodes) +if [[ "$ENABLED_SERVICES" =~ "q-agt" ]]; then + if [[ "$Q_PLUGIN" = "openvswitch" ]]; then + # Set up integration bridge + OVS_BRIDGE=${OVS_BRIDGE:-br-int} + sudo ovs-vsctl --no-wait -- --if-exists del-br $OVS_BRIDGE + sudo ovs-vsctl --no-wait add-br $OVS_BRIDGE + sudo ovs-vsctl --no-wait br-set-external-id $OVS_BRIDGE bridge-id br-int + fi + + # Start up the quantum <-> openvswitch agent + screen_it q-agt "sleep 4; sudo python $QUANTUM_DIR/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py $QUANTUM_DIR/quantum/plugins/openvswitch/ovs_quantum_plugin.ini -v" +fi + +# NOTE(bgh): I moved the network creation here because Quantum has to be up +# and running before we can communicate with it if we're using Quantum for +# networking (i.e. q-svc is enabled). + +if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then + # create a small network + $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 $FIXED_NETWORK_SIZE + + if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then + echo "Not creating floating IPs (not supported by QuantumManager)" + else + # create some floating ips + $NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE + fi +fi + # Launching nova-compute should be as simple as running ``nova-compute`` but # have to do a little more than that in our script. Since we add the group # ``libvirtd`` to our user in this script, when nova-compute is run it is diff --git a/stackrc b/stackrc index 9b110a3..75ec4aa 100644 --- a/stackrc +++ b/stackrc @@ -27,6 +27,10 @@ NOVACLIENT_BRANCH=master OPENSTACKX_REPO=https://github.com/cloudbuilders/openstackx.git OPENSTACKX_BRANCH=diablo +# quantum service +QUANTUM_REPO=https://github.com/openstack/quantum +QUANTUM_BRANCH=diablo + # Specify a comma-separated list of uec images to download and install into glance. IMAGE_URLS=http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-11.2_2.6.35-15_1.tar.gz From d9e544e5c37ac208b2fe8c468623b14ab57565ff Mon Sep 17 00:00:00 2001 From: Brad Hall Date: Fri, 28 Oct 2011 08:28:26 -0700 Subject: [PATCH 002/112] Add Quantum support: address code review comments (commit 1bfa3d53c1ee74525932b721c2dddd42fc129b8e) --- stack.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/stack.sh b/stack.sh index e7c383b..31194bc 100755 --- a/stack.sh +++ b/stack.sh @@ -792,8 +792,8 @@ if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE IF NOT EXISTS ovs_quantum;' else - echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin." - exit 1 + echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin." + exit 1 fi fi @@ -817,10 +817,8 @@ if [[ "$ENABLED_SERVICES" =~ "q-agt" ]]; then screen_it q-agt "sleep 4; sudo python $QUANTUM_DIR/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py $QUANTUM_DIR/quantum/plugins/openvswitch/ovs_quantum_plugin.ini -v" fi -# NOTE(bgh): I moved the network creation here because Quantum has to be up -# and running before we can communicate with it if we're using Quantum for -# networking (i.e. q-svc is enabled). - +# If we're using Quantum (i.e. q-svc is enabled), network creation has to +# happen after we've started the Quantum service. if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then # create a small network $NOVA_DIR/bin/nova-manage network create private $FIXED_RANGE 1 $FIXED_NETWORK_SIZE From f1f1dd961a51ba60a121a0ded75e6f465ba1675b Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 13:12:53 +0000 Subject: [PATCH 003/112] Update gitignore to ignore log files and localrc --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 22a7898..e482090 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ proto *~ +*.log +src localrc From 2567c81b27adc119046bb1cd9289307ea5edd22d Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Tue, 1 Nov 2011 12:36:59 -0500 Subject: [PATCH 004/112] Update for variable dist name --- tools/build_ramdisk.sh | 51 ++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/tools/build_ramdisk.sh b/tools/build_ramdisk.sh index 43f8999..e57aa03 100755 --- a/tools/build_ramdisk.sh +++ b/tools/build_ramdisk.sh @@ -1,25 +1,42 @@ #!/bin/bash # build_ramdisk.sh - Build RAM disk images +# exit on error to stop unexpected errors +set -o errexit + if [ ! "$#" -eq "1" ]; then - echo "$0 builds a gziped natty openstack install" + echo "$0 builds a gziped Ubuntu OpenStack install" echo "usage: $0 dest" exit 1 fi +# Echo commands +set -o xtrace + IMG_FILE=$1 -PROGDIR=`dirname $0` -CHROOTCACHE=${CHROOTCACHE:-/var/cache/devstack} - -# Source params -source ./stackrc +# Keep track of the current directory +TOOLS_DIR=$(cd $(dirname "$0") && pwd) +TOP_DIR=`cd $TOOLS_DIR/..; pwd` # Store cwd CWD=`pwd` +cd $TOP_DIR + +# Source params +source ./stackrc + +CACHEDIR=${CACHEDIR:-/var/cache/devstack} + DEST=${DEST:-/opt/stack} +# Configure the root password of the vm to be the same as ``ADMIN_PASSWORD`` +ROOT_PASSWORD=${ADMIN_PASSWORD:-password} + +# Base image (natty by default) +DIST_NAME=${DIST_NAME:-natty} + # Param string to pass to stack.sh. Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova" STACKSH_PARAMS=${STACKSH_PARAMS:-} @@ -31,21 +48,21 @@ modprobe nbd max_part=63 NBD=${NBD:-/dev/nbd9} NBD_DEV=`basename $NBD` -# clean install of natty -if [ ! -r $CHROOTCACHE/natty-base.img ]; then - $PROGDIR/get_uec_image.sh natty $CHROOTCACHE/natty-base.img +# clean install +if [ ! -r $CACHEDIR/$DIST_NAME-base.img ]; then + $TOOLS_DIR/get_uec_image.sh $DIST_NAME $CACHEDIR/$DIST_NAME-base.img # # copy kernel modules... # # NOTE(ja): is there a better way to do this? -# cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules +# cp -pr /lib/modules/`uname -r` $CACHEDIR/$DIST_NAME-base/lib/modules # # a simple password - pass -# echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd +# echo root:pass | chroot $CACHEDIR/$DIST_NAME-base chpasswd fi -# prime natty with as many apt/pips as we can -if [ ! -r $CHROOTCACHE/natty-dev.img ]; then - cp -p $CHROOTCACHE/natty-base.img $CHROOTCACHE/natty-dev.img +# prime image with as many apt/pips as we can +if [ ! -r $CACHEDIR/$DIST_NAME-dev.img ]; then + cp -p $CACHEDIR/$DIST_NAME-base.img $CACHEDIR/$DIST_NAME-dev.img - qemu-nbd -c $NBD $CHROOTCACHE/natty-dev.img + qemu-nbd -c $NBD $CACHEDIR/$DIST_NAME-dev.img if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then echo "Couldn't connect $NBD" exit 1 @@ -65,7 +82,7 @@ if [ ! -r $CHROOTCACHE/natty-dev.img ]; then chroot $MNTDIR chown stack $DEST # a simple password - pass - echo stack:pass | chroot $MNTDIR chpasswd + echo stack:$ROOT_PASSWORD | chroot $MNTDIR chpasswd # and has sudo ability (in the future this should be limited to only what # stack requires) @@ -80,7 +97,7 @@ fi # ====================================== if [ ! -r $IMG_FILE ]; then - qemu-nbd -c $NBD $CHROOTCACHE/natty-dev.img + qemu-nbd -c $NBD $CACHEDIR/$DIST_NAME-dev.img if ! timeout 60 sh -c "while ! [ -e ${NBD}p1 ]; do sleep 1; done"; then echo "Couldn't connect $NBD" exit 1 From dccd6b923e3308387464721a717229a0a81b0252 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Tue, 1 Nov 2011 15:46:14 -0500 Subject: [PATCH 005/112] Add map_nbd function --- tools/build_libvirt.sh | 41 +++++++++++++++---------- tools/build_ramdisk.sh | 68 ++++++++++++++++++++++++++---------------- tools/get_uec_image.sh | 42 +++++++++++++++----------- 3 files changed, 93 insertions(+), 58 deletions(-) diff --git a/tools/build_libvirt.sh b/tools/build_libvirt.sh index 5ae8fda..16259b1 100755 --- a/tools/build_libvirt.sh +++ b/tools/build_libvirt.sh @@ -239,26 +239,35 @@ rm -f $VM_DIR/disk # Create our instance fs qemu-img create -f qcow2 -b $VM_IMAGE disk +# Finds the next available NBD device +# Exits script if error connecting or none free +# map_nbd image +# returns full nbd device path +function map_nbd { + for i in `seq 0 15`; do + if [ ! -e /sys/block/nbd$i/pid ]; then + NBD=/dev/nbd$i + # Connect to nbd and wait till it is ready + qemu-nbd -c $NBD $1 + if ! timeout 60 sh -c "while ! [ -e ${NBD}p1 ]; do sleep 1; done"; then + echo "Couldn't connect $NBD" + exit 1 + fi + break + fi + done + if [ -z "$NBD" ]; then + echo "No free NBD slots" + exit 1 + fi + echo $NBD +} + # Make sure we have nbd-ness modprobe nbd max_part=63 # Set up nbd -for i in `seq 0 15`; do - if [ ! -e /sys/block/nbd$i/pid ]; then - NBD=/dev/nbd$i - # Connect to nbd and wait till it is ready - qemu-nbd -c $NBD disk - if ! timeout 60 sh -c "while ! [ -e ${NBD}p1 ]; do sleep 1; done"; then - echo "Couldn't connect $NBD" - exit 1 - fi - break - fi -done -if [ -z "$NBD" ]; then - echo "No free NBD slots" - exit 1 -fi +NBD=`map_nbd disk` NBD_DEV=`basename $NBD` # Mount the instance diff --git a/tools/build_ramdisk.sh b/tools/build_ramdisk.sh index e57aa03..06e5857 100755 --- a/tools/build_ramdisk.sh +++ b/tools/build_ramdisk.sh @@ -10,6 +10,9 @@ if [ ! "$#" -eq "1" ]; then exit 1 fi +# Set up nbd +modprobe nbd max_part=63 + # Echo commands set -o xtrace @@ -43,30 +46,42 @@ STACKSH_PARAMS=${STACKSH_PARAMS:-} # Option to use the version of devstack on which we are currently working USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1} -# Set up nbd -modprobe nbd max_part=63 -NBD=${NBD:-/dev/nbd9} -NBD_DEV=`basename $NBD` - # clean install if [ ! -r $CACHEDIR/$DIST_NAME-base.img ]; then $TOOLS_DIR/get_uec_image.sh $DIST_NAME $CACHEDIR/$DIST_NAME-base.img -# # copy kernel modules... -# # NOTE(ja): is there a better way to do this? -# cp -pr /lib/modules/`uname -r` $CACHEDIR/$DIST_NAME-base/lib/modules -# # a simple password - pass -# echo root:pass | chroot $CACHEDIR/$DIST_NAME-base chpasswd fi -# prime image with as many apt/pips as we can -if [ ! -r $CACHEDIR/$DIST_NAME-dev.img ]; then - cp -p $CACHEDIR/$DIST_NAME-base.img $CACHEDIR/$DIST_NAME-dev.img - - qemu-nbd -c $NBD $CACHEDIR/$DIST_NAME-dev.img - if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then - echo "Couldn't connect $NBD" +# Finds the next available NBD device +# Exits script if error connecting or none free +# map_nbd image +# returns full nbd device path +function map_nbd { + for i in `seq 0 15`; do + if [ ! -e /sys/block/nbd$i/pid ]; then + NBD=/dev/nbd$i + # Connect to nbd and wait till it is ready + qemu-nbd -c $NBD $1 + if ! timeout 60 sh -c "while ! [ -e ${NBD}p1 ]; do sleep 1; done"; then + echo "Couldn't connect $NBD" + exit 1 + fi + break + fi + done + if [ -z "$NBD" ]; then + echo "No free NBD slots" exit 1 fi + echo $NBD +} + +# prime image with as many apt/pips as we can +DEV_FILE=$CACHEDIR/$DIST_NAME-dev.img +DEV_FILE_TMP=`mktemp $DEV_FILE.XXXXXX` +if [ ! -r $DEV_FILE ]; then + cp -p $CACHEDIR/$DIST_NAME-base.img $DEV_FILE_TMP + + NBD=`map_nbd $DEV_FILE_TMP` MNTDIR=`mktemp -d --tmpdir mntXXXXXXXX` mount -t ext4 ${NBD}p1 $MNTDIR cp -p /etc/resolv.conf $MNTDIR/etc/resolv.conf @@ -82,7 +97,8 @@ if [ ! -r $CACHEDIR/$DIST_NAME-dev.img ]; then chroot $MNTDIR chown stack $DEST # a simple password - pass - echo stack:$ROOT_PASSWORD | chroot $MNTDIR chpasswd + echo stack:pass | chroot $MNTDIR chpasswd + echo root:$ROOT_PASSWORD | chroot $MNTDIR chpasswd # and has sudo ability (in the future this should be limited to only what # stack requires) @@ -91,27 +107,29 @@ if [ ! -r $CACHEDIR/$DIST_NAME-dev.img ]; then umount $MNTDIR rmdir $MNTDIR qemu-nbd -d $NBD + mv $DEV_FILE_TMP $DEV_FILE fi +rm -f $DEV_FILE_TMP # clone git repositories onto the system # ====================================== +IMG_FILE_TMP=`mktemp $IMG_FILE.XXXXXX` + if [ ! -r $IMG_FILE ]; then - qemu-nbd -c $NBD $CACHEDIR/$DIST_NAME-dev.img - if ! timeout 60 sh -c "while ! [ -e ${NBD}p1 ]; do sleep 1; done"; then - echo "Couldn't connect $NBD" - exit 1 - fi + NBD=`map_nbd $DEV_FILE` # Pre-create the image file # FIXME(dt): This should really get the partition size to # pre-create the image file - dd if=/dev/zero of=$IMG_FILE bs=1 count=1 seek=$((2*1024*1024*1024)) + dd if=/dev/zero of=$IMG_FILE_TMP bs=1 count=1 seek=$((2*1024*1024*1024)) # Create filesystem image for RAM disk - dd if=${NBD}p1 of=$IMG_FILE bs=1M + dd if=${NBD}p1 of=$IMG_FILE_TMP bs=1M qemu-nbd -d $NBD + mv $IMG_FILE_TMP $IMG_FILE fi +rm -f $IMG_FILE_TMP MNTDIR=`mktemp -d --tmpdir mntXXXXXXXX` mount -t ext4 -o loop $IMG_FILE $MNTDIR diff --git a/tools/get_uec_image.sh b/tools/get_uec_image.sh index 935feba..de37842 100755 --- a/tools/get_uec_image.sh +++ b/tools/get_uec_image.sh @@ -111,25 +111,33 @@ if [ $ROOTSIZE -gt 2000 ]; then qemu-img resize $IMG_FILE_TMP +$((ROOTSIZE - 2000))M fi +# Finds the next available NBD device +# Exits script if error connecting or none free +# map_nbd image +# returns full nbd device path +function map_nbd { + for i in `seq 0 15`; do + if [ ! -e /sys/block/nbd$i/pid ]; then + NBD=/dev/nbd$i + # Connect to nbd and wait till it is ready + qemu-nbd -c $NBD $1 + if ! timeout 60 sh -c "while ! [ -e ${NBD}p1 ]; do sleep 1; done"; then + echo "Couldn't connect $NBD" + exit 1 + fi + break + fi + done + if [ -z "$NBD" ]; then + echo "No free NBD slots" + exit 1 + fi + echo $NBD +} + # Set up nbd modprobe nbd max_part=63 -for i in `seq 1 15`; do - if [ ! -e /sys/block/nbd$i/pid ]; then - NBD=/dev/nbd$i - # Connect to nbd and wait till it is ready - qemu-nbd -c $NBD $IMG_FILE_TMP - if ! timeout 60 sh -c "while ! [ -e ${NBD}p1 ]; do sleep 1; done"; then - echo "Couldn't connect $NBD" - exit 1 - fi - break - fi -done -if [ -z "$NBD" ]; then - echo "No free NBD slots" - exit 1 -fi -NBD_DEV=`basename $NBD` +NBD=`map_nbd $IMG_FILE_TMP` # Resize partition 1 to full size of the disk image echo "d From 55c027372326380c3f29ed4dcd6a0b498c52a4dd Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Tue, 1 Nov 2011 17:44:03 -0500 Subject: [PATCH 006/112] Trap SIGINT, etc and release used resources --- tools/build_libvirt.sh | 26 +++++++++++++++++++++++--- tools/build_pxe_boot.sh | 16 ++++++++++++++++ tools/build_ramdisk.sh | 29 +++++++++++++++++++++++++++++ tools/build_usb_boot.sh | 20 ++++++++++++++++++++ tools/get_uec_image.sh | 21 +++++++++++++++++++++ 5 files changed, 109 insertions(+), 3 deletions(-) diff --git a/tools/build_libvirt.sh b/tools/build_libvirt.sh index 16259b1..48e2853 100755 --- a/tools/build_libvirt.sh +++ b/tools/build_libvirt.sh @@ -12,6 +12,27 @@ if [ ! "oneiric" = "$UBUNTU_VERSION" ]; then fi fi +# Clean up any resources that may be in use +cleanup() { + set +o errexit + unmount_images + + if [ -n "$ROOTFS" ]; then + umount $ROOTFS/dev + umount $ROOTFS + fi + + # Release NBD devices + if [ -n "$NBD" ]; then + qemu-nbd -d $NBD + fi + + # Kill ourselves to signal any calling process + trap 2; kill -2 $$ +} + +trap cleanup SIGHUP SIGINT SIGTERM + # Echo commands set -o xtrace @@ -100,9 +121,6 @@ function kill_unmount() { # Install deps if needed dpkg -l kvm libvirt-bin kpartx || apt-get install -y --force-yes kvm libvirt-bin kpartx -# Let Ctrl-c kill tail and exit -trap kill_unmount SIGINT - # Where Openstack code will live in image DEST=${DEST:-/opt/stack} @@ -390,7 +408,9 @@ sed -e 's/^PasswordAuthentication.*$/PasswordAuthentication yes/' -i $ROOTFS/etc # Unmount umount $ROOTFS || echo 'ok' +ROOTFS="" qemu-nbd -d $NBD +NBD="" # Create the instance cd $VM_DIR && virsh create libvirt.xml diff --git a/tools/build_pxe_boot.sh b/tools/build_pxe_boot.sh index da8bbcc..ab64098 100755 --- a/tools/build_pxe_boot.sh +++ b/tools/build_pxe_boot.sh @@ -11,6 +11,22 @@ PXEDIR=${PXEDIR:-/var/cache/devstack/pxe} OPWD=`pwd` PROGDIR=`dirname $0` +# Clean up any resources that may be in use +cleanup() { + set +o errexit + + # Mop up temporary files + if [ -n "$MNTDIR" -a -d "$MNTDIR" ]; then + umount $MNTDIR + rmdir $MNTDIR + fi + + # Kill ourselves to signal any calling process + trap 2; kill -2 $$ +} + +trap cleanup SIGHUP SIGINT SIGTERM + mkdir -p $DEST_DIR/pxelinux.cfg cd $DEST_DIR for i in memdisk menu.c32 pxelinux.0; do diff --git a/tools/build_ramdisk.sh b/tools/build_ramdisk.sh index 06e5857..187112a 100755 --- a/tools/build_ramdisk.sh +++ b/tools/build_ramdisk.sh @@ -10,6 +10,33 @@ if [ ! "$#" -eq "1" ]; then exit 1 fi +# Clean up any resources that may be in use +cleanup() { + set +o errexit + + # Mop up temporary files + if [ -n "$MNTDIR" -a -d "$MNTDIR" ]; then + umount $MNTDIR + rmdir $MNTDIR + fi + if [ -n "$DEV_FILE_TMP" -a -e "$DEV_FILE_TMP "]; then + rm -f $DEV_FILE_TMP + fi + if [ -n "$IMG_FILE_TMP" -a -e "$IMG_FILE_TMP" ]; then + rm -f $IMG_FILE_TMP + fi + + # Release NBD devices + if [ -n "$NBD" ]; then + qemu-nbd -d $NBD + fi + + # Kill ourselves to signal any calling process + trap 2; kill -2 $$ +} + +trap cleanup SIGHUP SIGINT SIGTERM + # Set up nbd modprobe nbd max_part=63 @@ -107,6 +134,7 @@ if [ ! -r $DEV_FILE ]; then umount $MNTDIR rmdir $MNTDIR qemu-nbd -d $NBD + NBD="" mv $DEV_FILE_TMP $DEV_FILE fi rm -f $DEV_FILE_TMP @@ -127,6 +155,7 @@ if [ ! -r $IMG_FILE ]; then dd if=${NBD}p1 of=$IMG_FILE_TMP bs=1M qemu-nbd -d $NBD + NBD="" mv $IMG_FILE_TMP $IMG_FILE fi rm -f $IMG_FILE_TMP diff --git a/tools/build_usb_boot.sh b/tools/build_usb_boot.sh index fc5e969..e4dabc0 100755 --- a/tools/build_usb_boot.sh +++ b/tools/build_usb_boot.sh @@ -11,6 +11,26 @@ PXEDIR=${PXEDIR:-/var/cache/devstack/pxe} OPWD=`pwd` PROGDIR=`dirname $0` +# Clean up any resources that may be in use +cleanup() { + set +o errexit + + # Mop up temporary files + if [ -n "$DEST_DEV" ]; then + umount $DEST_DIR + rmdir $DEST_DIR + fi + if [ -n "$MNTDIR" -a -d "$MNTDIR" ]; then + umount $MNTDIR + rmdir $MNTDIR + fi + + # Kill ourselves to signal any calling process + trap 2; kill -2 $$ +} + +trap cleanup SIGHUP SIGINT SIGTERM + if [ -b $DEST_DIR ]; then # We have a block device, install syslinux and mount it DEST_DEV=$DEST_DIR diff --git a/tools/get_uec_image.sh b/tools/get_uec_image.sh index de37842..3d62bba 100755 --- a/tools/get_uec_image.sh +++ b/tools/get_uec_image.sh @@ -26,6 +26,24 @@ usage() { exit 1 } +# Clean up any resources that may be in use +cleanup() { + set +o errexit + + # Mop up temporary files + if [ -n "$IMG_FILE_TMP" -a -e "$IMG_FILE_TMP" ]; then + rm -f $IMG_FILE_TMP + fi + + # Release NBD devices + if [ -n "$NBD" ]; then + qemu-nbd -d $NBD + fi + + # Kill ourselves to signal any calling process + trap 2; kill -2 $$ +} + while getopts f:hmr: c; do case $c in f) FORMAT=$OPTARG @@ -89,6 +107,8 @@ case $DIST_NAME in ;; esac +trap cleanup SIGHUP SIGINT SIGTERM + # Prepare the base image # Get the UEC image @@ -170,5 +190,6 @@ rm -f $MNTDIR/etc/resolv.conf umount $MNTDIR rmdir $MNTDIR qemu-nbd -d $NBD +NBD="" mv $IMG_FILE_TMP $IMG_FILE From de8b9a2340437220a45a5f1181a23576d12a37bb Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Tue, 1 Nov 2011 17:23:04 -0700 Subject: [PATCH 007/112] change screen name to stack - addresses issue #139 --- stack.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stack.sh b/stack.sh index 9466512..c7edb11 100755 --- a/stack.sh +++ b/stack.sh @@ -721,13 +721,13 @@ fi function screen_it { NL=`echo -ne '\015'` if [[ "$ENABLED_SERVICES" =~ "$1" ]]; then - screen -S nova -X screen -t $1 - screen -S nova -p $1 -X stuff "$2$NL" + screen -S stack -X screen -t $1 + screen -S stack -p $1 -X stuff "$2$NL" fi } # create a new named screen to run processes in -screen -d -m -S nova -t nova +screen -d -m -S stack -t stack sleep 1 # launch the glance registery service From 1d1dda14572576a3242f113bc0d3a8c5f09b14fa Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Tue, 1 Nov 2011 19:46:17 -0700 Subject: [PATCH 008/112] allow build_libvirt.sh not to destroy/recreate net --- tools/build_libvirt.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/build_libvirt.sh b/tools/build_libvirt.sh index 48e2853..fc281d3 100755 --- a/tools/build_libvirt.sh +++ b/tools/build_libvirt.sh @@ -174,6 +174,7 @@ unmount_images # Network configuration variables GUEST_NETWORK=${GUEST_NETWORK:-1} +GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes} GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50} GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24} @@ -194,8 +195,10 @@ cat > $NET_XML < EOF -virsh net-destroy devstack-$GUEST_NETWORK || true -virsh net-create $VM_DIR/net.xml +if [[ "$GUEST_RECREATE_NET" == "yes" ]]; then + virsh net-destroy devstack-$GUEST_NETWORK || true + virsh net-create $VM_DIR/net.xml +fi # libvirt.xml configuration LIBVIRT_XML=$VM_DIR/libvirt.xml From e19d88478949bc31c7d2d224722655992414910a Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Tue, 1 Nov 2011 20:06:55 -0700 Subject: [PATCH 009/112] add some spacing to the output --- stack.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stack.sh b/stack.sh index 9466512..e7f36e8 100755 --- a/stack.sh +++ b/stack.sh @@ -843,6 +843,10 @@ for ret in "${PIPESTATUS[@]}"; do [ $ret -eq 0 ] || exit $ret; done # Using the cloud # =============== +echo "" +echo "" +echo "" + # If you installed the horizon on this server, then you should be able # to access the site using your browser. if [[ "$ENABLED_SERVICES" =~ "horizon" ]]; then From f1b3dbc41a294ccfc25042ea106a10f8ae6c3457 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Tue, 1 Nov 2011 21:52:07 -0700 Subject: [PATCH 010/112] install arping - used in ha network --- files/apts/nova | 1 + 1 file changed, 1 insertion(+) diff --git a/files/apts/nova b/files/apts/nova index 8ae74a2..17eb877 100644 --- a/files/apts/nova +++ b/files/apts/nova @@ -1,6 +1,7 @@ dnsmasq-base kpartx parted +arping # used for send_arp_for_ha option in nova-network mysql-server python-mysqldb kvm From 4bd41ad77f9bc26b64a3a4362f787f5c9814f29a Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Tue, 1 Nov 2011 22:06:21 -0700 Subject: [PATCH 011/112] deleting build_kvm.sh in favor of build_libvirt.sh --- tools/build_kvm.sh | 402 --------------------------------------------- 1 file changed, 402 deletions(-) delete mode 100755 tools/build_kvm.sh diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh deleted file mode 100755 index 1b33926..0000000 --- a/tools/build_kvm.sh +++ /dev/null @@ -1,402 +0,0 @@ -#!/usr/bin/env bash - -# exit on error to stop unexpected errors -set -o errexit - -# Make sure that we have the proper version of ubuntu -UBUNTU_VERSION=`cat /etc/lsb-release | grep CODENAME | sed 's/.*=//g'` -if [ ! "oneiric" = "$UBUNTU_VERSION" ]; then - if [ ! "natty" = "$UBUNTU_VERSION" ]; then - echo "This script only works with oneiric and natty" - exit 1 - fi -fi - -# Echo commands -set -o xtrace - -# Keep track of the current directory -TOOLS_DIR=$(cd $(dirname "$0") && pwd) -TOP_DIR=$TOOLS_DIR/.. - -# Where to store files and instances -KVMSTACK_DIR=${KVMSTACK_DIR:-/opt/kvmstack} - -# Where to store images -IMAGES_DIR=$KVMSTACK_DIR/images - -# Create images dir -mkdir -p $IMAGES_DIR - -# Move to top devstack dir -cd $TOP_DIR - -# Abort if localrc is not set -if [ ! -e ./localrc ]; then - echo "You must have a localrc with ALL necessary passwords defined before proceeding." - echo "See stack.sh for required passwords." - exit 1 -fi - -# Source params -source ./stackrc - -# Configure the root password of the vm to be the same as ``ADMIN_PASSWORD`` -ROOT_PASSWORD=${ADMIN_PASSWORD:-password} - - -# Base image (natty by default) -DIST_NAME=${DIST_NAME:-natty} -IMAGE_FNAME=$DIST_NAME.raw - -# Name of our instance, used by libvirt -GUEST_NAME=${GUEST_NAME:-kvmstack} - -# Original version of built image -BASE_IMAGE=$KVMSTACK_DIR/images/$DIST_NAME.raw - -# Copy of base image, which we pre-install with tasty treats -VM_IMAGE=$IMAGES_DIR/$DIST_NAME.$GUEST_NAME.raw - -# Mop up after previous runs -virsh destroy $GUEST_NAME || true - -# Where this vm is stored -VM_DIR=$KVMSTACK_DIR/instances/$GUEST_NAME - -# Create vm dir -mkdir -p $VM_DIR - -# Mount point into copied base image -COPY_DIR=$VM_DIR/copy -mkdir -p $COPY_DIR - -# Create the base image if it does not yet exist -if [ ! -e $IMAGES_DIR/$IMAGE_FNAME ]; then - cd $TOOLS_DIR - ./make_image.sh -m -r 5000 $DIST_NAME raw - mv $DIST_NAME.raw $BASE_IMAGE - cd $TOP_DIR -fi - -# Create a copy of the base image -if [ ! -e $VM_IMAGE ]; then - cp -p $BASE_IMAGE $VM_IMAGE -fi - -# Unmount the copied base image -function unmount_images() { - # unmount the filesystem - while df | grep -q $COPY_DIR; do - umount $COPY_DIR || echo 'ok' - sleep 1 - done -} - -# Unmount from failed runs -unmount_images - -# Ctrl-c catcher -function kill_unmount() { - unmount_images - exit 1 -} - -# Install deps if needed -dpkg -l kvm libvirt-bin kpartx || apt-get install -y --force-yes kvm libvirt-bin kpartx - -# Let Ctrl-c kill tail and exit -trap kill_unmount SIGINT - -# Where Openstack code will live in image -DEST=${DEST:-/opt/stack} - -# Mount the file system -mount -o loop,offset=32256 $VM_IMAGE $COPY_DIR - -# git clone only if directory doesn't exist already. Since ``DEST`` might not -# be owned by the installation user, we create the directory and change the -# ownership to the proper user. -function git_clone { - if [ ! -d $2 ]; then - sudo mkdir $2 - sudo chown `whoami` $2 - git clone $1 $2 - cd $2 - # This checkout syntax works for both branches and tags - git checkout $3 - fi -} - -# Make sure that base requirements are installed -cp /etc/resolv.conf $COPY_DIR/etc/resolv.conf -chroot $COPY_DIR apt-get update -chroot $COPY_DIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` -chroot $COPY_DIR apt-get install -y --download-only rabbitmq-server libvirt-bin mysql-server -chroot $COPY_DIR pip install `cat files/pips/*` - -# Clean out code repos if directed to do so -if [ "$CLEAN" = "1" ]; then - rm -rf $COPY_DIR/$DEST -fi - -# Cache openstack code -mkdir -p $COPY_DIR/$DEST -git_clone $NOVA_REPO $COPY_DIR/$DEST/nova $NOVA_BRANCH -git_clone $GLANCE_REPO $COPY_DIR/$DEST/glance $GLANCE_BRANCH -git_clone $KEYSTONE_REPO $COPY_DIR/$DESTkeystone $KEYSTONE_BRANCH -git_clone $NOVNC_REPO $COPY_DIR/$DEST/noVNC $NOVNC_BRANCH -git_clone $HORIZON_REPO $COPY_DIR/$DEST/horizon $HORIZON_BRANCH $HORIZON_TAG -git_clone $NOVACLIENT_REPO $COPY_DIR/$DEST/python-novaclient $NOVACLIENT_BRANCH -git_clone $OPENSTACKX_REPO $COPY_DIR/$DEST/openstackx $OPENSTACKX_BRANCH -git_clone $KEYSTONE_REPO $COPY_DIR/$DEST/keystone $KEYSTONE_BRANCH -git_clone $NOVNC_REPO $COPY_DIR/$DEST/noVNC $NOVNC_BRANCH - -# Back to devstack -cd $TOP_DIR - -# Unmount the filesystems -unmount_images - -# Network configuration variables -BRIDGE=${BRIDGE:-br0} -GUEST_IP=${GUEST_IP:-192.168.1.50} -GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24} -GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0} -GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.1.1} -GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $(echo $GUEST_IP | sed "s/.*\.//")`"} -GUEST_RAM=${GUEST_RAM:-1524288} -GUEST_CORES=${GUEST_CORES:-1} - -# libvirt.xml configuration -LIBVIRT_XML=$VM_DIR/libvirt.xml -cat > $LIBVIRT_XML < - $GUEST_NAME - $GUEST_RAM - - hvm - - - - - - $GUEST_CORES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -EOF - -# Mount point for instance fs -ROOTFS=$VM_DIR/root -mkdir -p $ROOTFS - -# Make sure we have nbd-ness -modprobe nbd max_part=63 - -# Which NBD device to use? -NBD=${NBD:-/dev/nbd5} - -# Clean up from previous runs -umount $ROOTFS || echo 'ok' -qemu-nbd -d $NBD || echo 'ok' - -# Clean up old runs -cd $VM_DIR -rm -f $VM_DIR/disk - -# Create our instance fs -qemu-img create -f qcow2 -b $VM_IMAGE disk - -# Connect our nbd and wait till it is mountable -qemu-nbd -c $NBD disk -NBD_DEV=`basename $NBD` -if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then - echo "Couldn't connect $NBD" - exit 1 -fi - -# Mount the instance -mount $NBD $ROOTFS -o offset=32256 -t ext4 - -# Configure instance network -INTERFACES=$ROOTFS/etc/network/interfaces -cat > $INTERFACES <> $ROOTFS/etc/sudoers - -# Gracefully cp only if source file/dir exists -function cp_it { - if [ -e $1 ] || [ -d $1 ]; then - cp -pRL $1 $2 - fi -} - -# Copy over your ssh keys and env if desired -COPYENV=${COPYENV:-1} -if [ "$COPYENV" = "1" ]; then - cp_it ~/.ssh $ROOTFS/$DEST/.ssh - cp_it ~/.ssh/id_rsa.pub $ROOTFS/$DEST/.ssh/authorized_keys - cp_it ~/.gitconfig $ROOTFS/$DEST/.gitconfig - cp_it ~/.vimrc $ROOTFS/$DEST/.vimrc - cp_it ~/.bashrc $ROOTFS/$DEST/.bashrc -fi - -# pre-cache uec images -for image_url in ${IMAGE_URLS//,/ }; do - IMAGE_FNAME=`basename "$image_url"` - if [ ! -f $IMAGES_DIR/$IMAGE_FNAME ]; then - wget -c $image_url -O $IMAGES_DIR/$IMAGE_FNAME - fi - cp $IMAGES_DIR/$IMAGE_FNAME $ROOTFS/$DEST/devstack/files -done - -# Configure the runner -RUN_SH=$ROOTFS/$DEST/run.sh -cat > $RUN_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 -cat $DEST/run.sh.log -EOF -chmod 755 $RUN_SH - -# Make runner launch on boot -RC_LOCAL=$ROOTFS/etc/init.d/local -cat > $RC_LOCAL <> $ROOTFS/$DEST/.bashrc -echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $ROOTFS/etc/profile - -# Give stack ownership over $DEST so it may do the work needed -chroot $ROOTFS chown -R stack $DEST - -# Change boot params so that we get a console log -sudo sed -e "s/quiet splash/splash console=ttyS0 console=ttyS1,19200n8/g" -i $ROOTFS/boot/grub/menu.lst -sudo sed -e "s/^hiddenmenu//g" -i $ROOTFS/boot/grub/menu.lst - -# Set the hostname -echo $GUEST_NAME > $ROOTFS/etc/hostname - -# We need the hostname to resolve for rabbit to launch -if ! grep -q $GUEST_NAME $ROOTFS/etc/hosts; then - echo "$GUEST_IP $GUEST_NAME" >> $ROOTFS/etc/hosts -fi - -# Unmount -umount $ROOTFS || echo 'ok' -qemu-nbd -d $NBD - -# Create the instance -cd $VM_DIR && virsh create libvirt.xml - -# Tail the console log till we are done -WAIT_TILL_LAUNCH=${WAIT_TILL_LAUNCH:-1} -if [ "$WAIT_TILL_LAUNCH" = "1" ]; then - # Done creating the container, let's tail the log - echo - echo "=============================================================" - echo " -- YAY! --" - echo "=============================================================" - echo - echo "We're done launching the vm, about to start tailing the" - echo "stack.sh log. It will take a second or two to start." - echo - echo "Just CTRL-C at any time to stop tailing." - - while [ ! -e "$VM_DIR/console.log" ]; do - sleep 1 - done - - tail -F $VM_DIR/console.log & - - TAIL_PID=$! - - function kill_tail() { - kill $TAIL_PID - exit 1 - } - - # Let Ctrl-c kill tail and exit - trap kill_tail SIGINT - - echo "Waiting stack.sh to finish..." - while ! cat $VM_DIR/console.log | grep -q 'All done' ; do - sleep 5 - done - - kill $TAIL_PID - - if grep -q "stack.sh failed" $VM_DIR/console.log; then - exit 1 - fi - echo "" - echo "Finished - Zip-a-dee Doo-dah!" -fi From 2cec3dc846e5202c2cdf0f3f829a588392514d74 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 2 Nov 2011 07:03:38 -0500 Subject: [PATCH 012/112] unpause paused instances before terminating --- tools/xen/build_domU.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/xen/build_domU.sh b/tools/xen/build_domU.sh index 8e40225..c7bb3d1 100755 --- a/tools/xen/build_domU.sh +++ b/tools/xen/build_domU.sh @@ -229,6 +229,7 @@ xe vm-list --minimal name-label="$LABEL" | xargs ./scripts/uninstall-os-vpx.sh # Destroy any instances that were launched for uuid in `xe vm-list | grep -1 instance | grep uuid | sed "s/.*\: //g"`; do echo "Shutting down nova instance $uuid" + xe vm-unpause uuid=$uuid || true xe vm-shutdown uuid=$uuid xe vm-destroy uuid=$uuid done From af6ed6b1b5966aa468798584f81334510fb128a2 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 2 Nov 2011 07:50:27 -0500 Subject: [PATCH 013/112] source stackrc --- tools/xen/build_domU.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/xen/build_domU.sh b/tools/xen/build_domU.sh index c7bb3d1..65049af 100755 --- a/tools/xen/build_domU.sh +++ b/tools/xen/build_domU.sh @@ -7,6 +7,12 @@ if [ ! -e ../../localrc ]; then exit 1 fi +# This directory +TOP_DIR=$(cd $(dirname "$0") && pwd) + +# Source params +cd ../.. && source ./stackrc && cd $TOP_DIR + # Echo commands set -o xtrace @@ -41,9 +47,6 @@ GUEST_PASSWORD=${GUEST_PASSWORD:-secrete} # Size of image VDI_MB=${VDI_MB:-2500} -# This directory -TOP_DIR=$(cd $(dirname "$0") && pwd) - # Make sure we have git if ! which git; then GITDIR=/tmp/git-1.7.7 From 28fa4e8d940cb8a7a3d5fcb932a7552ad5f1c90c Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 12:30:55 +0100 Subject: [PATCH 014/112] Add swift support. Based on github.sh/cloudbuilders/deploy.sh/swift. This is a WIP branch. --- files/apts/swift | 19 +++++++ files/swift-account-server.conf | 19 +++++++ files/swift-container-server.conf | 21 ++++++++ files/swift-object-server.conf | 19 +++++++ files/swift-proxy-server.conf | 25 ++++++++++ files/swift-rsyncd.conf | 79 +++++++++++++++++++++++++++++ files/swift.conf | 3 ++ stack.sh | 83 ++++++++++++++++++++++++++++++- stackrc | 4 ++ 9 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 files/apts/swift create mode 100644 files/swift-account-server.conf create mode 100644 files/swift-container-server.conf create mode 100644 files/swift-object-server.conf create mode 100644 files/swift-proxy-server.conf create mode 100644 files/swift-rsyncd.conf create mode 100644 files/swift.conf diff --git a/files/apts/swift b/files/apts/swift new file mode 100644 index 0000000..0776707 --- /dev/null +++ b/files/apts/swift @@ -0,0 +1,19 @@ +curl +gcc +memcached +memcached +python-configobj +python-coverage +python-dev +python-eventlet +python-greenlet +python-netifaces +python-nose +python-nose +python-pastedeploy +python-setuptools +python-simplejson +python-webob +python-xattr +sqlite3 +xfsprogs diff --git a/files/swift-account-server.conf b/files/swift-account-server.conf new file mode 100644 index 0000000..b5451c6 --- /dev/null +++ b/files/swift-account-server.conf @@ -0,0 +1,19 @@ +[DEFAULT] +devices = %NODE_PATH%/node +mount_check = false +bind_port = %BIND_PORT% +user = stack +log_facility = LOG_LOCAL%LOG_FACILITY% + +[pipeline:main] +pipeline = account-server + +[app:account-server] +use = egg:swift#account + +[account-replicator] +vm_test_mode = yes + +[account-auditor] + +[account-reaper] diff --git a/files/swift-container-server.conf b/files/swift-container-server.conf new file mode 100644 index 0000000..c630076 --- /dev/null +++ b/files/swift-container-server.conf @@ -0,0 +1,21 @@ +[DEFAULT] +devices = %NODE_PATH%/node +mount_check = false +bind_port = %BIND_PORT% +user = stack +log_facility = LOG_LOCAL%LOG_FACILITY% + +[pipeline:main] +pipeline = container-server + +[app:container-server] +use = egg:swift#container + +[container-replicator] +vm_test_mode = yes + +[container-updater] + +[container-auditor] + +[container-sync] diff --git a/files/swift-object-server.conf b/files/swift-object-server.conf new file mode 100644 index 0000000..4a00713 --- /dev/null +++ b/files/swift-object-server.conf @@ -0,0 +1,19 @@ +[DEFAULT] +devices = %NODE_PATH%/node +mount_check = false +bind_port = %BIND_PORT% +user = stack +log_facility = LOG_LOCAL%LOG_FACILITY% + +[pipeline:main] +pipeline = object-server + +[app:object-server] +use = egg:swift#object + +[object-replicator] +vm_test_mode = yes + +[object-updater] + +[object-auditor] diff --git a/files/swift-proxy-server.conf b/files/swift-proxy-server.conf new file mode 100644 index 0000000..99fc286 --- /dev/null +++ b/files/swift-proxy-server.conf @@ -0,0 +1,25 @@ +[DEFAULT] +bind_port = 8080 +user = stack +log_facility = LOG_LOCAL1 + +[pipeline:main] +pipeline = healthcheck cache tempauth proxy-server + +[app:proxy-server] +use = egg:swift#proxy +allow_account_management = true + +[filter:tempauth] +use = egg:swift#tempauth +user_admin_admin = admin .admin .reseller_admin +user_test_tester = testing .admin +user_test2_tester2 = testing2 .admin +user_test_tester3 = testing3 +bind_ip = ${MY_IP} + +[filter:healthcheck] +use = egg:swift#healthcheck + +[filter:cache] +use = egg:swift#memcache diff --git a/files/swift-rsyncd.conf b/files/swift-rsyncd.conf new file mode 100644 index 0000000..80ec186 --- /dev/null +++ b/files/swift-rsyncd.conf @@ -0,0 +1,79 @@ +uid = stack +gid = stack +log file = /var/log/rsyncd.log +pid file = /var/run/rsyncd.pid +address = 127.0.0.1 + +[account6012] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/1/node/ +read only = false +lock file = /var/lock/account6012.lock + +[account6022] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/2/node/ +read only = false +lock file = /var/lock/account6022.lock + +[account6032] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/3/node/ +read only = false +lock file = /var/lock/account6032.lock + +[account6042] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/4/node/ +read only = false +lock file = /var/lock/account6042.lock + + +[container6011] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/1/node/ +read only = false +lock file = /var/lock/container6011.lock + +[container6021] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/2/node/ +read only = false +lock file = /var/lock/container6021.lock + +[container6031] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/3/node/ +read only = false +lock file = /var/lock/container6031.lock + +[container6041] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/4/node/ +read only = false +lock file = /var/lock/container6041.lock + + +[object6010] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/1/node/ +read only = false +lock file = /var/lock/object6010.lock + +[object6020] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/2/node/ +read only = false +lock file = /var/lock/object6020.lock + +[object6030] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/3/node/ +read only = false +lock file = /var/lock/object6030.lock + +[object6040] +max connections = 25 +path = %SWIFT_LOOPBACK_DISK_SIZE%/4/node/ +read only = false +lock file = /var/lock/object6040.lock diff --git a/files/swift.conf b/files/swift.conf new file mode 100644 index 0000000..98df466 --- /dev/null +++ b/files/swift.conf @@ -0,0 +1,3 @@ +[swift-hash] +# random unique string that can never change (DO NOT LOSE) +swift_hash_path_suffix = %SWIFT_HASH% diff --git a/stack.sh b/stack.sh index cba2db2..666b5f1 100755 --- a/stack.sh +++ b/stack.sh @@ -150,9 +150,10 @@ KEYSTONE_DIR=$DEST/keystone NOVACLIENT_DIR=$DEST/python-novaclient OPENSTACKX_DIR=$DEST/openstackx NOVNC_DIR=$DEST/noVNC +SWIFT_DIR=$DEST/swift # Specify which services to launch. These generally correspond to screen tabs -ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit} +ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit,swift} # Nova hypervisor configuration. We default to libvirt whth **kvm** but will # drop back to **qemu** if we are unable to load the kvm module. Stack.sh can @@ -270,6 +271,14 @@ read_password RABBIT_PASSWORD "ENTER A PASSWORD TO USE FOR RABBIT." # Glance connection info. Note the port must be specified. GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} +# SWIFT +# ----- +# +# Location of SWIFT drives +SWIFT_DRIVE_LOCATION=${SWIFT_DRIVE_LOCATION:-/srv} + +# Size of the loopback disks +SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} # Keystone # -------- @@ -349,6 +358,8 @@ function git_clone { # compute service git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH +# storage service +git_clone $SWIFT_REPO $SWIFT_DIR $SWIFT_BRANCH # image catalog service git_clone $GLANCE_REPO $GLANCE_DIR $GLANCE_BRANCH # unified auth system (manages accounts/tokens) @@ -370,6 +381,7 @@ git_clone $OPENSTACKX_REPO $OPENSTACKX_DIR $OPENSTACKX_BRANCH # setup our checkouts so they are installed into python path # allowing ``import nova`` or ``import glance.client`` cd $KEYSTONE_DIR; sudo python setup.py develop +cd $SWIFT_DIR; sudo python setup.py develop cd $GLANCE_DIR; sudo python setup.py develop cd $NOVACLIENT_DIR; sudo python setup.py develop cd $NOVA_DIR; sudo python setup.py develop @@ -580,6 +592,75 @@ if [[ "$ENABLED_SERVICES" =~ "n-net" ]]; then mkdir -p $NOVA_DIR/networks fi +# Storage Service +if [[ "$ENABLED_SERVICES" =~ "swift" ]];then + mkdir -p ${SWIFT_DRIVE_LOCATION}/drives + local s=${SWIFT_DRIVE_LOCATION}/drives/sdb1 # Shortcut variable + + # Create a loopback disk and format it with XFS. + if [[ ! -e ${SWIFT_DRIVE_LOCATION}/swift-disk ]];then + dd if=/dev/zero of=${SWIFT_DRIVE_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} + mkfs.xfs -f -i size=1024 ${SWIFT_DRIVE_LOCATION}/swift-disk + fi + + # Add the mountpoint to fstab + if ! egrep -q "^${SWIFT_DRIVE_LOCATION}/swift-disk" /etc/fstab;then + echo "# Added by devstack" | tee -a /etc/fstab + echo "${SWIFT_DRIVE_LOCATION}/swift-disk ${s} xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" | \ + tee -a /etc/fstab + fi + + # Create and mount drives. + mkdir -p ${s} + mount ${s} + mkdir ${s}/{1..4} + + # Create directories + install -g stack -o stack -d /etc/swift/{object,container,account}-server \ + ${SWIFT_DRIVE_LOCATION}/{1..4}/node/sdb1 /var/run/swift + + # Adjust rc.local to always have a /var/run/swift on reboot + # created and chown to our user. + # TODO (chmou): We may not have a "exit 0" + sed -i '/^exit 0/d' /etc/rc.local +cat <>/etc/rc.local +mkdir -p /var/run/swift +chown stack: /var/run/swift +exit 0 +EOF + + # Add rsync file + sed -e "s/%SWIFT_LOOPBACK_DISK_SIZE%/$SWIFT_DRIVE_LOCATION/" $FILES/swift-rsyncd.conf > /etc/rsyncd.conf + + # Copy proxy-server configuration + cp $FILES/swift-proxy-server.conf /etc/swift/ + + # Generate swift.conf, we need to have the swift-hash being random + # and unique. + local SWIFT_HASH=$(od -t x8 -N 8 -A n /etc/swift/swift.conf + + # We need to generate a object/account/proxy configuration + # emulating 4 nodes on different ports we have a litle function + # that help us doing that. + function generate_swift_configuration() { + local server_type=$1 + local bind_port=$2 + local log_facility=$3 + for node_number in {1..4};do + node_path=${SWIFT_DRIVE_LOCATION}/${node_number}/node + sed -e "s/%NODE_PATH%/${node_path}/;s/%BIND_PORT%/${bind_port}/;s/%LOG_FACILITY%/${log_facility}/" \ + $FILES/swift-${server_type}-server.conf > /etc/swift/${server_type}-server/${node_number}.conf + bind_port=$(( ${bind_port} + 10 )) + log_facility=$(( ${log_facility} + 1 )) + done + } + generate_swift_configuration object 6010 2 + generate_swift_configuration container 6011 2 + generate_swift_configuration account 6012 2 + +fi + # Volume Service # -------------- diff --git a/stackrc b/stackrc index 9b110a3..e880c17 100644 --- a/stackrc +++ b/stackrc @@ -2,6 +2,10 @@ NOVA_REPO=https://github.com/cloudbuilders/nova.git NOVA_BRANCH=diablo +# storage service +SWIFT_REPO=https://github.com/openstack/swift.git +SWIFT_BRANCH=diablo + # image catalog service GLANCE_REPO=https://github.com/cloudbuilders/glance.git GLANCE_BRANCH=diablo From a2cd841265c81e03a92a7abb5d788ad3d2d46bcd Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 12:36:10 +0100 Subject: [PATCH 015/112] Change SWIFT_DRIVE_LOCATION to SWIFT_LOCATION Fix some retarness along the way. --- files/swift-proxy-server.conf | 2 +- files/swift-rsyncd.conf | 24 ++++++++++++------------ stack.sh | 22 +++++++++++----------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/files/swift-proxy-server.conf b/files/swift-proxy-server.conf index 99fc286..9e2b1dd 100644 --- a/files/swift-proxy-server.conf +++ b/files/swift-proxy-server.conf @@ -16,7 +16,7 @@ user_admin_admin = admin .admin .reseller_admin user_test_tester = testing .admin user_test2_tester2 = testing2 .admin user_test_tester3 = testing3 -bind_ip = ${MY_IP} +bind_ip = 0.0.0.0 [filter:healthcheck] use = egg:swift#healthcheck diff --git a/files/swift-rsyncd.conf b/files/swift-rsyncd.conf index 80ec186..1cea98c 100644 --- a/files/swift-rsyncd.conf +++ b/files/swift-rsyncd.conf @@ -6,74 +6,74 @@ address = 127.0.0.1 [account6012] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/1/node/ +path = %SWIFT_LOCATION%/1/node/ read only = false lock file = /var/lock/account6012.lock [account6022] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/2/node/ +path = %SWIFT_LOCATION%/2/node/ read only = false lock file = /var/lock/account6022.lock [account6032] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/3/node/ +path = %SWIFT_LOCATION%/3/node/ read only = false lock file = /var/lock/account6032.lock [account6042] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/4/node/ +path = %SWIFT_LOCATION%/4/node/ read only = false lock file = /var/lock/account6042.lock [container6011] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/1/node/ +path = %SWIFT_LOCATION%/1/node/ read only = false lock file = /var/lock/container6011.lock [container6021] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/2/node/ +path = %SWIFT_LOCATION%/2/node/ read only = false lock file = /var/lock/container6021.lock [container6031] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/3/node/ +path = %SWIFT_LOCATION%/3/node/ read only = false lock file = /var/lock/container6031.lock [container6041] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/4/node/ +path = %SWIFT_LOCATION%/4/node/ read only = false lock file = /var/lock/container6041.lock [object6010] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/1/node/ +path = %SWIFT_LOCATION%/1/node/ read only = false lock file = /var/lock/object6010.lock [object6020] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/2/node/ +path = %SWIFT_LOCATION%/2/node/ read only = false lock file = /var/lock/object6020.lock [object6030] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/3/node/ +path = %SWIFT_LOCATION%/3/node/ read only = false lock file = /var/lock/object6030.lock [object6040] max connections = 25 -path = %SWIFT_LOOPBACK_DISK_SIZE%/4/node/ +path = %SWIFT_LOCATION%/4/node/ read only = false lock file = /var/lock/object6040.lock diff --git a/stack.sh b/stack.sh index 666b5f1..bfab078 100755 --- a/stack.sh +++ b/stack.sh @@ -275,7 +275,7 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} # ----- # # Location of SWIFT drives -SWIFT_DRIVE_LOCATION=${SWIFT_DRIVE_LOCATION:-/srv} +SWIFT_LOCATION=${SWIFT_LOCATION:-/srv} # Size of the loopback disks SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} @@ -594,19 +594,19 @@ fi # Storage Service if [[ "$ENABLED_SERVICES" =~ "swift" ]];then - mkdir -p ${SWIFT_DRIVE_LOCATION}/drives - local s=${SWIFT_DRIVE_LOCATION}/drives/sdb1 # Shortcut variable + mkdir -p ${SWIFT_LOCATION}/drives + local s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable # Create a loopback disk and format it with XFS. - if [[ ! -e ${SWIFT_DRIVE_LOCATION}/swift-disk ]];then - dd if=/dev/zero of=${SWIFT_DRIVE_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} - mkfs.xfs -f -i size=1024 ${SWIFT_DRIVE_LOCATION}/swift-disk + if [[ ! -e ${SWIFT_LOCATION}/swift-disk ]];then + dd if=/dev/zero of=${SWIFT_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} + mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/swift-disk fi # Add the mountpoint to fstab - if ! egrep -q "^${SWIFT_DRIVE_LOCATION}/swift-disk" /etc/fstab;then + if ! egrep -q "^${SWIFT_LOCATION}/swift-disk" /etc/fstab;then echo "# Added by devstack" | tee -a /etc/fstab - echo "${SWIFT_DRIVE_LOCATION}/swift-disk ${s} xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" | \ + echo "${SWIFT_LOCATION}/swift-disk ${s} xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" | \ tee -a /etc/fstab fi @@ -617,7 +617,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then # Create directories install -g stack -o stack -d /etc/swift/{object,container,account}-server \ - ${SWIFT_DRIVE_LOCATION}/{1..4}/node/sdb1 /var/run/swift + ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift # Adjust rc.local to always have a /var/run/swift on reboot # created and chown to our user. @@ -630,7 +630,7 @@ exit 0 EOF # Add rsync file - sed -e "s/%SWIFT_LOOPBACK_DISK_SIZE%/$SWIFT_DRIVE_LOCATION/" $FILES/swift-rsyncd.conf > /etc/rsyncd.conf + sed -e "s/%SWIFT_LOCATION%/$SWIFT_LOCATION/" $FILES/swift-rsyncd.conf > /etc/rsyncd.conf # Copy proxy-server configuration cp $FILES/swift-proxy-server.conf /etc/swift/ @@ -648,7 +648,7 @@ EOF local bind_port=$2 local log_facility=$3 for node_number in {1..4};do - node_path=${SWIFT_DRIVE_LOCATION}/${node_number}/node + node_path=${SWIFT_LOCATION}/${node_number}/node sed -e "s/%NODE_PATH%/${node_path}/;s/%BIND_PORT%/${bind_port}/;s/%LOG_FACILITY%/${log_facility}/" \ $FILES/swift-${server_type}-server.conf > /etc/swift/${server_type}-server/${node_number}.conf bind_port=$(( ${bind_port} + 10 )) From a03f005673107fd93226752f9531ae498b70da39 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 13:08:29 +0000 Subject: [PATCH 016/112] Fixes (still not fully tested). --- stack.sh | 33 ++++++++++++++++++++------------- stackrc | 2 +- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/stack.sh b/stack.sh index bfab078..546cc06 100755 --- a/stack.sh +++ b/stack.sh @@ -594,51 +594,56 @@ fi # Storage Service if [[ "$ENABLED_SERVICES" =~ "swift" ]];then - mkdir -p ${SWIFT_LOCATION}/drives - local s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable + sudo mkdir -p ${SWIFT_LOCATION}/drives + sudo chown -R stack: ${SWIFT_LOCATION}/drives + s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable # Create a loopback disk and format it with XFS. if [[ ! -e ${SWIFT_LOCATION}/swift-disk ]];then + sudo touch ${SWIFT_LOCATION}/swift-disk + sudo chown stack: ${SWIFT_LOCATION}/swift-disk + dd if=/dev/zero of=${SWIFT_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/swift-disk fi # Add the mountpoint to fstab if ! egrep -q "^${SWIFT_LOCATION}/swift-disk" /etc/fstab;then - echo "# Added by devstack" | tee -a /etc/fstab + echo "# Added by devstack" | sudo tee -a /etc/fstab echo "${SWIFT_LOCATION}/swift-disk ${s} xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" | \ - tee -a /etc/fstab + sudo tee -a /etc/fstab fi # Create and mount drives. mkdir -p ${s} - mount ${s} - mkdir ${s}/{1..4} + if ! egrep -q "$s" /proc/mounts;then + sudo mount ${s} + fi # Create directories - install -g stack -o stack -d /etc/swift/{object,container,account}-server \ - ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift + sudo install -g stack -o stack -d /etc/swift /etc/swift/{object,container,account}-server \ + ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ${s}/{1..4} # Adjust rc.local to always have a /var/run/swift on reboot # created and chown to our user. # TODO (chmou): We may not have a "exit 0" - sed -i '/^exit 0/d' /etc/rc.local -cat <>/etc/rc.local + sudo sed -i '/^exit 0/d' /etc/rc.local +cat < /etc/rsyncd.conf + sed -e "s/%SWIFT_LOCATION%/$SWIFT_LOCATION/" $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf # Copy proxy-server configuration cp $FILES/swift-proxy-server.conf /etc/swift/ # Generate swift.conf, we need to have the swift-hash being random # and unique. - local SWIFT_HASH=$(od -t x8 -N 8 -A n /etc/swift/swift.conf + swift_hash=$(od -t x8 -N 8 -A n /etc/swift/swift.conf # We need to generate a object/account/proxy configuration # emulating 4 nodes on different ports we have a litle function @@ -658,6 +663,8 @@ EOF generate_swift_configuration object 6010 2 generate_swift_configuration container 6011 2 generate_swift_configuration account 6012 2 + + unset s swift_hasH fi diff --git a/stackrc b/stackrc index e880c17..78479f9 100644 --- a/stackrc +++ b/stackrc @@ -4,7 +4,7 @@ NOVA_BRANCH=diablo # storage service SWIFT_REPO=https://github.com/openstack/swift.git -SWIFT_BRANCH=diablo +SWIFT_BRANCH=1.4.3 # image catalog service GLANCE_REPO=https://github.com/cloudbuilders/glance.git From a2118984c0b83925360bfe3388902696146b3468 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 15:36:00 +0100 Subject: [PATCH 017/112] Add script to create ring and start server --- files/swift-remakerings | 26 ++++++++++++++++++++++++++ files/swift-startmain | 3 +++ stack.sh | 9 +++++++++ 3 files changed, 38 insertions(+) create mode 100644 files/swift-remakerings create mode 100644 files/swift-startmain diff --git a/files/swift-remakerings b/files/swift-remakerings new file mode 100644 index 0000000..9343783 --- /dev/null +++ b/files/swift-remakerings @@ -0,0 +1,26 @@ +#!/bin/bash + +cd /etc/swift + +rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz + +swift-ring-builder object.builder create %SWIFT_PARTITION_POWER_SIZE% 3 1 +swift-ring-builder object.builder add z1-127.0.0.1:6010/sdb1 1 +swift-ring-builder object.builder add z2-127.0.0.1:6020/sdb2 1 +swift-ring-builder object.builder add z3-127.0.0.1:6030/sdb3 1 +swift-ring-builder object.builder add z4-127.0.0.1:6040/sdb4 1 +swift-ring-builder object.builder rebalance + +swift-ring-builder container.builder create %SWIFT_PARTITION_POWER_SIZE% 3 1 +swift-ring-builder container.builder add z1-127.0.0.1:6011/sdb1 1 +swift-ring-builder container.builder add z2-127.0.0.1:6021/sdb2 1 +swift-ring-builder container.builder add z3-127.0.0.1:6031/sdb3 1 +swift-ring-builder container.builder add z4-127.0.0.1:6041/sdb4 1 +swift-ring-builder container.builder rebalance + +swift-ring-builder account.builder create %SWIFT_PARTITION_POWER_SIZE% 3 1 +swift-ring-builder account.builder add z1-127.0.0.1:6012/sdb1 1 +swift-ring-builder account.builder add z2-127.0.0.1:6022/sdb2 1 +swift-ring-builder account.builder add z3-127.0.0.1:6032/sdb3 1 +swift-ring-builder account.builder add z4-127.0.0.1:6042/sdb4 1 +swift-ring-builder account.builder rebalance diff --git a/files/swift-startmain b/files/swift-startmain new file mode 100644 index 0000000..05b9509 --- /dev/null +++ b/files/swift-startmain @@ -0,0 +1,3 @@ +#!/bin/bash + +swift-init all start diff --git a/stack.sh b/stack.sh index 546cc06..4c93e67 100755 --- a/stack.sh +++ b/stack.sh @@ -280,6 +280,9 @@ SWIFT_LOCATION=${SWIFT_LOCATION:-/srv} # Size of the loopback disks SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} +# Default partition power size (bigger is slower) +SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} + # Keystone # -------- @@ -664,6 +667,12 @@ EOF generate_swift_configuration container 6011 2 generate_swift_configuration account 6012 2 + # Install swift helper scripts to remake the rings and start all services. + sed -e "s/%SWIFT_PARTITION_POWER_SIZE%/$SWIFT_PARTITION_POWER_SIZE/" $FILES/swift-remakerings | \ + sudo tee /usr/local/bin/swift-remakerings + sudo install -m755 $FILES/swift-startmain /usr/local/bin/ + sudo chmod +x /usr/local/bin/swift-* + unset s swift_hasH fi From d5651bb5c6fe3e51849742527aae77dadf826cb4 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 16:22:08 +0100 Subject: [PATCH 018/112] More fixes (this is now working). --- files/swift-proxy-server.conf | 1 + files/swift-startmain | 2 +- stack.sh | 14 +++++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) mode change 100644 => 100755 files/swift-startmain diff --git a/files/swift-proxy-server.conf b/files/swift-proxy-server.conf index 9e2b1dd..737a66d 100644 --- a/files/swift-proxy-server.conf +++ b/files/swift-proxy-server.conf @@ -9,6 +9,7 @@ pipeline = healthcheck cache tempauth proxy-server [app:proxy-server] use = egg:swift#proxy allow_account_management = true +account_autocreate = true [filter:tempauth] use = egg:swift#tempauth diff --git a/files/swift-startmain b/files/swift-startmain old mode 100644 new mode 100755 index 05b9509..69efebd --- a/files/swift-startmain +++ b/files/swift-startmain @@ -1,3 +1,3 @@ #!/bin/bash -swift-init all start +swift-init all restart diff --git a/stack.sh b/stack.sh index 4c93e67..5cb5a18 100755 --- a/stack.sh +++ b/stack.sh @@ -641,7 +641,7 @@ EOF sed -e "s/%SWIFT_LOCATION%/$SWIFT_LOCATION/" $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf # Copy proxy-server configuration - cp $FILES/swift-proxy-server.conf /etc/swift/ + cp $FILES/swift-proxy-server.conf /etc/swift/proxy-server.conf # Generate swift.conf, we need to have the swift-hash being random # and unique. @@ -656,8 +656,8 @@ EOF local bind_port=$2 local log_facility=$3 for node_number in {1..4};do - node_path=${SWIFT_LOCATION}/${node_number}/node - sed -e "s/%NODE_PATH%/${node_path}/;s/%BIND_PORT%/${bind_port}/;s/%LOG_FACILITY%/${log_facility}/" \ + node_path=${SWIFT_LOCATION}/${node_number} + sed -e "s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \ $FILES/swift-${server_type}-server.conf > /etc/swift/${server_type}-server/${node_number}.conf bind_port=$(( ${bind_port} + 10 )) log_facility=$(( ${log_facility} + 1 )) @@ -673,6 +673,14 @@ EOF sudo install -m755 $FILES/swift-startmain /usr/local/bin/ sudo chmod +x /usr/local/bin/swift-* + # Create ring + /usr/local/bin/swift-remakerings + + # Start everything + /usr/local/bin/swift-startmain || : + + # This should work (tempauth) + # swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat unset s swift_hasH fi From e1d2bcb1b9ba1dc178f753c4b41c4e75ef29b7f8 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 17:32:11 +0100 Subject: [PATCH 019/112] Fixes. Fix mounting location at the right place. Fix rerun of the script. Start rsync. Fix permissions. --- stack.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/stack.sh b/stack.sh index 5cb5a18..a449255 100755 --- a/stack.sh +++ b/stack.sh @@ -623,10 +623,18 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then sudo mount ${s} fi + for x in {1..4}; do sudo ln -sf $s/$x ${SWIFT_LOCATION}/$x; done + # Create directories - sudo install -g stack -o stack -d /etc/swift /etc/swift/{object,container,account}-server \ - ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ${s}/{1..4} + tmpd="" + for d in /etc/swift /etc/swift/{object,container,account}-server \ + ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ${s}/{1..4};do + [[ -d $d ]] && continue + sudo install -g stack -o stack -d $d + done + sudo chown -R stack: ${SWIFT_LOCATION}/{1..4}/node + # Adjust rc.local to always have a /var/run/swift on reboot # created and chown to our user. # TODO (chmou): We may not have a "exit 0" @@ -638,8 +646,9 @@ exit 0 EOF # Add rsync file - sed -e "s/%SWIFT_LOCATION%/$SWIFT_LOCATION/" $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf - + sed -e "s,%SWIFT_LOCATION%,$SWIFT_LOCATION," $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf + sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync + # Copy proxy-server configuration cp $FILES/swift-proxy-server.conf /etc/swift/proxy-server.conf @@ -673,6 +682,9 @@ EOF sudo install -m755 $FILES/swift-startmain /usr/local/bin/ sudo chmod +x /usr/local/bin/swift-* + # Start rsync + sudo /etc/init.d/rsync restart || : + # Create ring /usr/local/bin/swift-remakerings From 3b3b775f3bb668671fe91ac4b440b466f668be46 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 17:42:52 +0100 Subject: [PATCH 020/112] Ordering is important here. --- stack.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stack.sh b/stack.sh index a449255..3e0ea21 100755 --- a/stack.sh +++ b/stack.sh @@ -627,8 +627,8 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then # Create directories tmpd="" - for d in /etc/swift /etc/swift/{object,container,account}-server \ - ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ${s}/{1..4};do + for d in ${s}/{1..4} /etc/swift /etc/swift/{object,container,account}-server \ + ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ;do [[ -d $d ]] && continue sudo install -g stack -o stack -d $d done From 5ab5b2293240f7600e6b24aecfebe85f1abb1aa3 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 18:15:36 +0100 Subject: [PATCH 021/112] Fix variabe subst. --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 3e0ea21..d4e09be 100755 --- a/stack.sh +++ b/stack.sh @@ -655,7 +655,7 @@ EOF # Generate swift.conf, we need to have the swift-hash being random # and unique. swift_hash=$(od -t x8 -N 8 -A n /etc/swift/swift.conf + sed -e "s/%SWIFT_HASH%/$swift_hash/" $FILES/swift.conf > /etc/swift/swift.conf # We need to generate a object/account/proxy configuration # emulating 4 nodes on different ports we have a litle function From 45c5113701ecbb426d8fea95d0c416a89b089671 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 1 Nov 2011 19:32:23 +0100 Subject: [PATCH 022/112] Add keystone support with swift. --- files/keystone_data.sh | 3 ++- files/swift-proxy-server.conf | 7 ++++++- stack.sh | 28 +++++++++++++++++++++++----- stackrc | 4 ++++ 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/files/keystone_data.sh b/files/keystone_data.sh index a5e75a6..d926c52 100755 --- a/files/keystone_data.sh +++ b/files/keystone_data.sh @@ -30,12 +30,13 @@ $BIN_DIR/keystone-manage $* role grant KeystoneServiceAdmin admin $BIN_DIR/keystone-manage $* service add nova compute "Nova Compute Service" $BIN_DIR/keystone-manage $* service add glance image "Glance Image Service" $BIN_DIR/keystone-manage $* service add keystone identity "Keystone Identity Service" +$BIN_DIR/keystone-manage $* service add swift object-store "Swift Service" #endpointTemplates $BIN_DIR/keystone-manage $* endpointTemplates add RegionOne nova http://%HOST_IP%:8774/v1.1/%tenant_id% http://%HOST_IP%:8774/v1.1/%tenant_id% http://%HOST_IP%:8774/v1.1/%tenant_id% 1 1 $BIN_DIR/keystone-manage $* endpointTemplates add RegionOne glance http://%HOST_IP%:9292/v1.1/%tenant_id% http://%HOST_IP%:9292/v1.1/%tenant_id% http://%HOST_IP%:9292/v1.1/%tenant_id% 1 1 $BIN_DIR/keystone-manage $* endpointTemplates add RegionOne keystone http://%HOST_IP%:5000/v2.0 http://%HOST_IP%:35357/v2.0 http://%HOST_IP%:5000/v2.0 1 1 -# $BIN_DIR/keystone-manage $* endpointTemplates add RegionOne swift http://%HOST_IP%:8080/v1/AUTH_%tenant_id% http://%HOST_IP%:8080/ http://%HOST_IP%:8080/v1/AUTH_%tenant_id% 1 1 +$BIN_DIR/keystone-manage $* endpointTemplates add RegionOne swift http://%HOST_IP%:8080/v1/AUTH_%tenant_id% http://%HOST_IP%:8080/ http://%HOST_IP%:8080/v1/AUTH_%tenant_id% 1 1 # Tokens $BIN_DIR/keystone-manage $* token add %SERVICE_TOKEN% admin admin 2015-02-05T00:00 diff --git a/files/swift-proxy-server.conf b/files/swift-proxy-server.conf index 737a66d..9a3b54b 100644 --- a/files/swift-proxy-server.conf +++ b/files/swift-proxy-server.conf @@ -4,13 +4,18 @@ user = stack log_facility = LOG_LOCAL1 [pipeline:main] -pipeline = healthcheck cache tempauth proxy-server +pipeline = healthcheck cache %AUTH_SERVER% proxy-server [app:proxy-server] use = egg:swift#proxy allow_account_management = true account_autocreate = true +[filter:keystone] +use = egg:swiftkeystone2#keystone2 +keystone_admin_token = %SERVICE_TOKEN% +keystone_url = http://localhost:35357/v2.0 + [filter:tempauth] use = egg:swift#tempauth user_admin_admin = admin .admin .reseller_admin diff --git a/stack.sh b/stack.sh index d4e09be..8a1b9bc 100755 --- a/stack.sh +++ b/stack.sh @@ -151,6 +151,7 @@ NOVACLIENT_DIR=$DEST/python-novaclient OPENSTACKX_DIR=$DEST/openstackx NOVNC_DIR=$DEST/noVNC SWIFT_DIR=$DEST/swift +SWIFT_KEYSTONE_DIR=$DEST/swift-keystone2 # Specify which services to launch. These generally correspond to screen tabs ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit,swift} @@ -363,6 +364,8 @@ function git_clone { git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH # storage service git_clone $SWIFT_REPO $SWIFT_DIR $SWIFT_BRANCH +# swift + keystone middleware +git_clone $SWIFT_KEYSTONE_REPO $SWIFT_KEYSTONE_DIR $SWIFT_KEYSTONE_BRANCH # image catalog service git_clone $GLANCE_REPO $GLANCE_DIR $GLANCE_BRANCH # unified auth system (manages accounts/tokens) @@ -385,6 +388,7 @@ git_clone $OPENSTACKX_REPO $OPENSTACKX_DIR $OPENSTACKX_BRANCH # allowing ``import nova`` or ``import glance.client`` cd $KEYSTONE_DIR; sudo python setup.py develop cd $SWIFT_DIR; sudo python setup.py develop +cd $SWIFT_KEYSTONE_DIR; sudo python setup.py develop cd $GLANCE_DIR; sudo python setup.py develop cd $NOVACLIENT_DIR; sudo python setup.py develop cd $NOVA_DIR; sudo python setup.py develop @@ -648,9 +652,18 @@ EOF # Add rsync file sed -e "s,%SWIFT_LOCATION%,$SWIFT_LOCATION," $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync - - # Copy proxy-server configuration - cp $FILES/swift-proxy-server.conf /etc/swift/proxy-server.conf + + if [[ "$ENABLED_SERVICES" =~ "key" ]]; then + swift_auth_server=keystone + # Temporary until we get this integrated in swift. + sudo curl -s -o/usr/local/bin/swift \ + 'https://review.openstack.org/gitweb?p=openstack/swift.git;a=blob_plain;f=bin/swift;hb=48bfda6e2fdf3886c98bd15649887d54b9a2574e' + else + swift_auth_server=tempauth + fi + + sed "s/%SERVICE_TOKEN%/${SERVICE_TOKEN}/;s/%AUTH_SERVER%/${swift_auth_server}/" \ + $FILES/swift-proxy-server.conf|sudo tee /etc/swift/proxy-server.conf # Generate swift.conf, we need to have the swift-hash being random # and unique. @@ -664,6 +677,8 @@ EOF local server_type=$1 local bind_port=$2 local log_facility=$3 + local node_number + for node_number in {1..4};do node_path=${SWIFT_LOCATION}/${node_number} sed -e "s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \ @@ -693,8 +708,7 @@ EOF # This should work (tempauth) # swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat - unset s swift_hasH - + unset s swift_hash swift_auth_server tmpd fi # Volume Service @@ -976,6 +990,10 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then echo "examples on using novaclient command line is in exercise.sh" echo "the default users are: admin and demo" echo "the password: $ADMIN_PASSWORD" + if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then + echo "Swift: swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin:admin -K $ADMIN_PASSWORD stat" + fi + fi # indicate how long this took to run (bash maintained variable 'SECONDS') diff --git a/stackrc b/stackrc index 78479f9..6d4454e 100644 --- a/stackrc +++ b/stackrc @@ -6,6 +6,10 @@ NOVA_BRANCH=diablo SWIFT_REPO=https://github.com/openstack/swift.git SWIFT_BRANCH=1.4.3 +# swift and keystone integration +SWIFT_KEYSTONE_REPO=https://github.com/cloudbuilders/swift-keystone2.git +SWIFT_KEYSTONE_BRANCH=master + # image catalog service GLANCE_REPO=https://github.com/cloudbuilders/glance.git GLANCE_BRANCH=diablo From 5c50f0dcde905e41725d6bb4d2a708373916a26b Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 01:02:30 +0100 Subject: [PATCH 023/112] Don't enable it by default. --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 8a1b9bc..9343f22 100755 --- a/stack.sh +++ b/stack.sh @@ -154,7 +154,7 @@ SWIFT_DIR=$DEST/swift SWIFT_KEYSTONE_DIR=$DEST/swift-keystone2 # Specify which services to launch. These generally correspond to screen tabs -ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit,swift} +ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit} # Nova hypervisor configuration. We default to libvirt whth **kvm** but will # drop back to **qemu** if we are unable to load the kvm module. Stack.sh can From ab75f4becfb839e8bab5f602bb414a8f4eab090e Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 01:03:29 +0100 Subject: [PATCH 024/112] Ask for SWIFT_HASH. --- stack.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 9343f22..051be94 100755 --- a/stack.sh +++ b/stack.sh @@ -284,6 +284,9 @@ SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} # Default partition power size (bigger is slower) SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} +# Swift hash, this must be unique +read_password SWIFT_HASH "ENTER A RANDOM HASH SHARED BETWEEN ALL PROCESSES." + # Keystone # -------- @@ -667,7 +670,6 @@ EOF # Generate swift.conf, we need to have the swift-hash being random # and unique. - swift_hash=$(od -t x8 -N 8 -A n /etc/swift/swift.conf # We need to generate a object/account/proxy configuration From a55b09d9e86794c782e954084415da86cdb846ff Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 01:07:43 +0100 Subject: [PATCH 025/112] change stack to $USER --- stack.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/stack.sh b/stack.sh index 051be94..9ba0564 100755 --- a/stack.sh +++ b/stack.sh @@ -637,20 +637,10 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then for d in ${s}/{1..4} /etc/swift /etc/swift/{object,container,account}-server \ ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ;do [[ -d $d ]] && continue - sudo install -g stack -o stack -d $d + sudo install -o ${USER} -d $d done sudo chown -R stack: ${SWIFT_LOCATION}/{1..4}/node - - # Adjust rc.local to always have a /var/run/swift on reboot - # created and chown to our user. - # TODO (chmou): We may not have a "exit 0" - sudo sed -i '/^exit 0/d' /etc/rc.local -cat < Date: Wed, 2 Nov 2011 01:10:38 +0100 Subject: [PATCH 026/112] Don't use 'stack' in static but use $USER. --- files/swift-account-server.conf | 2 +- files/swift-container-server.conf | 2 +- files/swift-object-server.conf | 2 +- files/swift-proxy-server.conf | 2 +- stack.sh | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/files/swift-account-server.conf b/files/swift-account-server.conf index b5451c6..920d45c 100644 --- a/files/swift-account-server.conf +++ b/files/swift-account-server.conf @@ -2,7 +2,7 @@ devices = %NODE_PATH%/node mount_check = false bind_port = %BIND_PORT% -user = stack +user = %USER% log_facility = LOG_LOCAL%LOG_FACILITY% [pipeline:main] diff --git a/files/swift-container-server.conf b/files/swift-container-server.conf index c630076..8d59bf2 100644 --- a/files/swift-container-server.conf +++ b/files/swift-container-server.conf @@ -2,7 +2,7 @@ devices = %NODE_PATH%/node mount_check = false bind_port = %BIND_PORT% -user = stack +user = %USER% log_facility = LOG_LOCAL%LOG_FACILITY% [pipeline:main] diff --git a/files/swift-object-server.conf b/files/swift-object-server.conf index 4a00713..1b72e70 100644 --- a/files/swift-object-server.conf +++ b/files/swift-object-server.conf @@ -2,7 +2,7 @@ devices = %NODE_PATH%/node mount_check = false bind_port = %BIND_PORT% -user = stack +user = %USER% log_facility = LOG_LOCAL%LOG_FACILITY% [pipeline:main] diff --git a/files/swift-proxy-server.conf b/files/swift-proxy-server.conf index 9a3b54b..6b7dd52 100644 --- a/files/swift-proxy-server.conf +++ b/files/swift-proxy-server.conf @@ -1,6 +1,6 @@ [DEFAULT] bind_port = 8080 -user = stack +user = %USER% log_facility = LOG_LOCAL1 [pipeline:main] diff --git a/stack.sh b/stack.sh index 9ba0564..62be7f5 100755 --- a/stack.sh +++ b/stack.sh @@ -655,7 +655,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then swift_auth_server=tempauth fi - sed "s/%SERVICE_TOKEN%/${SERVICE_TOKEN}/;s/%AUTH_SERVER%/${swift_auth_server}/" \ + sed "s/%USER%/$USER/;s/%SERVICE_TOKEN%/${SERVICE_TOKEN}/;s/%AUTH_SERVER%/${swift_auth_server}/" \ $FILES/swift-proxy-server.conf|sudo tee /etc/swift/proxy-server.conf # Generate swift.conf, we need to have the swift-hash being random @@ -673,7 +673,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then for node_number in {1..4};do node_path=${SWIFT_LOCATION}/${node_number} - sed -e "s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \ + sed -e "s,%USER%,$USER,;s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \ $FILES/swift-${server_type}-server.conf > /etc/swift/${server_type}-server/${node_number}.conf bind_port=$(( ${bind_port} + 10 )) log_facility=$(( ${log_facility} + 1 )) From 067163dfd1db129d089a393d0a15d301f5384335 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 14:25:06 +0100 Subject: [PATCH 027/112] More stack user removals. --- files/swift-rsyncd.conf | 4 ++-- stack.sh | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/files/swift-rsyncd.conf b/files/swift-rsyncd.conf index 1cea98c..568f240 100644 --- a/files/swift-rsyncd.conf +++ b/files/swift-rsyncd.conf @@ -1,5 +1,5 @@ -uid = stack -gid = stack +uid = %USER% +gid = %GROUP% log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid address = 127.0.0.1 diff --git a/stack.sh b/stack.sh index 62be7f5..ed6daf8 100755 --- a/stack.sh +++ b/stack.sh @@ -121,7 +121,7 @@ if [[ $EUID -eq 0 ]]; then echo "Copying files to stack user" STACK_DIR="$DEST/${PWD##*/}" cp -r -f "$PWD" "$STACK_DIR" - chown -R stack "$STACK_DIR" + chown -R $USER "$STACK_DIR" if [[ "$SHELL_AFTER_RUN" != "no" ]]; then exec su -c "set -e; cd $STACK_DIR; bash stack.sh; bash" stack else @@ -604,14 +604,16 @@ fi # Storage Service if [[ "$ENABLED_SERVICES" =~ "swift" ]];then + USER_GROUP=$(id -g) + sudo mkdir -p ${SWIFT_LOCATION}/drives - sudo chown -R stack: ${SWIFT_LOCATION}/drives + sudo chown -R $USER: ${SWIFT_LOCATION}/drives s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable # Create a loopback disk and format it with XFS. if [[ ! -e ${SWIFT_LOCATION}/swift-disk ]];then sudo touch ${SWIFT_LOCATION}/swift-disk - sudo chown stack: ${SWIFT_LOCATION}/swift-disk + sudo chown $USER: ${SWIFT_LOCATION}/swift-disk dd if=/dev/zero of=${SWIFT_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/swift-disk @@ -637,13 +639,13 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then for d in ${s}/{1..4} /etc/swift /etc/swift/{object,container,account}-server \ ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ;do [[ -d $d ]] && continue - sudo install -o ${USER} -d $d + sudo install -o ${USER} -g $USER_GROUP -d $d done - sudo chown -R stack: ${SWIFT_LOCATION}/{1..4}/node + sudo chown -R $USER: ${SWIFT_LOCATION}/{1..4}/node # Add rsync file - sed -e "s,%SWIFT_LOCATION%,$SWIFT_LOCATION," $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf + sed -e "s/%GROUP%/${USER_GROUP}/;s/%USER%/$USER/;s,%SWIFT_LOCATION%,$SWIFT_LOCATION," $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync if [[ "$ENABLED_SERVICES" =~ "key" ]]; then From 55ca8c31647cd28d2870cddb8e38ea7316f82205 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 14:28:41 +0100 Subject: [PATCH 028/112] Remove fstab entry and mount it manually. --- stack.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/stack.sh b/stack.sh index ed6daf8..69d48de 100755 --- a/stack.sh +++ b/stack.sh @@ -619,17 +619,10 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/swift-disk fi - # Add the mountpoint to fstab - if ! egrep -q "^${SWIFT_LOCATION}/swift-disk" /etc/fstab;then - echo "# Added by devstack" | sudo tee -a /etc/fstab - echo "${SWIFT_LOCATION}/swift-disk ${s} xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" | \ - sudo tee -a /etc/fstab - fi - # Create and mount drives. mkdir -p ${s} if ! egrep -q "$s" /proc/mounts;then - sudo mount ${s} + sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 ${s} fi for x in {1..4}; do sudo ln -sf $s/$x ${SWIFT_LOCATION}/$x; done From 06018a6bdbfea7b423194bde1b8b05cd8ed91dff Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 16:18:47 +0100 Subject: [PATCH 029/112] Fix wording. --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 69d48de..83fec6a 100755 --- a/stack.sh +++ b/stack.sh @@ -285,7 +285,7 @@ SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} # Swift hash, this must be unique -read_password SWIFT_HASH "ENTER A RANDOM HASH SHARED BETWEEN ALL PROCESSES." +read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH." # Keystone # -------- From e1136cb8dc5c4583165e7472a7112bae6f165e02 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 16:19:16 +0100 Subject: [PATCH 030/112] Fix SWIFT_HASH_PREFIX variable. --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 83fec6a..7f2a5a2 100755 --- a/stack.sh +++ b/stack.sh @@ -655,7 +655,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then # Generate swift.conf, we need to have the swift-hash being random # and unique. - sed -e "s/%SWIFT_HASH%/$swift_hash/" $FILES/swift.conf > /etc/swift/swift.conf + sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift.conf > /etc/swift/swift.conf # We need to generate a object/account/proxy configuration # emulating 4 nodes on different ports we have a litle function From b93478f6c752380481a75119bcf56abae5533d25 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 16:49:56 +0100 Subject: [PATCH 031/112] Change drives location. Change drives and data location to ${SWIFT_DIR}/data --- stack.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/stack.sh b/stack.sh index 7f2a5a2..8de1e84 100755 --- a/stack.sh +++ b/stack.sh @@ -274,9 +274,9 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} # SWIFT # ----- -# + # Location of SWIFT drives -SWIFT_LOCATION=${SWIFT_LOCATION:-/srv} +SWIFT_LOCATION=${SWIFT_LOCATION:-${SWIFT_DIR}/data} # Size of the loopback disks SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} @@ -611,18 +611,21 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable # Create a loopback disk and format it with XFS. - if [[ ! -e ${SWIFT_LOCATION}/swift-disk ]];then - sudo touch ${SWIFT_LOCATION}/swift-disk - sudo chown $USER: ${SWIFT_LOCATION}/swift-disk + if [[ ! -e ${SWIFT_LOCATION}/drives/images/swift.img ]];then + mkdir -p ${SWIFT_LOCATION}/drives/images + sudo touch ${SWIFT_LOCATION}/drives/images/swift.img + sudo chown $USER: ${SWIFT_LOCATION}/drives/images/swift.img - dd if=/dev/zero of=${SWIFT_LOCATION}/swift-disk bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} - mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/swift-disk + dd if=/dev/zero of=${SWIFT_LOCATION}/drives/images/swift.img \ + bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} + mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/drives/images/swift.img fi # Create and mount drives. mkdir -p ${s} if ! egrep -q "$s" /proc/mounts;then - sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 ${s} + sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \ + ${SWIFT_LOCATION}/drives/images/swift.img ${s} fi for x in {1..4}; do sudo ln -sf $s/$x ${SWIFT_LOCATION}/$x; done From 3d9c5d5e4eaadd5f28b6830fb3d6056aa918704c Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 17:57:11 +0100 Subject: [PATCH 032/112] Add documentation and fixes. - Fix some spelling mistakes in the documentation. - Add swift documentation. - Try to make the code more explicit (ie: remove shortcut variables). --- stack.sh | 91 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 30 deletions(-) diff --git a/stack.sh b/stack.sh index 8de1e84..df9d4b2 100755 --- a/stack.sh +++ b/stack.sh @@ -70,7 +70,7 @@ fi # 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 +# useful for changing a branch or repository 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 @@ -241,7 +241,7 @@ MULTI_HOST=${MULTI_HOST:-0} # If you are running on a single node and don't need to access the VMs from # devices other than that node, you can set the flat interface to the same # value as ``FLAT_NETWORK_BRIDGE``. This will stop the network hiccup from -# occuring. +# occurring. FLAT_INTERFACE=${FLAT_INTERFACE:-eth0} ## FIXME(ja): should/can we check that FLAT_INTERFACE is sane? @@ -274,17 +274,31 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} # SWIFT # ----- +# TODO: implement glance support +# TODO: add logging to different location. -# Location of SWIFT drives +# By default the location of swift drives and objects is located inside +# the swift source directory. SWIFT_LOCATION variable allow you to redefine +# this. SWIFT_LOCATION=${SWIFT_LOCATION:-${SWIFT_DIR}/data} -# Size of the loopback disks +# devstack will create a loop-back disk formatted as XFS to store the +# swift data. By default the disk size is 1 gigabyte. The variable +# SWIFT_LOOPBACK_DISK_SIZE specified in bytes allow you to change +# that. SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} -# Default partition power size (bigger is slower) +# The ring uses a configurable number of bits from a path’s MD5 hash as +# a partition index that designates a device. The number of bits kept +# from the hash is known as the partition power, and 2 to the partition +# power indicates the partition count. Partitioning the full MD5 hash +# ring allows other parts of the cluster to work in batches of items at +# once which ends up either more efficient or at least less complex than +# working with each item separately or the entire cluster all at once. +# By default we define 9 for the partition count (which mean 512). SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} -# Swift hash, this must be unique +# SWIFT_HASH is a random unique string for a swift cluster that can never change. read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH." # Keystone @@ -299,7 +313,7 @@ read_password ADMIN_PASSWORD "ENTER A PASSWORD TO USE FOR HORIZON AND KEYSTONE ( LOGFILE=${LOGFILE:-"$PWD/stack.sh.$$.log"} ( # So that errors don't compound we exit on any errors so you see only the -# first error that occured. +# first error that occurred. trap failed ERR failed() { local r=$? @@ -604,13 +618,14 @@ fi # Storage Service if [[ "$ENABLED_SERVICES" =~ "swift" ]];then + # We first do a bit of setup by creating the directories and + # changing the permissions so we can run it as our user. + USER_GROUP=$(id -g) - sudo mkdir -p ${SWIFT_LOCATION}/drives - sudo chown -R $USER: ${SWIFT_LOCATION}/drives - s=${SWIFT_LOCATION}/drives/sdb1 # Shortcut variable + sudo chown -R $USER:${USER_GROUP} ${SWIFT_LOCATION}/drives - # Create a loopback disk and format it with XFS. + # We then create a loopback disk and format it to XFS. if [[ ! -e ${SWIFT_LOCATION}/drives/images/swift.img ]];then mkdir -p ${SWIFT_LOCATION}/drives/images sudo touch ${SWIFT_LOCATION}/drives/images/swift.img @@ -621,18 +636,22 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/drives/images/swift.img fi - # Create and mount drives. - mkdir -p ${s} - if ! egrep -q "$s" /proc/mounts;then + # After the drive being created we mount the disk with a few mount + # options to make it most efficient as possible for swift. + mkdir -p ${SWIFT_LOCATION}/drives/sdb1 + if ! egrep -q ${SWIFT_LOCATION}/drives/sdb1 /proc/mounts;then sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \ - ${SWIFT_LOCATION}/drives/images/swift.img ${s} + ${SWIFT_LOCATION}/drives/images/swift.img ${SWIFT_LOCATION}/drives/sdb1 fi + # We then create link to that mounted location so swift would know + # where to go. for x in {1..4}; do sudo ln -sf $s/$x ${SWIFT_LOCATION}/$x; done - # Create directories + # We now have to emulate a few different servers into one we + # create all the directories needed for swift tmpd="" - for d in ${s}/{1..4} /etc/swift /etc/swift/{object,container,account}-server \ + for d in ${SWIFT_LOCATION}/drives/sdb1/{1..4} /etc/swift /etc/swift/{object,container,account}-server \ ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ;do [[ -d $d ]] && continue sudo install -o ${USER} -g $USER_GROUP -d $d @@ -640,28 +659,35 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then sudo chown -R $USER: ${SWIFT_LOCATION}/{1..4}/node - # Add rsync file + # Swift use rsync to syncronize between all the different + # partitions (which make more sense when you have a multi-node + # setup) we configure it with our version of rsync. sed -e "s/%GROUP%/${USER_GROUP}/;s/%USER%/$USER/;s,%SWIFT_LOCATION%,$SWIFT_LOCATION," $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync + # By default Swift will be installed with the tempauth middleware + # which has some default username and password if you have + # configured keystone it will checkout the directory. if [[ "$ENABLED_SERVICES" =~ "key" ]]; then swift_auth_server=keystone - # Temporary until we get this integrated in swift. + # We need a special version of bin/swift which understand the + # OpenStack api 2.0, we download it until this is getting + # integrated in swift. sudo curl -s -o/usr/local/bin/swift \ 'https://review.openstack.org/gitweb?p=openstack/swift.git;a=blob_plain;f=bin/swift;hb=48bfda6e2fdf3886c98bd15649887d54b9a2574e' else swift_auth_server=tempauth fi + # We do the install of the proxy-server and swift configuration + # replacing a few directives to match our configuration. sed "s/%USER%/$USER/;s/%SERVICE_TOKEN%/${SERVICE_TOKEN}/;s/%AUTH_SERVER%/${swift_auth_server}/" \ $FILES/swift-proxy-server.conf|sudo tee /etc/swift/proxy-server.conf - # Generate swift.conf, we need to have the swift-hash being random - # and unique. sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift.conf > /etc/swift/swift.conf # We need to generate a object/account/proxy configuration - # emulating 4 nodes on different ports we have a litle function + # emulating 4 nodes on different ports we have a little function # that help us doing that. function generate_swift_configuration() { local server_type=$1 @@ -681,23 +707,28 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then generate_swift_configuration container 6011 2 generate_swift_configuration account 6012 2 - # Install swift helper scripts to remake the rings and start all services. + # We create two helper scripts : + # + # - swift-remakerings + # Allow to recreate rings from scratch. + # - swift-startmain + # Restart your full cluster. + # sed -e "s/%SWIFT_PARTITION_POWER_SIZE%/$SWIFT_PARTITION_POWER_SIZE/" $FILES/swift-remakerings | \ sudo tee /usr/local/bin/swift-remakerings sudo install -m755 $FILES/swift-startmain /usr/local/bin/ sudo chmod +x /usr/local/bin/swift-* - # Start rsync + # We then can start rsync. sudo /etc/init.d/rsync restart || : - # Create ring + # Create our ring for the object/container/account. /usr/local/bin/swift-remakerings - # Start everything + # And now we launch swift-startmain to get our cluster running + # ready to be tested. /usr/local/bin/swift-startmain || : - # This should work (tempauth) - # swift -A http://127.0.0.1:8080/auth/v1.0 -U test:tester -K testing stat unset s swift_hash swift_auth_server tmpd fi @@ -851,7 +882,7 @@ function screen_it { screen -d -m -S stack -t stack sleep 1 -# launch the glance registery service +# launch the glance registry service if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf" fi @@ -908,7 +939,7 @@ screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/apache2/error.log" # 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 # -# Override ``IMAGE_URLS`` with a comma-seperated list of uec images. +# Override ``IMAGE_URLS`` with a comma-separated list of uec images. # # * **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 From e8d11580912fbf3580b268baa7cb0371d214a8ab Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 18:16:32 +0100 Subject: [PATCH 033/112] Missed one variable subst from the last commit. --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index df9d4b2..d012507 100755 --- a/stack.sh +++ b/stack.sh @@ -646,7 +646,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then # We then create link to that mounted location so swift would know # where to go. - for x in {1..4}; do sudo ln -sf $s/$x ${SWIFT_LOCATION}/$x; done + for x in {1..4}; do sudo ln -sf ${SWIFT_LOCATION}/drives/sdb1/$x ${SWIFT_LOCATION}/$x; done # We now have to emulate a few different servers into one we # create all the directories needed for swift From bbed01d3905fca1561b4071e7a2c2fffaf8aca88 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 18:22:43 +0100 Subject: [PATCH 034/112] Add swift to exercise.sh --- exercise.sh | 19 +++++++++++++++++++ stack.sh | 4 ---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/exercise.sh b/exercise.sh index 99b0f3b..c737bcc 100755 --- a/exercise.sh +++ b/exercise.sh @@ -191,3 +191,22 @@ nova secgroup-delete $SECGROUP # make sure that we can describe instances euca-describe-instances + +# Testing Swift +# ============= + +# Check if we have to swift via keystone +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD stat + +# We start by creating a test container +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD post testcontainer + +# add some files into it. +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD upload testcontainer /etc/issue + +# list them +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD list testcontainer + +# And we may want to delete them now that we have tested that +# everything works. +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD delete --all testcontainer diff --git a/stack.sh b/stack.sh index d012507..3571df5 100755 --- a/stack.sh +++ b/stack.sh @@ -1011,10 +1011,6 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then echo "examples on using novaclient command line is in exercise.sh" echo "the default users are: admin and demo" echo "the password: $ADMIN_PASSWORD" - if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then - echo "Swift: swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin:admin -K $ADMIN_PASSWORD stat" - fi - fi # indicate how long this took to run (bash maintained variable 'SECONDS') From 8d5334c729c3625b97a23ead01aac313c40c7db8 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 18:50:57 +0100 Subject: [PATCH 035/112] Remove dup and whitespaces. --- files/apts/swift | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/files/apts/swift b/files/apts/swift index 0776707..c52c68b 100644 --- a/files/apts/swift +++ b/files/apts/swift @@ -1,19 +1,17 @@ -curl -gcc +curl +gcc memcached -memcached -python-configobj +python-configobj python-coverage python-dev -python-eventlet -python-greenlet +python-eventlet +python-greenlet python-netifaces python-nose -python-nose -python-pastedeploy -python-setuptools -python-simplejson -python-webob +python-pastedeploy +python-setuptools +python-simplejson +python-webob python-xattr -sqlite3 -xfsprogs +sqlite3 +xfsprogs From 1298dccb3d1696916ee2028f87634623ac33abc8 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 19:09:04 +0100 Subject: [PATCH 036/112] Fix delete of container. --- exercise.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercise.sh b/exercise.sh index c737bcc..c49f124 100755 --- a/exercise.sh +++ b/exercise.sh @@ -209,4 +209,4 @@ swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWOR # And we may want to delete them now that we have tested that # everything works. -swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD delete --all testcontainer +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD delete testcontainer From 537ddff25987e79470613a605fdfc24629eaa862 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 2 Nov 2011 19:09:30 +0100 Subject: [PATCH 037/112] Move all swift files to $FILES/swift/ --- .../account-server.conf} | 0 .../container-server.conf} | 0 .../object-server.conf} | 0 .../proxy-server.conf} | 0 files/{swift-rsyncd.conf => swift/rsyncd.conf} | 0 files/{ => swift}/swift-remakerings | 0 files/{ => swift}/swift-startmain | 0 files/{ => swift}/swift.conf | 0 stack.sh | 14 +++++++------- 9 files changed, 7 insertions(+), 7 deletions(-) rename files/{swift-account-server.conf => swift/account-server.conf} (100%) rename files/{swift-container-server.conf => swift/container-server.conf} (100%) rename files/{swift-object-server.conf => swift/object-server.conf} (100%) rename files/{swift-proxy-server.conf => swift/proxy-server.conf} (100%) rename files/{swift-rsyncd.conf => swift/rsyncd.conf} (100%) rename files/{ => swift}/swift-remakerings (100%) mode change 100644 => 100755 rename files/{ => swift}/swift-startmain (100%) rename files/{ => swift}/swift.conf (100%) diff --git a/files/swift-account-server.conf b/files/swift/account-server.conf similarity index 100% rename from files/swift-account-server.conf rename to files/swift/account-server.conf diff --git a/files/swift-container-server.conf b/files/swift/container-server.conf similarity index 100% rename from files/swift-container-server.conf rename to files/swift/container-server.conf diff --git a/files/swift-object-server.conf b/files/swift/object-server.conf similarity index 100% rename from files/swift-object-server.conf rename to files/swift/object-server.conf diff --git a/files/swift-proxy-server.conf b/files/swift/proxy-server.conf similarity index 100% rename from files/swift-proxy-server.conf rename to files/swift/proxy-server.conf diff --git a/files/swift-rsyncd.conf b/files/swift/rsyncd.conf similarity index 100% rename from files/swift-rsyncd.conf rename to files/swift/rsyncd.conf diff --git a/files/swift-remakerings b/files/swift/swift-remakerings old mode 100644 new mode 100755 similarity index 100% rename from files/swift-remakerings rename to files/swift/swift-remakerings diff --git a/files/swift-startmain b/files/swift/swift-startmain similarity index 100% rename from files/swift-startmain rename to files/swift/swift-startmain diff --git a/files/swift.conf b/files/swift/swift.conf similarity index 100% rename from files/swift.conf rename to files/swift/swift.conf diff --git a/stack.sh b/stack.sh index 3571df5..d8be465 100755 --- a/stack.sh +++ b/stack.sh @@ -617,7 +617,7 @@ if [[ "$ENABLED_SERVICES" =~ "n-net" ]]; then fi # Storage Service -if [[ "$ENABLED_SERVICES" =~ "swift" ]];then +if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then # We first do a bit of setup by creating the directories and # changing the permissions so we can run it as our user. @@ -662,7 +662,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then # Swift use rsync to syncronize between all the different # partitions (which make more sense when you have a multi-node # setup) we configure it with our version of rsync. - sed -e "s/%GROUP%/${USER_GROUP}/;s/%USER%/$USER/;s,%SWIFT_LOCATION%,$SWIFT_LOCATION," $FILES/swift-rsyncd.conf | sudo tee /etc/rsyncd.conf + sed -e "s/%GROUP%/${USER_GROUP}/;s/%USER%/$USER/;s,%SWIFT_LOCATION%,$SWIFT_LOCATION," $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync # By default Swift will be installed with the tempauth middleware @@ -682,9 +682,9 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then # We do the install of the proxy-server and swift configuration # replacing a few directives to match our configuration. sed "s/%USER%/$USER/;s/%SERVICE_TOKEN%/${SERVICE_TOKEN}/;s/%AUTH_SERVER%/${swift_auth_server}/" \ - $FILES/swift-proxy-server.conf|sudo tee /etc/swift/proxy-server.conf + $FILES/swift/proxy-server.conf|sudo tee /etc/swift/proxy-server.conf - sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift.conf > /etc/swift/swift.conf + sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift/swift.conf > /etc/swift/swift.conf # We need to generate a object/account/proxy configuration # emulating 4 nodes on different ports we have a little function @@ -698,7 +698,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then for node_number in {1..4};do node_path=${SWIFT_LOCATION}/${node_number} sed -e "s,%USER%,$USER,;s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \ - $FILES/swift-${server_type}-server.conf > /etc/swift/${server_type}-server/${node_number}.conf + $FILES/swift/${server_type}-server.conf > /etc/swift/${server_type}-server/${node_number}.conf bind_port=$(( ${bind_port} + 10 )) log_facility=$(( ${log_facility} + 1 )) done @@ -714,9 +714,9 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]];then # - swift-startmain # Restart your full cluster. # - sed -e "s/%SWIFT_PARTITION_POWER_SIZE%/$SWIFT_PARTITION_POWER_SIZE/" $FILES/swift-remakerings | \ + sed -e "s/%SWIFT_PARTITION_POWER_SIZE%/$SWIFT_PARTITION_POWER_SIZE/" $FILES/swift/swift-remakerings | \ sudo tee /usr/local/bin/swift-remakerings - sudo install -m755 $FILES/swift-startmain /usr/local/bin/ + sudo install -m755 $FILES/swift/swift-startmain /usr/local/bin/ sudo chmod +x /usr/local/bin/swift-* # We then can start rsync. From bdc254eb38037be51f125f3b84f5d4c698e7c2ab Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 2 Nov 2011 23:57:12 -0500 Subject: [PATCH 038/112] emergency fix to not install openvswitch if user is not using quantum --- files/apts/quantum | 2 -- stack.sh | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 files/apts/quantum diff --git a/files/apts/quantum b/files/apts/quantum deleted file mode 100644 index f5008ad..0000000 --- a/files/apts/quantum +++ /dev/null @@ -1,2 +0,0 @@ -openvswitch-switch -openvswitch-datapath-dkms diff --git a/stack.sh b/stack.sh index 31194bc..19d7e84 100755 --- a/stack.sh +++ b/stack.sh @@ -787,6 +787,10 @@ fi # Quantum if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then + # Install deps + # FIXME add to file/apts/quantum, but don't install if not needed! + apt_get install -y openvswitch-switch openvswitch-datapath-dkms + # Create database for the plugin/agent if [[ "$Q_PLUGIN" = "openvswitch" ]]; then if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then From ae7f264970d0139831e899810995523e72a89dda Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 3 Nov 2011 00:03:53 -0500 Subject: [PATCH 039/112] remove -y since this is using apt_get --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 19d7e84..446661a 100755 --- a/stack.sh +++ b/stack.sh @@ -789,7 +789,7 @@ fi if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then # Install deps # FIXME add to file/apts/quantum, but don't install if not needed! - apt_get install -y openvswitch-switch openvswitch-datapath-dkms + apt_get install openvswitch-switch openvswitch-datapath-dkms # Create database for the plugin/agent if [[ "$Q_PLUGIN" = "openvswitch" ]]; then From 0c3b60ce00bb23926668289110917cebcf47e0e4 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 3 Nov 2011 00:07:55 -0500 Subject: [PATCH 040/112] typo --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 446661a..6a001c6 100755 --- a/stack.sh +++ b/stack.sh @@ -788,7 +788,7 @@ fi # Quantum if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then # Install deps - # FIXME add to file/apts/quantum, but don't install if not needed! + # FIXME add to files/apts/quantum, but don't install if not needed! apt_get install openvswitch-switch openvswitch-datapath-dkms # Create database for the plugin/agent From 9a766999c82458783da274ac9fc2ecb642f837a9 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 3 Nov 2011 00:23:51 -0500 Subject: [PATCH 041/112] fix quantum branch name - diablo does not exist --- stackrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stackrc b/stackrc index 75ec4aa..d5bf651 100644 --- a/stackrc +++ b/stackrc @@ -29,7 +29,7 @@ OPENSTACKX_BRANCH=diablo # quantum service QUANTUM_REPO=https://github.com/openstack/quantum -QUANTUM_BRANCH=diablo +QUANTUM_BRANCH=stable/diablo # Specify a comma-separated list of uec images to download and install into glance. IMAGE_URLS=http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-11.2_2.6.35-15_1.tar.gz From f7788ac680a5fa50a96d57b61fecc4c77a7cfca8 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Thu, 3 Nov 2011 10:00:06 +0100 Subject: [PATCH 042/112] Use stable/diablo for swift. --- stackrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stackrc b/stackrc index b6cf33d..b541711 100644 --- a/stackrc +++ b/stackrc @@ -4,7 +4,7 @@ NOVA_BRANCH=diablo # storage service SWIFT_REPO=https://github.com/openstack/swift.git -SWIFT_BRANCH=1.4.3 +SWIFT_BRANCH=stable/diablo # swift and keystone integration SWIFT_KEYSTONE_REPO=https://github.com/cloudbuilders/swift-keystone2.git From 3875015010110fc31368676d8885218ea5dca3b5 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Thu, 3 Nov 2011 09:17:06 +0100 Subject: [PATCH 043/112] Change SWIFT_LOCATION to SWIFT_DATA_LOCATION --- files/swift/rsyncd.conf | 24 ++++++++++++------------ stack.sh | 38 +++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/files/swift/rsyncd.conf b/files/swift/rsyncd.conf index 568f240..66215c7 100644 --- a/files/swift/rsyncd.conf +++ b/files/swift/rsyncd.conf @@ -6,74 +6,74 @@ address = 127.0.0.1 [account6012] max connections = 25 -path = %SWIFT_LOCATION%/1/node/ +path = %SWIFT_DATA_LOCATION%/1/node/ read only = false lock file = /var/lock/account6012.lock [account6022] max connections = 25 -path = %SWIFT_LOCATION%/2/node/ +path = %SWIFT_DATA_LOCATION%/2/node/ read only = false lock file = /var/lock/account6022.lock [account6032] max connections = 25 -path = %SWIFT_LOCATION%/3/node/ +path = %SWIFT_DATA_LOCATION%/3/node/ read only = false lock file = /var/lock/account6032.lock [account6042] max connections = 25 -path = %SWIFT_LOCATION%/4/node/ +path = %SWIFT_DATA_LOCATION%/4/node/ read only = false lock file = /var/lock/account6042.lock [container6011] max connections = 25 -path = %SWIFT_LOCATION%/1/node/ +path = %SWIFT_DATA_LOCATION%/1/node/ read only = false lock file = /var/lock/container6011.lock [container6021] max connections = 25 -path = %SWIFT_LOCATION%/2/node/ +path = %SWIFT_DATA_LOCATION%/2/node/ read only = false lock file = /var/lock/container6021.lock [container6031] max connections = 25 -path = %SWIFT_LOCATION%/3/node/ +path = %SWIFT_DATA_LOCATION%/3/node/ read only = false lock file = /var/lock/container6031.lock [container6041] max connections = 25 -path = %SWIFT_LOCATION%/4/node/ +path = %SWIFT_DATA_LOCATION%/4/node/ read only = false lock file = /var/lock/container6041.lock [object6010] max connections = 25 -path = %SWIFT_LOCATION%/1/node/ +path = %SWIFT_DATA_LOCATION%/1/node/ read only = false lock file = /var/lock/object6010.lock [object6020] max connections = 25 -path = %SWIFT_LOCATION%/2/node/ +path = %SWIFT_DATA_LOCATION%/2/node/ read only = false lock file = /var/lock/object6020.lock [object6030] max connections = 25 -path = %SWIFT_LOCATION%/3/node/ +path = %SWIFT_DATA_LOCATION%/3/node/ read only = false lock file = /var/lock/object6030.lock [object6040] max connections = 25 -path = %SWIFT_LOCATION%/4/node/ +path = %SWIFT_DATA_LOCATION%/4/node/ read only = false lock file = /var/lock/object6040.lock diff --git a/stack.sh b/stack.sh index e0a931d..ce3c163 100755 --- a/stack.sh +++ b/stack.sh @@ -293,9 +293,9 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} # TODO: add logging to different location. # By default the location of swift drives and objects is located inside -# the swift source directory. SWIFT_LOCATION variable allow you to redefine +# the swift source directory. SWIFT_DATA_LOCATION variable allow you to redefine # this. -SWIFT_LOCATION=${SWIFT_LOCATION:-${SWIFT_DIR}/data} +SWIFT_DATA_LOCATION=${SWIFT_DATA_LOCATION:-${SWIFT_DIR}/data} # devstack will create a loop-back disk formatted as XFS to store the # swift data. By default the disk size is 1 gigabyte. The variable @@ -640,47 +640,47 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then # changing the permissions so we can run it as our user. USER_GROUP=$(id -g) - sudo mkdir -p ${SWIFT_LOCATION}/drives - sudo chown -R $USER:${USER_GROUP} ${SWIFT_LOCATION}/drives + sudo mkdir -p ${SWIFT_DATA_LOCATION}/drives + sudo chown -R $USER:${USER_GROUP} ${SWIFT_DATA_LOCATION}/drives # We then create a loopback disk and format it to XFS. - if [[ ! -e ${SWIFT_LOCATION}/drives/images/swift.img ]];then - mkdir -p ${SWIFT_LOCATION}/drives/images - sudo touch ${SWIFT_LOCATION}/drives/images/swift.img - sudo chown $USER: ${SWIFT_LOCATION}/drives/images/swift.img + if [[ ! -e ${SWIFT_DATA_LOCATION}/drives/images/swift.img ]];then + mkdir -p ${SWIFT_DATA_LOCATION}/drives/images + sudo touch ${SWIFT_DATA_LOCATION}/drives/images/swift.img + sudo chown $USER: ${SWIFT_DATA_LOCATION}/drives/images/swift.img - dd if=/dev/zero of=${SWIFT_LOCATION}/drives/images/swift.img \ + dd if=/dev/zero of=${SWIFT_DATA_LOCATION}/drives/images/swift.img \ bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} - mkfs.xfs -f -i size=1024 ${SWIFT_LOCATION}/drives/images/swift.img + mkfs.xfs -f -i size=1024 ${SWIFT_DATA_LOCATION}/drives/images/swift.img fi # After the drive being created we mount the disk with a few mount # options to make it most efficient as possible for swift. - mkdir -p ${SWIFT_LOCATION}/drives/sdb1 - if ! egrep -q ${SWIFT_LOCATION}/drives/sdb1 /proc/mounts;then + mkdir -p ${SWIFT_DATA_LOCATION}/drives/sdb1 + if ! egrep -q ${SWIFT_DATA_LOCATION}/drives/sdb1 /proc/mounts;then sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \ - ${SWIFT_LOCATION}/drives/images/swift.img ${SWIFT_LOCATION}/drives/sdb1 + ${SWIFT_DATA_LOCATION}/drives/images/swift.img ${SWIFT_DATA_LOCATION}/drives/sdb1 fi # We then create link to that mounted location so swift would know # where to go. - for x in {1..4}; do sudo ln -sf ${SWIFT_LOCATION}/drives/sdb1/$x ${SWIFT_LOCATION}/$x; done + for x in {1..4}; do sudo ln -sf ${SWIFT_DATA_LOCATION}/drives/sdb1/$x ${SWIFT_DATA_LOCATION}/$x; done # We now have to emulate a few different servers into one we # create all the directories needed for swift tmpd="" - for d in ${SWIFT_LOCATION}/drives/sdb1/{1..4} /etc/swift /etc/swift/{object,container,account}-server \ - ${SWIFT_LOCATION}/{1..4}/node/sdb1 /var/run/swift ;do + for d in ${SWIFT_DATA_LOCATION}/drives/sdb1/{1..4} /etc/swift /etc/swift/{object,container,account}-server \ + ${SWIFT_DATA_LOCATION}/{1..4}/node/sdb1 /var/run/swift ;do [[ -d $d ]] && continue sudo install -o ${USER} -g $USER_GROUP -d $d done - sudo chown -R $USER: ${SWIFT_LOCATION}/{1..4}/node + sudo chown -R $USER: ${SWIFT_DATA_LOCATION}/{1..4}/node # Swift use rsync to syncronize between all the different # partitions (which make more sense when you have a multi-node # setup) we configure it with our version of rsync. - sed -e "s/%GROUP%/${USER_GROUP}/;s/%USER%/$USER/;s,%SWIFT_LOCATION%,$SWIFT_LOCATION," $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf + sed -e "s/%GROUP%/${USER_GROUP}/;s/%USER%/$USER/;s,%SWIFT_DATA_LOCATION%,$SWIFT_DATA_LOCATION," $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync # By default Swift will be installed with the tempauth middleware @@ -714,7 +714,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then local node_number for node_number in {1..4};do - node_path=${SWIFT_LOCATION}/${node_number} + node_path=${SWIFT_DATA_LOCATION}/${node_number} sed -e "s,%USER%,$USER,;s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \ $FILES/swift/${server_type}-server.conf > /etc/swift/${server_type}-server/${node_number}.conf bind_port=$(( ${bind_port} + 10 )) From 3a64826b67c4fac5995600316db243fb8c7d4697 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Thu, 3 Nov 2011 10:43:46 +0100 Subject: [PATCH 044/112] Redefine swift configs in SWIFT_DIR We still need a link in /etc/swift until #885595 is fixed. --- files/swift/account-server.conf | 1 + files/swift/container-server.conf | 1 + files/swift/object-server.conf | 1 + files/swift/proxy-server.conf | 1 + files/swift/swift-remakerings | 2 +- stack.sh | 27 +++++++++++++++++++-------- 6 files changed, 24 insertions(+), 9 deletions(-) diff --git a/files/swift/account-server.conf b/files/swift/account-server.conf index 920d45c..db0f097 100644 --- a/files/swift/account-server.conf +++ b/files/swift/account-server.conf @@ -4,6 +4,7 @@ mount_check = false bind_port = %BIND_PORT% user = %USER% log_facility = LOG_LOCAL%LOG_FACILITY% +swift_dir = %SWIFT_CONFIG_LOCATION% [pipeline:main] pipeline = account-server diff --git a/files/swift/container-server.conf b/files/swift/container-server.conf index 8d59bf2..bdc3e3a 100644 --- a/files/swift/container-server.conf +++ b/files/swift/container-server.conf @@ -4,6 +4,7 @@ mount_check = false bind_port = %BIND_PORT% user = %USER% log_facility = LOG_LOCAL%LOG_FACILITY% +swift_dir = %SWIFT_CONFIG_LOCATION% [pipeline:main] pipeline = container-server diff --git a/files/swift/object-server.conf b/files/swift/object-server.conf index 1b72e70..06fbffe 100644 --- a/files/swift/object-server.conf +++ b/files/swift/object-server.conf @@ -4,6 +4,7 @@ mount_check = false bind_port = %BIND_PORT% user = %USER% log_facility = LOG_LOCAL%LOG_FACILITY% +swift_dir = %SWIFT_CONFIG_LOCATION% [pipeline:main] pipeline = object-server diff --git a/files/swift/proxy-server.conf b/files/swift/proxy-server.conf index 6b7dd52..fe7e39b 100644 --- a/files/swift/proxy-server.conf +++ b/files/swift/proxy-server.conf @@ -2,6 +2,7 @@ bind_port = 8080 user = %USER% log_facility = LOG_LOCAL1 +swift_dir = %SWIFT_CONFIG_LOCATION% [pipeline:main] pipeline = healthcheck cache %AUTH_SERVER% proxy-server diff --git a/files/swift/swift-remakerings b/files/swift/swift-remakerings index 9343783..c65353c 100755 --- a/files/swift/swift-remakerings +++ b/files/swift/swift-remakerings @@ -1,6 +1,6 @@ #!/bin/bash -cd /etc/swift +cd %SWIFT_CONFIG_LOCATION% rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz diff --git a/stack.sh b/stack.sh index ce3c163..4d97e8d 100755 --- a/stack.sh +++ b/stack.sh @@ -297,6 +297,10 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292} # this. SWIFT_DATA_LOCATION=${SWIFT_DATA_LOCATION:-${SWIFT_DIR}/data} +# We are going to have the configuration files inside the source +# directory, change SWIFT_CONFIG_LOCATION if you want to adjust that. +SWIFT_CONFIG_LOCATION=${SWIFT_CONFIG_LOCATION:-${SWIFT_DIR}/config} + # devstack will create a loop-back disk formatted as XFS to store the # swift data. By default the disk size is 1 gigabyte. The variable # SWIFT_LOOPBACK_DISK_SIZE specified in bytes allow you to change @@ -669,14 +673,21 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then # We now have to emulate a few different servers into one we # create all the directories needed for swift tmpd="" - for d in ${SWIFT_DATA_LOCATION}/drives/sdb1/{1..4} /etc/swift /etc/swift/{object,container,account}-server \ + for d in ${SWIFT_DATA_LOCATION}/drives/sdb1/{1..4} \ + ${SWIFT_CONFIG_LOCATION}/{object,container,account}-server \ ${SWIFT_DATA_LOCATION}/{1..4}/node/sdb1 /var/run/swift ;do [[ -d $d ]] && continue sudo install -o ${USER} -g $USER_GROUP -d $d done - sudo chown -R $USER: ${SWIFT_DATA_LOCATION}/{1..4}/node + # We do want to make sure this is all owned by our user. + sudo chown -R $USER: ${SWIFT_DATA_LOCATION}/{1..4}/node + sudo chown -R $USER: ${SWIFT_CONFIG_LOCATION} + # swift-init has a bug using /etc/swift until bug #885595 is fixed + # we have to create a link + sudo ln -s ${SWIFT_CONFIG_LOCATION} /etc/swift + # Swift use rsync to syncronize between all the different # partitions (which make more sense when you have a multi-node # setup) we configure it with our version of rsync. @@ -699,10 +710,10 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then # We do the install of the proxy-server and swift configuration # replacing a few directives to match our configuration. - sed "s/%USER%/$USER/;s/%SERVICE_TOKEN%/${SERVICE_TOKEN}/;s/%AUTH_SERVER%/${swift_auth_server}/" \ - $FILES/swift/proxy-server.conf|sudo tee /etc/swift/proxy-server.conf + sed "s,%SWIFT_CONFIG_LOCATION%,${SWIFT_CONFIG_LOCATION},;s/%USER%/$USER/;s/%SERVICE_TOKEN%/${SERVICE_TOKEN}/;s/%AUTH_SERVER%/${swift_auth_server}/" \ + $FILES/swift/proxy-server.conf|sudo tee ${SWIFT_CONFIG_LOCATION}/proxy-server.conf - sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift/swift.conf > /etc/swift/swift.conf + sed -e "s/%SWIFT_HASH%/$SWIFT_HASH/" $FILES/swift/swift.conf > ${SWIFT_CONFIG_LOCATION}/swift.conf # We need to generate a object/account/proxy configuration # emulating 4 nodes on different ports we have a little function @@ -715,8 +726,8 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then for node_number in {1..4};do node_path=${SWIFT_DATA_LOCATION}/${node_number} - sed -e "s,%USER%,$USER,;s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \ - $FILES/swift/${server_type}-server.conf > /etc/swift/${server_type}-server/${node_number}.conf + sed -e "s,%SWIFT_CONFIG_LOCATION%,${SWIFT_CONFIG_LOCATION},;s,%USER%,$USER,;s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \ + $FILES/swift/${server_type}-server.conf > ${SWIFT_CONFIG_LOCATION}/${server_type}-server/${node_number}.conf bind_port=$(( ${bind_port} + 10 )) log_facility=$(( ${log_facility} + 1 )) done @@ -732,7 +743,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then # - swift-startmain # Restart your full cluster. # - sed -e "s/%SWIFT_PARTITION_POWER_SIZE%/$SWIFT_PARTITION_POWER_SIZE/" $FILES/swift/swift-remakerings | \ + sed -e "s,%SWIFT_CONFIG_LOCATION%,${SWIFT_CONFIG_LOCATION},;s/%SWIFT_PARTITION_POWER_SIZE%/$SWIFT_PARTITION_POWER_SIZE/" $FILES/swift/swift-remakerings | \ sudo tee /usr/local/bin/swift-remakerings sudo install -m755 $FILES/swift/swift-startmain /usr/local/bin/ sudo chmod +x /usr/local/bin/swift-* From df5e9949aa599523c3e97203a2a70f4fd9b2a094 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Thu, 3 Nov 2011 09:36:13 -0500 Subject: [PATCH 045/112] don't install memcached in general list --- stack.sh | 2 +- tools/build_libvirt.sh | 2 +- tools/build_lxc.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stack.sh b/stack.sh index e0a931d..066aff3 100755 --- a/stack.sh +++ b/stack.sh @@ -355,7 +355,7 @@ fi # install apt requirements apt_get update -apt_get install `cat $FILES/apts/* | cut -d\# -f1 | grep -Ev "mysql-server|rabbitmq-server"` +apt_get install `cat $FILES/apts/* | cut -d\# -f1 | grep -Ev "mysql-server|rabbitmq-server|memcached"` # install python requirements sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*` diff --git a/tools/build_libvirt.sh b/tools/build_libvirt.sh index fc281d3..3de8cc5 100755 --- a/tools/build_libvirt.sh +++ b/tools/build_libvirt.sh @@ -145,7 +145,7 @@ function git_clone { # Make sure that base requirements are installed cp /etc/resolv.conf $COPY_DIR/etc/resolv.conf chroot $COPY_DIR apt-get update -chroot $COPY_DIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` +chroot $COPY_DIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server|memcached)"` chroot $COPY_DIR apt-get install -y --download-only rabbitmq-server libvirt-bin mysql-server chroot $COPY_DIR pip install `cat files/pips/*` diff --git a/tools/build_lxc.sh b/tools/build_lxc.sh index a2c5a22..13b98df 100755 --- a/tools/build_lxc.sh +++ b/tools/build_lxc.sh @@ -125,7 +125,7 @@ fi # Make sure that base requirements are installed chroot $CACHEDIR apt-get update -chroot $CACHEDIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` +chroot $CACHEDIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server|memcached)"` chroot $CACHEDIR apt-get install -y --download-only rabbitmq-server libvirt-bin mysql-server chroot $CACHEDIR pip install `cat files/pips/*` From b2857e4df6b4a13b2ba0b05073ed44dbe71eab26 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Thu, 3 Nov 2011 16:19:14 +0100 Subject: [PATCH 046/112] Only ask for swift_hash if swift is enabled. --- stack.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/stack.sh b/stack.sh index 066aff3..d1e35c0 100755 --- a/stack.sh +++ b/stack.sh @@ -313,9 +313,13 @@ SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} # By default we define 9 for the partition count (which mean 512). SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} -# SWIFT_HASH is a random unique string for a swift cluster that can never change. -read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH." - +# We only ask for Swift Hash if we have enabled swift service. +if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then + # SWIFT_HASH is a random unique string for a swift cluster that + # can never change. + read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH." +fi + # Keystone # -------- From 53ca603b4590b59392511c61fa152cdabc9a43f8 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Thu, 3 Nov 2011 17:04:26 +0100 Subject: [PATCH 047/112] Only run swift excercise when swift is enabled. --- exercise.sh | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/exercise.sh b/exercise.sh index c49f124..77d3a3b 100755 --- a/exercise.sh +++ b/exercise.sh @@ -192,21 +192,23 @@ nova secgroup-delete $SECGROUP # make sure that we can describe instances euca-describe-instances -# Testing Swift -# ============= +if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then + # Testing Swift + # ============= -# Check if we have to swift via keystone -swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD stat + # Check if we have to swift via keystone + swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD stat -# We start by creating a test container -swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD post testcontainer + # We start by creating a test container + swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD post testcontainer -# add some files into it. -swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD upload testcontainer /etc/issue + # add some files into it. + swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD upload testcontainer /etc/issue -# list them -swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD list testcontainer + # list them + swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD list testcontainer -# And we may want to delete them now that we have tested that -# everything works. -swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD delete testcontainer + # And we may want to delete them now that we have tested that + # everything works. + swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD delete testcontainer +fi From 23324e94e2f44eb685f7c3decf7ab75d3ed4c60c Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 3 Nov 2011 13:47:15 -0700 Subject: [PATCH 048/112] create the uec cachedir if it doesn't exist. Otherwise build_libvirt fails on clean installs --- tools/get_uec_image.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/get_uec_image.sh b/tools/get_uec_image.sh index 3d62bba..cb59b9a 100755 --- a/tools/get_uec_image.sh +++ b/tools/get_uec_image.sh @@ -114,6 +114,7 @@ trap cleanup SIGHUP SIGINT SIGTERM # Get the UEC image UEC_NAME=$DIST_NAME-server-cloudimg-amd64 if [ ! -e $CACHEDIR/$UEC_NAME-disk1.img ]; then + mkdir -p $CACHEDIR (cd $CACHEDIR && wget -N http://uec-images.ubuntu.com/$DIST_NAME/current/$UEC_NAME-disk1.img) fi From 1468133003a7f380dc9ae60328d5c187c975ff10 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Thu, 3 Nov 2011 15:52:37 -0500 Subject: [PATCH 049/112] only download - don't install apts - also pip install --- tools/build_libvirt.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/build_libvirt.sh b/tools/build_libvirt.sh index 3de8cc5..7efabbb 100755 --- a/tools/build_libvirt.sh +++ b/tools/build_libvirt.sh @@ -145,9 +145,8 @@ function git_clone { # Make sure that base requirements are installed cp /etc/resolv.conf $COPY_DIR/etc/resolv.conf chroot $COPY_DIR apt-get update -chroot $COPY_DIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server|memcached)"` -chroot $COPY_DIR apt-get install -y --download-only rabbitmq-server libvirt-bin mysql-server -chroot $COPY_DIR pip install `cat files/pips/*` +chroot $COPY_DIR apt-get install -y --download-only `cat files/apts/* | cut -d\# -f1` +chroot $COPY_DIR apt-get install -y --force-yes `cat files/apts/general` # Clean out code repos if directed to do so if [ "$CLEAN" = "1" ]; then From b244ef34d581f14ed8889c61ef5cd2fa06e8f5fa Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Thu, 3 Nov 2011 18:19:21 -0400 Subject: [PATCH 050/112] Use $DEST for volume backing file. --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 976872a..32b4539 100755 --- a/stack.sh +++ b/stack.sh @@ -778,7 +778,7 @@ if [[ "$ENABLED_SERVICES" =~ "n-vol" ]]; then # By default, the backing file is 2G in size, and is stored in /opt/stack. # if ! sudo vgdisplay | grep -q nova-volumes; then - VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-/opt/stack/nova-volumes-backing-file} + VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-$DEST/nova-volumes-backing-file} VOLUME_BACKING_FILE_SIZE=${VOLUME_BACKING_FILE_SIZE:-2052M} truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE DEV=`sudo losetup -f --show $VOLUME_BACKING_FILE` From ca2c047b6eb28cebba25870f3dda9e6eae2ab1ea Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 3 Nov 2011 16:29:32 -0700 Subject: [PATCH 051/112] fix caching so that there is the ability to download services without installing them. This is done with a #NOPRIME comment in apts/files/ --- files/apts/nova | 6 +++--- files/apts/swift | 2 +- tools/build_libvirt.sh | 4 ++-- tools/build_lxc.sh | 4 ++-- tools/build_nfs.sh | 5 +++-- tools/build_ramdisk.sh | 3 ++- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/files/apts/nova b/files/apts/nova index 17eb877..405d53b 100644 --- a/files/apts/nova +++ b/files/apts/nova @@ -2,7 +2,7 @@ dnsmasq-base kpartx parted arping # used for send_arp_for_ha option in nova-network -mysql-server +mysql-server # NOPRIME python-mysqldb kvm gawk @@ -11,10 +11,10 @@ ebtables sqlite3 sudo kvm -libvirt-bin +libvirt-bin # NOPRIME vlan curl -rabbitmq-server +rabbitmq-server # NOPRIME socat # used by ajaxterm python-mox python-paste diff --git a/files/apts/swift b/files/apts/swift index c52c68b..f298377 100644 --- a/files/apts/swift +++ b/files/apts/swift @@ -1,6 +1,6 @@ curl gcc -memcached +memcached # NOPRIME python-configobj python-coverage python-dev diff --git a/tools/build_libvirt.sh b/tools/build_libvirt.sh index 3de8cc5..d192879 100755 --- a/tools/build_libvirt.sh +++ b/tools/build_libvirt.sh @@ -145,8 +145,8 @@ function git_clone { # Make sure that base requirements are installed cp /etc/resolv.conf $COPY_DIR/etc/resolv.conf chroot $COPY_DIR apt-get update -chroot $COPY_DIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server|memcached)"` -chroot $COPY_DIR apt-get install -y --download-only rabbitmq-server libvirt-bin mysql-server +chroot $COPY_DIR apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1` +chroot $COPY_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` chroot $COPY_DIR pip install `cat files/pips/*` # Clean out code repos if directed to do so diff --git a/tools/build_lxc.sh b/tools/build_lxc.sh index 13b98df..9d8ce92 100755 --- a/tools/build_lxc.sh +++ b/tools/build_lxc.sh @@ -125,8 +125,8 @@ fi # Make sure that base requirements are installed chroot $CACHEDIR apt-get update -chroot $CACHEDIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server|memcached)"` -chroot $CACHEDIR apt-get install -y --download-only rabbitmq-server libvirt-bin mysql-server +chroot $CACHEDIR apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1` +chroot $CACHEDIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` chroot $CACHEDIR pip install `cat files/pips/*` # Clean out code repos if directed to do so diff --git a/tools/build_nfs.sh b/tools/build_nfs.sh index 5c591e4..39a2cf0 100755 --- a/tools/build_nfs.sh +++ b/tools/build_nfs.sh @@ -32,8 +32,9 @@ fi # prime natty with as many apt/pips as we can if [ ! -d $CHROOTCACHE/natty-dev ]; then rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/ - chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` - chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*` + chroot $CHROOTCACHE apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1` + chroot $CHROOTCACHE apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` + chroot $CHROOTCACHE pip install `cat files/pips/*` # Create a stack user that is a member of the libvirtd group so that stack # is able to interact with libvirt. diff --git a/tools/build_ramdisk.sh b/tools/build_ramdisk.sh index 187112a..2c914dc 100755 --- a/tools/build_ramdisk.sh +++ b/tools/build_ramdisk.sh @@ -113,7 +113,8 @@ if [ ! -r $DEV_FILE ]; then mount -t ext4 ${NBD}p1 $MNTDIR cp -p /etc/resolv.conf $MNTDIR/etc/resolv.conf - chroot $MNTDIR apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` + chroot $MNTDIR apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1` + chroot $MNTDIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` chroot $MNTDIR pip install `cat files/pips/*` # Create a stack user that is a member of the libvirtd group so that stack From 49946a14b5c4ef290397a8ffd4254f2ff3c0797e Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Fri, 4 Nov 2011 15:09:41 -0500 Subject: [PATCH 052/112] proper path for arping in sudoers --- files/sudo/nova | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/sudo/nova b/files/sudo/nova index 2ce1aac..62685b3 100644 --- a/files/sudo/nova +++ b/files/sudo/nova @@ -41,7 +41,7 @@ Cmnd_Alias NOVACMDS = /bin/chmod /var/lib/nova/tmp/*/root/.ssh, \ /usr/bin/socat, \ /sbin/parted, \ /usr/sbin/dnsmasq, \ - /usr/bin/arping + /usr/sbin/arping %USER% ALL = (root) NOPASSWD: SETENV: NOVACMDS From 346e49131b40d3dc492ce2ad193a3e316839631e Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Sat, 5 Nov 2011 00:22:47 -0500 Subject: [PATCH 053/112] add script that demonstrates separation of head abd compute roles when using xen --- tools/xen/build_domU.sh | 23 ++++++++++++++--------- tools/xen/build_domU_multi.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 9 deletions(-) create mode 100755 tools/xen/build_domU_multi.sh diff --git a/tools/xen/build_domU.sh b/tools/xen/build_domU.sh index 65049af..9804255 100755 --- a/tools/xen/build_domU.sh +++ b/tools/xen/build_domU.sh @@ -226,16 +226,21 @@ mkdir -p /boot/guest SR_UUID=`xe sr-list --minimal name-label="Local storage"` xe sr-param-set uuid=$SR_UUID other-config:i18n-key=local-storage -# Uninstall previous runs -xe vm-list --minimal name-label="$LABEL" | xargs ./scripts/uninstall-os-vpx.sh -# Destroy any instances that were launched -for uuid in `xe vm-list | grep -1 instance | grep uuid | sed "s/.*\: //g"`; do - echo "Shutting down nova instance $uuid" - xe vm-unpause uuid=$uuid || true - xe vm-shutdown uuid=$uuid - xe vm-destroy uuid=$uuid -done +# Shutdown previous runs +DO_SHUTDOWN=${DO_SHUTDOWN:-1} +if [ "$DO_SHUTDOWN" = "1" ]; then + # Uninstall previous runs + xe vm-list --minimal name-label="$LABEL" | xargs ./scripts/uninstall-os-vpx.sh + + # Destroy any instances that were launched + for uuid in `xe vm-list | grep -1 instance | grep uuid | sed "s/.*\: //g"`; do + echo "Shutting down nova instance $uuid" + xe vm-unpause uuid=$uuid || true + xe vm-shutdown uuid=$uuid + xe vm-destroy uuid=$uuid + done +fi # Path to head xva. By default keep overwriting the same one to save space USE_SEPARATE_XVAS=${USE_SEPARATE_XVAS:-0} diff --git a/tools/xen/build_domU_multi.sh b/tools/xen/build_domU_multi.sh new file mode 100755 index 0000000..130bec5 --- /dev/null +++ b/tools/xen/build_domU_multi.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# Echo commands +set -o xtrace + +# Head node host, which runs glance, api, keystone +HEAD_PUB_IP=${HEAD_PUB_IP:-192.168.1.57} +HEAD_MGT_IP=${HEAD_MGT_IP:-172.16.100.57} + +COMPUTE_PUB_IP=${COMPUTE_PUB_IP:-192.168.1.58} +COMPUTE_MGT_IP=${COMPUTE_MGT_IP:-172.16.100.58} + +# Networking params +FLOATING_RANGE=${FLOATING_RANGE:-192.168.1.196/30} + +# Variables common amongst all hosts in the cluster +COMMON_VARS="$STACKSH_PARAMS MYSQL_HOST=$HEAD_MGT_IP RABBIT_HOST=$HEAD_MGT_IP GLANCE_HOSTPORT=$HEAD_MGT_IP:9292 FLOATING_RANGE=$FLOATING_RANGE" + +# Helper to launch containers +function build_domU { + GUEST_NAME=$1 PUB_IP=$2 MGT_IP=$3 DO_SHUTDOWN=$4 TERMINATE=$TERMINATE STACKSH_PARAMS="$COMMON_VARS $5" ./build_domU.sh +} + +# Launch the head node - headnode uses a non-ip domain name, +# because rabbit won't launch with an ip addr hostname :( +build_domU HEADNODE $HEAD_PUB_IP $HEAD_MGT_IP 1 "ENABLED_SERVICES=g-api,g-reg,key,n-api,n-sch,n-vnc,horizon,mysql,rabbit" + +# Wait till the head node is up +while ! curl -L http://$HEAD_PUB_IP | grep -q username; do + echo "Waiting for head node ($HEAD_PUB_IP) to start..." + sleep 5 +done + +# Build the HA compute host +build_domU $COMPUTE_PUB_IP $COMPUTE_PUB_IP $COMPUTE_MGT_IP 0 "ENABLED_SERVICES=n-cpu,n-net,n-api" From 40b5737c4d00c0ba45989e98fb36dff102ffad4a Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Sat, 5 Nov 2011 00:30:07 -0500 Subject: [PATCH 054/112] fix comment --- tools/xen/build_domU.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/xen/build_domU.sh b/tools/xen/build_domU.sh index 9804255..6362849 100755 --- a/tools/xen/build_domU.sh +++ b/tools/xen/build_domU.sh @@ -230,7 +230,7 @@ xe sr-param-set uuid=$SR_UUID other-config:i18n-key=local-storage # Shutdown previous runs DO_SHUTDOWN=${DO_SHUTDOWN:-1} if [ "$DO_SHUTDOWN" = "1" ]; then - # Uninstall previous runs + # Shutdown all domU's that created previously xe vm-list --minimal name-label="$LABEL" | xargs ./scripts/uninstall-os-vpx.sh # Destroy any instances that were launched From 2bbcd682aaa615957ae3c4758cdc5ac9aab91e83 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Sat, 5 Nov 2011 16:19:03 -0500 Subject: [PATCH 055/112] Add SERVICE_TIMEOUT --- stack.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/stack.sh b/stack.sh index 32b4539..6b3e09c 100755 --- a/stack.sh +++ b/stack.sh @@ -175,6 +175,9 @@ if [ ! -n "$HOST_IP" ]; then HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'` fi +# Service startup timeout +SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60} + # Generic helper to configure passwords function read_password { set +o xtrace @@ -926,7 +929,7 @@ fi if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf" echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..." - if ! timeout 60 sh -c "while ! wget -q -O- http://$GLANCE_HOSTPORT; do sleep 1; done"; then + if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget -q -O- http://$GLANCE_HOSTPORT; do sleep 1; done"; then echo "g-api did not start" exit 1 fi @@ -936,7 +939,7 @@ fi if [[ "$ENABLED_SERVICES" =~ "key" ]]; then screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF -d" echo "Waiting for keystone to start..." - if ! timeout 60 sh -c "while ! wget -q -O- http://127.0.0.1:5000; do sleep 1; done"; then + if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget -q -O- http://127.0.0.1:5000; do sleep 1; done"; then echo "keystone did not start" exit 1 fi @@ -946,7 +949,7 @@ fi if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then screen_it n-api "cd $NOVA_DIR && $NOVA_DIR/bin/nova-api" echo "Waiting for nova-api to start..." - if ! timeout 60 sh -c "while ! wget -q -O- http://127.0.0.1:8774; do sleep 1; done"; then + if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget -q -O- http://127.0.0.1:8774; do sleep 1; done"; then echo "nova-api did not start" exit 1 fi From 43392f74b85f2ca74bdfd2b6268d0fb46cf57423 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Sat, 5 Nov 2011 16:55:15 -0500 Subject: [PATCH 056/112] Beef up error handling (#886666) --- tools/get_uec_image.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/get_uec_image.sh b/tools/get_uec_image.sh index cb59b9a..7b95aab 100755 --- a/tools/get_uec_image.sh +++ b/tools/get_uec_image.sh @@ -14,6 +14,9 @@ MIN_PKGS=${MIN_PKGS:-"apt-utils gpgv openssh-server"} TOOLS_DIR=$(cd $(dirname "$0") && pwd) TOP_DIR=`cd $TOOLS_DIR/..; pwd` +# exit on error to stop unexpected errors +set -o errexit + usage() { echo "Usage: $0 - Prepare Ubuntu images" echo "" @@ -44,6 +47,14 @@ cleanup() { trap 2; kill -2 $$ } +# apt-get wrapper to just get arguments set correctly +function apt_get() { + local sudo="sudo" + [ "$(id -u)" = "0" ] && sudo="env" + $sudo DEBIAN_FRONTEND=noninteractive apt-get \ + --option "Dpkg::Options::=--force-confold" --assume-yes "$@" +} + while getopts f:hmr: c; do case $c in f) FORMAT=$OPTARG @@ -107,7 +118,14 @@ case $DIST_NAME in ;; esac -trap cleanup SIGHUP SIGINT SIGTERM +trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT + +# Check for dependencies + +if [ ! -x "`which qemu-img`" -o ! -x "`which qemu-nbd`" ]; then + # Missing KVM? + apt_get install qemu-kvm +fi # Prepare the base image From 8b3eb5ffe31c6a112e9461f16c6955f303018f17 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 16:05:14 -0700 Subject: [PATCH 057/112] work towards simpiler uec --- tools/build_uec.sh | 198 ++++++++++++++++++++++++++++++++++++++++++++ tools/uec/meta-data | 19 +++++ tools/uec/user-data | 32 +++++++ 3 files changed, 249 insertions(+) create mode 100755 tools/build_uec.sh create mode 100644 tools/uec/meta-data create mode 100644 tools/uec/user-data diff --git a/tools/build_uec.sh b/tools/build_uec.sh new file mode 100755 index 0000000..aae4fb8 --- /dev/null +++ b/tools/build_uec.sh @@ -0,0 +1,198 @@ +#!/usr/bin/env bash + +# Make sure that we have the proper version of ubuntu +UBUNTU_VERSION=`cat /etc/lsb-release | grep CODENAME | sed 's/.*=//g'` +if [ ! "oneiric" = "$UBUNTU_VERSION" ]; then + if [ ! "natty" = "$UBUNTU_VERSION" ]; then + echo "This script only works with oneiric and natty" + exit 1 + fi +fi + +# exit on error to stop unexpected errors +set -o errexit + +# Keep track of the current directory +TOOLS_DIR=$(cd $(dirname "$0") && pwd) +TOP_DIR=`cd $TOOLS_DIR/..; pwd` + +# Abort if localrc is not set +if [ ! -e $TOP_DIR/localrc ]; then + echo "You must have a localrc with ALL necessary passwords defined before proceeding." + echo "See stack.sh for required passwords." + exit 1 +fi + +# Install deps if needed +dpkg -l kvm libvirt-bin kpartx || apt-get install -y --force-yes kvm libvirt-bin kpartx + +# Where to store files and instances +WORK_DIR=${WORK_DIR:-/opt/kvmstack} + +# Where to store images +IMAGES_DIR=$WORK_DIR/images + +# Original version of built image +DIST_NAME=${DIST_NAME:oneiric} +UEC_NAME=$DIST_NAME-server-cloudimg-amd64 +UEC_URL=http://uec-images.ubuntu.com/$DIST_NAME/current/$UEC_NAME-disk1.img +BASE_IMAGE=$IMAGES_DIR/$DIST_NAME.raw + +# download the base uec image if we haven't already +if [ ! -e $BASE_IMAGE ]; then + mkdir -p $IMAGES_DIR + curl $UEC_URL -O $BASE_IMAGE +fi + +cd $TOP_DIR + +# Source params +source ./stackrc + +# Configure the root password of the vm to be the same as ``ADMIN_PASSWORD`` +ROOT_PASSWORD=${ADMIN_PASSWORD:-password} + +# Name of our instance, used by libvirt +GUEST_NAME=${GUEST_NAME:-devstack} + +# Mop up after previous runs +virsh destroy $GUEST_NAME || true + +# Where this vm is stored +VM_DIR=$WORK_DIR/instances/$GUEST_NAME + +# Create vm dir and remove old disk +mkdir -p $VM_DIR +rm -f $VM_DIR/disk.img + +# Create a copy of the base image +qemu-img create -f qcow2 -b ${BASE_IMAGE} $VM_DIR/disk.img + +# Back to devstack +cd $TOP_DIR + +GUEST_NETWORK=${GUEST_NETWORK:-1} +GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes} +GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50} +GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24} +GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0} +GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1} +GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"} +GUEST_RAM=${GUEST_RAM:-1524288} +GUEST_CORES=${GUEST_CORES:-1} + +# libvirt.xml configuration +NET_XML=$VM_DIR/net.xml +cat > $NET_XML < + devstack-$GUEST_NETWORK + + + + +EOF + +if [[ "$GUEST_RECREATE_NET" == "yes" ]]; then + virsh net-destroy devstack-$GUEST_NETWORK || true + virsh net-create $VM_DIR/net.xml +fi + +# libvirt.xml configuration +LIBVIRT_XML=$VM_DIR/libvirt.xml +cat > $LIBVIRT_XML < + $GUEST_NAME + $GUEST_RAM + + hvm + + $VM_DIR/kernel + root=/dev/vda ro init=/usr/lib/cloud-init/uncloud-init ds=nocloud ubuntu-pass=ubuntu + + + + + + $GUEST_CORES + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +EOF + +# Create the instance +cd $VM_DIR && virsh create libvirt.xml + +# Tail the console log till we are done +WAIT_TILL_LAUNCH=${WAIT_TILL_LAUNCH:-1} +if [ "$WAIT_TILL_LAUNCH" = "1" ]; then + # Done creating the container, let's tail the log + echo + echo "=============================================================" + echo " -- YAY! --" + echo "=============================================================" + echo + echo "We're done launching the vm, about to start tailing the" + echo "stack.sh log. It will take a second or two to start." + echo + echo "Just CTRL-C at any time to stop tailing." + + while [ ! -e "$VM_DIR/console.log" ]; do + sleep 1 + done + + tail -F $VM_DIR/console.log & + + TAIL_PID=$! + + function kill_tail() { + kill $TAIL_PID + exit 1 + } + + # Let Ctrl-c kill tail and exit + trap kill_tail SIGINT + + set +o xtrace + + echo "Waiting stack.sh to finish..." + while ! cat $VM_DIR/console.log | grep -q 'All done' ; do + sleep 1 + done + + set -o xtrace + + kill $TAIL_PID + + if ! grep -q "^stack.sh completed in" $VM_DIR/console.log; then + exit 1 + fi + echo "" + echo "Finished - Zip-a-dee Doo-dah!" +fi diff --git a/tools/uec/meta-data b/tools/uec/meta-data new file mode 100644 index 0000000..d068195 --- /dev/null +++ b/tools/uec/meta-data @@ -0,0 +1,19 @@ +#ami-id: ami-fd4aa494 +#ami-launch-index: '0' +#ami-manifest-path: ubuntu-images-us/ubuntu-lucid-10.04-amd64-server-20100427.1.manifest.xml +#block-device-mapping: {ami: sda1, ephemeral0: sdb, ephemeral1: sdc, root: /dev/sda1} +hostname: smoser-sys +#instance-action: none +instance-id: i-87018aed +instance-type: m1.large +#kernel-id: aki-c8b258a1 +local-hostname: smoser-sys.mosers.us +#local-ipv4: 10.223.26.178 +#placement: {availability-zone: us-east-1d} +#public-hostname: ec2-184-72-174-120.compute-1.amazonaws.com +#public-ipv4: 184.72.174.120 +#public-keys: +# ec2-keypair.us-east-1: [ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCD9dlT00vOUC8Ttq6YH8RzUCVqPQl6HaSfWSTKYnZiVCpTBj1CaRZPLRLmkSB9Nziy4aRJa/LZMbBHXytQKnB1psvNknqC2UNlrXXMk+Vx5S4vg21MXYYimK4uZEY0Qz29QUiTyNsx18jpAaF4ocUpTpRhxPEBCcSCDmMbc27MU2XuTbasM2NjW/w0bBF3ZFhdH68dZICXdTxS2jUrtrCnc1D/QXVZ5kQO3jsmSyJg8E0nE+6Onpx2YRoVRSwjpGzVZ+BlXPnN5xBREBG8XxzhNFHJbek+RgK5TfL+k4yD4XhnVZuZu53cBAFhj+xPKhtisSd+YmaEq+Jt9uS0Ekd5 +# ec2-keypair.us-east-1, ''] +#reservation-id: r-e2225889 +#security-groups: default diff --git a/tools/uec/user-data b/tools/uec/user-data new file mode 100644 index 0000000..f9fa477 --- /dev/null +++ b/tools/uec/user-data @@ -0,0 +1,32 @@ +#cloud-config +#apt_update: false +#apt_upgrade: true +#packages: [ bzr, pastebinit, ubuntu-dev-tools, ccache, bzr-builddeb, vim-nox, git-core, lftp ] + +apt_sources: + - source: ppa:smoser/ppa + +disable_root: True + +mounts: + - [ ephemeral0, None ] + - [ swap, None ] + +ssh_import_id: [smoser ] + +sm_misc: + - &user_setup | + set -x; exec > ~/user_setup.log 2>&1 + echo "starting at $(date -R)" + echo "set -o vi" >> ~/.bashrc + cat >> ~/.profile < ~/runcmd.log' ] + - [ sudo, -Hu, ubuntu, sh, -c, 'read up sleep < /proc/uptime; echo $(date): runcmd up at $up | tee -a ~/runcmd.log' ] + - [ sudo, -Hu, ubuntu, sh, -c, *user_setup ] + +password: passw0rd +chpasswd: { expire: False } From 5f039326268cf452aa45c011b8ec4552fb49a578 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Sat, 5 Nov 2011 16:12:20 -0700 Subject: [PATCH 058/112] make some changes prepping for trunk branch --- files/nova-api-paste.ini | 127 +++++++++++++++++++++++++++++++++++++++ stack.sh | 34 ++++++----- 2 files changed, 145 insertions(+), 16 deletions(-) create mode 100644 files/nova-api-paste.ini diff --git a/files/nova-api-paste.ini b/files/nova-api-paste.ini new file mode 100644 index 0000000..0b56c9f --- /dev/null +++ b/files/nova-api-paste.ini @@ -0,0 +1,127 @@ +####### +# EC2 # +####### + +[composite:ec2] +use = egg:Paste#urlmap +/: ec2versions +/services/Cloud: ec2cloud +/services/Admin: ec2admin +/latest: ec2metadata +/2007-01-19: ec2metadata +/2007-03-01: ec2metadata +/2007-08-29: ec2metadata +/2007-10-10: ec2metadata +/2007-12-15: ec2metadata +/2008-02-01: ec2metadata +/2008-09-01: ec2metadata +/2009-04-04: ec2metadata +/1.0: ec2metadata + +[pipeline:ec2cloud] +pipeline = logrequest totoken authtoken keystonecontext cloudrequest authorizer ec2executor + +[pipeline:ec2admin] +pipeline = logrequest totoken authtoken keystonecontext adminrequest authorizer ec2executor + +[pipeline:ec2metadata] +pipeline = logrequest ec2md + +[pipeline:ec2versions] +pipeline = logrequest ec2ver + +[filter:logrequest] +paste.filter_factory = nova.api.ec2:RequestLogging.factory + +[filter:ec2lockout] +paste.filter_factory = nova.api.ec2:Lockout.factory + +[filter:totoken] +paste.filter_factory = keystone.middleware.ec2_token:EC2Token.factory + +[filter:ec2noauth] +paste.filter_factory = nova.api.ec2:NoAuth.factory + +[filter:authenticate] +paste.filter_factory = nova.api.ec2:Authenticate.factory + +[filter:cloudrequest] +controller = nova.api.ec2.cloud.CloudController +paste.filter_factory = nova.api.ec2:Requestify.factory + +[filter:adminrequest] +controller = nova.api.ec2.admin.AdminController +paste.filter_factory = nova.api.ec2:Requestify.factory + +[filter:authorizer] +paste.filter_factory = nova.api.ec2:Authorizer.factory + +[app:ec2executor] +paste.app_factory = nova.api.ec2:Executor.factory + +[app:ec2ver] +paste.app_factory = nova.api.ec2:Versions.factory + +[app:ec2md] +paste.app_factory = nova.api.ec2.metadatarequesthandler:MetadataRequestHandler.factory + +############# +# Openstack # +############# + +[composite:osapi] +use = egg:Paste#urlmap +/: osversions +/v1.0: openstackapi10 +/v1.1: openstackapi11 + +[pipeline:openstackapi10] +pipeline = faultwrap authtoken keystonecontext ratelimit osapiapp10 + +[pipeline:openstackapi11] +pipeline = faultwrap authtoken keystonecontext ratelimit extensions osapiapp11 + +[filter:faultwrap] +paste.filter_factory = nova.api.openstack:FaultWrapper.factory + +[filter:auth] +paste.filter_factory = nova.api.openstack.auth:AuthMiddleware.factory + +[filter:noauth] +paste.filter_factory = nova.api.openstack.auth:NoAuthMiddleware.factory + +[filter:ratelimit] +paste.filter_factory = nova.api.openstack.limits:RateLimitingMiddleware.factory + +[filter:extensions] +paste.filter_factory = nova.api.openstack.extensions:ExtensionMiddleware.factory + +[app:osapiapp10] +paste.app_factory = nova.api.openstack:APIRouterV10.factory + +[app:osapiapp11] +paste.app_factory = nova.api.openstack:APIRouterV11.factory + +[pipeline:osversions] +pipeline = faultwrap osversionapp + +[app:osversionapp] +paste.app_factory = nova.api.openstack.versions:Versions.factory + +########## +# Shared # +########## + +[filter:keystonecontext] +paste.filter_factory = keystone.middleware.nova_keystone_context:NovaKeystoneContext.factory + +[filter:authtoken] +paste.filter_factory = keystone.middleware.auth_token:filter_factory +service_protocol = http +service_host = 127.0.0.1 +service_port = 5000 +auth_host = 127.0.0.1 +auth_port = 35357 +auth_protocol = http +auth_uri = http://127.0.0.1:5000/ +admin_token = 999888777666 diff --git a/stack.sh b/stack.sh index 32b4539..da097bd 100755 --- a/stack.sh +++ b/stack.sh @@ -230,7 +230,7 @@ VLAN_INTERFACE=${VLAN_INTERFACE:-$PUBLIC_INTERFACE} # Multi-host is a mode where each compute node runs its own network node. This # allows network operations and routing for a VM to occur on the server that is # running the VM - removing a SPOF and bandwidth bottleneck. -MULTI_HOST=${MULTI_HOST:-0} +MULTI_HOST=${MULTI_HOST:-False} # If you are using FlatDHCP on multiple hosts, set the ``FLAT_INTERFACE`` # variable but make sure that the interface doesn't already have an @@ -323,7 +323,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then # can never change. read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH." fi - + # Keystone # -------- @@ -567,8 +567,10 @@ if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then # required for nova to validate keystone tokens - except we need to switch # the config to use our service token instead (instead of the invalid token # 999888777666). - cp $KEYSTONE_DIR/examples/paste/nova-api-paste.ini $NOVA_DIR/bin - sed -e "s,999888777666,$SERVICE_TOKEN,g" -i $NOVA_DIR/bin/nova-api-paste.ini + if [ ! -e $NOVA_DIR/bin/nova-api-paste.ini ]; then + cp $FILES/nova-api-paste.ini $NOVA_DIR/bin + sed -e "s,999888777666,$SERVICE_TOKEN,g" -i $NOVA_DIR/bin/nova-api-paste.ini + fi fi if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then @@ -650,13 +652,13 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then USER_GROUP=$(id -g) sudo mkdir -p ${SWIFT_DATA_LOCATION}/drives sudo chown -R $USER:${USER_GROUP} ${SWIFT_DATA_LOCATION}/drives - + # We then create a loopback disk and format it to XFS. if [[ ! -e ${SWIFT_DATA_LOCATION}/drives/images/swift.img ]];then mkdir -p ${SWIFT_DATA_LOCATION}/drives/images sudo touch ${SWIFT_DATA_LOCATION}/drives/images/swift.img sudo chown $USER: ${SWIFT_DATA_LOCATION}/drives/images/swift.img - + dd if=/dev/zero of=${SWIFT_DATA_LOCATION}/drives/images/swift.img \ bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} mkfs.xfs -f -i size=1024 ${SWIFT_DATA_LOCATION}/drives/images/swift.img @@ -673,9 +675,9 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then # We then create link to that mounted location so swift would know # where to go. for x in {1..4}; do sudo ln -sf ${SWIFT_DATA_LOCATION}/drives/sdb1/$x ${SWIFT_DATA_LOCATION}/$x; done - + # We now have to emulate a few different servers into one we - # create all the directories needed for swift + # create all the directories needed for swift tmpd="" for d in ${SWIFT_DATA_LOCATION}/drives/sdb1/{1..4} \ ${SWIFT_CONFIG_LOCATION}/{object,container,account}-server \ @@ -691,7 +693,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then # swift-init has a bug using /etc/swift until bug #885595 is fixed # we have to create a link sudo ln -s ${SWIFT_CONFIG_LOCATION} /etc/swift - + # Swift use rsync to syncronize between all the different # partitions (which make more sense when you have a multi-node # setup) we configure it with our version of rsync. @@ -727,7 +729,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then local bind_port=$2 local log_facility=$3 local node_number - + for node_number in {1..4};do node_path=${SWIFT_DATA_LOCATION}/${node_number} sed -e "s,%SWIFT_CONFIG_LOCATION%,${SWIFT_CONFIG_LOCATION},;s,%USER%,$USER,;s,%NODE_PATH%,${node_path},;s,%BIND_PORT%,${bind_port},;s,%LOG_FACILITY%,${log_facility}," \ @@ -754,14 +756,14 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then # We then can start rsync. sudo /etc/init.d/rsync restart || : - + # Create our ring for the object/container/account. /usr/local/bin/swift-remakerings # And now we launch swift-startmain to get our cluster running # ready to be tested. /usr/local/bin/swift-startmain || : - + unset s swift_hash swift_auth_server tmpd fi @@ -828,12 +830,12 @@ add_nova_flag "--glance_api_servers=$GLANCE_HOSTPORT" if [ -n "$INSTANCES_PATH" ]; then add_nova_flag "--instances_path=$INSTANCES_PATH" fi -if [ -n "$MULTI_HOST" ]; then - add_nova_flag "--multi_host=$MULTI_HOST" - add_nova_flag "--send_arp_for_ha=1" +if [ "$MULTI_HOST" != "False" ]; then + add_nova_flag "--multi_host" + add_nova_flag "--send_arp_for_ha" fi if [ "$SYSLOG" != "False" ]; then - add_nova_flag "--use_syslog=1" + add_nova_flag "--use_syslog" fi # XenServer From 228f246a838ace75b620292f46f746aee1035c48 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 17:36:14 -0700 Subject: [PATCH 059/112] work towards booting --- tools/build_uec.sh | 69 +++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index aae4fb8..24422af 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash -# Make sure that we have the proper version of ubuntu +# Ubuntu distro to install +DIST_NAME=${DIST_NAME:-oneiric} + +# Make sure that we have the proper version of ubuntu (only works on natty/oneiric) UBUNTU_VERSION=`cat /etc/lsb-release | grep CODENAME | sed 's/.*=//g'` if [ ! "oneiric" = "$UBUNTU_VERSION" ]; then if [ ! "natty" = "$UBUNTU_VERSION" ]; then @@ -9,13 +12,14 @@ if [ ! "oneiric" = "$UBUNTU_VERSION" ]; then fi fi -# exit on error to stop unexpected errors -set -o errexit - # Keep track of the current directory TOOLS_DIR=$(cd $(dirname "$0") && pwd) TOP_DIR=`cd $TOOLS_DIR/..; pwd` +# exit on error to stop unexpected errors +set -o errexit +set -o xtrace + # Abort if localrc is not set if [ ! -e $TOP_DIR/localrc ]; then echo "You must have a localrc with ALL necessary passwords defined before proceeding." @@ -30,18 +34,19 @@ dpkg -l kvm libvirt-bin kpartx || apt-get install -y --force-yes kvm libvirt-bin WORK_DIR=${WORK_DIR:-/opt/kvmstack} # Where to store images -IMAGES_DIR=$WORK_DIR/images +image_dir=$WORK_DIR/images/$DIST_NAME +mkdir -p $image_dir # Original version of built image -DIST_NAME=${DIST_NAME:oneiric} -UEC_NAME=$DIST_NAME-server-cloudimg-amd64 -UEC_URL=http://uec-images.ubuntu.com/$DIST_NAME/current/$UEC_NAME-disk1.img -BASE_IMAGE=$IMAGES_DIR/$DIST_NAME.raw +uec_url=http://uec-images.ubuntu.com/$DIST_NAME/current/$DIST_NAME-server-cloudimg-amd64.tar.gz +tarball=$image_dir/$(basename $UEC_URL) # download the base uec image if we haven't already -if [ ! -e $BASE_IMAGE ]; then - mkdir -p $IMAGES_DIR - curl $UEC_URL -O $BASE_IMAGE +if [ ! -f $tarball ]; then + curl $uec_url -o $tarball + tar -Sxvzf $tarball $image_dir + cp $image_dir/*.img $image_dir/disk + cp $image_dir/*-vmlinuz-virtual $image_dir/kernel fi cd $TOP_DIR @@ -59,14 +64,16 @@ GUEST_NAME=${GUEST_NAME:-devstack} virsh destroy $GUEST_NAME || true # Where this vm is stored -VM_DIR=$WORK_DIR/instances/$GUEST_NAME +vm_dir=$WORK_DIR/instances/$GUEST_NAME # Create vm dir and remove old disk -mkdir -p $VM_DIR -rm -f $VM_DIR/disk.img +mkdir -p $vm_dir +rm -f $vm_dir/disk # Create a copy of the base image -qemu-img create -f qcow2 -b ${BASE_IMAGE} $VM_DIR/disk.img +# qemu-img create -f qcow2 -b ${BASE_IMAGE} $vm_dir/disk +cp $image_dir/disk $vm_dir/disk +cp $image_dir/kernel $vm_dir/kernel # Back to devstack cd $TOP_DIR @@ -82,7 +89,7 @@ GUEST_RAM=${GUEST_RAM:-1524288} GUEST_CORES=${GUEST_CORES:-1} # libvirt.xml configuration -NET_XML=$VM_DIR/net.xml +NET_XML=$vm_dir/net.xml cat > $NET_XML < devstack-$GUEST_NETWORK @@ -94,20 +101,19 @@ EOF if [[ "$GUEST_RECREATE_NET" == "yes" ]]; then virsh net-destroy devstack-$GUEST_NETWORK || true - virsh net-create $VM_DIR/net.xml + virsh net-create $vm_dir/net.xml fi # libvirt.xml configuration -LIBVIRT_XML=$VM_DIR/libvirt.xml +LIBVIRT_XML=$vm_dir/libvirt.xml cat > $LIBVIRT_XML < $GUEST_NAME $GUEST_RAM - hvm - - $VM_DIR/kernel - root=/dev/vda ro init=/usr/lib/cloud-init/uncloud-init ds=nocloud ubuntu-pass=ubuntu + hvm + $vm_dir/kernel + root=/dev/vda console=ttyS0 init=/usr/lib/cloud-init/uncloud-init ds=nocloud ubuntu-pass=ubuntu @@ -117,7 +123,7 @@ cat > $LIBVIRT_XML < - + @@ -127,7 +133,7 @@ cat > $LIBVIRT_XML < - + @@ -147,11 +153,12 @@ cat > $LIBVIRT_XML < Date: Sat, 5 Nov 2011 17:37:33 -0700 Subject: [PATCH 060/112] uec_url should be underscore --- tools/build_uec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 24422af..53ada3e 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -39,7 +39,7 @@ mkdir -p $image_dir # Original version of built image uec_url=http://uec-images.ubuntu.com/$DIST_NAME/current/$DIST_NAME-server-cloudimg-amd64.tar.gz -tarball=$image_dir/$(basename $UEC_URL) +tarball=$image_dir/$(basename $uec_url) # download the base uec image if we haven't already if [ ! -f $tarball ]; then From 3b7685823ca62469499f6e4354cce8cfea6e8ee1 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 17:40:20 -0700 Subject: [PATCH 061/112] extract tarball in image dir --- tools/build_uec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 53ada3e..accc37b 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -44,7 +44,7 @@ tarball=$image_dir/$(basename $uec_url) # download the base uec image if we haven't already if [ ! -f $tarball ]; then curl $uec_url -o $tarball - tar -Sxvzf $tarball $image_dir + (cd $image_dir && tar -Sxvzf $tarball) cp $image_dir/*.img $image_dir/disk cp $image_dir/*-vmlinuz-virtual $image_dir/kernel fi From f5a76919b3da9a6a4c3a9a84b2455293b91e2711 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 17:47:50 -0700 Subject: [PATCH 062/112] closer to fine --- tools/build_uec.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index accc37b..5d93da3 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -71,9 +71,7 @@ mkdir -p $vm_dir rm -f $vm_dir/disk # Create a copy of the base image -# qemu-img create -f qcow2 -b ${BASE_IMAGE} $vm_dir/disk -cp $image_dir/disk $vm_dir/disk -cp $image_dir/kernel $vm_dir/kernel +qemu-img create -f qcow2 -b $image_dir/disk $vm_dir/disk # Back to devstack cd $TOP_DIR @@ -112,8 +110,8 @@ cat > $LIBVIRT_XML <$GUEST_RAM hvm - $vm_dir/kernel - root=/dev/vda console=ttyS0 init=/usr/lib/cloud-init/uncloud-init ds=nocloud ubuntu-pass=ubuntu + $image_dir/kernel + root=/dev/vda ro console=ttyS0 init=/usr/lib/cloud-init/uncloud-init ds=nocloud ubuntu-pass=ubuntu From a6282623449666f945d6a3e569513486513eb9cf Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 18:39:33 -0700 Subject: [PATCH 063/112] let dhcp work --- tools/build_uec.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 5d93da3..5f85486 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -93,7 +93,11 @@ cat > $NET_XML <devstack-$GUEST_NETWORK - + + + + + EOF From 63fa7abd561d401df613a9611ab125737895563e Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 18:49:36 -0700 Subject: [PATCH 064/112] tweaks --- tools/build_uec.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 5f85486..7d344f0 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -95,7 +95,7 @@ cat > $NET_XML < - + @@ -155,7 +155,7 @@ cat > $LIBVIRT_XML < Date: Sat, 5 Nov 2011 22:15:50 -0700 Subject: [PATCH 065/112] simple metadata service --- tools/uec/meta.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tools/uec/meta.py diff --git a/tools/uec/meta.py b/tools/uec/meta.py new file mode 100644 index 0000000..5b845d8 --- /dev/null +++ b/tools/uec/meta.py @@ -0,0 +1,29 @@ +import sys +from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler +from SimpleHTTPServer import SimpleHTTPRequestHandler + +def main(host, port, HandlerClass = SimpleHTTPRequestHandler, + ServerClass = HTTPServer, protocol="HTTP/1.0"): + """simple http server that listens on a give address:port""" + + server_address = (host, port) + + HandlerClass.protocol_version = protocol + httpd = ServerClass(server_address, HandlerClass) + + sa = httpd.socket.getsockname() + print "Serving HTTP on", sa[0], "port", sa[1], "..." + httpd.serve_forever() + +if __name__ == '__main__': + if sys.argv[1:]: + address = sys.argv[1] + else: + address = '0.0.0.0' + if ':' in address: + host, port = address.split(':') + else: + host = address + port = 8080 + + main(host, int(port)) From 9ed6bbd503469e23bbe03b4ec15c955a07a47e9d Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 22:28:46 -0700 Subject: [PATCH 066/112] attempt to run the metadata service --- tools/build_uec.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 7d344f0..9b67cf2 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -115,7 +115,7 @@ cat > $LIBVIRT_XML < hvm $image_dir/kernel - root=/dev/vda ro console=ttyS0 init=/usr/lib/cloud-init/uncloud-init ds=nocloud ubuntu-pass=ubuntu + root=/dev/vda ro console=ttyS0 init=/usr/lib/cloud-init/uncloud-init ds=nocloud-net;s=http://192.168.$GUEST.1:4567/ ubuntu-pass=ubuntu @@ -154,6 +154,10 @@ cat > $LIBVIRT_XML < EOF +cp -r $TOOLS_DIR/uec $vm_dir/uec + +(cd $vm_dir/uec; python meta.py 192.168.$GUEST_NETWORK.1:4567 &) + # Create the instance virsh create $vm_dir/libvirt.xml From f504e281c0e1563f7d2d1c6faa6c6f820a2982af Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 22:29:35 -0700 Subject: [PATCH 067/112] don't need to spawn a bash --- tools/build_uec.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 9b67cf2..4ef2d04 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -156,7 +156,8 @@ EOF cp -r $TOOLS_DIR/uec $vm_dir/uec -(cd $vm_dir/uec; python meta.py 192.168.$GUEST_NETWORK.1:4567 &) +cd $vm_dir/uec +python meta.py 192.168.$GUEST_NETWORK.1:4567 & # Create the instance virsh create $vm_dir/libvirt.xml From 438ea577c4a27570ff402087cfbede07b888e239 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 22:33:49 -0700 Subject: [PATCH 068/112] typo --- tools/build_uec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 4ef2d04..efae619 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -115,7 +115,7 @@ cat > $LIBVIRT_XML < hvm $image_dir/kernel - root=/dev/vda ro console=ttyS0 init=/usr/lib/cloud-init/uncloud-init ds=nocloud-net;s=http://192.168.$GUEST.1:4567/ ubuntu-pass=ubuntu + root=/dev/vda ro console=ttyS0 init=/usr/lib/cloud-init/uncloud-init ds=nocloud-net;s=http://192.168.$GUEST_NETWORK.1:4567/ ubuntu-pass=ubuntu From e49f751aa9b495f7e2f19f5a82caff6aec27da18 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 22:34:45 -0700 Subject: [PATCH 069/112] force the uec to be recreated --- tools/build_uec.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index efae619..0a82103 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -154,6 +154,7 @@ cat > $LIBVIRT_XML < EOF +rm -rf $vm_dir/uec cp -r $TOOLS_DIR/uec $vm_dir/uec cd $vm_dir/uec From ee34f62ba7b552062388df1520287d856d216c8d Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 22:41:57 -0700 Subject: [PATCH 070/112] kill the old metadata process --- tools/build_uec.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 0a82103..b4052f2 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -157,6 +157,8 @@ EOF rm -rf $vm_dir/uec cp -r $TOOLS_DIR/uec $vm_dir/uec +# (re)start a metadata service +`lsof -i -n | grep 192.168.$GUEST_NETWORK.1:4567 | awk '{print $2}' | xargs -n1 kill -9` cd $vm_dir/uec python meta.py 192.168.$GUEST_NETWORK.1:4567 & From d7ce7afe0fc67e40ff5c711794ef31d3f7a3031c Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 22:47:28 -0700 Subject: [PATCH 071/112] set the hostname --- tools/build_uec.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index b4052f2..719d268 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -154,11 +154,20 @@ cat > $LIBVIRT_XML < EOF + rm -rf $vm_dir/uec cp -r $TOOLS_DIR/uec $vm_dir/uec +# set metadata +cat > $vm_dir/uec/meta-data< Date: Sat, 5 Nov 2011 22:49:51 -0700 Subject: [PATCH 072/112] switch lsof syntax --- tools/build_uec.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 719d268..61709ab 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -166,8 +166,7 @@ instance-type: m1.large EOF # (re)start a metadata service -#lsof -iTCP:4567 -sTCP:LISTEN -n -lsof -i -n | grep 192.168.$GUEST_NETWORK.1:4567 | awk '{print $2}' | xargs -n1 kill -9 +lsof -iTCP@192.168.$GUEST_NETWORK.1:4567 -n | awk '{print $2}' | xargs -n1 kill -9 cd $vm_dir/uec python meta.py 192.168.$GUEST_NETWORK.1:4567 & From 3ce79aa55bdadd4be53cee8ad9c0ef5da0ad3749 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 22:52:20 -0700 Subject: [PATCH 073/112] improve kill --- tools/build_uec.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 61709ab..b7567f6 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -166,7 +166,10 @@ instance-type: m1.large EOF # (re)start a metadata service -lsof -iTCP@192.168.$GUEST_NETWORK.1:4567 -n | awk '{print $2}' | xargs -n1 kill -9 +( + pid=`lsof -iTCP@192.168.$GUEST_NETWORK.1:4567 -n | awk '{print $2}' | tail -1` + [ "$pid" == "PID" ] || kill -9 $pid +) cd $vm_dir/uec python meta.py 192.168.$GUEST_NETWORK.1:4567 & From cc03cc8d58514a4c88579791fdfa0559569f9818 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 22:54:54 -0700 Subject: [PATCH 074/112] kill works --- tools/build_uec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index b7567f6..89d4661 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -168,7 +168,7 @@ EOF # (re)start a metadata service ( pid=`lsof -iTCP@192.168.$GUEST_NETWORK.1:4567 -n | awk '{print $2}' | tail -1` - [ "$pid" == "PID" ] || kill -9 $pid + [ ! -e $pid ] || kill -9 $pid ) cd $vm_dir/uec python meta.py 192.168.$GUEST_NETWORK.1:4567 & From 9645b0c9c9d862a585e8923cad79e916f7585b6e Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 23:05:33 -0700 Subject: [PATCH 075/112] kill ... --- tools/build_uec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 89d4661..f420d6b 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -168,7 +168,7 @@ EOF # (re)start a metadata service ( pid=`lsof -iTCP@192.168.$GUEST_NETWORK.1:4567 -n | awk '{print $2}' | tail -1` - [ ! -e $pid ] || kill -9 $pid + [ -z "$pid" ] || kill -9 $pid ) cd $vm_dir/uec python meta.py 192.168.$GUEST_NETWORK.1:4567 & From 7306f3bfc77e92657107c9ec17da35a6df2110f5 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 23:13:34 -0700 Subject: [PATCH 076/112] more metadata --- tools/build_uec.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index f420d6b..87b7275 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -163,6 +163,7 @@ cat > $vm_dir/uec/meta-data< Date: Sat, 5 Nov 2011 23:16:53 -0700 Subject: [PATCH 077/112] more userdata --- tools/build_uec.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 87b7275..392427d 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -166,6 +166,14 @@ instance-type: m1.large local-hostname: $GUEST_NAME.local EOF +# set metadata +cat > $vm_dir/uec/user-data< Date: Sat, 5 Nov 2011 23:20:11 -0700 Subject: [PATCH 078/112] more userdata --- tools/build_uec.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 392427d..3b5e49f 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -172,6 +172,9 @@ cat > $vm_dir/uec/user-data< Date: Sat, 5 Nov 2011 23:30:22 -0700 Subject: [PATCH 079/112] git clone --- tools/build_uec.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 3b5e49f..cd0f0e0 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -175,6 +175,8 @@ packages: [ vim-nox, git-core ] password: pass chpasswd: { expire: False } disable_root: false +runcmd: + - [ git, clone, https://github.com/cloudbuilders/devstack.git ] EOF # (re)start a metadata service From 446a3304bcdff585d0fcea487a89e247bbaa4f6b Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 23:36:29 -0700 Subject: [PATCH 080/112] another attempt at userdata --- tools/build_uec.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index cd0f0e0..d6de847 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -168,15 +168,18 @@ EOF # set metadata cat > $vm_dir/uec/user-data< localrc +echo ADMIN_PASSWORD=golfing >> localrc +echo MYSQL_PASSWORD=golfing >> localrc +echo RABBIT_PASSWORD=golfing >> localrc +echo SERVICE_TOKEN=123124123124 >> localrc +echo FLAT_INTERFACE=br100 >> localrc +./stack.sh EOF # (re)start a metadata service From 9102d454f6a892ebb9e000f34a1b515c49da3f8c Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 23:49:08 -0700 Subject: [PATCH 081/112] resize the uec image --- tools/build_uec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index d6de847..e1d6447 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -45,7 +45,7 @@ tarball=$image_dir/$(basename $uec_url) if [ ! -f $tarball ]; then curl $uec_url -o $tarball (cd $image_dir && tar -Sxvzf $tarball) - cp $image_dir/*.img $image_dir/disk + resize-part-image $image_dir/*.img 10G $image_dir/disk cp $image_dir/*-vmlinuz-virtual $image_dir/kernel fi From 6b1c26e96194d8a20d25cf3b11674d2a2fe72136 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sun, 6 Nov 2011 00:13:30 -0700 Subject: [PATCH 082/112] use the provided localrc --- tools/build_uec.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index e1d6447..240ea78 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -173,12 +173,9 @@ apt-get update apt-get install git -y git clone https://github.com/cloudbuilders/devstack.git cd devstack -echo DASH_BRANCH=instance-overview > localrc -echo ADMIN_PASSWORD=golfing >> localrc -echo MYSQL_PASSWORD=golfing >> localrc -echo RABBIT_PASSWORD=golfing >> localrc -echo SERVICE_TOKEN=123124123124 >> localrc -echo FLAT_INTERFACE=br100 >> localrc +cat > localrc < Date: Sun, 6 Nov 2011 00:22:41 -0700 Subject: [PATCH 083/112] use the right devstack sha --- tools/build_uec.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 240ea78..cb1ce2d 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -173,6 +173,9 @@ apt-get update apt-get install git -y git clone https://github.com/cloudbuilders/devstack.git cd devstack +git remote set-url origin `cd $TOP_DIR; git remote show origin | grep Fetch | awk '{print $3}'` +git fetch +git checkout $GIT_COMMIT cat > localrc < Date: Sun, 6 Nov 2011 00:26:29 -0700 Subject: [PATCH 084/112] accidentally running stack.sh ... --- tools/build_uec.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index cb1ce2d..98b39b9 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -176,9 +176,9 @@ cd devstack git remote set-url origin `cd $TOP_DIR; git remote show origin | grep Fetch | awk '{print $3}'` git fetch git checkout $GIT_COMMIT -cat > localrc < localrc < Date: Sun, 6 Nov 2011 00:32:21 -0700 Subject: [PATCH 085/112] use the right revision --- tools/build_uec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 98b39b9..2a69952 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -175,7 +175,7 @@ git clone https://github.com/cloudbuilders/devstack.git cd devstack git remote set-url origin `cd $TOP_DIR; git remote show origin | grep Fetch | awk '{print $3}'` git fetch -git checkout $GIT_COMMIT +git checkout `git rev-parse HEAD` cat > localrc < Date: Sun, 6 Nov 2011 00:42:11 -0700 Subject: [PATCH 086/112] sleep half a second to allow bash to start in screen --- stack.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/stack.sh b/stack.sh index 32b4539..bb26e44 100755 --- a/stack.sh +++ b/stack.sh @@ -909,6 +909,7 @@ function screen_it { NL=`echo -ne '\015'` if [[ "$ENABLED_SERVICES" =~ "$1" ]]; then screen -S stack -X screen -t $1 + sleep 0.5 screen -S stack -p $1 -X stuff "$2$NL" fi } From 5f4ae107efbc481db5d3c30c90a63934a2664d51 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sun, 6 Nov 2011 07:47:09 -0800 Subject: [PATCH 087/112] chown should be to stack user, not root --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index bb26e44..7b0c900 100755 --- a/stack.sh +++ b/stack.sh @@ -121,7 +121,7 @@ if [[ $EUID -eq 0 ]]; then echo "Copying files to stack user" STACK_DIR="$DEST/${PWD##*/}" cp -r -f "$PWD" "$STACK_DIR" - chown -R $USER "$STACK_DIR" + chown -R stack "$STACK_DIR" if [[ "$SHELL_AFTER_RUN" != "no" ]]; then exec su -c "set -e; cd $STACK_DIR; bash stack.sh; bash" stack else From 53d7533d1570a7fe536126c3b4e84ae4928931a1 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sun, 6 Nov 2011 07:54:11 -0800 Subject: [PATCH 088/112] pull DIST_NAME from source --- tools/build_uec.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 2a69952..a0c2788 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -1,8 +1,5 @@ #!/usr/bin/env bash -# Ubuntu distro to install -DIST_NAME=${DIST_NAME:-oneiric} - # Make sure that we have the proper version of ubuntu (only works on natty/oneiric) UBUNTU_VERSION=`cat /etc/lsb-release | grep CODENAME | sed 's/.*=//g'` if [ ! "oneiric" = "$UBUNTU_VERSION" ]; then @@ -16,6 +13,14 @@ fi TOOLS_DIR=$(cd $(dirname "$0") && pwd) TOP_DIR=`cd $TOOLS_DIR/..; pwd` +cd $TOP_DIR + +# Source params +source ./stackrc + +# Ubuntu distro to install +DIST_NAME=${DIST_NAME:-oneiric} + # exit on error to stop unexpected errors set -o errexit set -o xtrace @@ -49,10 +54,6 @@ if [ ! -f $tarball ]; then cp $image_dir/*-vmlinuz-virtual $image_dir/kernel fi -cd $TOP_DIR - -# Source params -source ./stackrc # Configure the root password of the vm to be the same as ``ADMIN_PASSWORD`` ROOT_PASSWORD=${ADMIN_PASSWORD:-password} From 00d6bc6529899326568f37375db77ac3cea008e1 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sun, 6 Nov 2011 07:56:18 -0800 Subject: [PATCH 089/112] Don't forget to echo so we can find it --- tools/build_uec.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index a0c2788..bccddaf 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -181,6 +181,7 @@ cat > localrc < Date: Sun, 6 Nov 2011 08:00:28 -0800 Subject: [PATCH 090/112] should speed up by 20 seconds - sudo and no sleep --- stack.sh | 3 +-- tools/build_uec.sh | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stack.sh b/stack.sh index 7b0c900..33eb207 100755 --- a/stack.sh +++ b/stack.sh @@ -103,8 +103,7 @@ if [[ $EUID -eq 0 ]]; then # since this script runs as a normal user, we need to give that user # ability to run sudo - apt_get update - apt_get install sudo + dpkg -l sudo || apt_get update && apt_get install sudo if ! getent passwd stack >/dev/null; then echo "Creating a user called stack" diff --git a/tools/build_uec.sh b/tools/build_uec.sh index bccddaf..266356b 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -171,13 +171,14 @@ EOF cat > $vm_dir/uec/user-data< localrc < Date: Sun, 6 Nov 2011 08:09:03 -0800 Subject: [PATCH 091/112] Switch the way we check for completion --- tools/build_uec.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 266356b..44c8c0f 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -182,7 +182,6 @@ ROOTSLEEP=0 `cat $TOP_DIR/localrc` LOCAL_EOF ./stack.sh -echo "All done" EOF # (re)start a metadata service @@ -228,7 +227,7 @@ if [ "$WAIT_TILL_LAUNCH" = "1" ]; then trap kill_tail SIGINT echo "Waiting stack.sh to finish..." - while ! cat $vm_dir/console.log | grep -q 'All done' ; do + while ! cat $vm_dir/console.log | grep -q '^stack.sh (completed|failed)' ; do sleep 1 done From d55a5159128a213789d9a7a6db3ed6225206eec3 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sun, 6 Nov 2011 08:16:42 -0800 Subject: [PATCH 092/112] egrep needed for parens --- tools/build_uec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 44c8c0f..ada6596 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -227,7 +227,7 @@ if [ "$WAIT_TILL_LAUNCH" = "1" ]; then trap kill_tail SIGINT echo "Waiting stack.sh to finish..." - while ! cat $vm_dir/console.log | grep -q '^stack.sh (completed|failed)' ; do + while ! egrep -q '^stack.sh (completed|failed)' $vm_dir/console.log ; do sleep 1 done From b17c4f30eb6038f58e0186d8621406b68bf54914 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sun, 6 Nov 2011 09:25:55 -0800 Subject: [PATCH 093/112] make sure hostname resolves --- tools/build_uec.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index ada6596..ee78192 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -170,6 +170,8 @@ EOF # set metadata cat > $vm_dir/uec/user-data< Date: Sun, 6 Nov 2011 09:35:13 -0800 Subject: [PATCH 094/112] run hostname on remote server --- tools/build_uec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index ee78192..cbcdad6 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -171,7 +171,7 @@ EOF cat > $vm_dir/uec/user-data< Date: Sun, 6 Nov 2011 10:29:10 -0800 Subject: [PATCH 095/112] increase the dhcp range --- tools/build_uec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index cbcdad6..a0997e0 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -96,7 +96,7 @@ cat > $NET_XML < - + From dca89009f5f5468f13158eec3b080ecb0bb5545f Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sun, 6 Nov 2011 10:33:33 -0800 Subject: [PATCH 096/112] destroying the network isn't enough to delete the leases --- tools/build_uec.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index a0997e0..3ee1e2f 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -104,6 +104,8 @@ EOF if [[ "$GUEST_RECREATE_NET" == "yes" ]]; then virsh net-destroy devstack-$GUEST_NETWORK || true + # destroying the network isn't enough to delete the leases + rm -f /var/lib/libvirt/dnsmasq/devstack-$GUEST_NETWORK.leases virsh net-create $vm_dir/net.xml fi From 9812ffb9980a7ed7c3512873d522ac6ee5f52742 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Sun, 6 Nov 2011 11:18:26 -0800 Subject: [PATCH 097/112] clean up service token --- files/nova-api-paste.ini | 2 +- stack.sh | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/files/nova-api-paste.ini b/files/nova-api-paste.ini index 0b56c9f..2c642f8 100644 --- a/files/nova-api-paste.ini +++ b/files/nova-api-paste.ini @@ -124,4 +124,4 @@ auth_host = 127.0.0.1 auth_port = 35357 auth_protocol = http auth_uri = http://127.0.0.1:5000/ -admin_token = 999888777666 +admin_token = %SERVICE_TOKEN% diff --git a/stack.sh b/stack.sh index da097bd..fd305e2 100755 --- a/stack.sh +++ b/stack.sh @@ -562,15 +562,12 @@ fi # ---- if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then - # We are going to use the sample http middleware configuration from the - # keystone project to launch nova. This paste config adds the configuration - # required for nova to validate keystone tokens - except we need to switch - # the config to use our service token instead (instead of the invalid token - # 999888777666). - if [ ! -e $NOVA_DIR/bin/nova-api-paste.ini ]; then - cp $FILES/nova-api-paste.ini $NOVA_DIR/bin - sed -e "s,999888777666,$SERVICE_TOKEN,g" -i $NOVA_DIR/bin/nova-api-paste.ini - fi + # We are going to use a sample http middleware configuration based on the + # one from the keystone project to launch nova. This paste config adds + # the configuration required for nova to validate keystone tokens. We add + # our own service token to the configuration. + cp $FILES/nova-api-paste.ini $NOVA_DIR/bin + sed -e "s,%SERVICE_TOKEN%,$SERVICE_TOKEN,g" -i $NOVA_DIR/bin/nova-api-paste.ini fi if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then From 6cbf2872544be0d81f0c9471ae5be7d8e319b7ea Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Mon, 7 Nov 2011 07:23:34 -0800 Subject: [PATCH 098/112] Fix typo in exercise.sh --- exercise.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercise.sh b/exercise.sh index 77d3a3b..cca9a13 100755 --- a/exercise.sh +++ b/exercise.sh @@ -165,7 +165,7 @@ ping -c1 -w1 $IP nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0 # FIXME (anthony): make xs support security groups -if [ "$VIRT_DRIVER" != "xenserver"]; then +if [ "$VIRT_DRIVER" != "xenserver" ]; then # test we can aren't able to ping our floating ip within ASSOCIATE_TIMEOUT seconds if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then print "Security group failure - ping should not be allowed!" From f0b41f3fb7c8802cfbd1576e10f268e20d5e1e7b Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 7 Nov 2011 09:51:15 -0800 Subject: [PATCH 099/112] update for why we sleep --- stack.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 33eb207..ca8ab41 100755 --- a/stack.sh +++ b/stack.sh @@ -908,7 +908,10 @@ function screen_it { NL=`echo -ne '\015'` if [[ "$ENABLED_SERVICES" =~ "$1" ]]; then screen -S stack -X screen -t $1 - sleep 0.5 + # sleep to allow bash to be ready to be send the command - we are + # creating a new window in screen and then sends characters, so if + # bash isn't running by the time we send the command, nothing happens + sleep 1 screen -S stack -p $1 -X stuff "$2$NL" fi } From 955e5e73f2badc22532d8054bd0965e26510cab8 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 7 Nov 2011 10:29:05 -0800 Subject: [PATCH 100/112] don't need static uec meta/user data since we generate --- tools/uec/meta-data | 19 ------------------- tools/uec/user-data | 32 -------------------------------- 2 files changed, 51 deletions(-) delete mode 100644 tools/uec/meta-data delete mode 100644 tools/uec/user-data diff --git a/tools/uec/meta-data b/tools/uec/meta-data deleted file mode 100644 index d068195..0000000 --- a/tools/uec/meta-data +++ /dev/null @@ -1,19 +0,0 @@ -#ami-id: ami-fd4aa494 -#ami-launch-index: '0' -#ami-manifest-path: ubuntu-images-us/ubuntu-lucid-10.04-amd64-server-20100427.1.manifest.xml -#block-device-mapping: {ami: sda1, ephemeral0: sdb, ephemeral1: sdc, root: /dev/sda1} -hostname: smoser-sys -#instance-action: none -instance-id: i-87018aed -instance-type: m1.large -#kernel-id: aki-c8b258a1 -local-hostname: smoser-sys.mosers.us -#local-ipv4: 10.223.26.178 -#placement: {availability-zone: us-east-1d} -#public-hostname: ec2-184-72-174-120.compute-1.amazonaws.com -#public-ipv4: 184.72.174.120 -#public-keys: -# ec2-keypair.us-east-1: [ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCD9dlT00vOUC8Ttq6YH8RzUCVqPQl6HaSfWSTKYnZiVCpTBj1CaRZPLRLmkSB9Nziy4aRJa/LZMbBHXytQKnB1psvNknqC2UNlrXXMk+Vx5S4vg21MXYYimK4uZEY0Qz29QUiTyNsx18jpAaF4ocUpTpRhxPEBCcSCDmMbc27MU2XuTbasM2NjW/w0bBF3ZFhdH68dZICXdTxS2jUrtrCnc1D/QXVZ5kQO3jsmSyJg8E0nE+6Onpx2YRoVRSwjpGzVZ+BlXPnN5xBREBG8XxzhNFHJbek+RgK5TfL+k4yD4XhnVZuZu53cBAFhj+xPKhtisSd+YmaEq+Jt9uS0Ekd5 -# ec2-keypair.us-east-1, ''] -#reservation-id: r-e2225889 -#security-groups: default diff --git a/tools/uec/user-data b/tools/uec/user-data deleted file mode 100644 index f9fa477..0000000 --- a/tools/uec/user-data +++ /dev/null @@ -1,32 +0,0 @@ -#cloud-config -#apt_update: false -#apt_upgrade: true -#packages: [ bzr, pastebinit, ubuntu-dev-tools, ccache, bzr-builddeb, vim-nox, git-core, lftp ] - -apt_sources: - - source: ppa:smoser/ppa - -disable_root: True - -mounts: - - [ ephemeral0, None ] - - [ swap, None ] - -ssh_import_id: [smoser ] - -sm_misc: - - &user_setup | - set -x; exec > ~/user_setup.log 2>&1 - echo "starting at $(date -R)" - echo "set -o vi" >> ~/.bashrc - cat >> ~/.profile < ~/runcmd.log' ] - - [ sudo, -Hu, ubuntu, sh, -c, 'read up sleep < /proc/uptime; echo $(date): runcmd up at $up | tee -a ~/runcmd.log' ] - - [ sudo, -Hu, ubuntu, sh, -c, *user_setup ] - -password: passw0rd -chpasswd: { expire: False } From e3c47a351e869cd9026bc37879ccf7f9c709e285 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 7 Nov 2011 10:44:43 -0800 Subject: [PATCH 101/112] parameterize vm size, improve metadata, conditional for ubuntu version --- tools/build_uec.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 3ee1e2f..6bab526 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -1,12 +1,9 @@ #!/usr/bin/env bash # Make sure that we have the proper version of ubuntu (only works on natty/oneiric) -UBUNTU_VERSION=`cat /etc/lsb-release | grep CODENAME | sed 's/.*=//g'` -if [ ! "oneiric" = "$UBUNTU_VERSION" ]; then - if [ ! "natty" = "$UBUNTU_VERSION" ]; then - echo "This script only works with oneiric and natty" - exit 1 - fi +if ! egrep -q "oneiric|natty" /etc/lsb-release; then + echo "This script only works with ubuntu oneiric and natty" + exit 1 fi # Keep track of the current directory @@ -21,6 +18,9 @@ source ./stackrc # Ubuntu distro to install DIST_NAME=${DIST_NAME:-oneiric} +# Configure how large the VM should be +GUEST_SIZE=${GUEST_SIZE:-10G} + # exit on error to stop unexpected errors set -o errexit set -o xtrace @@ -33,7 +33,8 @@ if [ ! -e $TOP_DIR/localrc ]; then fi # Install deps if needed -dpkg -l kvm libvirt-bin kpartx || apt-get install -y --force-yes kvm libvirt-bin kpartx +DEPS="kvm libvirt-bin kpartx" +dpkg -l $DEPS || apt-get install -y --force-yes $DEPS # Where to store files and instances WORK_DIR=${WORK_DIR:-/opt/kvmstack} @@ -50,7 +51,7 @@ tarball=$image_dir/$(basename $uec_url) if [ ! -f $tarball ]; then curl $uec_url -o $tarball (cd $image_dir && tar -Sxvzf $tarball) - resize-part-image $image_dir/*.img 10G $image_dir/disk + resize-part-image $image_dir/*.img $GUEST_SIZE $image_dir/disk cp $image_dir/*-vmlinuz-virtual $image_dir/kernel fi @@ -164,8 +165,8 @@ cp -r $TOOLS_DIR/uec $vm_dir/uec # set metadata cat > $vm_dir/uec/meta-data< Date: Mon, 7 Nov 2011 14:06:15 -0500 Subject: [PATCH 102/112] Comment out log_file options in glance configs Comment out log_file options in glance config files to make log output appear in g-api and g-reg screen windows, like the other server daemons... --- files/glance-api.conf | 2 +- files/glance-registry.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/glance-api.conf b/files/glance-api.conf index 3499ff7..bb758af 100644 --- a/files/glance-api.conf +++ b/files/glance-api.conf @@ -24,7 +24,7 @@ registry_port = 9191 # Log to this file. Make sure you do not set the same log # file for both the API and registry servers! -log_file = %DEST%/glance/api.log +#log_file = %DEST%/glance/api.log # Send logs to syslog (/dev/log) instead of to file specified by `log_file` use_syslog = %SYSLOG% diff --git a/files/glance-registry.conf b/files/glance-registry.conf index 351b09f..1e04186 100644 --- a/files/glance-registry.conf +++ b/files/glance-registry.conf @@ -13,7 +13,7 @@ bind_port = 9191 # Log to this file. Make sure you do not set the same log # file for both the API and registry servers! -log_file = %DEST%/glance/registry.log +#log_file = %DEST%/glance/registry.log # Where to store images filesystem_store_datadir = %DEST%/glance/images From e7fa90934d3d0f1dc0a89fbf6f498e927f041d39 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 7 Nov 2011 16:10:59 -0600 Subject: [PATCH 103/112] script to warm apts/pips on a base image, to speed up performace of build_ scripts --- tools/warm_apts_and_pips.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tools/warm_apts_and_pips.sh diff --git a/tools/warm_apts_and_pips.sh b/tools/warm_apts_and_pips.sh new file mode 100644 index 0000000..c0b02b9 --- /dev/null +++ b/tools/warm_apts_and_pips.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# Keep track of the current directory +TOOLS_DIR=$(cd $(dirname "$0") && pwd) +TOP_DIR=`cd $TOOLS_DIR/..; pwd` + +# cd to top of devstack +cd $TOP_DIR + +# Echo usage +usage() { + echo "Cache OpenStack dependencies on a uec image to speed up performance." + echo "" + echo "Usage: $0 [full path to raw uec base image]" +} + +# Make sure this is a raw image +if ! qemu-img info $1 | grep -q "file format: raw"; then + usage + exit 1 +fi + +# Mount the image +STAGING_DIR=`mktemp -d uec.XXXXXXXXXX` +mkdir -p $STAGING_DIR +mount -t ext4 -o loop $1 $STAGING_DIR + +# Make sure that base requirements are installed +cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf + +# Perform caching on the base image to speed up subsequent runs +chroot $STAGING_DIR apt-get update +chroot $STAGING_DIR apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1` +chroot $STAGING_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` +chroot $STAGING_DIR pip install `cat files/pips/*` +umount $STAGING_DIR && rm -rf $STAGING_DIR From 069f2f7a534b8ace5e9a6e68143c7951b65d4046 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 7 Nov 2011 16:13:03 -0600 Subject: [PATCH 104/112] +x --- tools/warm_apts_and_pips.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools/warm_apts_and_pips.sh diff --git a/tools/warm_apts_and_pips.sh b/tools/warm_apts_and_pips.sh old mode 100644 new mode 100755 From 8655bf0e6efdd3d87a5ed149be2ee5e3aa8473db Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 7 Nov 2011 16:37:00 -0600 Subject: [PATCH 105/112] more checks to make sure script is run as intended --- tools/warm_apts_and_pips.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/warm_apts_and_pips.sh b/tools/warm_apts_and_pips.sh index c0b02b9..b20519f 100755 --- a/tools/warm_apts_and_pips.sh +++ b/tools/warm_apts_and_pips.sh @@ -1,5 +1,11 @@ #!/usr/bin/env bash +# echo commands +set -o xtrace + +# exit on error to stop unexpected errors +set -o errexit + # Keep track of the current directory TOOLS_DIR=$(cd $(dirname "$0") && pwd) TOP_DIR=`cd $TOOLS_DIR/..; pwd` @@ -20,6 +26,12 @@ if ! qemu-img info $1 | grep -q "file format: raw"; then exit 1 fi +# Make sure we are in the correct dir +if [ ! -d files/apts ]; then + echo "Please run this script from devstack/tools/" + exit 1 +fi + # Mount the image STAGING_DIR=`mktemp -d uec.XXXXXXXXXX` mkdir -p $STAGING_DIR From 208ae2f6aa0bf5dbc669c6fd4f2e4649c04ed039 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 7 Nov 2011 16:38:03 -0600 Subject: [PATCH 106/112] fix some comments --- tools/warm_apts_and_pips.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/warm_apts_and_pips.sh b/tools/warm_apts_and_pips.sh index b20519f..10bd4af 100755 --- a/tools/warm_apts_and_pips.sh +++ b/tools/warm_apts_and_pips.sh @@ -1,16 +1,16 @@ #!/usr/bin/env bash -# echo commands +# Echo commands set -o xtrace -# exit on error to stop unexpected errors +# Exit on error to stop unexpected errors set -o errexit # Keep track of the current directory TOOLS_DIR=$(cd $(dirname "$0") && pwd) TOP_DIR=`cd $TOOLS_DIR/..; pwd` -# cd to top of devstack +# Change dir to top of devstack cd $TOP_DIR # Echo usage From 7e436c212ea2ac7fe60bddedf49548729675111e Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 9 Nov 2011 00:12:00 -0800 Subject: [PATCH 107/112] use dhcp_release --- files/apts/nova | 1 + stack.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/files/apts/nova b/files/apts/nova index 405d53b..9eefed7 100644 --- a/files/apts/nova +++ b/files/apts/nova @@ -1,4 +1,5 @@ dnsmasq-base +dnsmasq-utils # for dhcp_release kpartx parted arping # used for send_arp_for_ha option in nova-network diff --git a/stack.sh b/stack.sh index 841cbb4..78851b9 100755 --- a/stack.sh +++ b/stack.sh @@ -826,6 +826,7 @@ add_nova_flag "--ec2_dmz_host=$EC2_DMZ_HOST" add_nova_flag "--rabbit_host=$RABBIT_HOST" add_nova_flag "--rabbit_password=$RABBIT_PASSWORD" add_nova_flag "--glance_api_servers=$GLANCE_HOSTPORT" +add_nova_flag "--force_dhcp_release" if [ -n "$INSTANCES_PATH" ]; then add_nova_flag "--instances_path=$INSTANCES_PATH" fi From e28f77565d0dd214db5fa01bdea41c88e52dbafc Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 9 Nov 2011 11:48:09 -0800 Subject: [PATCH 108/112] install cloud-utils, so that we have resize-part-image --- tools/build_uec.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index 6bab526..a15a18a 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -# Make sure that we have the proper version of ubuntu (only works on natty/oneiric) -if ! egrep -q "oneiric|natty" /etc/lsb-release; then +# Make sure that we have the proper version of ubuntu (only works on oneiric) +if ! egrep -q "oneiric" /etc/lsb-release; then echo "This script only works with ubuntu oneiric and natty" exit 1 fi @@ -33,7 +33,7 @@ if [ ! -e $TOP_DIR/localrc ]; then fi # Install deps if needed -DEPS="kvm libvirt-bin kpartx" +DEPS="kvm libvirt-bin kpartx cloud-utils" dpkg -l $DEPS || apt-get install -y --force-yes $DEPS # Where to store files and instances From 5605ec11446d70e466f4ff0a4a50292b8c3f633f Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Wed, 9 Nov 2011 12:40:01 -0800 Subject: [PATCH 109/112] now that we are using apt-get download this file doesn't speed things up that much --- files/apts/preseed | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 files/apts/preseed diff --git a/files/apts/preseed b/files/apts/preseed deleted file mode 100644 index 8712d5d..0000000 --- a/files/apts/preseed +++ /dev/null @@ -1,18 +0,0 @@ -# a collection of packages that speed up installation as they are dependencies -# of packages we can't install during bootstraping (rabbitmq-server, -# mysql-server, libvirt-bin) -# -# NOTE: only add packages to this file that aren't needed directly -mysql-common -mysql-client-5.1 -erlang-base -erlang-ssl -erlang-nox -erlang-inets -erlang-mnesia -libhtml-template-perl -gettext-base -libavahi-client3 -libxml2-utils -libpciaccess0 -libparted0debian1 From 593e9aa87a2f81b4e1ff03ca8b8ee1789164890b Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 9 Nov 2011 12:42:08 -0800 Subject: [PATCH 110/112] fix message - no natty support --- tools/build_uec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_uec.sh b/tools/build_uec.sh index a15a18a..d57cb29 100755 --- a/tools/build_uec.sh +++ b/tools/build_uec.sh @@ -2,7 +2,7 @@ # Make sure that we have the proper version of ubuntu (only works on oneiric) if ! egrep -q "oneiric" /etc/lsb-release; then - echo "This script only works with ubuntu oneiric and natty" + echo "This script only works with ubuntu oneiric." exit 1 fi From c1024d8987a9b35ef41f5a5615f9827d4b4e4468 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 9 Nov 2011 18:58:07 -0800 Subject: [PATCH 111/112] tweaks to warm script, add script to configure stack user --- tools/setup_stack_user.sh | 66 +++++++++++++++++++++++++++++++++++++ tools/warm_apts_and_pips.sh | 11 ++++--- 2 files changed, 73 insertions(+), 4 deletions(-) create mode 100755 tools/setup_stack_user.sh diff --git a/tools/setup_stack_user.sh b/tools/setup_stack_user.sh new file mode 100755 index 0000000..85d418e --- /dev/null +++ b/tools/setup_stack_user.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +# Echo commands +set -o xtrace + +# Exit on error to stop unexpected errors +set -o errexit + +# Keep track of the current directory +TOOLS_DIR=$(cd $(dirname "$0") && pwd) +TOP_DIR=`cd $TOOLS_DIR/..; pwd` + +# Change dir to top of devstack +cd $TOP_DIR + +# Echo usage +usage() { + echo "Add stack user and keys" + echo "" + echo "Usage: $0 [full path to raw uec base image]" +} + +# Make sure this is a raw image +if ! qemu-img info $1 | grep -q "file format: raw"; then + usage + exit 1 +fi + +# Mount the image +DEST=/opt/stack +STAGING_DIR=/tmp/`echo $1 | sed "s/\//_/g"`.stage.user +mkdir -p $STAGING_DIR +umount $STAGING_DIR || true +sleep 1 +mount -t ext4 -o loop $1 $STAGING_DIR +mkdir -p $STAGING_DIR/$DEST + +# Create a stack user that is a member of the libvirtd group so that stack +# is able to interact with libvirt. +chroot $STAGING_DIR groupadd libvirtd || true +chroot $STAGING_DIR useradd stack -s /bin/bash -d $DEST -G libvirtd || true + +# a simple password - pass +echo stack:pass | chroot $STAGING_DIR chpasswd + +# and has sudo ability (in the future this should be limited to only what +# stack requires) +echo "stack ALL=(ALL) NOPASSWD: ALL" >> $STAGING_DIR/etc/sudoers + +# Gracefully cp only if source file/dir exists +function cp_it { + if [ -e $1 ] || [ -d $1 ]; then + cp -pRL $1 $2 + fi +} + +# Copy over your ssh keys and env if desired +cp_it ~/.ssh $STAGING_DIR/$DEST/.ssh +cp_it ~/.ssh/id_rsa.pub $STAGING_DIR/$DEST/.ssh/authorized_keys +cp_it ~/.gitconfig $STAGING_DIR/$DEST/.gitconfig +cp_it ~/.vimrc $STAGING_DIR/$DEST/.vimrc +cp_it ~/.bashrc $STAGING_DIR/$DEST/.bashrc + +# Give stack ownership over $DEST so it may do the work needed +chroot $STAGING_DIR chown -R stack $DEST + diff --git a/tools/warm_apts_and_pips.sh b/tools/warm_apts_and_pips.sh index 10bd4af..854a938 100755 --- a/tools/warm_apts_and_pips.sh +++ b/tools/warm_apts_and_pips.sh @@ -33,8 +33,10 @@ if [ ! -d files/apts ]; then fi # Mount the image -STAGING_DIR=`mktemp -d uec.XXXXXXXXXX` +STAGING_DIR=/tmp/`echo $1 | sed "s/\//_/g"`.stage mkdir -p $STAGING_DIR +umount $STAGING_DIR || true +sleep 1 mount -t ext4 -o loop $1 $STAGING_DIR # Make sure that base requirements are installed @@ -43,6 +45,7 @@ cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf # Perform caching on the base image to speed up subsequent runs chroot $STAGING_DIR apt-get update chroot $STAGING_DIR apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1` -chroot $STAGING_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` -chroot $STAGING_DIR pip install `cat files/pips/*` -umount $STAGING_DIR && rm -rf $STAGING_DIR +chroot $STAGING_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` || true +mkdir -p $STAGING_DIR/var/cache/pip +PIP_DOWNLOAD_CACHE=/var/cache/pip chroot $STAGING_DIR pip install `cat files/pips/*` || true +umount $STAGING_DIR From e228093ecda9300428a399600758580eff3b44fe Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 9 Nov 2011 22:29:22 -0800 Subject: [PATCH 112/112] some cleanup for utility scripts --- tools/setup_stack_user.sh | 10 +++++++++- tools/warm_apts_and_pips.sh | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/setup_stack_user.sh b/tools/setup_stack_user.sh index 85d418e..231a20f 100755 --- a/tools/setup_stack_user.sh +++ b/tools/setup_stack_user.sh @@ -40,9 +40,15 @@ mkdir -p $STAGING_DIR/$DEST chroot $STAGING_DIR groupadd libvirtd || true chroot $STAGING_DIR useradd stack -s /bin/bash -d $DEST -G libvirtd || true -# a simple password - pass +# Add a simple password - pass echo stack:pass | chroot $STAGING_DIR chpasswd +# Configure sudo +grep -q "^#includedir.*/etc/sudoers.d" $STAGING_DIR/etc/sudoers || + echo "#includedir /etc/sudoers.d" | sudo tee -a $STAGING_DIR/etc/sudoers +cp $TOP_DIR/files/sudo/* $STAGING_DIR/etc/sudoers.d/ +sed -e "s,%USER%,$USER,g" -i $STAGING_DIR/etc/sudoers.d/* + # and has sudo ability (in the future this should be limited to only what # stack requires) echo "stack ALL=(ALL) NOPASSWD: ALL" >> $STAGING_DIR/etc/sudoers @@ -64,3 +70,5 @@ cp_it ~/.bashrc $STAGING_DIR/$DEST/.bashrc # Give stack ownership over $DEST so it may do the work needed chroot $STAGING_DIR chown -R stack $DEST +# Unmount +umount $STAGING_DIR diff --git a/tools/warm_apts_and_pips.sh b/tools/warm_apts_and_pips.sh index 854a938..ec7e916 100755 --- a/tools/warm_apts_and_pips.sh +++ b/tools/warm_apts_and_pips.sh @@ -48,4 +48,6 @@ chroot $STAGING_DIR apt-get install -y --download-only `cat files/apts/* | grep chroot $STAGING_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` || true mkdir -p $STAGING_DIR/var/cache/pip PIP_DOWNLOAD_CACHE=/var/cache/pip chroot $STAGING_DIR pip install `cat files/pips/*` || true + +# Unmount umount $STAGING_DIR