Add raw image support
diff --git a/make_image.sh b/make_image.sh
index 28b2eac..3bfa683 100755
--- a/make_image.sh
+++ b/make_image.sh
@@ -3,7 +3,7 @@
#
# make_image.sh release format
#
-# Supported formats: qcow (kvm), vmdk (vmserver), vdi (vbox), vhd (vpc)
+# Supported formats: qcow (kvm), vmdk (vmserver), vdi (vbox), vhd (vpc), raw
#
# Requires sudo to root
@@ -36,22 +36,29 @@
case $FORMAT in
kvm|qcow2) FORMAT=qcow2
- TARGET=kvm
+ QFORMAT=qcow2
+ HYPER=kvm
;;
vmserver|vmdk)
FORMAT=vmdk
- TARGET=vmserver
+ QFORMAT=vmdk
+ HYPER=vmserver
;;
- vbox|vdi) FORMAT=qcow2
- TARGET=kvm
- FINAL_FORMAT=vdi
+ vbox|vdi) FORMAT=vdi
+ QFORMAT=vdi
+ HYPER=kvm
;;
- vhd|vpc) FORMAT=qcow2
- TARGET=kvm
- FINAL_FORMAT=vhd
+ vhd|vpc) FORMAT=vhd
+ QFORMAT=vpc
+ HYPER=kvm
;;
xen) FORMAT=raw
- TARGET=xen
+ QFORMAT=raw
+ HYPER=xen
+ ;;
+ raw) FORMAT=raw
+ QFORMAT=raw
+ HYPER=kvm
;;
*) echo "Unknown format: $FORMAT"
usage
@@ -74,24 +81,23 @@
fi
# Build the image
-sudo vmbuilder $TARGET ubuntu --suite $RELEASE \
+TMPDISK=`mktemp imgXXXXXXXX`
+SIZE=$[$ROOTSIZE+$SWAPSIZE+1]
+dd if=/dev/null of=$TMPDISK bs=1M seek=$SIZE
+sudo vmbuilder $HYPER ubuntu --suite $RELEASE \
-o \
--rootsize=$ROOTSIZE \
--swapsize=$SWAPSIZE \
--tmpfs - \
--addpkg=openssh-server \
+ --raw=$TMPDISK \
-# --mirror=$MIRROR \
-
-if [ -z "$FINAL_FORMAT" ]; then
+if [ "$FORMAT" = "raw" ]; then
# Get image
- mv ubuntu-$TARGET/tmp*.$FORMAT $RELEASE.$FORMAT
+ mv $TMPDISK $RELEASE.$FORMAT
else
# Convert image
- tgt=$FINAL_FORMAT
- if [ "$tgt" = "vhd" ]; then
- tgt=vpc
- fi
- qemu-img convert -O $tgt ubuntu-$TARGET/tmp*.$FORMAT $RELEASE.$FINAL_FORMAT
+ qemu-img convert -O $QFORMAT $TMPDISK $RELEASE.$FORMAT
+ rm $TMPDISK
fi
-rm -rf ubuntu-$TARGET
+rm -rf ubuntu-$HYPER
diff --git a/upload_image.sh b/upload_image.sh
index 39a2fba..cf913b8 100755
--- a/upload_image.sh
+++ b/upload_image.sh
@@ -63,6 +63,7 @@
# Look for stack.sh's install
GLANCE="/opt/glance/bin/glance"
else
+ # Install Glance client in /opt
echo "Glance not found, must install client"
OWD=`pwd`
cd /opt
@@ -79,9 +80,10 @@
# Create image if it doesn't exist
if [ ! -r $RELEASE.$FORMAT ]; then
DIR=`dirname $0`
- echo "$RELEASE.$FORMAT not found, creating...must be root to do this:"
+ echo "$RELEASE.$FORMAT not found, creating..."
$DIR/make_image.sh $RELEASE $FORMAT
fi
# Upload the image
+echo "Uploading image $RELEASE.$FORMAT to $HOST"
$GLANCE add name=$RELEASE.$FORMAT is_public=true disk_format=$FORMAT --host $HOST --port $PORT <$RELEASE.$FORMAT