summaryrefslogtreecommitdiffstats
path: root/autocluster
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2013-02-19 12:55:47 +1100
committerMartin Schwenke <martin@meltin.net>2013-02-19 12:55:47 +1100
commit0e2c4f51f4478e5b0e69649339864776a8b5144f (patch)
tree8059e24902c077f3ab1075d06ed50d1c935cc392 /autocluster
parent37b2555b68320cd6c900d6879d08db82a481215f (diff)
downloadautocluster-0e2c4f51f4478e5b0e69649339864776a8b5144f.tar.gz
autocluster-0e2c4f51f4478e5b0e69649339864776a8b5144f.tar.xz
autocluster-0e2c4f51f4478e5b0e69649339864776a8b5144f.zip
New hook hack_disk_hooks to customise the value of $DISKautocluster-0.7
Works for base, system and shared disks. Signed-off-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'autocluster')
-rwxr-xr-xautocluster40
1 files changed, 31 insertions, 9 deletions
diff --git a/autocluster b/autocluster
index 8d7ae2f..8f9fa30 100755
--- a/autocluster
+++ b/autocluster
@@ -167,6 +167,14 @@ clear_hooks ()
##############################
+# These hooks are intended to customise the value of $DISK. They have
+# access to 1 argument ("base", "system", "shared") and the variables
+# $VIRTBASE, $CLUSTER, $BASENAME (for "base"), $NAME (for "system"),
+# $SHARED_DISK_NUM (for "shared"). A hook must be deterministic and
+# should not be stateful, since they can be called multiple times for
+# the same disk.
+hack_disk_hooks=""
+
# common node creation stuff
create_node_COMMON ()
{
@@ -179,21 +187,29 @@ create_node_COMMON ()
die "Error: if BASE_FORMAT is \"qcow2\" then SYSTEM_DISK_FORMAT must also be \"qcow2\"."
fi
- IPNUM=$(($FIRSTIP + $ip_offset))
- DISK="${VIRTBASE}/${CLUSTER}/${NAME}.${SYSTEM_DISK_FORMAT}"
- local base_disk="${VIRTBASE}/${BASENAME}.${BASE_FORMAT}"
+ local IPNUM=$(($FIRSTIP + $ip_offset))
+ # Determine base image name. We use $DISK temporarily to allow
+ # the path to be hacked.
+ local DISK="${VIRTBASE}/${BASENAME}.${BASE_FORMAT}"
if [ "$BASE_PER_NODE_TYPE" = "yes" ] ; then
- base_disk="${VIRTBASE}/${BASENAME}-${type}.${BASE_FORMAT}"
+ DISK="${VIRTBASE}/${BASENAME}-${type}.${BASE_FORMAT}"
fi
+ run_hooks hack_disk_hooks "base"
+ local base_disk="$DISK"
- mkdir -p $VIRTBASE/$CLUSTER tmp
+ # Determine the system disk image name.
+ DISK="${VIRTBASE}/${CLUSTER}/${NAME}.${SYSTEM_DISK_FORMAT}"
+ run_hooks hack_disk_hooks "system"
local di="$DISK"
if [ "$DISK_FOLLOW_SYMLINKS" = "yes" -a -L "$DISK" ] ; then
di=$(readlink "$DISK")
fi
rm -f "$di"
+ local di_dirname="${di%/*}"
+ mkdir -p "$di_dirname"
+
case "$SYSTEM_DISK_FORMAT" in
qcow2)
echo "Creating the disk..."
@@ -229,6 +245,8 @@ create_node_COMMON ()
# Pull the UUID for this node out of the map.
UUID=$(awk "\$1 == $ip_offset {print \$2}" $uuid_map)
+ mkdir -p tmp
+
echo "Creating $NAME.xml"
substitute_vars $template_file tmp/$NAME.xml
@@ -474,10 +492,11 @@ test_proxy() {
kickstart_floppy_create_hooks=
# create base image
-create_base() {
-
- NAME="$BASENAME"
- DISK="${VIRTBASE}/${NAME}.${BASE_FORMAT}"
+create_base()
+{
+ local NAME="$BASENAME"
+ local DISK="${VIRTBASE}/${NAME}.${BASE_FORMAT}"
+ run_hooks hack_disk_hooks "base"
mkdir -p $KVMLOG
@@ -488,6 +507,9 @@ create_base() {
if [ "$DISK_FOLLOW_SYMLINKS" = "yes" -a -L "$DISK" ] ; then
di=$(readlink "$DISK")
fi
+ rm -f "$di"
+ local di_dirname="${di%/*}"
+ mkdir -p "$di_dirname"
echo "Creating the disk"
qemu-img create -f $BASE_FORMAT "$di" $DISKSIZE