Commit e036304a authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Create floppy image the helper vm will be using

The project is still not workable yet
parent f4bd39d8
......@@ -4,6 +4,7 @@ else
progress_monitor_support=no
endif
osname=$(PACKAGE)
osdir=$(OS_DIR)/$(osname)
defaultdir=$(DEFAULT_DIR)
variantsdir=$(DESTDIR)${sysconfdir}/ganeti/snf-image/variants
......
......@@ -123,7 +123,7 @@ get_api20_arguments() {
IMG_FORMAT=$OSP_IMG_FORMAT
IMG_PASSWD=$OSP_IMG_PASSWD
}
er
map_disk0() {
blockdev="$1"
filesystem_dev_base=`$KPARTX -l -p- $blockdev | \
......@@ -162,6 +162,25 @@ format_disk0() {
EOF
}
create_floppy() {
local img=$1
local target=`mktemp -d` || exit 1
CLEANUP+=("rmdir $target")
dd bs=512 count=2880 if=/dev/zero of=$img
mkfs.ext2 -F $img > /dev/null
mount $img $target -o loop
sed \
-e 's|@IMAGE_TYPE[@]|$(IMAGE_TYPE)|g' \
-e 's|@PASSWORD[@]|$(IMG_PASSWD)|g' \
-e 's|@HOSTNAME[@]|$(instance)|g' \
-e 's|@SSH_KEY[@]|$(IMG_SSH_KEY)|g' \
rules.template > $target/rules
umount $target
}
cleanup() {
if [ ${#CLEANUP[*]} -gt 0 ]; then
LAST_ELEMENT=$((${#CLEANUP[*]}-1))
......
......@@ -62,7 +62,7 @@ if [ ! -b $blockdev ]; then
CLEANUP+=("$LOSETUP -d $blockdev")
fi
${IMAGE_TYPE}_format_disk0 $blockdev
format_disk0 $blockdev ${IMAGE_TYPE}
filesystem_dev=$(map_disk0 $blockdev)
CLEANUP+=("unmap_disk0 $blockdev")
......@@ -75,6 +75,12 @@ root_dev="${filesystem_dev}-1"
# avoid polluting the host cache with useless data.
$MONITOR dd bs=4M if=$IMAGE_FILE of=$root_dev oflag=direct
# Create a floppy image
floppy=`mktemp floppy.XXXXXXXX` || exit 1
CLEANUP+=("rm -f $floppy")
create_floppy $floppy
#Invoke the helper vm to do the dirty job...
# Execute cleanups
......
IMAGE_TYPE=@IMAGE_TYPE@
PASSWORD=@PASSWORD@
HOSTNAME=@HOSTNAME@
SSH_KEY=@SSH_KEY@
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment