From: Martin Schwenke Date: Mon, 7 May 2012 03:54:46 +0000 (+1000) Subject: New option DISK_FOLLOW_SYMLINKS X-Git-Tag: autocluster-0.5~23 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=b3e3340a1e23360bf0efa4b8a1bd471dd31ac885;p=tridge%2Fautocluster.git New option DISK_FOLLOW_SYMLINKS If DISK_FOLLOW_SYMLINKS=yes then for any disk image paths that are a symlink, follow the symlink when creating the image. This allows disk images to be reorganised, perhaps across several disks, and replaced with symlinks. On the next cluster creation the symlinks will be respected and the layout of disk images will be maintained. Signed-off-by: Martin Schwenke --- diff --git a/autocluster b/autocluster index f5fae9f..cec09e4 100755 --- a/autocluster +++ b/autocluster @@ -197,28 +197,32 @@ create_node_COMMON () mkdir -p $VIRTBASE/$CLUSTER tmp - rm -f "$DISK" + local di="$DISK" + if [ "$DISK_FOLLOW_SYMLINKS" = "yes" -a -L "$DISK" ] ; then + di=$(readlink "$DISK") + fi + rm -f "$di" case "$SYSTEM_DISK_FORMAT" in qcow2) echo "Creating the disk..." - qemu-img create -b "$base_disk" -f qcow2 "$DISK" + qemu-img create -b "$base_disk" -f qcow2 "$di" create_node_configure_image "$DISK" "$type" ;; raw) echo "Creating the disk..." - cp -v --sparse=always "$base_disk" "$DISK" + cp -v --sparse=always "$base_disk" "$di" create_node_configure_image "$DISK" "$type" ;; reflink) echo "Creating the disk..." - cp -v --reflink=always "$base_disk" "$DISK" + cp -v --reflink=always "$base_disk" "$di" create_node_configure_image "$DISK" "$type" ;; mmclone) echo "Creating the disk (using mmclone)..." local base_snap="${base_disk}.snap" [ -f "$base_snap" ] || mmclone snap "$base_disk" "$base_snap" - mmclone copy "$base_snap" "$DISK" + mmclone copy "$base_snap" "$di" create_node_configure_image "$DISK" "$type" ;; none) @@ -488,8 +492,13 @@ create_base() { echo "Testing WEBPROXY $WEBPROXY" test_proxy + local di="$DISK" + if [ "$DISK_FOLLOW_SYMLINKS" = "yes" -a -L "$DISK" ] ; then + di=$(readlink "$DISK") + fi + echo "Creating the disk" - qemu-img create -f $BASE_FORMAT "$DISK" $DISKSIZE + qemu-img create -f $BASE_FORMAT "$di" $DISKSIZE rm -rf tmp mkdir -p mnt tmp tmp/ISO diff --git a/config.d/00base.defconf b/config.d/00base.defconf index 5cb7d1c..ba39c06 100644 --- a/config.d/00base.defconf +++ b/config.d/00base.defconf @@ -40,6 +40,9 @@ defconf BASENAME "ac-base" \ defconf BASE_PER_NODE_TYPE "no" \ "" "Use per-node-type base images" +defconf DISK_FOLLOW_SYMLINKS "no" \ + "" "If disk images use symlinks then follow them to overwrite" + ###################################################################### # Virtualisation diff --git a/config.d/10shareddisk.defconf b/config.d/10shareddisk.defconf index 903727c..d53765d 100644 --- a/config.d/10shareddisk.defconf +++ b/config.d/10shareddisk.defconf @@ -128,6 +128,9 @@ EOF local i for i in $(seq 1 $SHAREDDISK_COUNT); do local f="$VIRTBASE/$CLUSTER/shared$i" + if [ "$DISK_FOLLOW_SYMLINKS" = "yes" -a -L "$f" ] ; then + f=$(readlink "$f") + fi rm -f "$f" if [ "$SHARED_DISK_TYPE" = "iscsi" ] ; then dd if=/dev/zero seek=$SHAREDDISKSIZE bs=1 count=1 of="$f" diff --git a/config.d/60tsm.defconf b/config.d/60tsm.defconf index 8e2aacd..1e22f1d 100644 --- a/config.d/60tsm.defconf +++ b/config.d/60tsm.defconf @@ -84,8 +84,13 @@ create_node_tsm_server () echo "Creating TSM server node $name" create_node_COMMON "$name" "$ip_offset" "$type" "$TSM_TEMPLATE" + local di="$TSMDISK" + if [ "$DISK_FOLLOW_SYMLINKS" = "yes" -a -L "$TSMDISK" ] ; then + di=$(readlink "$TSMDISK") + fi + echo "Creating tsm disk" - qemu-img create -f qcow2 "$TSMDISK" $TSMDISKSIZE + qemu-img create -f qcow2 "$di" $TSMDISKSIZE echo }