From db0078b9ba57ef40100de1887fab8b9814c5b243 Mon Sep 17 00:00:00 2001 From: Nikos Skalkotos Date: Wed, 9 Nov 2011 17:07:31 +0200 Subject: [PATCH] Add initial support for custom images --- snf-image-host/create | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/snf-image-host/create b/snf-image-host/create index 8bc80eb..3056501 100755 --- a/snf-image-host/create +++ b/snf-image-host/create @@ -36,7 +36,13 @@ set -o pipefail ganeti_os_main -image_file="$IMAGE_DIR/$IMAGE_NAME-$ARCH.$IMAGE_TYPE" +if [ "$IMAGE_TYPE" = custom ]; then + image_file=/dev/null + image_size=0 +else + image_file="$IMAGE_DIR/$IMAGE_NAME-$ARCH.$IMAGE_TYPE" + image_size="$(stat -L -c %s "$image_file")" +fi if [ ! -e "$image_file" ]; then log_error "Image file \`$image_file' does not exit." @@ -45,7 +51,6 @@ fi monitor="" #Empty if progress monitor support is disabled if [ "$progress_monitor_support" = "yes" ]; then - image_size="$(stat -L -c %s "$image_file")" monitor="$(printf "%q" "$PROGRESS_MONITOR") \ -i $(printf "%q" "$INSTANCE_NAME") -r $image_size" fi @@ -70,16 +75,20 @@ case "$IMAGE_TYPE" in add_cleanup unmap_disk0 "$blockdev" snf_export_ROOT=1 ;; - diskdump) + diskdump, custom) target="$blockdev" ;; esac -# dd the dump to its new home :-) -# Deploying an image file on a target block device is a streaming copy -# operation. Enable the direct I/O flag on the output fd to avoid polluting the -# host cache with useless data. -$monitor dd bs=4M if="$image_file" of="$target" oflag=direct +if [ "$IMAGE_TYPE" = "custom" ]; then + wget -O - $IMAGE_NAME | $monitor dd bs=4M of="$target" oflag=direct +else + # dd the dump to its new home :-) + # Deploying an image file on a target block device is a streaming copy + # operation. Enable the direct I/O flag on the output fd to avoid polluting + # the host cache with useless data. + $monitor dd bs=4M if="$image_file" of="$target" oflag=direct +fi # Create a floppy image floppy=$(mktemp --tmpdir floppy.XXXXXX) -- 1.7.10.4