Remove unused tools

Remove old tools for building ramdisk images and the original
PXE boot environment.

Change-Id: I81dcc823387c610d3090e5397ed5e42244d6dc3d
This commit is contained in:
Dean Troyer 2014-07-31 13:29:34 -05:00
parent f29569db7a
commit 4a3d590fd9
10 changed files with 0 additions and 1212 deletions

@ -1,38 +0,0 @@
#!/usr/bin/env bash
# **build_bm.sh**
# Build an OpenStack install on a bare metal machine.
set +x
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
# Import common functions
source $TOP_DIR/functions
# Source params
source ./stackrc
# Param string to pass to stack.sh. Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova"
STACKSH_PARAMS=${STACKSH_PARAMS:-}
# Option to use the version of devstack on which we are currently working
USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
# Configure the runner
RUN_SH=`mktemp`
cat > $RUN_SH <<EOF
#!/usr/bin/env bash
# Install and run stack.sh
cd devstack
$STACKSH_PARAMS ./stack.sh
EOF
# Make the run.sh executable
chmod 755 $RUN_SH
scp -r . root@$CONTAINER_IP:devstack
scp $RUN_SH root@$CONTAINER_IP:$RUN_SH
ssh root@$CONTAINER_IP $RUN_SH

@ -1,40 +0,0 @@
#!/usr/bin/env bash
# **build_bm_multi.sh**
# Build an OpenStack install on several bare metal machines.
SHELL_AFTER_RUN=no
# Variables common amongst all hosts in the cluster
COMMON_VARS="MYSQL_HOST=$HEAD_HOST RABBIT_HOST=$HEAD_HOST GLANCE_HOSTPORT=$HEAD_HOST:9292 NETWORK_MANAGER=FlatDHCPManager FLAT_INTERFACE=eth0 FLOATING_RANGE=$FLOATING_RANGE MULTI_HOST=1 SHELL_AFTER_RUN=$SHELL_AFTER_RUN"
# Helper to launch containers
function run_bm {
# For some reason container names with periods can cause issues :/
CONTAINER=$1 CONTAINER_IP=$2 CONTAINER_NETMASK=$NETMASK CONTAINER_GATEWAY=$GATEWAY NAMESERVER=$NAMESERVER TERMINATE=$TERMINATE STACKSH_PARAMS="$COMMON_VARS $3" ./tools/build_bm.sh
}
# Launch the head node - headnode uses a non-ip domain name,
# because rabbit won't launch with an ip addr hostname :(
run_bm STACKMASTER $HEAD_HOST "ENABLED_SERVICES=g-api,g-reg,key,n-api,n-sch,n-vnc,horizon,mysql,rabbit"
# Wait till the head node is up
if [ ! "$TERMINATE" = "1" ]; then
echo "Waiting for head node ($HEAD_HOST) to start..."
if ! timeout 60 sh -c "while ! wget -q -O- http://$HEAD_HOST | grep -q username; do sleep 1; done"; then
echo "Head node did not start"
exit 1
fi
fi
PIDS=""
# Launch the compute hosts in parallel
for compute_host in ${COMPUTE_HOSTS//,/ }; do
run_bm $compute_host $compute_host "ENABLED_SERVICES=n-cpu,n-net,n-api" &
PIDS="$PIDS $!"
done
for x in $PIDS; do
wait $x
done
echo "build_bm_multi complete"

@ -1,120 +0,0 @@
#!/bin/bash -e
# **build_pxe_env.sh**
# Create a PXE boot environment
#
# build_pxe_env.sh destdir
#
# Requires Ubuntu Oneiric
#
# Only needs to run as root if the destdir permissions require it
dpkg -l syslinux || apt-get install -y syslinux
DEST_DIR=${1:-/tmp}/tftpboot
PXEDIR=${PXEDIR:-/opt/ramstack/pxe}
PROGDIR=`dirname $0`
# Clean up any resources that may be in use
function 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 SIGQUIT EXIT
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
mkdir -p $DEST_DIR/pxelinux.cfg
cd $DEST_DIR
for i in memdisk menu.c32 pxelinux.0; do
cp -pu /usr/lib/syslinux/$i $DEST_DIR
done
CFG=$DEST_DIR/pxelinux.cfg/default
cat >$CFG <<EOF
default menu.c32
prompt 0
timeout 0
MENU TITLE devstack PXE Boot Menu
EOF
# Setup devstack boot
mkdir -p $DEST_DIR/ubuntu
if [ ! -d $PXEDIR ]; then
mkdir -p $PXEDIR
fi
# Get image into place
if [ ! -r $PXEDIR/stack-initrd.img ]; then
cd $TOP_DIR
$PROGDIR/build_ramdisk.sh $PXEDIR/stack-initrd.img
fi
if [ ! -r $PXEDIR/stack-initrd.gz ]; then
gzip -1 -c $PXEDIR/stack-initrd.img >$PXEDIR/stack-initrd.gz
fi
cp -pu $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu
if [ ! -r $PXEDIR/vmlinuz-*-generic ]; then
MNTDIR=`mktemp -d --tmpdir mntXXXXXXXX`
mount -t ext4 -o loop $PXEDIR/stack-initrd.img $MNTDIR
if [ ! -r $MNTDIR/boot/vmlinuz-*-generic ]; then
echo "No kernel found"
umount $MNTDIR
rmdir $MNTDIR
exit 1
else
cp -pu $MNTDIR/boot/vmlinuz-*-generic $PXEDIR
fi
umount $MNTDIR
rmdir $MNTDIR
fi
# Get generic kernel version
KNAME=`basename $PXEDIR/vmlinuz-*-generic`
KVER=${KNAME#vmlinuz-}
cp -pu $PXEDIR/vmlinuz-$KVER $DEST_DIR/ubuntu
cat >>$CFG <<EOF
LABEL devstack
MENU LABEL ^devstack
MENU DEFAULT
KERNEL ubuntu/vmlinuz-$KVER
APPEND initrd=ubuntu/stack-initrd.gz ramdisk_size=2109600 root=/dev/ram0
EOF
# Get Ubuntu
if [ -d $PXEDIR -a -r $PXEDIR/natty-base-initrd.gz ]; then
cp -pu $PXEDIR/natty-base-initrd.gz $DEST_DIR/ubuntu
cat >>$CFG <<EOF
LABEL ubuntu
MENU LABEL ^Ubuntu Natty
KERNEL ubuntu/vmlinuz-$KVER
APPEND initrd=ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0
EOF
fi
# Local disk boot
cat >>$CFG <<EOF
LABEL local
MENU LABEL ^Local disk
LOCALBOOT 0
EOF
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT

@ -1,230 +0,0 @@
#!/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 Ubuntu OpenStack install"
echo "usage: $0 dest"
exit 1
fi
# Clean up any resources that may be in use
function 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
# Echo commands
set -o xtrace
IMG_FILE=$1
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
# Import common functions
. $TOP_DIR/functions
# Store cwd
CWD=`pwd`
cd $TOP_DIR
# Source params
source ./stackrc
CACHEDIR=${CACHEDIR:-/opt/stack/cache}
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:-}
# Option to use the version of devstack on which we are currently working
USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
# clean install
if [ ! -r $CACHEDIR/$DIST_NAME-base.img ]; then
$TOOLS_DIR/get_uec_image.sh $DIST_NAME $CACHEDIR/$DIST_NAME-base.img
fi
# Finds and returns full device path for the next available NBD device.
# Exits script if error connecting or none free.
# map_nbd image
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 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
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`
# Create a stack user that is a member of the libvirtd group so that stack
# is able to interact with libvirt.
chroot $MNTDIR groupadd libvirtd
chroot $MNTDIR useradd $STACK_USER -s /bin/bash -d $DEST -G libvirtd
mkdir -p $MNTDIR/$DEST
chroot $MNTDIR chown $STACK_USER $DEST
# A simple password - pass
echo $STACK_USER: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)
echo "$STACK_USER ALL=(ALL) NOPASSWD: ALL" >> $MNTDIR/etc/sudoers
umount $MNTDIR
rmdir $MNTDIR
qemu-nbd -d $NBD
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
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_TMP bs=1 count=1 seek=$((2*1024*1024*1024))
# Create filesystem image for RAM disk
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
MNTDIR=`mktemp -d --tmpdir mntXXXXXXXX`
mount -t ext4 -o loop $IMG_FILE $MNTDIR
cp -p /etc/resolv.conf $MNTDIR/etc/resolv.conf
# We need to install a non-virtual kernel and modules to boot from
if [ ! -r "`ls $MNTDIR/boot/vmlinuz-*-generic | head -1`" ]; then
chroot $MNTDIR apt-get install -y linux-generic
fi
git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH
git_clone $HORIZON_REPO $DEST/horizon $HORIZON_BRANCH
git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH
git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
# Use this version of devstack
rm -rf $MNTDIR/$DEST/devstack
cp -pr $CWD $MNTDIR/$DEST/devstack
chroot $MNTDIR chown -R $STACK_USER $DEST/devstack
# Configure host network for DHCP
mkdir -p $MNTDIR/etc/network
cat > $MNTDIR/etc/network/interfaces <<EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
EOF
# Set hostname
echo "ramstack" >$MNTDIR/etc/hostname
echo "127.0.0.1 localhost ramstack" >$MNTDIR/etc/hosts
# Configure the runner
RUN_SH=$MNTDIR/$DEST/run.sh
cat > $RUN_SH <<EOF
#!/usr/bin/env bash
# Get IP range
set \`ip addr show dev eth0 | grep inet\`
PREFIX=\`echo \$2 | cut -d. -f1,2,3\`
export FLOATING_RANGE="\$PREFIX.224/27"
# Kill any existing screens
killall screen
# Run stack.sh
cd $DEST/devstack && \$STACKSH_PARAMS ./stack.sh > $DEST/run.sh.log
echo >> $DEST/run.sh.log
echo >> $DEST/run.sh.log
echo "All done! Time to start clicking." >> $DEST/run.sh.log
EOF
# Make the run.sh executable
chmod 755 $RUN_SH
chroot $MNTDIR chown $STACK_USER $DEST/run.sh
umount $MNTDIR
rmdir $MNTDIR

@ -1,180 +0,0 @@
#!/usr/bin/env bash
# **build_uec_ramdisk.sh**
# Build RAM disk images based on UEC image
# Exit on error to stop unexpected errors
set -o errexit
if [ ! "$#" -eq "1" ]; then
echo "$0 builds a gziped Ubuntu OpenStack install"
echo "usage: $0 dest"
exit 1
fi
# 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."
exit 1
fi
# Clean up resources that may be in use
function cleanup {
set +o errexit
if [ -n "$MNT_DIR" ]; then
umount $MNT_DIR/dev
umount $MNT_DIR
fi
if [ -n "$DEST_FILE_TMP" ]; then
rm $DEST_FILE_TMP
fi
# Kill ourselves to signal parents
trap 2; kill -2 $$
}
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
# Output dest image
DEST_FILE=$1
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
# Import common functions
. $TOP_DIR/functions
cd $TOP_DIR
# Source params
source ./stackrc
DEST=${DEST:-/opt/stack}
# Ubuntu distro to install
DIST_NAME=${DIST_NAME:-oneiric}
# Configure how large the VM should be
GUEST_SIZE=${GUEST_SIZE:-2G}
# 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."
echo "See stack.sh for required passwords."
exit 1
fi
# Install deps if needed
DEPS="kvm libvirt-bin kpartx cloud-utils curl"
apt_get install -y --force-yes $DEPS
# Where to store files and instances
CACHEDIR=${CACHEDIR:-/opt/stack/cache}
WORK_DIR=${WORK_DIR:-/opt/ramstack}
# Where to store images
image_dir=$WORK_DIR/images/$DIST_NAME
mkdir -p $image_dir
# Get the base image if it does not yet exist
if [ ! -e $image_dir/disk ]; then
$TOOLS_DIR/get_uec_image.sh -r 2000M $DIST_NAME $image_dir/disk
fi
# 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}
# Pre-load the image with basic environment
if [ ! -e $image_dir/disk-primed ]; then
cp $image_dir/disk $image_dir/disk-primed
$TOOLS_DIR/warm_apts_for_uec.sh $image_dir/disk-primed
$TOOLS_DIR/copy_dev_environment_to_uec.sh $image_dir/disk-primed
fi
# Back to devstack
cd $TOP_DIR
DEST_FILE_TMP=`mktemp $DEST_FILE.XXXXXX`
MNT_DIR=`mktemp -d --tmpdir mntXXXXXXXX`
cp $image_dir/disk-primed $DEST_FILE_TMP
mount -t ext4 -o loop $DEST_FILE_TMP $MNT_DIR
mount -o bind /dev /$MNT_DIR/dev
cp -p /etc/resolv.conf $MNT_DIR/etc/resolv.conf
echo root:$ROOT_PASSWORD | chroot $MNT_DIR chpasswd
touch $MNT_DIR/$DEST/.ramdisk
# We need to install a non-virtual kernel and modules to boot from
if [ ! -r "`ls $MNT_DIR/boot/vmlinuz-*-generic | head -1`" ]; then
chroot $MNT_DIR apt-get install -y linux-generic
fi
git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH
git_clone $HORIZON_REPO $DEST/horizon $HORIZON_BRANCH
git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH
git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
git_clone $TEMPEST_REPO $DEST/tempest $TEMPEST_BRANCH
# Use this version of devstack
rm -rf $MNT_DIR/$DEST/devstack
cp -pr $TOP_DIR $MNT_DIR/$DEST/devstack
chroot $MNT_DIR chown -R stack $DEST/devstack
# Configure host network for DHCP
mkdir -p $MNT_DIR/etc/network
cat > $MNT_DIR/etc/network/interfaces <<EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
EOF
# Set hostname
echo "ramstack" >$MNT_DIR/etc/hostname
echo "127.0.0.1 localhost ramstack" >$MNT_DIR/etc/hosts
# Configure the runner
RUN_SH=$MNT_DIR/$DEST/run.sh
cat > $RUN_SH <<EOF
#!/usr/bin/env bash
# Get IP range
set \`ip addr show dev eth0 | grep inet\`
PREFIX=\`echo \$2 | cut -d. -f1,2,3\`
export FLOATING_RANGE="\$PREFIX.224/27"
# Kill any existing screens
killall screen
# Run stack.sh
cd $DEST/devstack && \$STACKSH_PARAMS ./stack.sh > $DEST/run.sh.log
echo >> $DEST/run.sh.log
echo >> $DEST/run.sh.log
echo "All done! Time to start clicking." >> $DEST/run.sh.log
EOF
# Make the run.sh executable
chmod 755 $RUN_SH
chroot $MNT_DIR chown stack $DEST/run.sh
umount $MNT_DIR/dev
umount $MNT_DIR
rmdir $MNT_DIR
mv $DEST_FILE_TMP $DEST_FILE
rm -f $DEST_FILE_TMP
trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT

@ -1,148 +0,0 @@
#!/bin/bash -e
# **build_usb_boot.sh**
# Create a syslinux boot environment
#
# build_usb_boot.sh destdev
#
# Assumes syslinux is installed
# Needs to run as root
DEST_DIR=${1:-/tmp/syslinux-boot}
PXEDIR=${PXEDIR:-/opt/ramstack/pxe}
# Clean up any resources that may be in use
function 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 SIGQUIT EXIT
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
if [ -b $DEST_DIR ]; then
# We have a block device, install syslinux and mount it
DEST_DEV=$DEST_DIR
DEST_DIR=`mktemp -d --tmpdir mntXXXXXX`
mount $DEST_DEV $DEST_DIR
if [ ! -d $DEST_DIR/syslinux ]; then
mkdir -p $DEST_DIR/syslinux
fi
# Install syslinux on the device
syslinux --install --directory syslinux $DEST_DEV
else
# We have a directory (for sanity checking output)
DEST_DEV=""
if [ ! -d $DEST_DIR/syslinux ]; then
mkdir -p $DEST_DIR/syslinux
fi
fi
# Get some more stuff from syslinux
for i in memdisk menu.c32; do
cp -pu /usr/lib/syslinux/$i $DEST_DIR/syslinux
done
CFG=$DEST_DIR/syslinux/syslinux.cfg
cat >$CFG <<EOF
default /syslinux/menu.c32
prompt 0
timeout 0
MENU TITLE devstack Boot Menu
EOF
# Setup devstack boot
mkdir -p $DEST_DIR/ubuntu
if [ ! -d $PXEDIR ]; then
mkdir -p $PXEDIR
fi
# Get image into place
if [ ! -r $PXEDIR/stack-initrd.img ]; then
cd $TOP_DIR
$TOOLS_DIR/build_uec_ramdisk.sh $PXEDIR/stack-initrd.img
fi
if [ ! -r $PXEDIR/stack-initrd.gz ]; then
gzip -1 -c $PXEDIR/stack-initrd.img >$PXEDIR/stack-initrd.gz
fi
cp -pu $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu
if [ ! -r $PXEDIR/vmlinuz-*-generic ]; then
MNTDIR=`mktemp -d --tmpdir mntXXXXXXXX`
mount -t ext4 -o loop $PXEDIR/stack-initrd.img $MNTDIR
if [ ! -r $MNTDIR/boot/vmlinuz-*-generic ]; then
echo "No kernel found"
umount $MNTDIR
rmdir $MNTDIR
if [ -n "$DEST_DEV" ]; then
umount $DEST_DIR
rmdir $DEST_DIR
fi
exit 1
else
cp -pu $MNTDIR/boot/vmlinuz-*-generic $PXEDIR
fi
umount $MNTDIR
rmdir $MNTDIR
fi
# Get generic kernel version
KNAME=`basename $PXEDIR/vmlinuz-*-generic`
KVER=${KNAME#vmlinuz-}
cp -pu $PXEDIR/vmlinuz-$KVER $DEST_DIR/ubuntu
cat >>$CFG <<EOF
LABEL devstack
MENU LABEL ^devstack
MENU DEFAULT
KERNEL /ubuntu/vmlinuz-$KVER
APPEND initrd=/ubuntu/stack-initrd.gz ramdisk_size=2109600 root=/dev/ram0
EOF
# Get Ubuntu
if [ -d $PXEDIR -a -r $PXEDIR/natty-base-initrd.gz ]; then
cp -pu $PXEDIR/natty-base-initrd.gz $DEST_DIR/ubuntu
cat >>$CFG <<EOF
LABEL ubuntu
MENU LABEL ^Ubuntu Natty
KERNEL /ubuntu/vmlinuz-$KVER
APPEND initrd=/ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0
EOF
fi
# Local disk boot
cat >>$CFG <<EOF
LABEL local
MENU LABEL ^Local disk
LOCALBOOT 0
EOF
if [ -n "$DEST_DEV" ]; then
umount $DEST_DIR
rmdir $DEST_DIR
fi
trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT

@ -1,73 +0,0 @@
#!/usr/bin/env bash
# **copy_dev_environment_to_uec.sh**
# 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)
# Import common functions
. $TOP_DIR/functions
# Change dir to top of devstack
cd $TOP_DIR
# Source params
source ./stackrc
# Echo usage
function 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_USER -s /bin/bash -d $DEST -G libvirtd || true
# Add a simple password - pass
echo $STACK_USER:pass | chroot $STAGING_DIR chpasswd
# Configure sudo
( umask 226 && echo "$STACK_USER ALL=(ALL) NOPASSWD:ALL" \
> $STAGING_DIR/etc/sudoers.d/50_stack_sh )
# 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
# Copy devstack
rm -rf $STAGING_DIR/$DEST/devstack
cp_it . $STAGING_DIR/$DEST/devstack
# Give stack ownership over $DEST so it may do the work needed
chroot $STAGING_DIR chown -R $STACK_USER $DEST
# Unmount
umount $STAGING_DIR

@ -1,109 +0,0 @@
#!/bin/bash
# **get_uec_image.sh**
# Download and prepare Ubuntu UEC images
CACHEDIR=${CACHEDIR:-/opt/stack/cache}
ROOTSIZE=${ROOTSIZE:-2000M}
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
# Import common functions
. $TOP_DIR/functions
# Exit on error to stop unexpected errors
set -o errexit
set -o xtrace
function usage {
echo "Usage: $0 - Download and prepare Ubuntu UEC images"
echo ""
echo "$0 [-r rootsize] release imagefile [kernel]"
echo ""
echo "-r size - root fs size (min 2000MB)"
echo "release - Ubuntu release: lucid - quantal"
echo "imagefile - output image file"
echo "kernel - output kernel"
exit 1
}
# Clean up any resources that may be in use
function 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
# Kill ourselves to signal any calling process
trap 2; kill -2 $$
}
while getopts hr: c; do
case $c in
h) usage
;;
r) ROOTSIZE=$OPTARG
;;
esac
done
shift `expr $OPTIND - 1`
if [[ ! "$#" -eq "2" && ! "$#" -eq "3" ]]; then
usage
fi
# Default args
DIST_NAME=$1
IMG_FILE=$2
IMG_FILE_TMP=`mktemp $IMG_FILE.XXXXXX`
KERNEL=$3
case $DIST_NAME in
saucy) ;;
raring) ;;
quantal) ;;
precise) ;;
*) echo "Unknown release: $DIST_NAME"
usage
;;
esac
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
# Check dependencies
if [ ! -x "`which qemu-img`" -o -z "`dpkg -l | grep cloud-utils`" ]; then
# Missing KVM?
apt_get install qemu-kvm cloud-utils
fi
# Find resize script
RESIZE=`which resize-part-image || which uec-resize-image`
if [ -z "$RESIZE" ]; then
echo "resize tool from cloud-utils not found"
exit 1
fi
# Get the UEC image
UEC_NAME=$DIST_NAME-server-cloudimg-amd64
if [ ! -d $CACHEDIR/$DIST_NAME ]; then
mkdir -p $CACHEDIR/$DIST_NAME
fi
if [ ! -e $CACHEDIR/$DIST_NAME/$UEC_NAME.tar.gz ]; then
(cd $CACHEDIR/$DIST_NAME && wget -N http://uec-images.ubuntu.com/$DIST_NAME/current/$UEC_NAME.tar.gz)
(cd $CACHEDIR/$DIST_NAME && tar Sxvzf $UEC_NAME.tar.gz)
fi
$RESIZE $CACHEDIR/$DIST_NAME/$UEC_NAME.img ${ROOTSIZE} $IMG_FILE_TMP
mv $IMG_FILE_TMP $IMG_FILE
# Copy kernel to destination
if [ -n "$KERNEL" ]; then
cp -p $CACHEDIR/$DIST_NAME/*-vmlinuz-virtual $KERNEL
fi
trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT

@ -1,221 +0,0 @@
#!/bin/bash
# **install_openvpn.sh**
# Install OpenVPN and generate required certificates
#
# install_openvpn.sh --client name
# install_openvpn.sh --server [name]
#
# name is used on the CN of the generated cert, and the filename of
# the configuration, certificate and key files.
#
# --server mode configures the host with a running OpenVPN server instance
# --client mode creates a tarball of a client configuration for this server
# Get config file
if [ -e localrc ]; then
. localrc
fi
if [ -e vpnrc ]; then
. vpnrc
fi
# Do some IP manipulation
function cidr2netmask {
set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
if [[ $1 -gt 1 ]]; then
shift $1
else
shift
fi
echo ${1-0}.${2-0}.${3-0}.${4-0}
}
FIXED_NET=`echo $FIXED_RANGE | cut -d'/' -f1`
FIXED_CIDR=`echo $FIXED_RANGE | cut -d'/' -f2`
FIXED_MASK=`cidr2netmask $FIXED_CIDR`
# VPN Config
VPN_SERVER=${VPN_SERVER:-`ifconfig eth0 | awk "/inet addr:/ { print \$2 }" | cut -d: -f2`} # 50.56.12.212
VPN_PROTO=${VPN_PROTO:-tcp}
VPN_PORT=${VPN_PORT:-6081}
VPN_DEV=${VPN_DEV:-tap0}
VPN_BRIDGE=${VPN_BRIDGE:-br100}
VPN_BRIDGE_IF=${VPN_BRIDGE_IF:-$FLAT_INTERFACE}
VPN_CLIENT_NET=${VPN_CLIENT_NET:-$FIXED_NET}
VPN_CLIENT_MASK=${VPN_CLIENT_MASK:-$FIXED_MASK}
VPN_CLIENT_DHCP="${VPN_CLIENT_DHCP:-net.1 net.254}"
VPN_DIR=/etc/openvpn
CA_DIR=$VPN_DIR/easy-rsa
function usage {
echo "$0 - OpenVPN install and certificate generation"
echo ""
echo "$0 --client name"
echo "$0 --server [name]"
echo ""
echo " --server mode configures the host with a running OpenVPN server instance"
echo " --client mode creates a tarball of a client configuration for this server"
exit 1
}
if [ -z $1 ]; then
usage
fi
# Install OpenVPN
VPN_EXEC=`which openvpn`
if [ -z "$VPN_EXEC" -o ! -x "$VPN_EXEC" ]; then
apt-get install -y openvpn bridge-utils
fi
if [ ! -d $CA_DIR ]; then
cp -pR /usr/share/doc/openvpn/examples/easy-rsa/2.0/ $CA_DIR
fi
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $TOOLS_DIR/.. && pwd)
WEB_DIR=$TOP_DIR/../vpn
if [[ ! -d $WEB_DIR ]]; then
mkdir -p $WEB_DIR
fi
WEB_DIR=$(cd $TOP_DIR/../vpn && pwd)
cd $CA_DIR
source ./vars
# Override the defaults
export KEY_COUNTRY="US"
export KEY_PROVINCE="TX"
export KEY_CITY="SanAntonio"
export KEY_ORG="Cloudbuilders"
export KEY_EMAIL="rcb@lists.rackspace.com"
if [ ! -r $CA_DIR/keys/dh1024.pem ]; then
# Initialize a new CA
$CA_DIR/clean-all
$CA_DIR/build-dh
$CA_DIR/pkitool --initca
openvpn --genkey --secret $CA_DIR/keys/ta.key ## Build a TLS key
fi
function do_server {
NAME=$1
# Generate server certificate
$CA_DIR/pkitool --server $NAME
(cd $CA_DIR/keys;
cp $NAME.crt $NAME.key ca.crt dh1024.pem ta.key $VPN_DIR
)
cat >$VPN_DIR/br-up <<EOF
#!/bin/bash
BR="$VPN_BRIDGE"
TAP="\$1"
if [[ ! -d /sys/class/net/\$BR ]]; then
brctl addbr \$BR
fi
for t in \$TAP; do
openvpn --mktun --dev \$t
brctl addif \$BR \$t
ifconfig \$t 0.0.0.0 promisc up
done
EOF
chmod +x $VPN_DIR/br-up
cat >$VPN_DIR/br-down <<EOF
#!/bin/bash
BR="$VPN_BRIDGE"
TAP="\$1"
for i in \$TAP; do
brctl delif \$BR $t
openvpn --rmtun --dev \$i
done
EOF
chmod +x $VPN_DIR/br-down
cat >$VPN_DIR/$NAME.conf <<EOF
proto $VPN_PROTO
port $VPN_PORT
dev $VPN_DEV
up $VPN_DIR/br-up
down $VPN_DIR/br-down
cert $NAME.crt
key $NAME.key # This file should be kept secret
ca ca.crt
dh dh1024.pem
duplicate-cn
server-bridge $VPN_CLIENT_NET $VPN_CLIENT_MASK $VPN_CLIENT_DHCP
ifconfig-pool-persist ipp.txt
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
EOF
/etc/init.d/openvpn restart
}
function do_client {
NAME=$1
# Generate a client certificate
$CA_DIR/pkitool $NAME
TMP_DIR=`mktemp -d`
(cd $CA_DIR/keys;
cp -p ca.crt ta.key $NAME.key $NAME.crt $TMP_DIR
)
if [ -r $VPN_DIR/hostname ]; then
HOST=`cat $VPN_DIR/hostname`
else
HOST=`hostname`
fi
cat >$TMP_DIR/$HOST.conf <<EOF
proto $VPN_PROTO
port $VPN_PORT
dev $VPN_DEV
cert $NAME.crt
key $NAME.key # This file should be kept secret
ca ca.crt
client
remote $VPN_SERVER $VPN_PORT
resolv-retry infinite
nobind
user nobody
group nogroup
persist-key
persist-tun
comp-lzo
verb 3
EOF
(cd $TMP_DIR; tar cf $WEB_DIR/$NAME.tar *)
rm -rf $TMP_DIR
echo "Client certificate and configuration is in $WEB_DIR/$NAME.tar"
}
# Process command line args
case $1 in
--client) if [ -z $2 ]; then
usage
fi
do_client $2
;;
--server) if [ -z $2 ]; then
NAME=`hostname`
else
NAME=$2
# Save for --client use
echo $NAME >$VPN_DIR/hostname
fi
do_server $NAME
;;
--clean) $CA_DIR/clean-all
;;
*) usage
esac

@ -1,53 +0,0 @@
#!/usr/bin/env bash
# **warm_apts_for_uec.sh**
# 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
function 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
# 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=/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
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` || true
# Unmount
umount $STAGING_DIR