Merge pull request #91 from cloudbuilders/dt-build_kvm
Fix concurrent build_kvm.sh runs
This commit is contained in:
commit
f299dee29e
1 changed files with 13 additions and 13 deletions
|
@ -45,15 +45,15 @@ source ./stackrc
|
|||
DIST_NAME=${DIST_NAME:-natty}
|
||||
IMAGE_FNAME=$DIST_NAME.raw
|
||||
|
||||
# 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}
|
||||
|
||||
# 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
|
||||
|
||||
# Mop up after previous runs
|
||||
virsh destroy $CONTAINER_NAME
|
||||
|
||||
|
@ -70,14 +70,14 @@ 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
|
||||
|
||||
# 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
|
||||
|
||||
|
@ -306,7 +306,7 @@ chmod 755 $RUN_SH
|
|||
RC_LOCAL=$ROOTFS/etc/init.d/local
|
||||
cat > $RC_LOCAL <<EOF
|
||||
#!/bin/sh -e
|
||||
# Reboot if this is our first run to enable console log on natty :(
|
||||
# Reboot if this is our first run to enable console log on $DIST_NAME :(
|
||||
if [ ! -e /root/firstlaunch ]; then
|
||||
touch /root/firstlaunch
|
||||
reboot -f
|
||||
|
|
Loading…
Reference in a new issue