From 4cbb267679b54d83287bbe6f51f5edb5d005f4c0 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 3 Oct 2011 09:14:36 -0500 Subject: [PATCH 01/11] Move chroot cache dirs out of devstack dir --- build_nfs.sh | 34 ++++++++++++++++++---------------- build_pxe_ramdisk.sh | 35 ++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/build_nfs.sh b/build_nfs.sh index 6434df4..6290c74 100755 --- a/build_nfs.sh +++ b/build_nfs.sh @@ -1,5 +1,7 @@ #!/bin/bash +CHROOTCACHE=${CHROOTCACHE:-/root/cache} + # Source params source ./stackrc @@ -12,24 +14,24 @@ DEST="/nfs/$NAME" rm -rf $DEST # build a proto image - natty + packages that will install (optimization) -if [ ! -d proto ]; then - debootstrap natty proto - cp files/sources.list proto/etc/apt/sources.list - chroot proto apt-get update - chroot proto apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` - chroot proto pip install `cat files/pips/*` - git_clone $NOVA_REPO proto/opt/nova $NOVA_BRANCH - git_clone $GLANCE_REPO proto/opt/glance $GLANCE_BRANCH - git_clone $KEYSTONE_REPO proto/opt/keystone $KEYSTONE_BRANCH - git_clone $NOVNC_REPO proto/opt/novnc $NOVNC_BRANCH - git_clone $DASH_REPO proto/opt/dash $DASH_BRANCH $DASH_TAG - git_clone $NOVACLIENT_REPO proto/opt/python-novaclient $NOVACLIENT_BRANCH - git_clone $OPENSTACKX_REPO proto/opt/openstackx $OPENSTACKX_BRANCH - chroot proto mkdir -p /opt/files - wget -c http://images.ansolabs.com/tty.tgz -O proto/opt/files/tty.tgz +if [ ! -d $CHROOTCACHE/proto ]; then + debootstrap natty $CHROOTCACHE/proto + cp files/sources.list $CHROOTCACHE/proto/etc/apt/sources.list + chroot $CHROOTCACHE/proto apt-get update + chroot $CHROOTCACHE/proto apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` + chroot $CHROOTCACHE/proto pip install `cat files/pips/*` + git_clone $NOVA_REPO $CHROOTCACHE/proto/opt/nova $NOVA_BRANCH + git_clone $GLANCE_REPO $CHROOTCACHE/proto/opt/glance $GLANCE_BRANCH + git_clone $KEYSTONE_REPO $CHROOTCACHE/proto/opt/keystone $KEYSTONE_BRANCH + git_clone $NOVNC_REPO $CHROOTCACHE/proto/opt/novnc $NOVNC_BRANCH + git_clone $DASH_REPO $CHROOTCACHE/proto/opt/dash $DASH_BRANCH $DASH_TAG + git_clone $NOVACLIENT_REPO $CHROOTCACHE/proto/opt/python-novaclient $NOVACLIENT_BRANCH + git_clone $OPENSTACKX_REPO $CHROOTCACHE/proto/opt/openstackx $OPENSTACKX_BRANCH + chroot $CHROOTCACHE/proto mkdir -p /opt/files + wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/proto/opt/files/tty.tgz fi -cp -pr proto $DEST +cp -pr $CHROOTCACHE/proto $DEST # set hostname echo $NAME > $DEST/etc/hostname diff --git a/build_pxe_ramdisk.sh b/build_pxe_ramdisk.sh index a9b9225..5736fec 100755 --- a/build_pxe_ramdisk.sh +++ b/build_pxe_ramdisk.sh @@ -7,44 +7,45 @@ if [ ! "$#" -eq "1" ]; then fi PROGDIR=`dirname $0` +CHROOTCACHE=${CHROOTCACHE:-/root/cache} # Source params source ./stackrc # clean install of natty -if [ ! -d natty-base ]; then - $PROGDIR/make_image.sh -C natty natty-base +if [ ! -d $CHROOTCACHE/natty-base ]; then + $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base # copy kernel modules... # NOTE(ja): is there a better way to do this? - cp -pr /lib/modules/`uname -r` natty-base/lib/modules + cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules # a simple password - pass - echo root:pass | chroot natty-base chpasswd + echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd fi # prime natty with as many apt/pips as we can -if [ ! -d primed ]; then - rsync -azH natty-base/ primed/ - chroot primed apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` - chroot primed pip install `cat files/pips/*` +if [ ! -d $CHROOTCACHE/natty-dev ]; then + rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/ + chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` + chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*` # Create a stack user that is a member of the libvirtd group so that stack # is able to interact with libvirt. - chroot primed groupadd libvirtd - chroot primed useradd stack -s /bin/bash -d /opt -G libvirtd + chroot $CHROOTCACHE/natty-dev groupadd libvirtd + chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d /opt -G libvirtd # a simple password - pass - echo stack:pass | chroot primed chpasswd + echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd # and has sudo ability (in the future this should be limited to only what # stack requires) - echo "stack ALL=(ALL) NOPASSWD: ALL" >> primed/etc/sudoers + echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers fi # clone git repositories onto the system # ====================================== -if [ ! -d cloned ]; then - rsync -azH primed/ cloned/ +if [ ! -d $CHROOTCACHE/natty-stack ]; then + rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/ fi # git clone only if directory doesn't exist already. Since ``DEST`` might not @@ -53,7 +54,7 @@ fi function git_clone { # clone new copy or fetch latest changes - CHECKOUT=cloned$2 + CHECKOUT=$CHROOTCACHE/natty-stack$2 if [ ! -d $CHECKOUT ]; then mkdir -p $CHECKOUT git clone $1 $CHECKOUT @@ -73,7 +74,7 @@ function git_clone { popd # give ownership to the stack user - chroot cloned/ chown -R stack $2 + chroot $CHROOTCACHE/natty-stack/ chown -R stack $2 } git_clone $NOVA_REPO /opt/stack/nova $NOVA_BRANCH @@ -97,7 +98,7 @@ mkfs.ext2 -F $IMG # mount blank image loopback and load it mkdir -p $MNT mount -o loop $IMG $MNT -rsync -azH cloned/ $MNT +rsync -azH $CHROOTCACHE/natty-stack/ $MNT # umount and cleanup umount $MNT From cc806544507d082c44582d3287453fa8cb79e83c Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 3 Oct 2011 09:30:57 -0500 Subject: [PATCH 02/11] build_nfs.sh match build_pxe_ramdisk.sh --- build_nfs.sh | 109 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 76 insertions(+), 33 deletions(-) diff --git a/build_nfs.sh b/build_nfs.sh index 6290c74..8d04844 100755 --- a/build_nfs.sh +++ b/build_nfs.sh @@ -1,5 +1,6 @@ #!/bin/bash +PROGDIR=`dirname $0` CHROOTCACHE=${CHROOTCACHE:-/root/cache} # Source params @@ -13,25 +14,83 @@ DEST="/nfs/$NAME" # remove old nfs filesystem if one exists rm -rf $DEST -# build a proto image - natty + packages that will install (optimization) -if [ ! -d $CHROOTCACHE/proto ]; then - debootstrap natty $CHROOTCACHE/proto - cp files/sources.list $CHROOTCACHE/proto/etc/apt/sources.list - chroot $CHROOTCACHE/proto apt-get update - chroot $CHROOTCACHE/proto apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` - chroot $CHROOTCACHE/proto pip install `cat files/pips/*` - git_clone $NOVA_REPO $CHROOTCACHE/proto/opt/nova $NOVA_BRANCH - git_clone $GLANCE_REPO $CHROOTCACHE/proto/opt/glance $GLANCE_BRANCH - git_clone $KEYSTONE_REPO $CHROOTCACHE/proto/opt/keystone $KEYSTONE_BRANCH - git_clone $NOVNC_REPO $CHROOTCACHE/proto/opt/novnc $NOVNC_BRANCH - git_clone $DASH_REPO $CHROOTCACHE/proto/opt/dash $DASH_BRANCH $DASH_TAG - git_clone $NOVACLIENT_REPO $CHROOTCACHE/proto/opt/python-novaclient $NOVACLIENT_BRANCH - git_clone $OPENSTACKX_REPO $CHROOTCACHE/proto/opt/openstackx $OPENSTACKX_BRANCH - chroot $CHROOTCACHE/proto mkdir -p /opt/files - wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/proto/opt/files/tty.tgz +# clean install of natty +if [ ! -d $CHROOTCACHE/natty-base ]; then + $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base + # copy kernel modules... + # NOTE(ja): is there a better way to do this? + cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules + # a simple password - pass + echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd fi -cp -pr $CHROOTCACHE/proto $DEST +# prime natty with as many apt/pips as we can +if [ ! -d $CHROOTCACHE/natty-dev ]; then + rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/ + chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` + chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*` + + # Create a stack user that is a member of the libvirtd group so that stack + # is able to interact with libvirt. + chroot $CHROOTCACHE/natty-dev groupadd libvirtd + chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d /opt -G libvirtd + + # a simple password - pass + echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd + + # and has sudo ability (in the future this should be limited to only what + # stack requires) + echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers +fi + +# clone git repositories onto the system +# ====================================== + +if [ ! -d $CHROOTCACHE/natty-stack ]; then + rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/ +fi + +# git clone only if directory doesn't exist already. Since ``DEST`` might not +# be owned by the installation user, we create the directory and change the +# ownership to the proper user. +function git_clone { + + # clone new copy or fetch latest changes + CHECKOUT=$CHROOTCACHE/natty-stack$2 + if [ ! -d $CHECKOUT ]; then + mkdir -p $CHECKOUT + git clone $1 $CHECKOUT + else + pushd $CHECKOUT + git fetch + popd + fi + + # FIXME(ja): checkout specified version (should works for branches and tags) + + pushd $CHECKOUT + # checkout the proper branch/tag + git checkout $3 + # force our local version to be the same as the remote version + git reset --hard origin/$3 + popd + + # give ownership to the stack user + chroot $CHROOTCACHE/natty-stack/ chown -R stack $2 +} + +git_clone $NOVA_REPO /opt/stack/nova $NOVA_BRANCH +git_clone $GLANCE_REPO /opt/stack/glance $GLANCE_BRANCH +git_clone $KEYSTONE_REPO /opt/stack/keystone $KEYSTONE_BRANCH +git_clone $NOVNC_REPO /opt/stack/novnc $NOVNC_BRANCH +git_clone $DASH_REPO /opt/stack/dash $DASH_BRANCH $DASH_TAG +git_clone $NOVACLIENT_REPO /opt/stack/python-novaclient $NOVACLIENT_BRANCH +git_clone $OPENSTACKX_REPO /opt/stack/openstackx $OPENSTACKX_BRANCH + +chroot $CHROOTCACHE/natty-stack mkdir -p /opt/stack/files +wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack/opt/stack/files/tty.tgz + +cp -pr $CHROOTCACHE/natty-stack $DEST # set hostname echo $NAME > $DEST/etc/hostname @@ -54,19 +113,3 @@ if [ -f /root/.ssh/id_rsa.pub ]; then chmod 700 $DEST/root/.ssh cp /root/.ssh/id_rsa.pub $DEST/root/.ssh/authorized_keys fi - -# set root password to password -echo root:pass | chroot $DEST chpasswd - -# Create a stack user that is a member of the libvirtd group so that stack -# is able to interact with libvirt. -chroot $DEST groupadd libvirtd -chroot $DEST useradd stack -s /bin/bash -d /opt -G libvirtd -# a simple password - pass -echo stack:pass | chroot $DEST chpasswd -# give stack ownership over /opt so it may do the work needed -chroot $DEST chown -R stack /opt - -# and has sudo ability (in the future this should be limited to only what -# stack requires) -echo "stack ALL=(ALL) NOPASSWD: ALL" >> $DEST/etc/sudoers From 11e5e6fc3da3f3de78d1897ce453e74e84d10540 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 3 Oct 2011 09:40:32 -0500 Subject: [PATCH 03/11] use for /opt/stack --- build_nfs.sh | 22 ++++++++++++---------- build_pxe_ramdisk.sh | 20 ++++++++++++-------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/build_nfs.sh b/build_nfs.sh index 8d04844..9ffa3cb 100755 --- a/build_nfs.sh +++ b/build_nfs.sh @@ -33,7 +33,9 @@ if [ ! -d $CHROOTCACHE/natty-dev ]; then # Create a stack user that is a member of the libvirtd group so that stack # is able to interact with libvirt. chroot $CHROOTCACHE/natty-dev groupadd libvirtd - chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d /opt -G 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 # a simple password - pass echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd @@ -79,16 +81,16 @@ function git_clone { chroot $CHROOTCACHE/natty-stack/ chown -R stack $2 } -git_clone $NOVA_REPO /opt/stack/nova $NOVA_BRANCH -git_clone $GLANCE_REPO /opt/stack/glance $GLANCE_BRANCH -git_clone $KEYSTONE_REPO /opt/stack/keystone $KEYSTONE_BRANCH -git_clone $NOVNC_REPO /opt/stack/novnc $NOVNC_BRANCH -git_clone $DASH_REPO /opt/stack/dash $DASH_BRANCH $DASH_TAG -git_clone $NOVACLIENT_REPO /opt/stack/python-novaclient $NOVACLIENT_BRANCH -git_clone $OPENSTACKX_REPO /opt/stack/openstackx $OPENSTACKX_BRANCH +git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH +git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH +git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH +git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH +git_clone $DASH_REPO $DEST/dash $DASH_BRANCH $DASH_TAG +git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH +git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH -chroot $CHROOTCACHE/natty-stack mkdir -p /opt/stack/files -wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack/opt/stack/files/tty.tgz +chroot $CHROOTCACHE/natty-stack mkdir -p $DEST/files +wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack$DEST/files/tty.tgz cp -pr $CHROOTCACHE/natty-stack $DEST diff --git a/build_pxe_ramdisk.sh b/build_pxe_ramdisk.sh index 5736fec..d12f23b 100755 --- a/build_pxe_ramdisk.sh +++ b/build_pxe_ramdisk.sh @@ -12,6 +12,8 @@ CHROOTCACHE=${CHROOTCACHE:-/root/cache} # Source params source ./stackrc +DEST=${DEST:-/opt/stack} + # clean install of natty if [ ! -d $CHROOTCACHE/natty-base ]; then $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base @@ -31,7 +33,9 @@ if [ ! -d $CHROOTCACHE/natty-dev ]; then # Create a stack user that is a member of the libvirtd group so that stack # is able to interact with libvirt. chroot $CHROOTCACHE/natty-dev groupadd libvirtd - chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d /opt -G 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 # a simple password - pass echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd @@ -77,13 +81,13 @@ function git_clone { chroot $CHROOTCACHE/natty-stack/ chown -R stack $2 } -git_clone $NOVA_REPO /opt/stack/nova $NOVA_BRANCH -git_clone $GLANCE_REPO /opt/stack/glance $GLANCE_BRANCH -git_clone $KEYSTONE_REPO /opt/stack/keystone $KEYSTONE_BRANCH -git_clone $NOVNC_REPO /opt/stack/novnc $NOVNC_BRANCH -git_clone $DASH_REPO /opt/stack/dash $DASH_BRANCH -git_clone $NOVACLIENT_REPO /opt/stack/python-novaclient $NOVACLIENT_BRANCH -git_clone $OPENSTACKX_REPO /opt/stack/openstackx $OPENSTACKX_BRANCH +git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH +git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH +git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH +git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH +git_clone $DASH_REPO $DEST/dash $DASH_BRANCH +git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH +git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH # build a new image BASE=build.$$ From 03412c8cb91c64cb2f3dcfb9316a4a952500e1e0 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 3 Oct 2011 09:56:41 -0500 Subject: [PATCH 04/11] Copy devstack into image --- build_nfs.sh | 35 ++++++++++++++++------------------- build_pxe_ramdisk.sh | 9 +++++++++ 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/build_nfs.sh b/build_nfs.sh index 9ffa3cb..a6c8b4c 100755 --- a/build_nfs.sh +++ b/build_nfs.sh @@ -6,10 +6,12 @@ CHROOTCACHE=${CHROOTCACHE:-/root/cache} # Source params source ./stackrc -# TODO: make dest not hardcoded +# Store cwd +CWD=`pwd` NAME=$1 -DEST="/nfs/$NAME" +NFSDIR="/nfs/$NAME" +DEST=${DEST:-/opt/stack} # remove old nfs filesystem if one exists rm -rf $DEST @@ -92,26 +94,21 @@ git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH chroot $CHROOTCACHE/natty-stack mkdir -p $DEST/files wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack$DEST/files/tty.tgz -cp -pr $CHROOTCACHE/natty-stack $DEST - -# set hostname -echo $NAME > $DEST/etc/hostname -echo "127.0.0.1 localhost $NAME" > $DEST/etc/hosts - -# copy kernel modules -cp -pr /lib/modules/`uname -r` $DEST/lib/modules - +# 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 +fi -# copy openstack installer and requirement lists to a new directory. -mkdir -p $DEST/opt +cp -pr $CHROOTCACHE/natty-stack $NFSDIR -# inject stack.sh and dependant files -cp -r files $DEST/opt/files -cp stack.sh $DEST/opt/stack.sh +# set hostname +echo $NAME > $NFSDIR/etc/hostname +echo "127.0.0.1 localhost $NAME" > $NFSDIR/etc/hosts # injecting root's public ssh key if it exists if [ -f /root/.ssh/id_rsa.pub ]; then - mkdir $DEST/root/.ssh - chmod 700 $DEST/root/.ssh - cp /root/.ssh/id_rsa.pub $DEST/root/.ssh/authorized_keys + mkdir $NFSDIR/root/.ssh + chmod 700 $NFSDIR/root/.ssh + cp /root/.ssh/id_rsa.pub $NFSDIR/root/.ssh/authorized_keys fi diff --git a/build_pxe_ramdisk.sh b/build_pxe_ramdisk.sh index d12f23b..9d26886 100755 --- a/build_pxe_ramdisk.sh +++ b/build_pxe_ramdisk.sh @@ -12,6 +12,9 @@ CHROOTCACHE=${CHROOTCACHE:-/root/cache} # Source params source ./stackrc +# Store cwd +CWD=`pwd` + DEST=${DEST:-/opt/stack} # clean install of natty @@ -89,6 +92,12 @@ 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 $CACHEDIR/$DEST/devstack + cp -pr $CWD $CACHEDIR/$DEST/devstack +fi + # build a new image BASE=build.$$ IMG=$BASE.img From 6994f9478921e3436401cc95d68e9d99d937cc85 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 3 Oct 2011 11:03:27 -0500 Subject: [PATCH 05/11] Missed a save --- build_pxe_ramdisk.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build_pxe_ramdisk.sh b/build_pxe_ramdisk.sh index 9d26886..feba18e 100755 --- a/build_pxe_ramdisk.sh +++ b/build_pxe_ramdisk.sh @@ -94,8 +94,8 @@ git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH # Use this version of devstack? if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then - rm -rf $CACHEDIR/$DEST/devstack - cp -pr $CWD $CACHEDIR/$DEST/devstack + rm -rf $$CHROOTCACHE/natty-stack/$DEST/devstack + cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack fi # build a new image From a3379e0eb13ebf3e8c25d40ea3f79a2189f8f75b Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 3 Oct 2011 11:14:13 -0500 Subject: [PATCH 06/11] Default USE_CURRENT_DEVSTACK to 1 --- build_nfs.sh | 3 +++ build_pxe_ramdisk.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/build_nfs.sh b/build_nfs.sh index a6c8b4c..f2a7b13 100755 --- a/build_nfs.sh +++ b/build_nfs.sh @@ -13,6 +13,9 @@ NAME=$1 NFSDIR="/nfs/$NAME" DEST=${DEST:-/opt/stack} +# Option to use the version of devstack on which we are currently working +USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1} + # remove old nfs filesystem if one exists rm -rf $DEST diff --git a/build_pxe_ramdisk.sh b/build_pxe_ramdisk.sh index feba18e..63e2ed4 100755 --- a/build_pxe_ramdisk.sh +++ b/build_pxe_ramdisk.sh @@ -17,6 +17,9 @@ CWD=`pwd` DEST=${DEST:-/opt/stack} +# Option to use the version of devstack on which we are currently working +USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1} + # clean install of natty if [ ! -d $CHROOTCACHE/natty-base ]; then $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base From 10db445b3213478b7adaad368cb702dc3b05aac6 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 3 Oct 2011 11:16:32 -0500 Subject: [PATCH 07/11] Move ramdisk images to CHROOTCACHEDIR --- build_nfs.sh | 2 +- build_pxe_ramdisk.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build_nfs.sh b/build_nfs.sh index f2a7b13..185d0ad 100755 --- a/build_nfs.sh +++ b/build_nfs.sh @@ -99,7 +99,7 @@ wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack$DEST/file # Use this version of devstack? if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then - rm -rf $$CHROOTCACHE/natty-stack/$DEST/devstack + rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack fi diff --git a/build_pxe_ramdisk.sh b/build_pxe_ramdisk.sh index 63e2ed4..46eeb05 100755 --- a/build_pxe_ramdisk.sh +++ b/build_pxe_ramdisk.sh @@ -97,12 +97,12 @@ 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 + rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack fi # build a new image -BASE=build.$$ +BASE=$CHROOTCACHE/build.$$ IMG=$BASE.img MNT=$BASE/ From 3508a3a926687bb6fa15130c736384495d2b877c Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 3 Oct 2011 11:43:28 -0500 Subject: [PATCH 08/11] Move PXE cache to /root/pxe --- build_pxe_boot.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/build_pxe_boot.sh b/build_pxe_boot.sh index 2c4cc0e..9d44949 100755 --- a/build_pxe_boot.sh +++ b/build_pxe_boot.sh @@ -20,6 +20,7 @@ if [ "$1" = "-k" ]; then fi DEST_DIR=${1:-/tmp}/tftpboot +PXEDIR=${PXEDIR:-/root/pxe} OPWD=`pwd` PROGDIR=`dirname $0` @@ -41,23 +42,23 @@ EOF # Setup devstack boot mkdir -p $DEST_DIR/ubuntu -if [ ! -d $OPWD/pxe ]; then - mkdir -p $OPWD/pxe +if [ ! -d $PXEDIR ]; then + mkdir -p $PXEDIR fi -if [ ! -r $OPWD/pxe/vmlinuz-${KVER} ]; then +if [ ! -r $PXEDIR/vmlinuz-${KVER} ]; then sudo chmod 644 /boot/vmlinuz-${KVER} if [ ! -r /boot/vmlinuz-${KVER} ]; then echo "No kernel found" else - cp -p /boot/vmlinuz-${KVER} $OPWD/pxe + cp -p /boot/vmlinuz-${KVER} $PXEDIR fi fi -cp -p $OPWD/pxe/vmlinuz-${KVER} $DEST_DIR/ubuntu -if [ ! -r $OPWD/pxe/stack-initrd.gz ]; then - cd $OPWD - sudo $PROGDIR/build_pxe_ramdisk.sh $OPWD/pxe/stack-initrd.gz +cp -p $PXEDIR/vmlinuz-${KVER} $DEST_DIR/ubuntu +if [ ! -r $PXEDIR/stack-initrd.gz ]; then + cd $PXEDIR + sudo $PROGDIR/build_pxe_ramdisk.sh $PXEDIR/stack-initrd.gz fi -cp -p $OPWD/pxe/stack-initrd.gz $DEST_DIR/ubuntu +cp -p $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu cat >>$DEFAULT <>$DEFAULT < Date: Mon, 3 Oct 2011 13:42:16 -0500 Subject: [PATCH 09/11] Configure network for DHCP --- build_pxe_ramdisk.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build_pxe_ramdisk.sh b/build_pxe_ramdisk.sh index 46eeb05..51220ab 100755 --- a/build_pxe_ramdisk.sh +++ b/build_pxe_ramdisk.sh @@ -101,6 +101,16 @@ if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack fi +# Configure host network for DHCP +mkdir -p $CHROOTCACHE/natty-stack/etc/network +cat > $$CHROOTCACHE/natty-stack/etc/network/interfaces < Date: Mon, 3 Oct 2011 16:31:36 -0500 Subject: [PATCH 10/11] Fix two typos --- build_pxe_boot.sh | 2 +- make_image.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build_pxe_boot.sh b/build_pxe_boot.sh index 9d44949..4f59ed6 100755 --- a/build_pxe_boot.sh +++ b/build_pxe_boot.sh @@ -55,7 +55,7 @@ if [ ! -r $PXEDIR/vmlinuz-${KVER} ]; then fi cp -p $PXEDIR/vmlinuz-${KVER} $DEST_DIR/ubuntu if [ ! -r $PXEDIR/stack-initrd.gz ]; then - cd $PXEDIR + cd $OPWD sudo $PROGDIR/build_pxe_ramdisk.sh $PXEDIR/stack-initrd.gz fi cp -p $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu diff --git a/make_image.sh b/make_image.sh index 81dd97c..0d5074b 100755 --- a/make_image.sh +++ b/make_image.sh @@ -144,7 +144,7 @@ dd if=/dev/null of=$TMPDISK bs=1M seek=$SIZE count=1 if [ -n "$IMAGEONLY" ]; then # Build image from chroot sudo vmbuilder $HYPER ubuntu $ARGS \ - --existing-chroot=$CHR \ + --existing-chroot=$CHROOTDIR \ --overwrite \ --rootsize=$ROOTSIZE \ --swapsize=$SWAPSIZE \ From d4a3bac8d5bbb9e54a4279f7fa74669c7fed97d0 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Mon, 3 Oct 2011 21:16:27 -0500 Subject: [PATCH 11/11] Move cache dir to /var/cache/devstack --- build_nfs.sh | 2 +- build_pxe_boot.sh | 2 +- build_pxe_ramdisk.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build_nfs.sh b/build_nfs.sh index 185d0ad..651bae2 100755 --- a/build_nfs.sh +++ b/build_nfs.sh @@ -1,7 +1,7 @@ #!/bin/bash PROGDIR=`dirname $0` -CHROOTCACHE=${CHROOTCACHE:-/root/cache} +CHROOTCACHE=${CHROOTCACHE:-/var/cache/devstack} # Source params source ./stackrc diff --git a/build_pxe_boot.sh b/build_pxe_boot.sh index 4f59ed6..4feb14d 100755 --- a/build_pxe_boot.sh +++ b/build_pxe_boot.sh @@ -20,7 +20,7 @@ if [ "$1" = "-k" ]; then fi DEST_DIR=${1:-/tmp}/tftpboot -PXEDIR=${PXEDIR:-/root/pxe} +PXEDIR=${PXEDIR:-/var/cache/devstack/pxe} OPWD=`pwd` PROGDIR=`dirname $0` diff --git a/build_pxe_ramdisk.sh b/build_pxe_ramdisk.sh index 51220ab..a01656b 100755 --- a/build_pxe_ramdisk.sh +++ b/build_pxe_ramdisk.sh @@ -7,7 +7,7 @@ if [ ! "$#" -eq "1" ]; then fi PROGDIR=`dirname $0` -CHROOTCACHE=${CHROOTCACHE:-/root/cache} +CHROOTCACHE=${CHROOTCACHE:-/var/cache/devstack} # Source params source ./stackrc @@ -103,7 +103,7 @@ fi # Configure host network for DHCP mkdir -p $CHROOTCACHE/natty-stack/etc/network -cat > $$CHROOTCACHE/natty-stack/etc/network/interfaces < $CHROOTCACHE/natty-stack/etc/network/interfaces <