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

Add new variable-to-floppy export mechanism

Many bugs have been fixed.
parent 64605956
......@@ -7,9 +7,10 @@ endif
osname=$(PACKAGE)
osdir=$(OS_DIR)/$(osname)
defaultdir=$(DEFAULT_DIR)
variantsdir=$(DESTDIR)${sysconfdir}/ganeti/snf-image/variants
variantsdir=${sysconfdir}/ganeti/snf-image/variants
dist_os_SCRIPTS = host/create
dist_os_SCRIPTS = ${srcdir}/host/create ${srcdir}/host/import \
${srcdir}/host/export ${srcdir}/host/rename ${srcdir}/host/verify
dist_os_DATA = ${srcdir}/host/ganeti_api_version ${srcdir}/host/parameters.list \
${srcdir}/host/variants.list
......@@ -41,4 +42,10 @@ host/common.sh: Makefile
$(edit) $${srcdir}$@.in >$@.tmp
mv $@.tmp $@
install-exec-local:
@mkdir_p@ "$(DESTDIR)$(osdir)"
@mkdir_p@ "$(DESTDIR)$(variantsdir)"
touch "$(DESTDIR)$(variantsdir)/default.conf"
CLEANFILES = $(os_DATA)
......@@ -105,16 +105,16 @@ get_api10_arguments() {
}
get_api20_arguments() {
get_api_10_arguments
if [ -z "$OSP_IMG_ID"]; then
get_api10_arguments
if [ -z "$OSP_IMG_ID" ]; then
log_error "Missing OS API Parameter: OSP_IMG_ID"
exit 1
fi
if [ -z "$OSP_IMG_FORMAT"]; then
if [ -z "$OSP_IMG_FORMAT" ]; then
log_error "Missing OS API Parameter: OSP_IMG_FORMAT"
exit 1
fi
if [ -z "$OSP_IMG_PASSWD"]; then
if [ -z "$OSP_IMG_PASSWD" ]; then
log_error "Missing OS API Parameter: OSP_IMG_PASSWD"
exit 1
fi
......@@ -123,12 +123,12 @@ 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 | \
filesystem_dev_base=$($KPARTX -l -p- $blockdev | \
grep -m 1 -- "-1.*$blockdev" | \
$AWK '{print $1}'`
$AWK '{print $1}')
if [ -z "$filesystem_dev_base" ]; then
log_error "Cannot interpret kpartx output and get partition mapping"
exit 1
......@@ -165,19 +165,13 @@ EOF
create_floppy() {
local img=$1
local target=`mktemp -d` || exit 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
set|egrep ^snf_export_\\w+|sed -e 's/^snf_export_/GANETI_/' > $target/rules
umount $target
}
......@@ -198,7 +192,7 @@ if [ -f "$DEFAULT_FILE" ]; then
. "$DEFAULT_FILE"
fi
: ${ARCH:="x86_64}
: ${ARCH:="x86_64"}
: ${CUSTOMIZE_DIR:="@sysconfdir@/ganeti/snf-image/hooks"}
: ${VARIANTS_DIR:="@sysconfdir@/ganeti/snf-image/variants"}
: ${IMAGE_DIR:="@localstatedir@/lib/snf-image"}
......
......@@ -76,9 +76,13 @@ root_dev="${filesystem_dev}-1"
$MONITOR dd bs=4M if=$IMAGE_FILE of=$root_dev oflag=direct
# Create a floppy image
floppy=`mktemp floppy.XXXXXXXX` || exit 1
floppy=$(mktemp --tmpdir floppy.XXXXXXXX) || exit 1
CLEANUP+=("rm -f $floppy")
snf_export_FORMAT=${IMG_FORMAT}
snf_export_PASSWORD=${IMG_PASSWD}
snf_export_HOSTNAME=${instance}
create_floppy $floppy
#Invoke the helper vm to do the dirty job...
......
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