1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-20 10:50:08 +03:00

bug #4052: do not create snap dirs for CDs

for qcow2 TM drivers

(cherry picked from commit 9cad48284d2fccb8457150d4f30918333d0c1d73)
This commit is contained in:
Javi Fontan 2015-11-16 11:59:19 +01:00
parent f6ec52dddc
commit 7ac678fe0b
2 changed files with 17 additions and 5 deletions

View File

@ -80,11 +80,16 @@ ssh_make_path $DST_HOST $DST_DIR
# Clone (cp) SRC into DST
#-------------------------------------------------------------------------------
if [ -n "$ORIGINAL_SIZE" -a "$SIZE" -gt "$ORIGINAL_SIZE" ]; then
RESIZE_CMD="qemu-img resize ${DST_PATH} ${SIZE}M"
fi
type="$(file -b --mime-type $SRC_PATH)"
CLONE_CMD=$(cat <<EOF
if [ "$type" == "application/x-iso9660-image" ]; then
CLONE_CMD="cp ${SRC_PATH} ${DST_PATH}"
else
if [ -n "$ORIGINAL_SIZE" -a "$SIZE" -gt "$ORIGINAL_SIZE" ]; then
RESIZE_CMD="qemu-img resize ${DST_PATH} ${SIZE}M"
fi
CLONE_CMD=$(cat <<EOF
cd $DST_DIR
mkdir -p ${DST_PATH}.snap
rm -f $DST_PATH
@ -93,6 +98,7 @@ ln -s ${DST_PATH}.snap/0 ${DST_PATH}
${RESIZE_CMD}
EOF
)
fi
case $SRC in
http://*)

View File

@ -64,7 +64,12 @@ ssh_make_path $DST_HOST $DST_DIR
#-------------------------------------------------------------------------------
log "Linking $SRC_PATH in $DST"
CMD=$(cat <<EOT
type="$(file -b --mime-type $SRC_PATH)"
if [ "$type" == "application/x-iso9660-image" ]; then
CMD="ln -sf ${SRC_PATH} ${DST_PATH}"
else
CMD=$(cat <<EOT
set -ex
mkdir -p "${SNAP_DIR}"
@ -80,6 +85,7 @@ ln -sf "$SNAP_DIR/\$SNAP" "$DST_PATH"
ln -sf "$SNAP_DIR" "${DST_PATH}.snap"
EOT
)
fi
ssh_exec_and_log $DST_HOST "$CMD" "Error linking $SRC to $DST"