progress_monitor_support=no
endif
+if PITHOSIMGSUPPORT
+pithos_backend_support=yes
+else
+pithos_backend_support=no
+endif
+
+if NETWORKIMGSUPPORT
+network_backend_support=yes
+else
+network_backend_support=no
+endif
+
osname=$(PACKAGE)
osdir=$(OS_DIR)/$(osname)
defaultdir=$(DEFAULT_DIR)
-e 's|@QEMU_IMG[@]|$(QEMU_IMG)|g' \
-e 's|@INSTALL_MBR[@]|$(INSTALL_MBR)|g' \
-e 's|@PROGRESS_MONITOR[@]|$(PROGRESS_MONITOR)|g' \
- -e 's|@progress_monitor_support[@]|$(progress_monitor_support)|g'
+ -e 's|@progress_monitor_support[@]|$(progress_monitor_support)|g' \
+ -e 's|@pithos_backend_support[@]|$(pithos_backend_support)|g' \
+ -e 's|@network_backend_support[@]|$(network_backend_support)|g'
%:%.in Makefile
rm -f $@ $@.tmp
PROGRESS_MONITOR="snf-progress-monitor"
progress_monitor_support="@progress_monitor_support@"
+pithos_backend_support="@pithos_backend_support@"
+network_backend_support="@network_backend_support@"
CLEANUP=( )
umount "$target"
}
+get_backend_type() {
+ local id=$1
+
+ if [[ "$id" =~ ^pithos: ]]; then
+ if [ "$pithos_backend_support" = "yes" ]; then
+ echo "pithos"
+ else
+ log_error "Retrieving images from pithos is not supported"
+ exit 1
+ fi
+ elif [[ "$id" =~ ^(http|ftp)s?: ]]; then
+ if [ "$network_backend_support" = "yes" ]; then
+ echo "network";
+ else
+ log_error "Retrieving images from the network is not supported."
+ exit 1
+ fi
+ else
+ echo "local";
+ fi
+}
+
# this one is only to be called by create
ganeti_os_main() {
if [ -z "$OS_API_VERSION" -o "$OS_API_VERSION" = "5" ]; then
get_api10_arguments
elif [ "$OS_API_VERSION" = "20" ]; then
get_api20_arguments
- IMAGE_NAME=$IMG_ID
- IMAGE_TYPE=$IMG_FORMAT
+ IMAGE_NAME="$IMG_ID"
+ IMAGE_TYPE="$IMG_FORMAT"
+ BACKEND_TYPE=$(get_backend_type $IMG_ID)
else
log_error "Unknown OS API VERSION $OS_API_VERSION"
exit 1
: ${HELPER_CACHE_FILE:="@HELPER_DIR@/cache.tar"}
: ${HELPER_EXTRA_PKGS:="linux-image-amd64,e2fsprogs,ntfs-3g,ntfsprogs,xmlstarlet,python,parted,reglookup,chntpw"}
: ${HELPER_MIRROR:=""}
-
+: ${PITHOS_DB:="sqlite:////@localstatedir@/lib/pithos/backend.db"}
+: ${PITHOS_DATA:="@localstatedir@/lib/pithos/"}
SCRIPT_NAME=$(basename $0)
AM_INIT_AUTOMAKE([1.9 foreign tar-ustar -Wall -Wno-portability])
AM_INIT_AUTOMAKE([subdir-objects])
+AC_ARG_ENABLE([pithos_backend],
+ AS_HELP_STRING([--enable-pithos-backend],
+ [enable support for pithos-hosted images])
+)
+AS_IF([test "x$enable_pithos_backend" = "xyes"],,
+ [AC_MSG_NOTICE(pithos backend support not enabled)])
+AM_CONDITIONAL(PITHOSIMGSUPPORT, [test "x$enable_pithos_backend" = "xyes"])
+
+AC_ARG_ENABLE([network_backend],
+ AS_HELP_STRING([--enable-network-backend],
+ [enable support for network-hosted images
+ (this depends on cURL)])
+)
+AS_IF([test "x$enable_network_backend" = "xyes"],,
+ [AC_MSG_NOTICE(network backend support not enabled)])
+AM_CONDITIONAL(NETWORKIMGSUPPORT, [test "x$enable_network_backend" = "xyes"])
+
# --with-progress-monitor
AC_ARG_WITH([progress-monitor],
[AS_HELP_STRING([--with-progress-monitor=PRGRM_PATH],
[path to progress-monitor program]
[[snf-progress-monitor]])],
[if test "$withval" = "yes" ; then
- AC_PATH_PROG(PROGRESS_MONITOR, [snf-progress-monitor], [], [$PATH:/usr/sbin:/sbin])
- if test -z "$PROGRESS_MONITOR" ; then
- AC_MSG_FAILURE([Could not find snf-progress-monitor.])
- fi
- else
- PROGRESS_MONITOR="$withval"
- fi],
+ AC_PATH_PROG(PROGRESS_MONITOR, [snf-progress-monitor], [], [$PATH:/usr/sbin:/sbin])
+ if test -z "$PROGRESS_MONITOR" ; then
+ AC_MSG_FAILURE([Could not find snf-progress-monitor.])
+ fi
+ else
+ PROGRESS_MONITOR="$withval"
+ fi],
[AC_MSG_NOTICE(progress-monitor support not enabled)]
)
AC_MSG_ERROR([timelimit not found in $PATH:/usr/sbin:/sbin])
fi
-AC_PATH_PROG(CURL, [curl], [], [$PATH:/usr/sbin:/sbin])
-if test -z "$CURL" ; then
- AC_MSG_ERROR([curl not found in $PATH:/usr/sbin:/sbin])
+if test "x$enable_network_backend" = "xyes" ; then
+ AC_PATH_PROG(CURL, [curl], [], [$PATH:/usr/sbin:/sbin])
+ if test -z "$CURL" ; then
+ AC_MSG_ERROR([curl is needed for network backend support but was not \
+ found in $PATH:/usr/sbin:/sbin]
+ [To disable network backend support ommit --enable-network-backend])
+ fi
fi
AC_CONFIG_FILES([
ganeti_os_main
-if [ "$IMAGE_TYPE" = custom ]; then
- image_file=/dev/null
- image_size=\
- $($CURL -sI "$IMAGE_NAME" | grep ^Content-Length: | cut -d" " -f2)
-else
- image_file="$IMAGE_DIR/$IMAGE_NAME.$IMAGE_TYPE"
- image_size="$(stat -L -c %s "$image_file")"
-fi
-
-if [ ! -e "$image_file" ]; then
- log_error "Image file \`$image_file' does not exit."
- exit 1
-fi
+case $BACKEND_TYPE in
+ local)
+ image_file="$IMAGE_DIR/$(echo "$IMAGE_NAME" | sed 's/^file://').$IMAGE_TYPE"
+ if [ ! -e "$image_file" ]; then
+ log_error "Image file \`$image_file' does not exit."
+ exit 1
+ fi
+ image_size="$(stat -L -c %s "$image_file")"
+ ;;
+ network)
+ image_cmd="$CURL $(printf "%q" "$IMAGE_NAME") 2> /dev/null"
+ image_size=$($CURL -sI "$IMAGE_NAME" | grep ^Content-Length: | cut -d" " -f2)
+ ;;
+ pithos)
+ cmd_args= "--db $(printf "%q" "${PITHOS_DB}") \
+ --data $(printf "%q" "${PITHOS_DATA}") \
+ $(printf "%q" "${IMAGE_NAME}")"
+ image_cmd="./pithcat $cmd_args"
+ image_size=$(./pithcat -s $cmd_args)
+ ;;
+esac
monitor="" #Empty if progress monitor support is disabled
if [ "$progress_monitor_support" = "yes" ]; then
snf_export_PROPERTY_OSFAMILY="linux"
fi
;;
- diskdump|custom)
+ diskdump)
target="$blockdev"
;;
esac
-if [ "$IMAGE_TYPE" = "custom" ]; then
- "$CURL" "$IMAGE_NAME" 2>/dev/null |\
- $monitor dd bs=4M of="$target" oflag=direct
-else
+if [ "$BACKEND_TYPE" = "local" ]; then
# dd the dump to its new home :-)
# Deploying an image file on a target block device is a streaming copy
# operation. Enable the direct I/O flag on the output fd to avoid polluting
# the host cache with useless data.
$monitor dd bs=4M if="$image_file" of="$target" oflag=direct
+else
+ $image_cmd | $monitor dd bs=4M of="$target" oflag=direct
fi
# Create a floppy image
# define a mirror. Debootstrap will use it's default debian URL.
# HELPER_MIRROR="http://ftp.debian.org/debian"
+# PITHOS_DB: Pithos database in SQLAlchemy format
+# PITHOS_DB="sqlite:////var/lib/pithos/backend.db"
+
+# PITHOS_DATA: Directory where pithos data are hosted
+# PITHOS_DATA="/var/lib/pithos/"
+
# Paths for needed programs. Uncommend and change the variables below, if you
# don't want to use the default one.
# LOSETUP="losetup"