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

Feature : Fix logic. Only resize of ORIGINAL_SIZE is defined

and if it's smaller than the desired size.
This commit is contained in:
Jaime Melis 2015-08-13 15:38:41 +02:00
parent 3ba03db8e8
commit 8d40a75a31
4 changed files with 11 additions and 14 deletions
src/tm_mad
ceph
qcow2
shared
ssh

@ -66,7 +66,7 @@ while IFS= read -r -d '' element; do
CEPH_USER="${XPATH_ELEMENTS[j++]}"
SIZE="${XPATH_ELEMENTS[j++]}"
ORIGINAL_SIZE="${XPATH_ELEMENTS[j++]:-0}"
ORIGINAL_SIZE="${XPATH_ELEMENTS[j++]}"
#-------------------------------------------------------------------------------
# Clone the image
@ -91,7 +91,7 @@ CLONE_CMD=$(cat <<EOF
$RBD copy $SRC_PATH $RBD_DST
fi
if [ "$SIZE" -ge "$ORIGINAL_SIZE" ]; then
if [ -n "$ORIGINAL_SIZE" -a "$SIZE" -gt "$ORIGINAL_SIZE" ]; then
$RBD resize $RBD_DST --size $SIZE
fi
EOF

@ -80,6 +80,10 @@ 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
CLONE_CMD=$(cat <<EOF
cd $DST_DIR
mkdir -p ${DST_PATH}.snap
@ -101,9 +105,6 @@ http://*)
*)
log "Cloning $SRC_PATH in $DST"
if [ -n "$ORIGINAL_SIZE" -a "$SIZE" -gt "$ORIGINAL_SIZE" ]; then
RESIZE_CMD="qemu-img resize ${DST_PATH} ${SIZE}M"
fi
ssh_exec_and_log "$DST_HOST" "$CLONE_CMD" "Error copying $SRC to $DST"
;;

@ -84,6 +84,10 @@ 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
case $SRC in
http://*)
log "Downloading $SRC into $DST_PATH"
@ -95,12 +99,6 @@ http://*)
*)
log "Cloning $SRC_PATH in $DST"
ORIGINAL_SIZE=${ORIGINAL_SIZE:-0}
# if [ "$SIZE" -ge "$ORIGINAL_SIZE" ]; then
# RESIZE_CMD="; qemu-img resize ${DST_PATH} ${SIZE}M"
# fi
CLONE_CMD="cd ${DST_DIR}; \
cp ${SRC_PATH} ${DST_PATH} \
${RESIZE_CMD}"

@ -93,9 +93,7 @@ http://*)
"Error copying $SRC to $DST"
fi
ORIGINAL_SIZE=${ORIGINAL_SIZE:-0}
if [ "$SIZE" -ge "$ORIGINAL_SIZE" ]; then
if [ -n "$ORIGINAL_SIZE" -a "$SIZE" -gt "$ORIGINAL_SIZE" ]; then
RESIZE_CMD="qemu-img resize ${DST_PATH} ${SIZE}M"
ssh_exec_and_log "$DST_HOST" "$RESIZE_CMD" \
"Error resizing image $DST"