summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2012-05-07 13:54:46 +1000
committerMartin Schwenke <martin@meltin.net>2012-05-07 13:54:46 +1000
commitb3e3340a1e23360bf0efa4b8a1bd471dd31ac885 (patch)
tree5e47b71a2db28e7c9d36ef52c31049410108258d
parentd8c144444949d4577315a533112f8f10d327b1b6 (diff)
downloadautocluster-b3e3340a1e23360bf0efa4b8a1bd471dd31ac885.tar.gz
autocluster-b3e3340a1e23360bf0efa4b8a1bd471dd31ac885.tar.xz
autocluster-b3e3340a1e23360bf0efa4b8a1bd471dd31ac885.zip
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 <martin@meltin.net>
-rwxr-xr-xautocluster21
-rw-r--r--config.d/00base.defconf3
-rw-r--r--config.d/10shareddisk.defconf3
-rw-r--r--config.d/60tsm.defconf7
4 files changed, 27 insertions, 7 deletions
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" \
"<yes|no>" "Use per-node-type base images"
+defconf DISK_FOLLOW_SYMLINKS "no" \
+ "<yes|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
}