summaryrefslogtreecommitdiff
path: root/ironic_python_agent/shell
diff options
context:
space:
mode:
authorJay Faulkner <jay@jvf.cc>2014-05-27 16:57:12 -0700
committerJay Faulkner <jay@jvf.cc>2014-06-03 16:52:33 -0700
commita7d68658838e8d7c956c2c69a84b55def858d001 (patch)
treebd2276d0b9e719bfde6b45d63a1ef5d9a9ba2120 /ironic_python_agent/shell
parent59d6523a3554897b4d327f9b0ec22d4af180bc48 (diff)
downloadironic-python-agent-a7d68658838e8d7c956c2c69a84b55def858d001.tar.gz
Allow configdrive partition to be precreated
This adds support for copying configdrives to disks that already have partitions enabled and labeled for configdrives. This is neccessary for supporting configdrives on partitioning schemes we don't support yet (like GPT) or for some future agent iteration where we create partitions separately. Change-Id: Iee5b87d82be08febc495aaef3272ced4f2f32235
Diffstat (limited to 'ironic_python_agent/shell')
-rwxr-xr-xironic_python_agent/shell/copy_configdrive_to_disk.sh24
1 files changed, 15 insertions, 9 deletions
diff --git a/ironic_python_agent/shell/copy_configdrive_to_disk.sh b/ironic_python_agent/shell/copy_configdrive_to_disk.sh
index 768a37da..da0b9097 100755
--- a/ironic_python_agent/shell/copy_configdrive_to_disk.sh
+++ b/ironic_python_agent/shell/copy_configdrive_to_disk.sh
@@ -34,15 +34,21 @@ DEVICE="$2"
[[ -f $CONFIGDRIVE ]] || usage "$CONFIGDRIVE (CONFIGDRIVE) is not a regular file"
[[ -b $DEVICE ]] || usage "$DEVICE (DEVICE) is not a block device"
-# Create small partition at the end of the device
-log "Adding configdrive partition to $DEVICE"
-parted -a optimal -s -- $DEVICE mkpart primary ext2 -64MiB -0
-
-# Find partition we just created
-# Dump all partitions, ignore empty ones, then get the last partition ID
-ISO_PARTITION=`sfdisk --dump $DEVICE | grep -v ' 0,' | tail -n1 | awk '{print $1}'`
-
-# This generates the ISO image of the config drive.
+# Check for preexisting partition for configdrive
+EXISTING_PARTITION=`/sbin/blkid -l -o device $DEVICE -t LABEL=config-2`
+if [[ $? == 0 ]]; then
+ ISO_PARTITION=$EXISTING_PARTITION
+else
+ # Create small partition at the end of the device
+ log "Adding configdrive partition to $DEVICE"
+ parted -a optimal -s -- $DEVICE mkpart primary ext2 -64MiB -0
+
+ # Find partition we just created
+ # Dump all partitions, ignore empty ones, then get the last partition ID
+ ISO_PARTITION=`sfdisk --dump $DEVICE | grep -v ' 0,' | tail -n1 | awk '{print $1}'`
+fi
+
+# This writes the ISO image to the config drive.
log "Writing Configdrive contents in $CONFIGDRIVE to $ISO_PARTITION"
dd if=$CONFIGDRIVE of=$ISO_PARTITION bs=64K oflag=direct