From f6fd4dcf2e9c29f3ed4b911abc16bbb4b8af4b70 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Tue, 11 Oct 2011 20:03:05 -0500 Subject: [PATCH 01/57] Check out devstack by default --- stackrc | 4 ++++ tools/build_ramdisk.sh | 2 ++ 2 files changed, 6 insertions(+) diff --git a/stackrc b/stackrc index 15d73ce..871db69 100644 --- a/stackrc +++ b/stackrc @@ -27,6 +27,10 @@ NOVACLIENT_BRANCH=master OPENSTACKX_REPO=https://github.com/cloudbuilders/openstackx.git OPENSTACKX_BRANCH=diablo +# devstack is this collection of scripts +DEVSTACK_REPO=https://github.com/cloudbuilders/devstack.git +DEVSTACK_BRANCH=master + # allow local overrides of env variables if [ -f ./localrc ]; then source ./localrc diff --git a/tools/build_ramdisk.sh b/tools/build_ramdisk.sh index 63d37a9..85d3743 100755 --- a/tools/build_ramdisk.sh +++ b/tools/build_ramdisk.sh @@ -100,6 +100,8 @@ git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack +else + git_clone $DEVSTACK_REPO $DEST/devstack $DEVSTACK_BRANCH fi # Configure host network for DHCP From b5da51972cf8d6e7919d87dfe0767bffdb16a441 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 17 Oct 2011 13:32:06 -0500 Subject: [PATCH 02/57] Always use current devstack in ramdisk --- stackrc | 4 ---- tools/build_ramdisk.sh | 11 ++++------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/stackrc b/stackrc index 871db69..15d73ce 100644 --- a/stackrc +++ b/stackrc @@ -27,10 +27,6 @@ NOVACLIENT_BRANCH=master OPENSTACKX_REPO=https://github.com/cloudbuilders/openstackx.git OPENSTACKX_BRANCH=diablo -# devstack is this collection of scripts -DEVSTACK_REPO=https://github.com/cloudbuilders/devstack.git -DEVSTACK_BRANCH=master - # allow local overrides of env variables if [ -f ./localrc ]; then source ./localrc diff --git a/tools/build_ramdisk.sh b/tools/build_ramdisk.sh index 85d3743..437b103 100755 --- a/tools/build_ramdisk.sh +++ b/tools/build_ramdisk.sh @@ -96,13 +96,10 @@ git_clone $DASH_REPO $DEST/dash $DASH_BRANCH git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH -# Use this version of devstack? -if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then - rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack - cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack -else - git_clone $DEVSTACK_REPO $DEST/devstack $DEVSTACK_BRANCH -fi +# Use this version of devstack +rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack +cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack +chroot $CHROOTCACHE/natty-stack chown -R stack $DEST/devstack # Configure host network for DHCP mkdir -p $CHROOTCACHE/natty-stack/etc/network From 314bc2247d2e2312ab0bb41aa7aba85afd96ad12 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Tue, 18 Oct 2011 16:32:13 -0500 Subject: [PATCH 03/57] Fix another chroot/chown combo --- tools/build_ramdisk.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_ramdisk.sh b/tools/build_ramdisk.sh index 437b103..0f93735 100755 --- a/tools/build_ramdisk.sh +++ b/tools/build_ramdisk.sh @@ -42,7 +42,7 @@ if [ ! -d $CHROOTCACHE/natty-dev ]; then chroot $CHROOTCACHE/natty-dev groupadd libvirtd chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd mkdir -p $CHROOTCACHE/natty-dev/$DEST - chown stack $CHROOTCACHE/natty-dev/$DEST + chroot $CHROOTCACHE/natty-dev chown stack $DEST # a simple password - pass echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd From acff87a2023fa96e8b8983b73a380ad613783a89 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 20 Oct 2011 10:12:58 -0700 Subject: [PATCH 04/57] initial support for volumes --- stack.sh | 28 +++++++++++++++++++++++++++- tools/build_lxc.sh | 3 ++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/stack.sh b/stack.sh index 61c0f57..79cc377 100755 --- a/stack.sh +++ b/stack.sh @@ -127,7 +127,7 @@ OPENSTACKX_DIR=$DEST/openstackx NOVNC_DIR=$DEST/noVNC # Specify which services to launch. These generally correspond to screen tabs -ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,dash,mysql,rabbit} +ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,dash,mysql,rabbit,n-vol} # Nova hypervisor configuration. We default to **kvm** but will drop back to # **qemu** if we are unable to load the kvm module. Stack.sh can also install @@ -534,6 +534,31 @@ if [[ "$ENABLED_SERVICES" =~ "n-net" ]]; then mkdir -p $NOVA_DIR/networks fi +# Volume Service +# -------------- + +if [[ "$ENABLED_SERVICES" =~ "n-vol" ]]; then + # + # Configure a default volume group called 'nova-volumes' for the nova-volume + # service if it does not yet exist. If you don't wish to use a file backed + # volume group, create your own volume group called 'nova-volumes' before + # invoking stack.sh. + # + # By default, the backing file is 2G in size, and is stored in /opt/stack. + # + VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-/opt/stack/nova-volumes-backing-file} + VOLUME_BACKING_FILE_SIZE=${VOLUME_BACKING_FILE_SIZE:-2052M} + if ! sudo vgdisplay | grep -q nova-volumes; then + truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE + DEV=`sudo losetup -f --show $VOLUME_BACKING_FILE` + sudo vgcreate nova-volumes $DEV + fi + + # Configure iscsitarget + sudo sed 's/ISCSITARGET_ENABLE=false/ISCSITARGET_ENABLE=true/' -i /etc/default/iscsitarget + sudo /etc/init.d/iscsitarget restart +fi + function add_nova_flag { echo "$1" >> $NOVA_DIR/bin/nova.conf } @@ -671,6 +696,7 @@ fi # within the context of our original shell (so our groups won't be updated). # Use 'sg' to execute nova-compute as a member of the libvirtd group. screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_DIR/bin/nova-compute" +screen_it n-vol "cd $NOVA_DIR && $NOVA_DIR/bin/nova-volume" screen_it n-net "cd $NOVA_DIR && $NOVA_DIR/bin/nova-network" screen_it n-sch "cd $NOVA_DIR && $NOVA_DIR/bin/nova-scheduler" screen_it n-vnc "cd $NOVNC_DIR && ./utils/nova-wsproxy.py 6080 --web . --flagfile=../nova/bin/nova.conf" diff --git a/tools/build_lxc.sh b/tools/build_lxc.sh index df9e32e..8525b49 100755 --- a/tools/build_lxc.sh +++ b/tools/build_lxc.sh @@ -38,7 +38,8 @@ DEST=${DEST:-/opt/stack} WAIT_TILL_LAUNCH=${WAIT_TILL_LAUNCH:-1} # Param string to pass to stack.sh. Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova" -STACKSH_PARAMS=${STACKSH_PARAMS:-} +# By default, n-vol is disabled for lxc +STACKSH_PARAMS=${STACKSH_PARAMS:-"ENABLED_SERVICES=g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,dash,mysql,rabbit"} # Option to use the version of devstack on which we are currently working USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1} From 6ab10d46a874765f7c69366a5473ac6a42a92556 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 20 Oct 2011 10:24:50 -0700 Subject: [PATCH 05/57] add an openrc file so that users can easily use the client --- exercise.sh | 40 ++-------------------------------------- openrc | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 38 deletions(-) create mode 100644 openrc diff --git a/exercise.sh b/exercise.sh index f35adef..c62e86d 100755 --- a/exercise.sh +++ b/exercise.sh @@ -19,44 +19,8 @@ set -o xtrace # Settings # ======== -# Use stackrc and localrc for settings -source ./stackrc - -HOST=${HOST:-localhost} - -# Nova original used project_id as the *account* that owned resources (servers, -# ip address, ...) With the addition of Keystone we have standardized on the -# term **tenant** as the entity that owns the resources. **novaclient** still -# uses the old deprecated terms project_id. Note that this field should now be -# set to tenant_name, not tenant_id. -export NOVA_PROJECT_ID=${TENANT:-demo} - -# In addition to the owning entity (tenant), nova stores the entity performing -# the action as the **user**. -export NOVA_USERNAME=${USERNAME:-demo} - -# With Keystone you pass the keystone password instead of an api key. -export NOVA_API_KEY=${ADMIN_PASSWORD:-secrete} - -# With the addition of Keystone, to use an openstack cloud you should -# authenticate against keystone, which returns a **Token** and **Service -# Catalog**. The catalog contains the endpoint for all services the user/tenant -# has access to - including nova, glance, keystone, swift, ... We currently -# recommend using the 2.0 *auth api*. -# -# *NOTE*: Using the 2.0 *auth api* does mean that compute api is 2.0. We will -# use the 1.1 *compute api* -export NOVA_URL=${NOVA_URL:-http://$HOST:5000/v2.0/} - -# Currently novaclient needs you to specify the *compute api* version. This -# needs to match the config of your catalog returned by Keystone. -export NOVA_VERSION=1.1 - -# FIXME - why does this need to be specified? -export NOVA_REGION_NAME=RegionOne - -# set log level to DEBUG (helps debug issues) -export NOVACLIENT_DEBUG=1 +# Use openrc + stackrc + localrc for settings +source ./openrc # Get a token for clients that don't support service catalog # ========================================================== diff --git a/openrc b/openrc new file mode 100644 index 0000000..09e0ca5 --- /dev/null +++ b/openrc @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Load local configuration +source ./stackrc + +# Set api host endpoint +HOST=${HOST:-localhost} + +# Nova original used project_id as the *account* that owned resources (servers, +# ip address, ...) With the addition of Keystone we have standardized on the +# term **tenant** as the entity that owns the resources. **novaclient** still +# uses the old deprecated terms project_id. Note that this field should now be +# set to tenant_name, not tenant_id. +export NOVA_PROJECT_ID=${TENANT:-demo} + +# In addition to the owning entity (tenant), nova stores the entity performing +# the action as the **user**. +export NOVA_USERNAME=${USERNAME:-demo} + +# With Keystone you pass the keystone password instead of an api key. +export NOVA_API_KEY=${ADMIN_PASSWORD:-secrete} + +# With the addition of Keystone, to use an openstack cloud you should +# authenticate against keystone, which returns a **Token** and **Service +# Catalog**. The catalog contains the endpoint for all services the user/tenant +# has access to - including nova, glance, keystone, swift, ... We currently +# recommend using the 2.0 *auth api*. +# +# *NOTE*: Using the 2.0 *auth api* does mean that compute api is 2.0. We will +# use the 1.1 *compute api* +export NOVA_URL=${NOVA_URL:-http://$HOST:5000/v2.0/} + +# Currently novaclient needs you to specify the *compute api* version. This +# needs to match the config of your catalog returned by Keystone. +export NOVA_VERSION=1.1 + +# FIXME - why does this need to be specified? +export NOVA_REGION_NAME=RegionOne + +# set log level to DEBUG (helps debug issues) +export NOVACLIENT_DEBUG=1 From b22263a60485a614a76e03227ea994e239929a74 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 20 Oct 2011 10:26:30 -0700 Subject: [PATCH 06/57] tweaks per jesse comments --- stack.sh | 4 ++-- tools/build_lxc.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stack.sh b/stack.sh index 79cc377..2b38f32 100755 --- a/stack.sh +++ b/stack.sh @@ -546,9 +546,9 @@ if [[ "$ENABLED_SERVICES" =~ "n-vol" ]]; then # # By default, the backing file is 2G in size, and is stored in /opt/stack. # - VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-/opt/stack/nova-volumes-backing-file} - VOLUME_BACKING_FILE_SIZE=${VOLUME_BACKING_FILE_SIZE:-2052M} if ! sudo vgdisplay | grep -q nova-volumes; then + VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-/opt/stack/nova-volumes-backing-file} + VOLUME_BACKING_FILE_SIZE=${VOLUME_BACKING_FILE_SIZE:-2052M} truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE DEV=`sudo losetup -f --show $VOLUME_BACKING_FILE` sudo vgcreate nova-volumes $DEV diff --git a/tools/build_lxc.sh b/tools/build_lxc.sh index 8525b49..c95e47a 100755 --- a/tools/build_lxc.sh +++ b/tools/build_lxc.sh @@ -38,7 +38,7 @@ DEST=${DEST:-/opt/stack} WAIT_TILL_LAUNCH=${WAIT_TILL_LAUNCH:-1} # Param string to pass to stack.sh. Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova" -# By default, n-vol is disabled for lxc +# By default, n-vol is disabled for lxc, as iscsitarget doesn't work properly in lxc STACKSH_PARAMS=${STACKSH_PARAMS:-"ENABLED_SERVICES=g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,dash,mysql,rabbit"} # Option to use the version of devstack on which we are currently working From d81ed0316f8932a380af569fd0d7ecbb3fca391c Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 20 Oct 2011 13:09:39 -0700 Subject: [PATCH 07/57] allow overrides for all params --- openrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openrc b/openrc index e45b8fd..b79962a 100644 --- a/openrc +++ b/openrc @@ -32,10 +32,10 @@ export NOVA_URL=${NOVA_URL:-http://$HOST:5000/v2.0/} # Currently novaclient needs you to specify the *compute api* version. This # needs to match the config of your catalog returned by Keystone. -export NOVA_VERSION=1.1 +export NOVA_VERSION=${NOVA_VERSION:-1.1} # FIXME - why does this need to be specified? -export NOVA_REGION_NAME=RegionOne +export NOVA_REGION_NAME=${NOVA_REGION_NAME:-RegionOne} # set log level to DEBUG (helps debug issues) -export NOVACLIENT_DEBUG=1 +export NOVACLIENT_DEBUG=${NOVACLIENT_DEBUG:-0} From a7e2bfbf3f808e989b7a207f5c483772ca9f39ba Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 20 Oct 2011 15:30:25 -0700 Subject: [PATCH 08/57] disable n-vol by default for now --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 2b38f32..04de14a 100755 --- a/stack.sh +++ b/stack.sh @@ -127,7 +127,7 @@ OPENSTACKX_DIR=$DEST/openstackx NOVNC_DIR=$DEST/noVNC # Specify which services to launch. These generally correspond to screen tabs -ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,dash,mysql,rabbit,n-vol} +ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,dash,mysql,rabbit} # Nova hypervisor configuration. We default to **kvm** but will drop back to # **qemu** if we are unable to load the kvm module. Stack.sh can also install From e4f030fef125578c447448735d0a2dd1d79ab4fb Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Fri, 21 Oct 2011 14:28:03 -0500 Subject: [PATCH 09/57] Add CONTAINER_NAME to BASE_IMAGE_COPY value --- tools/build_kvm.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 207f86b..7511898 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -45,14 +45,14 @@ source ./stackrc DIST_NAME=${DIST_NAME:-natty} IMAGE_FNAME=$DIST_NAME.raw +# Name of our instance, used by libvirt +CONTAINER_NAME=${CONTAINER_NAME:-kvmstack} + # Original version of built image BASE_IMAGE=$KVMSTACK_DIR/images/natty.raw # Copy of base image, which we pre-install with tasty treats -BASE_IMAGE_COPY=$IMAGES_DIR/$DIST_NAME.raw.copy - -# Name of our instance, used by libvirt -CONTAINER_NAME=${CONTAINER_NAME:-kvmstack} +BASE_IMAGE_COPY=$IMAGES_DIR/$DIST_NAME.$CONTAINER_NAME.raw.copy # Mop up after previous runs virsh destroy $CONTAINER_NAME From ad57a3a8e81e42f0a4dba0e5f836cce4044a78d4 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Fri, 21 Oct 2011 14:29:30 -0500 Subject: [PATCH 10/57] Change hard-coded natty to DIST_NAME --- tools/build_kvm.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 7511898..6c364cb 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -49,7 +49,7 @@ IMAGE_FNAME=$DIST_NAME.raw CONTAINER_NAME=${CONTAINER_NAME:-kvmstack} # Original version of built image -BASE_IMAGE=$KVMSTACK_DIR/images/natty.raw +BASE_IMAGE=$KVMSTACK_DIR/images/$DIST_NAME.raw # Copy of base image, which we pre-install with tasty treats BASE_IMAGE_COPY=$IMAGES_DIR/$DIST_NAME.$CONTAINER_NAME.raw.copy @@ -70,8 +70,8 @@ mkdir -p $COPY_DIR # Create the base image if it does not yet exist if [ ! -e $IMAGES_DIR/$IMAGE_FNAME ]; then cd $TOOLS_DIR - ./make_image.sh -m -r 5000 natty raw - mv natty.raw $BASE_IMAGE + ./make_image.sh -m -r 5000 $DIST_NAME raw + mv $DIST_NAME.raw $BASE_IMAGE cd $TOP_DIR fi @@ -306,7 +306,7 @@ chmod 755 $RUN_SH RC_LOCAL=$ROOTFS/etc/init.d/local cat > $RC_LOCAL < Date: Fri, 21 Oct 2011 14:58:44 -0500 Subject: [PATCH 11/57] Rename BASE_IMAGE_COPY to VM_IMAGE --- tools/build_kvm.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 6c364cb..c047803 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -52,7 +52,7 @@ CONTAINER_NAME=${CONTAINER_NAME:-kvmstack} BASE_IMAGE=$KVMSTACK_DIR/images/$DIST_NAME.raw # Copy of base image, which we pre-install with tasty treats -BASE_IMAGE_COPY=$IMAGES_DIR/$DIST_NAME.$CONTAINER_NAME.raw.copy +VM_IMAGE=$IMAGES_DIR/$DIST_NAME.$CONTAINER_NAME.raw # Mop up after previous runs virsh destroy $CONTAINER_NAME @@ -76,8 +76,8 @@ if [ ! -e $IMAGES_DIR/$IMAGE_FNAME ]; then fi # Create a copy of the base image -if [ ! -e $BASE_IMAGE_COPY ]; then - cp -p $BASE_IMAGE $BASE_IMAGE_COPY +if [ ! -e $VM_IMAGE ]; then + cp -p $BASE_IMAGE $VM_IMAGE fi # Unmount the copied base image @@ -108,7 +108,7 @@ trap kill_unmount SIGINT DEST=${DEST:-/opt/stack} # Mount the file system -mount -o loop,offset=32256 $BASE_IMAGE_COPY $COPY_DIR +mount -o loop,offset=32256 $VM_IMAGE $COPY_DIR # git clone only if directory doesn't exist already. Since ``DEST`` might not # be owned by the installation user, we create the directory and change the @@ -231,7 +231,7 @@ cd $VM_DIR rm -f $VM_DIR/disk # Create our instance fs -qemu-img create -f qcow2 -b $BASE_IMAGE_COPY disk +qemu-img create -f qcow2 -b $VM_IMAGE disk sleep 5 From 9c8537316397d51ac7aa46ee9408232a2b434dd4 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Fri, 21 Oct 2011 19:05:40 -0700 Subject: [PATCH 12/57] typo - fixes issue #90 --- openrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openrc b/openrc index b79962a..dd04730 100644 --- a/openrc +++ b/openrc @@ -26,8 +26,8 @@ export NOVA_API_KEY=${ADMIN_PASSWORD:-secrete} # has access to - including nova, glance, keystone, swift, ... We currently # recommend using the 2.0 *auth api*. # -# *NOTE*: Using the 2.0 *auth api* does mean that compute api is 2.0. We will -# use the 1.1 *compute api* +# *NOTE*: Using the 2.0 *auth api* does not mean that compute api is 2.0. We +# will use the 1.1 *compute api* export NOVA_URL=${NOVA_URL:-http://$HOST:5000/v2.0/} # Currently novaclient needs you to specify the *compute api* version. This From ec1d0318abd5e56cf248da0063ddaa18278653ef Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Fri, 21 Oct 2011 19:22:55 -0700 Subject: [PATCH 13/57] libvirt.xml needs to be created in correct location --- tools/build_kvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index c047803..b9f6163 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -166,7 +166,7 @@ CONTAINER_RAM=${CONTAINER_RAM:-1524288} CONTAINER_CORES=${CONTAINER_CORES:-1} # libvirt.xml configuration -LIBVIRT_XML=libvirt.xml +LIBVIRT_XML=$VM_DIR/libvirt.xml cat > $LIBVIRT_XML < $CONTAINER_NAME From ccc11c9d186fb645233514cd5c4799aed6eb7148 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Sat, 22 Oct 2011 20:52:29 -0700 Subject: [PATCH 14/57] use CONTAINER_NAME instead of CONTAINER like build_kvm.sh --- tools/build_lxc.sh | 22 +++++++++++----------- tools/build_lxc_multi.sh | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/build_lxc.sh b/tools/build_lxc.sh index fc71be8..5785a3e 100755 --- a/tools/build_lxc.sh +++ b/tools/build_lxc.sh @@ -27,7 +27,7 @@ CWD=`pwd` # Configurable params BRIDGE=${BRIDGE:-br0} -CONTAINER=${CONTAINER:-STACK} +CONTAINER_NAME=${CONTAINER_NAME:-STACK} CONTAINER_IP=${CONTAINER_IP:-192.168.1.50} CONTAINER_CIDR=${CONTAINER_CIDR:-$CONTAINER_IP/24} CONTAINER_NETMASK=${CONTAINER_NETMASK:-255.255.255.0} @@ -60,7 +60,7 @@ if ! which cgdelete | grep -q cgdelete; then fi # Create lxc configuration -LXC_CONF=/tmp/$CONTAINER.conf +LXC_CONF=/tmp/$CONTAINER_NAME.conf cat > $LXC_CONF < Date: Sat, 22 Oct 2011 20:56:23 -0700 Subject: [PATCH 15/57] update build lxc/kvm variables to GUEST instead of CONTAINER --- tools/build_kvm.sh | 37 ++++++++++++++++++------------------- tools/build_lxc.sh | 40 ++++++++++++++++++++-------------------- tools/build_lxc_multi.sh | 2 +- 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index b9f6163..59ed649 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -46,19 +46,19 @@ DIST_NAME=${DIST_NAME:-natty} IMAGE_FNAME=$DIST_NAME.raw # Name of our instance, used by libvirt -CONTAINER_NAME=${CONTAINER_NAME:-kvmstack} +GUEST_NAME=${GUEST_NAME:-kvmstack} # Original version of built image BASE_IMAGE=$KVMSTACK_DIR/images/$DIST_NAME.raw # Copy of base image, which we pre-install with tasty treats -VM_IMAGE=$IMAGES_DIR/$DIST_NAME.$CONTAINER_NAME.raw +VM_IMAGE=$IMAGES_DIR/$DIST_NAME.$GUEST_NAME.raw # Mop up after previous runs -virsh destroy $CONTAINER_NAME +virsh destroy $GUEST_NAME # Where this vm is stored -VM_DIR=$KVMSTACK_DIR/instances/$CONTAINER_NAME +VM_DIR=$KVMSTACK_DIR/instances/$GUEST_NAME # Create vm dir mkdir -p $VM_DIR @@ -156,21 +156,20 @@ cd $TOP_DIR # Network configuration variables BRIDGE=${BRIDGE:-br0} -CONTAINER=${CONTAINER:-STACK} -CONTAINER_IP=${CONTAINER_IP:-192.168.1.50} -CONTAINER_CIDR=${CONTAINER_CIDR:-$CONTAINER_IP/24} -CONTAINER_NETMASK=${CONTAINER_NETMASK:-255.255.255.0} -CONTAINER_GATEWAY=${CONTAINER_GATEWAY:-192.168.1.1} -CONTAINER_MAC=${CONTAINER_MAC:-"02:16:3e:07:69:`printf '%02X' $(echo $CONTAINER_IP | sed "s/.*\.//")`"} -CONTAINER_RAM=${CONTAINER_RAM:-1524288} -CONTAINER_CORES=${CONTAINER_CORES:-1} +GUEST_IP=${GUEST_IP:-192.168.1.50} +GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24} +GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0} +GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.1.1} +GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $(echo $GUEST_IP | sed "s/.*\.//")`"} +GUEST_RAM=${GUEST_RAM:-1524288} +GUEST_CORES=${GUEST_CORES:-1} # libvirt.xml configuration LIBVIRT_XML=$VM_DIR/libvirt.xml cat > $LIBVIRT_XML < - $CONTAINER_NAME - $CONTAINER_RAM + $GUEST_NAME + $GUEST_RAM hvm @@ -178,7 +177,7 @@ cat > $LIBVIRT_XML < - $CONTAINER_CORES + $GUEST_CORES @@ -188,7 +187,7 @@ cat > $LIBVIRT_XML < - + @@ -250,9 +249,9 @@ iface lo inet loopback auto eth0 iface eth0 inet static - address $CONTAINER_IP - netmask $CONTAINER_NETMASK - gateway $CONTAINER_GATEWAY + address $GUEST_IP + netmask $GUEST_NETMASK + gateway $GUEST_GATEWAY EOF # User configuration for the instance diff --git a/tools/build_lxc.sh b/tools/build_lxc.sh index 5785a3e..9cbbedf 100755 --- a/tools/build_lxc.sh +++ b/tools/build_lxc.sh @@ -27,11 +27,11 @@ CWD=`pwd` # Configurable params BRIDGE=${BRIDGE:-br0} -CONTAINER_NAME=${CONTAINER_NAME:-STACK} -CONTAINER_IP=${CONTAINER_IP:-192.168.1.50} -CONTAINER_CIDR=${CONTAINER_CIDR:-$CONTAINER_IP/24} -CONTAINER_NETMASK=${CONTAINER_NETMASK:-255.255.255.0} -CONTAINER_GATEWAY=${CONTAINER_GATEWAY:-192.168.1.1} +GUEST_NAME=${GUEST_NAME:-STACK} +GUEST_IP=${GUEST_IP:-192.168.1.50} +GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24} +GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0} +GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.1.1} NAMESERVER=${NAMESERVER:-`cat /etc/resolv.conf | grep nameserver | head -1 | cut -d " " -f2`} COPYENV=${COPYENV:-1} DEST=${DEST:-/opt/stack} @@ -60,22 +60,22 @@ if ! which cgdelete | grep -q cgdelete; then fi # Create lxc configuration -LXC_CONF=/tmp/$CONTAINER_NAME.conf +LXC_CONF=/tmp/$GUEST_NAME.conf cat > $LXC_CONF < $RUN_SH < Date: Mon, 24 Oct 2011 10:41:49 -0700 Subject: [PATCH 16/57] diablo branch for noVNC --- stackrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stackrc b/stackrc index aaee6ec..82dd527 100644 --- a/stackrc +++ b/stackrc @@ -12,7 +12,7 @@ KEYSTONE_BRANCH=diablo # a websockets/html5 or flash powered VNC console for vm instances NOVNC_REPO=https://github.com/cloudbuilders/noVNC.git -NOVNC_BRANCH=master +NOVNC_BRANCH=diablo # django powered web control panel for openstack DASH_REPO=https://github.com/cloudbuilders/openstack-dashboard.git From f1bfba27225d42fa678080b749924d00eb2e6e0b Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 10:56:10 -0700 Subject: [PATCH 17/57] document how to overwrite the debug settings --- openrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openrc b/openrc index dd04730..4f953de 100644 --- a/openrc +++ b/openrc @@ -38,4 +38,4 @@ export NOVA_VERSION=${NOVA_VERSION:-1.1} export NOVA_REGION_NAME=${NOVA_REGION_NAME:-RegionOne} # set log level to DEBUG (helps debug issues) -export NOVACLIENT_DEBUG=${NOVACLIENT_DEBUG:-0} +# export NOVACLIENT_DEBUG=1 From 540b98837148c19ceac2d4e76d573604ae6f0815 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 11:09:07 -0700 Subject: [PATCH 18/57] change to git:// from https:// remotes --- stackrc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stackrc b/stackrc index 82dd527..c063864 100644 --- a/stackrc +++ b/stackrc @@ -1,30 +1,30 @@ # compute service -NOVA_REPO=https://github.com/cloudbuilders/nova.git +NOVA_REPO=git://github.com/cloudbuilders/nova.git NOVA_BRANCH=diablo # image catalog service -GLANCE_REPO=https://github.com/cloudbuilders/glance.git +GLANCE_REPO=git://github.com/cloudbuilders/glance.git GLANCE_BRANCH=diablo # unified auth system (manages accounts/tokens) -KEYSTONE_REPO=https://github.com/cloudbuilders/keystone.git +KEYSTONE_REPO=git://github.com/cloudbuilders/keystone.git KEYSTONE_BRANCH=diablo # a websockets/html5 or flash powered VNC console for vm instances -NOVNC_REPO=https://github.com/cloudbuilders/noVNC.git +NOVNC_REPO=git://github.com/cloudbuilders/noVNC.git NOVNC_BRANCH=diablo # django powered web control panel for openstack -DASH_REPO=https://github.com/cloudbuilders/openstack-dashboard.git +DASH_REPO=git://github.com/cloudbuilders/openstack-dashboard.git DASH_BRANCH=diablo # python client library to nova that dashboard (and others) use -NOVACLIENT_REPO=https://github.com/cloudbuilders/python-novaclient.git +NOVACLIENT_REPO=git://github.com/rackspace/python-novaclient.git NOVACLIENT_BRANCH=master # openstackx is a collection of extensions to openstack.compute & nova # that is *deprecated*. The code is being moved into python-novaclient & nova. -OPENSTACKX_REPO=https://github.com/cloudbuilders/openstackx.git +OPENSTACKX_REPO=git://github.com/cloudbuilders/openstackx.git OPENSTACKX_BRANCH=diablo # Specify a comma-separated list of uec images to download and install into glance. From 6fc71019c9db6137b6004b85c761500d36cd6409 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 11:29:08 -0700 Subject: [PATCH 19/57] documentation on exercise --- exercise.sh | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/exercise.sh b/exercise.sh index 35ff403..8923b3e 100755 --- a/exercise.sh +++ b/exercise.sh @@ -59,8 +59,8 @@ nova secgroup-list # Create a secgroup nova secgroup-create $SECGROUP "test_secgroup description" -# Flavors -# ------- +# determine flavor +# ---------------- # List of flavors: nova flavor-list @@ -72,6 +72,16 @@ NAME="myserver" nova boot --flavor $FLAVOR --image $IMAGE $NAME --security_groups=$SECGROUP +# Testing +# ======= + +# First check if it spins up (becomes active and responds to ping on +# internal ip). If you run this script from a nova node, you should +# bypass security groups and have direct access to the server. + +# Waiting for boot +# ---------------- + # let's give it 10 seconds to launch sleep 10 @@ -89,7 +99,11 @@ ping -c1 -w1 $IP || true sleep 5 ping -c1 -w1 $IP -# allow icmp traffic + +# Security Groups & Floating IPs +# ------------------------------ + +# allow icmp traffic (ping) nova secgroup-add-rule $SECGROUP icmp -1 -1 0.0.0.0/0 # List rules for a secgroup @@ -99,31 +113,31 @@ nova secgroup-list-rules $SECGROUP nova floating-ip-create # store floating address -FIP=`nova floating-ip-list | grep None | head -1 | cut -d '|' -f2 | sed 's/ //g'` +FLOATING_IP=`nova floating-ip-list | grep None | head -1 | cut -d '|' -f2 | sed 's/ //g'` # add floating ip to our server -nova add-floating-ip $NAME $FIP +nova add-floating-ip $NAME $FLOATING_IP # sleep for a smidge sleep 1 -# ping our fip -ping -c1 -w1 $FIP +# ping our floating ip +ping -c1 -w1 $FLOATING_IP -# dis-allow icmp traffic +# dis-allow icmp traffic (ping) nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0 # sleep for a smidge sleep 1 -# ping our fip -if ( ping -c1 -w1 $FIP); then +# ping our floating ip +if ( ping -c1 -w1 $FLOATING_IP ); then print "Security group failure - ping should not be allowed!" exit 1 fi # de-allocate the floating ip -nova floating-ip-delete $FIP +nova floating-ip-delete $FLOATING_IP # shutdown the server nova delete $NAME From 1369c05f9b7958e140b447542ab28041f450330a Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 12:38:13 -0700 Subject: [PATCH 20/57] can't unmount if cwd is in copy --- tools/build_kvm.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 59ed649..23ce493 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -148,12 +148,12 @@ git_clone $OPENSTACKX_REPO $COPY_DIR/$DEST/openstackx $OPENSTACKX_BRANCH git_clone $KEYSTONE_REPO $COPY_DIR/$DEST/keystone $KEYSTONE_BRANCH git_clone $NOVNC_REPO $COPY_DIR/$DEST/noVNC $NOVNC_BRANCH -# Unmount the filesystems -unmount_images - # Back to devstack cd $TOP_DIR +# Unmount the filesystems +unmount_images + # Network configuration variables BRIDGE=${BRIDGE:-br0} GUEST_IP=${GUEST_IP:-192.168.1.50} From 4b8ab92ebbf58712edb963430cb73aae51717648 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 12:42:43 -0700 Subject: [PATCH 21/57] errexit for build_kvm.sh --- tools/build_kvm.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 23ce493..cc7d121 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# exit on error to stop unexpected errors +set -o errexit + # Make sure that we have the proper version of ubuntu UBUNTU_VERSION=`cat /etc/lsb-release | grep CODENAME | sed 's/.*=//g'` if [ ! "oneiric" = "$UBUNTU_VERSION" ]; then From b169b6354d9d663b52add12d2d92b13946444a3c Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 12:46:01 -0700 Subject: [PATCH 22/57] typo in setting root password --- tools/build_kvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index cc7d121..cc63ba2 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -20,7 +20,7 @@ TOOLS_DIR=$(cd $(dirname "$0") && pwd) TOP_DIR=$TOOLS_DIR/.. # Configure the root password of the vm -ROOT_PASSWORD=${ROOT_PASSWORD:password} +ROOT_PASSWORD=${ROOT_PASSWORD:-password} # Where to store files and instances KVMSTACK_DIR=${KVMSTACK_DIR:-/opt/kvmstack} From 61e0a2e0da571c67ea25b708668be7a1ffe2805a Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 12:47:13 -0700 Subject: [PATCH 23/57] don't explode if domain doesn't already exist in build_kvm.sh --- tools/build_kvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index cc63ba2..38a4943 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -58,7 +58,7 @@ BASE_IMAGE=$KVMSTACK_DIR/images/$DIST_NAME.raw VM_IMAGE=$IMAGES_DIR/$DIST_NAME.$GUEST_NAME.raw # Mop up after previous runs -virsh destroy $GUEST_NAME +virsh destroy $GUEST_NAME || true # Where this vm is stored VM_DIR=$KVMSTACK_DIR/instances/$GUEST_NAME From f5ecd5bcaf478e19444120fc57993c0222d726ea Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 12:59:29 -0700 Subject: [PATCH 24/57] Add comment about why the sleep is there --- tools/build_kvm.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 38a4943..03a3877 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -235,8 +235,12 @@ rm -f $VM_DIR/disk # Create our instance fs qemu-img create -f qcow2 -b $VM_IMAGE disk +# FIXME: we are sleeping because these qemu commands appear to not complete +# before they return... We should apply fix that is done in nova's disk.py sleep 5 +# FIXME: we are sleeping because these qemu commands appear to not complete +# before they return... We should apply fix that is done in nova's disk.py qemu-nbd -c $NBD disk sleep 5 From f75d848ececdd59a1dcb240cf7956598366b9621 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 13:38:52 -0700 Subject: [PATCH 25/57] openrc should use same variables as stack.sh --- openrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openrc b/openrc index 4f953de..cc31531 100644 --- a/openrc +++ b/openrc @@ -4,7 +4,7 @@ source ./stackrc # Set api host endpoint -HOST=${HOST:-localhost} +HOST_IP=${HOST_IP:-127.0.0.1} # Nova original used project_id as the *account* that owned resources (servers, # ip address, ...) With the addition of Keystone we have standardized on the @@ -28,7 +28,7 @@ export NOVA_API_KEY=${ADMIN_PASSWORD:-secrete} # # *NOTE*: Using the 2.0 *auth api* does not mean that compute api is 2.0. We # will use the 1.1 *compute api* -export NOVA_URL=${NOVA_URL:-http://$HOST:5000/v2.0/} +export NOVA_URL=${NOVA_URL:-http://$HOST_IP:5000/v2.0/} # Currently novaclient needs you to specify the *compute api* version. This # needs to match the config of your catalog returned by Keystone. From e61f3185cea5eeb4b873784ff74300b4c76d3c81 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 13:43:04 -0700 Subject: [PATCH 26/57] use HOST_IP as in stack.sh --- exercise.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercise.sh b/exercise.sh index 8923b3e..85f404a 100755 --- a/exercise.sh +++ b/exercise.sh @@ -29,7 +29,7 @@ source ./openrc # returns a token and catalog of endpoints. We use python to parse the token # and save it. -TOKEN=`curl -s -d "{\"auth\":{\"passwordCredentials\": {\"username\": \"$NOVA_USERNAME\", \"password\": \"$NOVA_API_KEY\"}}}" -H "Content-type: application/json" http://$HOST:5000/v2.0/tokens | python -c "import sys; import json; tok = json.loads(sys.stdin.read()); print tok['access']['token']['id'];"` +TOKEN=`curl -s -d "{\"auth\":{\"passwordCredentials\": {\"username\": \"$NOVA_USERNAME\", \"password\": \"$NOVA_API_KEY\"}}}" -H "Content-type: application/json" http://$HOST_IP:5000/v2.0/tokens | python -c "import sys; import json; tok = json.loads(sys.stdin.read()); print tok['access']['token']['id'];"` # Launching a server # ================== From 9af93e95513621114d8f92f7b96395bc4581ec5c Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 24 Oct 2011 16:11:20 -0500 Subject: [PATCH 27/57] Add oneric to supported list --- tools/make_image.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/make_image.sh b/tools/make_image.sh index 32d59bd..0faee4e 100755 --- a/tools/make_image.sh +++ b/tools/make_image.sh @@ -97,6 +97,7 @@ case $FORMAT in esac case $RELEASE in + oneric) ;; natty) ;; maverick) ;; lucid) ;; From fcfa9c3d1f382c8136bc6ceba4499f6be73f0f40 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 24 Oct 2011 16:18:52 -0500 Subject: [PATCH 28/57] Add oneiric to supported list --- tools/make_image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/make_image.sh b/tools/make_image.sh index 0faee4e..d81cef5 100755 --- a/tools/make_image.sh +++ b/tools/make_image.sh @@ -97,7 +97,7 @@ case $FORMAT in esac case $RELEASE in - oneric) ;; + oneiric) ;; natty) ;; maverick) ;; lucid) ;; From f56e395d8216c7e94486ad3df3eb6377ebb5a7b1 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 24 Oct 2011 16:05:57 -0700 Subject: [PATCH 29/57] Make ec2 credentials work properly --- exercise.sh | 6 ++++++ files/apts/general | 1 + files/keystone_data.sh | 6 +++--- openrc | 12 +++++++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/exercise.sh b/exercise.sh index 85f404a..36a6d6f 100755 --- a/exercise.sh +++ b/exercise.sh @@ -147,3 +147,9 @@ nova secgroup-delete $SECGROUP # FIXME: validate shutdown within 5 seconds # (nova show $NAME returns 1 or status != ACTIVE)? + +# Testing Euca2ools +# ================== + +# make sure that we can describe instances +euca-describe-instances diff --git a/files/apts/general b/files/apts/general index b47a60d..31fa752 100644 --- a/files/apts/general +++ b/files/apts/general @@ -16,3 +16,4 @@ iputils-ping wget curl tcpdump +euca2ools # only for testing client diff --git a/files/keystone_data.sh b/files/keystone_data.sh index 2cca345..5349311 100755 --- a/files/keystone_data.sh +++ b/files/keystone_data.sh @@ -36,8 +36,8 @@ $BIN_DIR/keystone-manage $* endpointTemplates add RegionOne keystone http://%HOS # Tokens $BIN_DIR/keystone-manage $* token add %SERVICE_TOKEN% admin admin 2015-02-05T00:00 -# EC2 related creds - note we are setting the token to user_password +# EC2 related creds - note we are setting the secret key to ADMIN_PASSWORD # but keystone doesn't parse them - it is just a blob from keystone's # point of view -$BIN_DIR/keystone-manage $* credentials add admin EC2 'admin_%ADMIN_PASSWORD%' admin admin || echo "no support for adding credentials" -$BIN_DIR/keystone-manage $* credentials add demo EC2 'demo_%ADMIN_PASSWORD%' demo demo || echo "no support for adding credentials" +$BIN_DIR/keystone-manage $* credentials add admin EC2 'admin' '%ADMIN_PASSWORD%' admin || echo "no support for adding credentials" +$BIN_DIR/keystone-manage $* credentials add demo EC2 'demo' '%ADMIN_PASSWORD%' demo || echo "no support for adding credentials" diff --git a/openrc b/openrc index cc31531..324780b 100644 --- a/openrc +++ b/openrc @@ -26,7 +26,7 @@ export NOVA_API_KEY=${ADMIN_PASSWORD:-secrete} # has access to - including nova, glance, keystone, swift, ... We currently # recommend using the 2.0 *auth api*. # -# *NOTE*: Using the 2.0 *auth api* does not mean that compute api is 2.0. We +# *NOTE*: Using the 2.0 *auth api* does not mean that compute api is 2.0. We # will use the 1.1 *compute api* export NOVA_URL=${NOVA_URL:-http://$HOST_IP:5000/v2.0/} @@ -37,5 +37,15 @@ export NOVA_VERSION=${NOVA_VERSION:-1.1} # FIXME - why does this need to be specified? export NOVA_REGION_NAME=${NOVA_REGION_NAME:-RegionOne} +# Set the ec2 url so euca2ools works +export EC2_URL=${EC2_URL:-http://$HOST_IP:8773/services/Cloud} + +# Access key is set in the initial keystone data to be the same as username +export EC2_ACCESS_KEY=${USERNAME:-demo} + +# Secret key is set in the initial keystone data to the admin password +export EC2_SECRET_KEY=${ADMIN_PASSWORD:-secrete} + # set log level to DEBUG (helps debug issues) # export NOVACLIENT_DEBUG=1 + From 87a73e8216f9b0f1d4229c683f75b97c57832952 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 17:06:58 -0700 Subject: [PATCH 30/57] only run apt-get install if needed - fixes multiple builds being kicked off at once --- tools/build_kvm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 03a3877..dbfb5ce 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -101,8 +101,8 @@ function kill_unmount() { exit 1 } -# Install deps -apt-get install -y --force-yes kvm libvirt-bin kpartx +# Install deps if needed +dpkg -l kvm libvirt-bin kpartx || apt-get install -y --force-yes kvm libvirt-bin kpartx # Let Ctrl-c kill tail and exit trap kill_unmount SIGINT From eeec0206285e200f34b6005459c4d79a588e7f1d Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 18:42:11 -0700 Subject: [PATCH 31/57] another attempt at reclone which preserves existing git object dir --- stack.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/stack.sh b/stack.sh index 18206cd..74cb383 100755 --- a/stack.sh +++ b/stack.sh @@ -302,20 +302,27 @@ sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*` # be owned by the installation user, we create the directory and change the # ownership to the proper user. function git_clone { - # if there is an existing checkout, move it out of the way - if [[ "$RECLONE" == "yes" ]]; then - # FIXME(ja): if we were smarter we could speed up RECLONE by - # using the old git repo as the basis of our new clone... - if [ -d $2 ]; then - mv $2 /tmp/stack.`date +%s` - fi - fi + # do a full clone only if the directory doesn't exist if [ ! -d $2 ]; then git clone $1 $2 cd $2 # This checkout syntax works for both branches and tags git checkout $3 + elif [[ "$RECLONE" == "yes" ]]; then + # if it does exist then simulate what clone does if asked to RECLONE + cd $2 + # set the url to pull from and fetch + git remote set-url origin $1 + git fetch origin + # if we don't delete the local content, then our system has pyc files + # from the previous branch leading to breakage (due to the py files + # having older timestamps than our pyc, so python thinks the pyc files + # are correct using them) + rm -rf * + git checkout -f origin/$3 + git branch -D $3 + git checkout -b $3 fi } From 917c66584f9c4d596fdf651330e48cd5219a4436 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 18:47:06 -0700 Subject: [PATCH 32/57] use variable names for git_clone function --- stack.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/stack.sh b/stack.sh index 74cb383..ed5dc36 100755 --- a/stack.sh +++ b/stack.sh @@ -303,26 +303,31 @@ sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*` # ownership to the proper user. function git_clone { + GIT_REMOTE=$1 + GIT_DEST=$2 + GIT_BRANCH=$3 + # do a full clone only if the directory doesn't exist - if [ ! -d $2 ]; then - git clone $1 $2 + if [ ! -d $GIT_DEST ]; then + git clone $GIT_REMOTE $GIT_DEST cd $2 # This checkout syntax works for both branches and tags - git checkout $3 + git checkout $GIT_BRANCH elif [[ "$RECLONE" == "yes" ]]; then # if it does exist then simulate what clone does if asked to RECLONE - cd $2 + cd $GIT_BRANCH # set the url to pull from and fetch - git remote set-url origin $1 + git remote set-url origin $GIT_REMOTE git fetch origin # if we don't delete the local content, then our system has pyc files # from the previous branch leading to breakage (due to the py files # having older timestamps than our pyc, so python thinks the pyc files # are correct using them) rm -rf * - git checkout -f origin/$3 - git branch -D $3 - git checkout -b $3 + git checkout -f origin/$GIT_BRANCH + # a local branch might not exist for $3 + git branch -D $GIT_BRANCH || true + git checkout -b $GIT_BRANCH fi } From b9b3ad49a6fc318b51c3746036721918924b523e Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 18:52:13 -0700 Subject: [PATCH 33/57] some of the files are owned by root --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index ed5dc36..8dbb9e9 100755 --- a/stack.sh +++ b/stack.sh @@ -323,7 +323,7 @@ function git_clone { # from the previous branch leading to breakage (due to the py files # having older timestamps than our pyc, so python thinks the pyc files # are correct using them) - rm -rf * + sudo rm -rf * git checkout -f origin/$GIT_BRANCH # a local branch might not exist for $3 git branch -D $GIT_BRANCH || true From 480644bd7461f514f66b41e87ff727c6d86f7fdb Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 18:52:58 -0700 Subject: [PATCH 34/57] error in conversion --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 8dbb9e9..e3f8a94 100755 --- a/stack.sh +++ b/stack.sh @@ -315,7 +315,7 @@ function git_clone { git checkout $GIT_BRANCH elif [[ "$RECLONE" == "yes" ]]; then # if it does exist then simulate what clone does if asked to RECLONE - cd $GIT_BRANCH + cd $GIT_DEST # set the url to pull from and fetch git remote set-url origin $GIT_REMOTE git fetch origin From 9fef844fd9adf0d1a2a68890d5b4d92244f95874 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 19:06:46 -0700 Subject: [PATCH 35/57] use git clean - thanks lundy --- stack.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/stack.sh b/stack.sh index e3f8a94..4b73102 100755 --- a/stack.sh +++ b/stack.sh @@ -319,11 +319,10 @@ function git_clone { # set the url to pull from and fetch git remote set-url origin $GIT_REMOTE git fetch origin - # if we don't delete the local content, then our system has pyc files - # from the previous branch leading to breakage (due to the py files - # having older timestamps than our pyc, so python thinks the pyc files - # are correct using them) - sudo rm -rf * + # remove the existing ignored files (like pyc) as they cause breakage + # (due to the py files having older timestamps than our pyc, so python + # thinks the pyc files are correct using them) + sudo git clean -f -d git checkout -f origin/$GIT_BRANCH # a local branch might not exist for $3 git branch -D $GIT_BRANCH || true From e09a6e4a82debdc5d8d06b0b74312d1266208b76 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 19:09:52 -0700 Subject: [PATCH 36/57] update comment --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 4b73102..6c7dcdf 100755 --- a/stack.sh +++ b/stack.sh @@ -324,7 +324,7 @@ function git_clone { # thinks the pyc files are correct using them) sudo git clean -f -d git checkout -f origin/$GIT_BRANCH - # a local branch might not exist for $3 + # a local branch might not exist git branch -D $GIT_BRANCH || true git checkout -b $GIT_BRANCH fi From ac1831e0747bcf3ce0ea871d5fd04fe42d00be61 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 21:37:00 -0700 Subject: [PATCH 37/57] simplify uec image url parsing --- stack.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stack.sh b/stack.sh index 18206cd..5eccaa6 100755 --- a/stack.sh +++ b/stack.sh @@ -740,8 +740,8 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then for image_url in ${IMAGE_URLS//,/ }; do # Downloads the image (uec ami+aki style), then extracts it. - IMAGE_FNAME=`echo "$image_url" | python -c "import sys; print sys.stdin.read().split('/')[-1]"` - IMAGE_NAME=`echo "$IMAGE_FNAME" | python -c "import sys; print sys.stdin.read().split('.tar.gz')[0].split('.tgz')[0]"` + IMAGE_FNAME=`basename "$image_url"` + IMAGE_NAME=`basename -s .tar.gz "$IMAGE_FNAME"` if [ ! -f $FILES/$IMAGE_FNAME ]; then wget -c $image_url -O $FILES/$IMAGE_FNAME fi From f70569e33d4484fbe66dad4399d9887c0185de22 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 21:56:25 -0700 Subject: [PATCH 38/57] don't modify the paste.ini inplace - copy to nova, then modify --- stack.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/stack.sh b/stack.sh index 18206cd..b54b486 100755 --- a/stack.sh +++ b/stack.sh @@ -470,11 +470,15 @@ fi # Nova # ---- -# 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). -sudo sed -e "s,999888777666,$SERVICE_TOKEN,g" -i $KEYSTONE_DIR/examples/paste/nova-api-paste.ini +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). + 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 +fi if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then @@ -591,7 +595,7 @@ add_nova_flag "--libvirt_type=$LIBVIRT_TYPE" add_nova_flag "--osapi_extensions_path=$OPENSTACKX_DIR/extensions" add_nova_flag "--vncproxy_url=http://$HOST_IP:6080" add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/" -add_nova_flag "--api_paste_config=$KEYSTONE_DIR/examples/paste/nova-api-paste.ini" +add_nova_flag "--api_paste_config=$NOVA_DIR/bint/nova-api-paste.ini" add_nova_flag "--image_service=nova.image.glance.GlanceImageService" add_nova_flag "--ec2_dmz_host=$EC2_DMZ_HOST" add_nova_flag "--rabbit_host=$RABBIT_HOST" From 42dc9a77156df998d5663b01b0d63ea27ec1930f Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 22:03:11 -0700 Subject: [PATCH 39/57] this is why we do a test run before merging --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index b54b486..b07b2bc 100755 --- a/stack.sh +++ b/stack.sh @@ -595,7 +595,7 @@ add_nova_flag "--libvirt_type=$LIBVIRT_TYPE" add_nova_flag "--osapi_extensions_path=$OPENSTACKX_DIR/extensions" add_nova_flag "--vncproxy_url=http://$HOST_IP:6080" add_nova_flag "--vncproxy_wwwroot=$NOVNC_DIR/" -add_nova_flag "--api_paste_config=$NOVA_DIR/bint/nova-api-paste.ini" +add_nova_flag "--api_paste_config=$NOVA_DIR/bin/nova-api-paste.ini" add_nova_flag "--image_service=nova.image.glance.GlanceImageService" add_nova_flag "--ec2_dmz_host=$EC2_DMZ_HOST" add_nova_flag "--rabbit_host=$RABBIT_HOST" From 381591ad66758bf8d2b7660ecf5b1db98080fd90 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 24 Oct 2011 22:25:16 -0700 Subject: [PATCH 40/57] raise error if stack.sh failed --- tools/build_kvm.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index dbfb5ce..26a195e 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -378,6 +378,10 @@ if [ "$WAIT_TILL_LAUNCH" = "1" ]; then done kill $TAIL_PID + + if grep -q "stack.sh failed" $VM_DIR/console.log; then + exit 1 + fi echo "" echo "Finished - Zip-a-dee Doo-dah!" fi From e959d83325529f9833ffe0bcca22f2e2d96a0951 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 24 Oct 2011 22:41:50 -0700 Subject: [PATCH 41/57] add deps for diablo volumes --- files/apts/nova | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/files/apts/nova b/files/apts/nova index eb85e26..594f2da 100644 --- a/files/apts/nova +++ b/files/apts/nova @@ -33,3 +33,7 @@ python-suds python-lockfile python-m2crypto python-boto + +# Stuff for diablo volumes +iscsitarget +lvm2 From 8ecd2948ad7a4f1dad0e31ff48729a0c2695cc7e Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 24 Oct 2011 22:58:14 -0700 Subject: [PATCH 42/57] only attempt to ping private ip for single node deployments --- exercise.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/exercise.sh b/exercise.sh index 36a6d6f..7a1ed9b 100755 --- a/exercise.sh +++ b/exercise.sh @@ -91,14 +91,18 @@ nova show $NAME | grep status | grep -q ACTIVE # get the IP of the server IP=`nova show $NAME | grep "private network" | cut -d"|" -f3` -# ping it once (timeout of a second) -ping -c1 -w1 $IP || true +# for single node deployments, we can ping private ips +MULTI_HOST=${MULTI_HOST:-0} +if [ "$MULTI_HOST" = "0"]; then + # ping it once (timeout of a second) + ping -c1 -w1 $IP || true -# sometimes the first ping fails (10 seconds isn't enough time for the VM's -# network to respond?), so let's wait 5 seconds and really test ping -sleep 5 + # sometimes the first ping fails (10 seconds isn't enough time for the VM's + # network to respond?), so let's wait 5 seconds and really test ping + sleep 5 -ping -c1 -w1 $IP + ping -c1 -w1 $IP +fi # Security Groups & Floating IPs # ------------------------------ From 68565361445d42bcdc5258294392c6a40310385c Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 24 Oct 2011 23:20:12 -0700 Subject: [PATCH 43/57] Fix issue #98 - wait till nbd is connected using method in nova's disk.py --- tools/build_kvm.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 26a195e..32c7bf6 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -235,15 +235,13 @@ rm -f $VM_DIR/disk # Create our instance fs qemu-img create -f qcow2 -b $VM_IMAGE disk -# FIXME: we are sleeping because these qemu commands appear to not complete -# before they return... We should apply fix that is done in nova's disk.py -sleep 5 - -# FIXME: we are sleeping because these qemu commands appear to not complete -# before they return... We should apply fix that is done in nova's disk.py +# Connect our nbd and wait till it is mountable qemu-nbd -c $NBD disk - -sleep 5 +NBD_DEV=`basename $NBD` +if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then + echo "Couldn't connect $NBD" + exit 1 +fi # Mount the instance mount $NBD $ROOTFS -o offset=32256 -t ext4 From 216ad694355487cd240f39d574f30e029f18b0d9 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 25 Oct 2011 00:10:21 -0700 Subject: [PATCH 44/57] fix basename invocation --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 5eccaa6..7e4d466 100755 --- a/stack.sh +++ b/stack.sh @@ -741,7 +741,7 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then for image_url in ${IMAGE_URLS//,/ }; do # Downloads the image (uec ami+aki style), then extracts it. IMAGE_FNAME=`basename "$image_url"` - IMAGE_NAME=`basename -s .tar.gz "$IMAGE_FNAME"` + IMAGE_NAME=`basename "$IMAGE_FNAME" .tar.gz` if [ ! -f $FILES/$IMAGE_FNAME ]; then wget -c $image_url -O $FILES/$IMAGE_FNAME fi From 70506b1b74d0260c2aec37879e7d7d9f9d398a6d Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 25 Oct 2011 00:20:44 -0700 Subject: [PATCH 45/57] in multi mode, send gratuitous arp --- stack.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/stack.sh b/stack.sh index 7e4d466..b093616 100755 --- a/stack.sh +++ b/stack.sh @@ -603,6 +603,7 @@ if [ -n "$FLAT_INTERFACE" ]; then fi if [ -n "$MULTI_HOST" ]; then add_nova_flag "--multi_host=$MULTI_HOST" + add_nova_flag "--send_arp_for_ha=1" fi # Nova Database From 9d8e8cf1eeedffdb0678e7760f5cbbda8bcab982 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 25 Oct 2011 00:34:35 -0700 Subject: [PATCH 46/57] association seems to take a bit longer on multi host configs --- exercise.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercise.sh b/exercise.sh index 7a1ed9b..b73d6aa 100755 --- a/exercise.sh +++ b/exercise.sh @@ -123,7 +123,7 @@ FLOATING_IP=`nova floating-ip-list | grep None | head -1 | cut -d '|' -f2 | sed nova add-floating-ip $NAME $FLOATING_IP # sleep for a smidge -sleep 1 +sleep 5 # ping our floating ip ping -c1 -w1 $FLOATING_IP @@ -132,7 +132,7 @@ ping -c1 -w1 $FLOATING_IP nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0 # sleep for a smidge -sleep 1 +sleep 5 # ping our floating ip if ( ping -c1 -w1 $FLOATING_IP ); then From c2b3cf7ff87cd93113a36eb9756705b905a7f6dc Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Tue, 25 Oct 2011 08:52:31 -0700 Subject: [PATCH 47/57] switch back to https (to get around firewall issues) --- stackrc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/stackrc b/stackrc index c063864..9ba1043 100644 --- a/stackrc +++ b/stackrc @@ -1,30 +1,30 @@ # compute service -NOVA_REPO=git://github.com/cloudbuilders/nova.git +NOVA_REPO=https://github.com/cloudbuilders/nova.git NOVA_BRANCH=diablo # image catalog service -GLANCE_REPO=git://github.com/cloudbuilders/glance.git +GLANCE_REPO=https://github.com/cloudbuilders/glance.git GLANCE_BRANCH=diablo # unified auth system (manages accounts/tokens) -KEYSTONE_REPO=git://github.com/cloudbuilders/keystone.git +KEYSTONE_REPO=https://github.com/cloudbuilders/keystone.git KEYSTONE_BRANCH=diablo # a websockets/html5 or flash powered VNC console for vm instances -NOVNC_REPO=git://github.com/cloudbuilders/noVNC.git +NOVNC_REPO=https://github.com/cloudbuilders/noVNC.git NOVNC_BRANCH=diablo # django powered web control panel for openstack -DASH_REPO=git://github.com/cloudbuilders/openstack-dashboard.git +DASH_REPO=https://github.com/cloudbuilders/openstack-dashboard.git DASH_BRANCH=diablo # python client library to nova that dashboard (and others) use -NOVACLIENT_REPO=git://github.com/rackspace/python-novaclient.git +NOVACLIENT_REPO=https://github.com/rackspace/python-novaclient.git NOVACLIENT_BRANCH=master # openstackx is a collection of extensions to openstack.compute & nova # that is *deprecated*. The code is being moved into python-novaclient & nova. -OPENSTACKX_REPO=git://github.com/cloudbuilders/openstackx.git +OPENSTACKX_REPO=https://github.com/cloudbuilders/openstackx.git OPENSTACKX_BRANCH=diablo # Specify a comma-separated list of uec images to download and install into glance. From e753fdf42c45a7319159f401158b717960aa99ba Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Tue, 25 Oct 2011 15:45:26 -0500 Subject: [PATCH 48/57] Add get_uec_image.sh --- tools/get_uec_image.sh | 159 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100755 tools/get_uec_image.sh diff --git a/tools/get_uec_image.sh b/tools/get_uec_image.sh new file mode 100755 index 0000000..fde53d2 --- /dev/null +++ b/tools/get_uec_image.sh @@ -0,0 +1,159 @@ +#!/bin/bash +# get_uec_image.sh - Prepare Ubuntu images in various formats +# +# Supported formats: qcow (kvm), vmdk (vmserver), vdi (vbox), vhd (vpc), raw +# +# Requires to run as root + +CACHEDIR=${CACHEDIR:-/var/cache/devstack} +FORMAT=${FORMAT:-qcow2} +ROOTSIZE=${ROOTSIZE:-2000} +MIN_PKGS=${MIN_PKGS:-"apt-utils gpgv openssh-server"} + +usage() { + echo "Usage: $0 - Prepare Ubuntu images" + echo "" + echo "$0 [-f format] [-r rootsize] release imagefile" + echo "" + echo "-f format - image format: qcow2 (default), vmdk, vdi, vhd, xen, raw, fs" + echo "-r size - root fs size in MB (min 2000MB)" + echo "release - Ubuntu release: jaunty - oneric" + echo "imagefile - output image file + exit 1 +} + +while getopts f:hmr: c; do + case $c in + f) FORMAT=$OPTARG + ;; + h) usage + ;; + m) MINIMAL=1 + ;; + r) ROOTSIZE=$OPTARG + if $(( ROOTSIZE < 2000 )); then + echo "root size must be greater than 2000MB" + exit 1 + fi + ;; + esac +done +shift `expr $OPTIND - 1` + +if [ ! "$#" -eq "2" ]; then + usage +fi + +# Default args +DIST_NAME=$1 +IMG_FILE=$2 + +case $FORMAT in + kvm|qcow2) FORMAT=qcow2 + QFORMAT=qcow2 + ;; + vmserver|vmdk) + FORMAT=vmdk + QFORMAT=vmdk + ;; + vbox|vdi) FORMAT=vdi + QFORMAT=vdi + ;; + vhd|vpc) FORMAT=vhd + QFORMAT=vpc + ;; + xen) FORMAT=raw + QFORMAT=raw + ;; + raw) FORMAT=raw + QFORMAT=raw + ;; + *) echo "Unknown format: $FORMAT" + usage +esac + +case $DIST_NAME in + oneiric) ;; + natty) ;; + maverick) ;; + lucid) ;; + karmic) ;; + jaunty) ;; + *) echo "Unknown release: $DIST_NAME" + usage + ;; +esac + +# Set up nbd +modprobe nbd max_part=63 +NBD=${NBD:-/dev/nbd9} +NBD_DEV=`basename $NBD` + +# Prepare the base image + +# Get the UEC image +UEC_NAME=$DIST_NAME-server-cloudimg-amd64 +if [ ! -e $CACHEDIR/$UEC_NAME-disk1.img ]; then + (cd $CACHEDIR; wget -N http://uec-images.ubuntu.com/$DIST_NAME/current/$UEC_NAME-disk1.img) + + + # Connect to nbd and wait till it is ready + qemu-nbd -d $NBD + qemu-nbd -c $NBD $CACHEDIR/$UEC_NAME-disk1.img + if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then + echo "Couldn't connect $NBD" + exit 1 + fi + MNTDIR=`mktemp -d mntXXXXXXXX` + mount -t ext4 ${NBD}p1 $MNTDIR + + # Install our required packages + cp -p files/sources.list $MNTDIR/etc/apt/sources.list + cp -p /etc/resolv.conf $MNTDIR/etc/resolv.conf + chroot $MNTDIR apt-get update + chroot $MNTDIR apt-get install -y $MIN_PKGS + rm -f $MNTDIR/etc/resolv.conf + + umount $MNTDIR + rmdir $MNTDIR + qemu-nbd -d $NBD +fi + +if [ "$FORMAT" = "qcow2" ]; then + # Just copy image + cp -p $CACHEDIR/$UEC_NAME-disk1.img $IMG_FILE +else + # Convert image + qemu-img convert -O $QFORMAT $CACHEDIR/$UEC_NAME-disk1.img $IMG_FILE +fi + +# Resize the image if necessary +if [ $ROOTSIZE -gt 2000 ]; then + # Resize the container + qemu-img resize $IMG_FILE +$((ROOTSIZE - 2000))M + + # Connect to nbd and wait till it is ready + qemu-nbd -c $NBD $IMG_FILE + if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then + echo "Couldn't connect $NBD" + exit 1 + fi + + # Resize partition 1 to full size of the disk image + echo "d +n +p +1 +2 + +t +83 +a +1 +w +" | fdisk $NBD + fsck -t ext4 -f ${NBD}p1 + resize2fs ${NBD}p1 + + qemu-nbd -d $NBD +fi From ecc5a909292db82648d48cc7ae0e873f7f9d66ac Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Tue, 25 Oct 2011 15:49:47 -0500 Subject: [PATCH 49/57] Add check for version compatibility --- tools/make_image.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/make_image.sh b/tools/make_image.sh index d81cef5..e957c75 100755 --- a/tools/make_image.sh +++ b/tools/make_image.sh @@ -65,6 +65,13 @@ if [ -n "$IMAGEONLY" ]; then RELEASE="pass" fi +# Make sure that we have the proper version of ubuntu +UBUNTU_VERSION=`cat /etc/lsb-release | grep CODENAME | sed 's/.*=//g'` +if [ "$UBUNTU_VERSION" = "natty" -a "$RELEASE" = "oneiric" ]; then + echo "natty installs can't build oneiric images" + exit 1 +fi + case $FORMAT in kvm|qcow2) FORMAT=qcow2 QFORMAT=qcow2 From a03b99dc997d7fefaea88162fc93a05e086d518b Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Tue, 25 Oct 2011 16:28:49 -0500 Subject: [PATCH 50/57] Fix typos --- tools/get_uec_image.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/get_uec_image.sh b/tools/get_uec_image.sh index fde53d2..e9d708d 100755 --- a/tools/get_uec_image.sh +++ b/tools/get_uec_image.sh @@ -3,7 +3,7 @@ # # Supported formats: qcow (kvm), vmdk (vmserver), vdi (vbox), vhd (vpc), raw # -# Requires to run as root +# Required to run as root CACHEDIR=${CACHEDIR:-/var/cache/devstack} FORMAT=${FORMAT:-qcow2} @@ -18,7 +18,7 @@ usage() { echo "-f format - image format: qcow2 (default), vmdk, vdi, vhd, xen, raw, fs" echo "-r size - root fs size in MB (min 2000MB)" echo "release - Ubuntu release: jaunty - oneric" - echo "imagefile - output image file + echo "imagefile - output image file" exit 1 } From 6065772feca1862844efd6388b4782354154a6fc Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Tue, 25 Oct 2011 23:41:59 -0700 Subject: [PATCH 51/57] cache the images --- tools/build_kvm.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 32c7bf6..d804f42 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -284,6 +284,15 @@ if [ "$COPYENV" = "1" ]; then cp_it ~/.bashrc $ROOTFS/$DEST/.bashrc fi +# pre-cache uec images +for image_url in ${IMAGE_URLS//,/ }; do + IMAGE_FNAME=`basename "$image_url"` + if [ ! -f $IMAGES_DIR/$IMAGE_FNAME ]; then + wget -c $image_url -O $IMAGES_DIR/$IMAGE_FNAME + fi + cp $IMAGES_DIR/$IMAGE_FNAME $ROOTFS/$DEST/devstack/files/images +fi + # Configure the runner RUN_SH=$ROOTFS/$DEST/run.sh cat > $RUN_SH < Date: Tue, 25 Oct 2011 23:43:03 -0700 Subject: [PATCH 52/57] typo --- tools/build_kvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index d804f42..4ca1f1a 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -291,7 +291,7 @@ for image_url in ${IMAGE_URLS//,/ }; do wget -c $image_url -O $IMAGES_DIR/$IMAGE_FNAME fi cp $IMAGES_DIR/$IMAGE_FNAME $ROOTFS/$DEST/devstack/files/images -fi +done # Configure the runner RUN_SH=$ROOTFS/$DEST/run.sh From 244655f0c57f5453b701c5e9c55608cea55b6a97 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Tue, 25 Oct 2011 23:48:39 -0700 Subject: [PATCH 53/57] copy to a directory not file --- tools/build_kvm.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 4ca1f1a..3f32598 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -290,6 +290,7 @@ for image_url in ${IMAGE_URLS//,/ }; do if [ ! -f $IMAGES_DIR/$IMAGE_FNAME ]; then wget -c $image_url -O $IMAGES_DIR/$IMAGE_FNAME fi + mkdir -p $ROOTFS/$DEST/devstack/files/images cp $IMAGES_DIR/$IMAGE_FNAME $ROOTFS/$DEST/devstack/files/images done From 00dcc067f7f4e2c2faaba9aeb3cc23a1981eaf12 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Tue, 25 Oct 2011 23:51:43 -0700 Subject: [PATCH 54/57] put them in the right place --- tools/build_kvm.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 3f32598..97260e2 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -290,8 +290,7 @@ for image_url in ${IMAGE_URLS//,/ }; do if [ ! -f $IMAGES_DIR/$IMAGE_FNAME ]; then wget -c $image_url -O $IMAGES_DIR/$IMAGE_FNAME fi - mkdir -p $ROOTFS/$DEST/devstack/files/images - cp $IMAGES_DIR/$IMAGE_FNAME $ROOTFS/$DEST/devstack/files/images + cp $IMAGES_DIR/$IMAGE_FNAME $ROOTFS/$DEST/devstack/files done # Configure the runner From 56a505fc2d3b95c310f2330b4e4d45d8dfe8f0e1 Mon Sep 17 00:00:00 2001 From: Justin Shepherd Date: Wed, 26 Oct 2011 10:45:02 -0500 Subject: [PATCH 55/57] bug fix.. resulted in following error message: ./exercise.sh: line 96: [: missing `]' --- exercise.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercise.sh b/exercise.sh index b73d6aa..3f2c94e 100755 --- a/exercise.sh +++ b/exercise.sh @@ -93,7 +93,7 @@ IP=`nova show $NAME | grep "private network" | cut -d"|" -f3` # for single node deployments, we can ping private ips MULTI_HOST=${MULTI_HOST:-0} -if [ "$MULTI_HOST" = "0"]; then +if [ "$MULTI_HOST" = "0" ]; then # ping it once (timeout of a second) ping -c1 -w1 $IP || true From 7d45a0fa601fab0e4e7237f8920e049744a94c4a Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Wed, 26 Oct 2011 08:51:15 -0700 Subject: [PATCH 56/57] default the root password to admin password and don't fail if group already exists --- tools/build_kvm.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh index 32c7bf6..ea135f6 100755 --- a/tools/build_kvm.sh +++ b/tools/build_kvm.sh @@ -19,9 +19,6 @@ set -o xtrace TOOLS_DIR=$(cd $(dirname "$0") && pwd) TOP_DIR=$TOOLS_DIR/.. -# Configure the root password of the vm -ROOT_PASSWORD=${ROOT_PASSWORD:-password} - # Where to store files and instances KVMSTACK_DIR=${KVMSTACK_DIR:-/opt/kvmstack} @@ -44,6 +41,10 @@ fi # Source params source ./stackrc +# Configure the root password of the vm to be the same as ``ADMIN_PASSWORD`` +ROOT_PASSWORD=${ADMIN_PASSWORD:-password} + + # Base image (natty by default) DIST_NAME=${DIST_NAME:-natty} IMAGE_FNAME=$DIST_NAME.raw @@ -260,7 +261,7 @@ iface eth0 inet static EOF # User configuration for the instance -chroot $ROOTFS groupadd libvirtd +chroot $ROOTFS groupadd libvirtd || true chroot $ROOTFS useradd stack -s /bin/bash -d $DEST -G libvirtd cp -pr $TOOLS_DIR/.. $ROOTFS/$DEST/devstack echo "root:$ROOT_PASSWORD" | chroot $ROOTFS chpasswd From ad21d1a78e83ea8db1c87b65e646215d9cce8198 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Wed, 26 Oct 2011 12:39:00 -0700 Subject: [PATCH 57/57] raise an error if stack fails in lxc --- tools/build_lxc.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/build_lxc.sh b/tools/build_lxc.sh index 9cbbedf..b629183 100755 --- a/tools/build_lxc.sh +++ b/tools/build_lxc.sh @@ -301,6 +301,11 @@ if [ "$WAIT_TILL_LAUNCH" = "1" ]; then done kill $TAIL_PID + + if grep -q "stack.sh failed" $ROOTFS/$DEST/run.sh.log; then + exit 1 + fi + echo "" echo "Finished - Zip-a-dee Doo-dah!" fi