mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
B #4781: ceph delete image if it fails being created
This commit is contained in:
parent
59085947bf
commit
33b96e7357
@ -24,6 +24,28 @@
|
||||
# - vmid is the id of the VM
|
||||
# - dsid is the target datastore (0 is the system datastore)
|
||||
|
||||
function ssh_exec_and_log_no_exit
|
||||
{
|
||||
SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF
|
||||
export LANG=C
|
||||
export LC_ALL=C
|
||||
$2
|
||||
EOF`
|
||||
SSH_EXEC_RC=$?
|
||||
|
||||
if [ $SSH_EXEC_RC -ne 0 ]; then
|
||||
log_error "Command \"$2\" failed: $SSH_EXEC_ERR"
|
||||
|
||||
if [ -n "$3" ]; then
|
||||
error_message "$3"
|
||||
else
|
||||
error_message "Error executing $2: $SSH_EXEC_ERR"
|
||||
fi
|
||||
|
||||
return $SSH_EXEC_RC
|
||||
fi
|
||||
}
|
||||
|
||||
SIZE=$1
|
||||
FSTYPE=$2
|
||||
DST=$3
|
||||
@ -107,9 +129,22 @@ MKIMAGE_CMD=$(cat <<EOF
|
||||
EOF
|
||||
)
|
||||
|
||||
DELIMAGE_CMD=$(cat <<EOF
|
||||
export PATH=/usr/sbin:/sbin:\$PATH
|
||||
$RBD rm $RBD_SOURCE
|
||||
EOF
|
||||
)
|
||||
|
||||
log "Making volatile disk of ${SIZE}M at $DST"
|
||||
|
||||
ssh_exec_and_log "$DST_HOST" "$MKIMAGE_CMD" \
|
||||
ssh_exec_and_log_no_exit "$DST_HOST" "$MKIMAGE_CMD" \
|
||||
"Error creating volatile disk.$DISK_ID ($RBD_SOURCE) in $DST_HOST into pool $POOL_NAME."
|
||||
|
||||
exit 0
|
||||
rc=$?
|
||||
|
||||
if [ $rc != 0 ]; then
|
||||
ssh_exec_and_log_no_exit "$DST_HOST" "$DELIMAGE_CMD" \
|
||||
"Error removing image"
|
||||
fi
|
||||
|
||||
exit $rc
|
||||
|
Loading…
x
Reference in New Issue
Block a user