mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-23 05:04:56 +09:00
B #2010: Drivers' action scripts may not fail on error
This commit is contained in:
1 parent
4b46008ebd
commit
17d062edcc
13 files changed
+65
-22
No files matched your search
@@ -143,7 +143,7 @@ http://*|https://*)
|
||||
;;
|
||||
esac
|
||||
|
||||
exec_and_log "eval $DUMP | $SSH $DST_HOST $DD of=$TMP_DST bs=64k" \
|
||||
multiline_exec_and_log "set -e -o pipefail; $DUMP | $SSH $DST_HOST $DD of=$TMP_DST bs=64k" \
|
||||
"Error dumping $SRC to $DST_HOST:$TMP_DST"
|
||||
|
||||
if [ "$RBD_FORMAT" = "2" ]; then
|
||||
|
||||
@@ -64,7 +64,15 @@ DST=`generate_image_path`
|
||||
if [ -n "$BRIDGE_LIST" ]; then
|
||||
log "Copying remotely local image $SRC to the image repository"
|
||||
DST_HOST=`get_destination_host $ID`
|
||||
ssh_exec_and_log "$DST_HOST" "mkdir -p $BASE_PATH; cp -f $SRC $DST" "Error copying $SRC to $DST in $DST_HOST"
|
||||
|
||||
CMD=$(cat <<EOF
|
||||
set -e -o pipefail
|
||||
mkdir -p $BASE_PATH
|
||||
cp -f $SRC $DST
|
||||
EOF
|
||||
)
|
||||
|
||||
ssh_exec_and_log "$DST_HOST" "${CMD}" "Error copying $SRC to $DST in $DST_HOST"
|
||||
else
|
||||
log "Copying local image $SRC to the image repository"
|
||||
mkdir -p "$BASE_PATH"
|
||||
|
||||
@@ -134,10 +134,10 @@ if [ -n "$BRIDGE_LIST" ]; then
|
||||
DST_HOST=`get_destination_host $ID`
|
||||
TMP_DST="$STAGING_DIR/$IMAGE_HASH"
|
||||
|
||||
exec_and_log "eval $COPY_COMMAND | $SSH $DST_HOST $DD of=$TMP_DST bs=64k" \
|
||||
multiline_exec_and_log "set -e -o pipefail; $COPY_COMMAND | $SSH $DST_HOST $DD of=$TMP_DST bs=64k" \
|
||||
"Error dumping $SRC to $DST_HOST:$TMP_DST"
|
||||
|
||||
ssh_exec_and_log "$DST_HOST" "mkdir -p $BASE_PATH; mv -f $TMP_DST $DST" \
|
||||
ssh_exec_and_log "$DST_HOST" "set -e -o pipefail; mkdir -p $BASE_PATH; mv -f $TMP_DST $DST" \
|
||||
"Error moving $TMP_DST to $DST in $DST_HOST"
|
||||
|
||||
if [ "x$CONVERT" = 'xyes' ] && [ -n "$DRIVER" ]; then
|
||||
@@ -146,7 +146,7 @@ if [ -n "$BRIDGE_LIST" ]; then
|
||||
fi
|
||||
else
|
||||
mkdir -p "$BASE_PATH"
|
||||
exec_and_log "$COPY_COMMAND" "Error copying $SRC to $DST"
|
||||
multiline_exec_and_log "set -e -o pipefail; $COPY_COMMAND" "Error copying $SRC to $DST"
|
||||
|
||||
if [ "x$CONVERT" = 'xyes' ] && [ -n "$DRIVER" ]; then
|
||||
multiline_exec_and_log "$CONVERT_CMD" "Error converting $DST"
|
||||
|
||||
@@ -77,7 +77,7 @@ if [ -n "$BRIDGE_LIST" ]; then
|
||||
DST_HOST=`get_destination_host $ID`
|
||||
CP_CMD="$UTILS_PATH/downloader.sh -n '${IMPORT_SOURCE}' -"
|
||||
|
||||
exec_and_log "eval $CP_CMD | $SSH ${DST_HOST} $DD of=${DST_PATH} bs=64k" \
|
||||
multiline_exec_and_log "set -e -o pipefail; $CP_CMD | $SSH ${DST_HOST} $DD of=${DST_PATH} bs=64k" \
|
||||
"Error dumping ${IMPORT_SOURCE} to ${DST_HOST}:${DST_PATH}"
|
||||
|
||||
#if [ "${DISPOSE}" = "YES" ]; then
|
||||
|
||||
+11
-4
@@ -54,9 +54,16 @@ ssh_make_path $DST_HOST $DST_DIR
|
||||
#-------------------------------------------------------------------------------
|
||||
log "Linking $SRC_PATH in $DST"
|
||||
|
||||
ssh_exec_and_log $DST_HOST \
|
||||
"cd $DST_DIR; rm -f $DST_PATH ; ln -s $SRC_PATH $DST_PATH" \
|
||||
"Error linking $SRC to $DST"
|
||||
CMD=$(cat <<EOF
|
||||
set -e -o pipefail
|
||||
|
||||
cd $DST_DIR
|
||||
rm -f $DST_PATH
|
||||
ln -s $SRC_PATH $DST_PATH
|
||||
EOF
|
||||
)
|
||||
|
||||
ssh_exec_and_log "${DST_HOST}" "${CMD}" \
|
||||
"Error linking $SRC to $DST"
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -116,6 +116,7 @@ EOF
|
||||
|
||||
# delete old volume and update device symlinks
|
||||
DELETE_CMD=$(cat <<EOF
|
||||
set -e -o pipefail
|
||||
${SUDO} ${LVREMOVE} -f ${SRC_DEV}
|
||||
${SUDO} ${SYNC}
|
||||
|
||||
@@ -126,7 +127,7 @@ EOF
|
||||
|
||||
LOCK="tm-fs_lvm-${SRC_DS_SYS_ID}.lock"
|
||||
exclusive "${LOCK}" 120 ssh_exec_and_log "${SRC_HOST}" "${DELETE_CMD}" \
|
||||
"Error dumping ${SRC} to ${DST}"
|
||||
"Error deleting old LV ${SRC_DEV}"
|
||||
fi
|
||||
|
||||
# activate
|
||||
|
||||
@@ -53,11 +53,13 @@ VG_NAME="vg-one-$DS_SYS_ID"
|
||||
DEV="/dev/${VG_NAME}/${LV_NAME}"
|
||||
|
||||
DUMP_CMD=$(cat <<EOF
|
||||
set -e -o pipefail
|
||||
$DD if=$DEV of=$DST_PATH bs=64k
|
||||
EOF
|
||||
)
|
||||
|
||||
DELETE_CMD=$(cat <<EOF
|
||||
set -e -o pipefail
|
||||
$SUDO $LVREMOVE -f $DEV
|
||||
EOF
|
||||
)
|
||||
|
||||
@@ -103,6 +103,8 @@ else
|
||||
fi
|
||||
|
||||
CLONE_CMD=$(cat <<EOF
|
||||
set -e -o pipefail
|
||||
|
||||
cd $DST_DIR
|
||||
|
||||
rm -rf "${DST_PATH}.snap"
|
||||
|
||||
@@ -73,7 +73,13 @@ fi
|
||||
SNAP_PATH="${SNAP_DIR}/${SNAP_ID}"
|
||||
SNAP_PATH_SHORT="${SNAP_DIR_SHORT}/${SNAP_ID}"
|
||||
|
||||
SNAP_CMD="cd "${SNAP_DIR}" ; qemu-img create -f qcow2 -o backing_fmt=qcow2 -b \"${SNAP_PATH_SHORT}\" \"\$(readlink -f ${DISK_PATH})\""
|
||||
SNAP_CMD=$(cat <<EOF
|
||||
set -e -o pipefail
|
||||
|
||||
cd "${SNAP_DIR}"
|
||||
qemu-img create -f qcow2 -o backing_fmt=qcow2 -b "${SNAP_PATH_SHORT}" "\$(readlink -f ${DISK_PATH})"
|
||||
EOF
|
||||
)
|
||||
|
||||
ssh_exec_and_log "${SRC_HOST}" "${SNAP_CMD}" \
|
||||
"Error reverting snapshot to ${SNAP_PATH}"
|
||||
+13
-8
@@ -92,18 +92,23 @@ ssh_make_path $DST_HOST $DST_DIR $MONITOR
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
if [ -n "$ORIGINAL_SIZE" -a "$SIZE" -gt "$ORIGINAL_SIZE" ]; then
|
||||
RESIZE_CMD="; qemu-img resize ${DST_PATH} ${SIZE}M"
|
||||
RESIZE_CMD="qemu-img resize ${DST_PATH} ${SIZE}M"
|
||||
fi
|
||||
|
||||
log "Cloning $SRC_PATH in $DST"
|
||||
|
||||
CLONE_CMD="cd ${DST_DIR}; \
|
||||
rm -f ${DST_PATH}; \
|
||||
cp ${SRC_PATH} ${DST_PATH} \
|
||||
${RESIZE_CMD}"
|
||||
CLONE_CMD=$(cat <<EOF
|
||||
set -e -o pipefail
|
||||
|
||||
ssh_exec_and_log $DST_HOST \
|
||||
"$CLONE_CMD" \
|
||||
"Error copying $SRC to $DST"
|
||||
cd ${DST_DIR}
|
||||
rm -f ${DST_PATH}
|
||||
cp ${SRC_PATH} ${DST_PATH}
|
||||
|
||||
${RESIZE_CMD}
|
||||
EOF
|
||||
)
|
||||
|
||||
ssh_exec_and_log $DST_HOST "$CLONE_CMD" \
|
||||
"Error copying $SRC to $DST"
|
||||
|
||||
exit 0
|
||||
@@ -83,6 +83,8 @@ fi
|
||||
# Move the image back to the datastore
|
||||
#-------------------------------------------------------------------------------
|
||||
CPSCRIPT=$(cat <<EOF
|
||||
set -e -o pipefail
|
||||
|
||||
SRC_READLN=\$($READLINK -f $SRC_PATH)
|
||||
DST_READLN=\$($READLINK -f $DST_PATH)
|
||||
|
||||
|
||||
@@ -79,7 +79,12 @@ SNAP_PATH="${SNAP_DIR}/${SNAP_ID}"
|
||||
SNAP_PATH_RELATIVE=$(basename ${SNAP_PATH})
|
||||
CURRENT_PATH="${CURRENT_PATH:-${DISK_PATH}}"
|
||||
|
||||
CMD="rm \"${CURRENT_PATH}\" ; cp \"${SNAP_PATH}\" \"${CURRENT_PATH}\""
|
||||
CMD=$(cat <<EOF
|
||||
set -e -o pipefail
|
||||
rm "${CURRENT_PATH}"
|
||||
cp "${SNAP_PATH}" "${CURRENT_PATH}"
|
||||
EOF
|
||||
)
|
||||
|
||||
ssh_exec_and_log "${SRC_HOST}" "${CMD}" \
|
||||
"Error reverting snapshot to ${SNAP_PATH}"
|
||||
|
||||
@@ -68,7 +68,12 @@ SNAP_PATH="${SNAP_DIR}/${SNAP_ID}"
|
||||
SNAP_PATH_RELATIVE=$(basename ${SNAP_PATH})
|
||||
CURRENT_PATH=${DISK_PATH}
|
||||
|
||||
CMD="rm \"${CURRENT_PATH}\" ; cp \"${SNAP_PATH}\" \"${CURRENT_PATH}\""
|
||||
CMD=$(cat <<EOF
|
||||
set -e -o pipefail
|
||||
rm "${CURRENT_PATH}"
|
||||
cp "${SNAP_PATH}" "${CURRENT_PATH}"
|
||||
EOF
|
||||
)
|
||||
|
||||
ssh_exec_and_log "${SRC_HOST}" "${CMD}" \
|
||||
"Error reverting snapshot to ${SNAP_PATH}"
|
||||
|
||||
Reference in new issue
Block a user