From 8b3eb5ffe31c6a112e9461f16c6955f303018f17 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 16:05:14 -0700 Subject: [PATCH 01/42] 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 228f246a838ace75b620292f46f746aee1035c48 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 5 Nov 2011 17:36:14 -0700 Subject: [PATCH 02/42] 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 03/42] 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 04/42] 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 05/42] 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 06/42] 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 07/42] 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 08/42] 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 09/42] 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 10/42] 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 11/42] 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 12/42] 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 13/42] 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 14/42] 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 15/42] 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 16/42] 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 17/42] 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 18/42] 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 19/42] 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 20/42] 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 21/42] 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 22/42] 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 23/42] 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 24/42] 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 25/42] 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 26/42] 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 27/42] 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 28/42] 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 29/42] 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 30/42] 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 31/42] 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 32/42] 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 33/42] 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 34/42] 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 35/42] 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 36/42] 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 37/42] 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 38/42] 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 39/42] 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 f0b41f3fb7c8802cfbd1576e10f268e20d5e1e7b Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 7 Nov 2011 09:51:15 -0800 Subject: [PATCH 40/42] 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 41/42] 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 42/42] 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<