From 49946a14b5c4ef290397a8ffd4254f2ff3c0797e Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Fri, 4 Nov 2011 15:09:41 -0500 Subject: [PATCH 01/50] 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 02/50] add script that demonstrates separation of head abd compute roles when using xen --- tools/xen/build_domU.sh | 25 +++++++++++++++---------- tools/xen/build_domU_multi.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 10 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 03/50] 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 04/50] 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 05/50] 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 06/50] 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 07/50] 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 08/50] 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 09/50] 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 10/50] 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 11/50] 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 12/50] 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 13/50] 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 14/50] 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 15/50] 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 16/50] 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 17/50] 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 18/50] 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 19/50] 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 20/50] 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 21/50] 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 22/50] 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 23/50] 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 24/50] 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 25/50] 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 26/50] 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 27/50] 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 28/50] 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 29/50] 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 30/50] 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 31/50] 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 32/50] 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 33/50] 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 34/50] 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 35/50] 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 36/50] 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 37/50] 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 38/50] 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 39/50] 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 40/50] 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 41/50] 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 42/50] 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 43/50] 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 44/50] 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 45/50] 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 46/50] 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 47/50] 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 48/50] 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 49/50] 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 50/50] 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<