mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-25 23:21:29 +03:00
Feature #3987: Checkpoint is stored in Ceph. Needs refactor.
This commit is contained in:
parent
f51a38f634
commit
b90da12397
@ -50,12 +50,45 @@ CEPH_UTILS=${DRIVER_PATH}/../../datastore/ceph/ceph_utils.sh
|
||||
DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
|
||||
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Delete and exit if directory
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
if [ `is_disk $DST_PATH` -eq 0 ]; then
|
||||
# Directory
|
||||
# Directory: delete checkpoint and directory
|
||||
|
||||
unset i j XPATH_ELEMENTS
|
||||
|
||||
while IFS= read -r -d '' element; do
|
||||
XPATH_ELEMENTS[i++]="$element"
|
||||
done < <(onedatastore show -x $DS_ID | $XPATH \
|
||||
/DATASTORE/TEMPLATE/SOURCE \
|
||||
/DATASTORE/TEMPLATE/CLONE \
|
||||
/DATASTORE/TEMPLATE/CEPH_USER \
|
||||
/DATASTORE/TEMPLATE/CEPH_CONF \
|
||||
/DATASTORE/TEMPLATE/POOL_NAME)
|
||||
|
||||
SRC="${XPATH_ELEMENTS[j++]}"
|
||||
CLONE="${XPATH_ELEMENTS[j++]}"
|
||||
CEPH_USER="${XPATH_ELEMENTS[j++]}"
|
||||
CEPH_CONF="${XPATH_ELEMENTS[j++]}"
|
||||
POOL_NAME="${XPATH_ELEMENTS[j++]:-$POOL_NAME}"
|
||||
|
||||
if [ -n "$CEPH_USER" ]; then
|
||||
RBD="$RBD --id ${CEPH_USER}"
|
||||
fi
|
||||
|
||||
if [ -n "$CEPH_CONF" ]; then
|
||||
RBD="$RBD --conf ${CEPH_CONF}"
|
||||
fi
|
||||
|
||||
RBD_SRC_CHECKPOINT="${POOL_NAME}/one-sys-${VM_ID}-checkpoint"
|
||||
|
||||
ssh_exec_and_log "$DST_HOST" "$RBD rm $RBD_SRC_CHECKPOINT 2>/dev/null || exit 0" \
|
||||
"Error deleting $RBD_SRC_CHECKPOINT in $DST_HOST"
|
||||
|
||||
log "Deleting $DST_PATH"
|
||||
ssh_exec_and_log "$DST_HOST" "rm -rf $DST_PATH" "Error deleting $DST_PATH"
|
||||
exit 0
|
||||
@ -67,8 +100,6 @@ fi
|
||||
|
||||
DISK_ID=$(echo "$DST_PATH" | $AWK -F. '{print $NF}')
|
||||
|
||||
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
|
||||
|
||||
unset i j XPATH_ELEMENTS
|
||||
|
||||
while IFS= read -r -d '' element; do
|
||||
@ -84,7 +115,7 @@ SRC="${XPATH_ELEMENTS[j++]}"
|
||||
CLONE="${XPATH_ELEMENTS[j++]}"
|
||||
CEPH_USER="${XPATH_ELEMENTS[j++]}"
|
||||
CEPH_CONF="${XPATH_ELEMENTS[j++]}"
|
||||
POOL_NAME="${XPATH_ELEMENTS[j++]}"
|
||||
POOL_NAME="${XPATH_ELEMENTS[j++]:-$POOL_NAME}"
|
||||
|
||||
# No need to delete no cloned images
|
||||
if [ "$CLONE" = "NO" ]; then
|
||||
|
@ -19,13 +19,57 @@
|
||||
source $(dirname $0)/kvmrc
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
|
||||
# Checkpoint file: /var/lib/one//datastores/<DS_ID>/<VM_ID>/checkpoint
|
||||
FILE=$1
|
||||
FILE_XML=${FILE}.xml
|
||||
DRIVER_PATH=$(dirname $0)
|
||||
|
||||
FILE=$1
|
||||
HOST=$2
|
||||
DEPLOY_ID=$3
|
||||
VMID=$4
|
||||
|
||||
VM_ID=$4
|
||||
DS_ID=$5
|
||||
|
||||
FILE_XML=${FILE}.xml
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Ceph
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
|
||||
|
||||
while IFS= read -r -d '' element; do
|
||||
XPATH_ELEMENTS[i++]="$element"
|
||||
done < <(cat | $XPATH \
|
||||
/VMM_DRIVER_ACTION_DATA/DATASTORE/TM_MAD \
|
||||
/VMM_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/CEPH_USER \
|
||||
/VMM_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/CEPH_CONF \
|
||||
/VMM_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/POOL_NAME \
|
||||
/VMM_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RBD_FORMAT)
|
||||
|
||||
|
||||
TM_MAD="${XPATH_ELEMENTS[j++]}"
|
||||
CEPH_USER="${XPATH_ELEMENTS[j++]}"
|
||||
CEPH_CONF="${XPATH_ELEMENTS[j++]}"
|
||||
POOL_NAME="${XPATH_ELEMENTS[j++]:-$POOL_NAME}"
|
||||
RBD_FORMAT="${XPATH_ELEMENTS[j++]:-$RBD_FORMAT}"
|
||||
|
||||
if [ -n "$CEPH_USER" ]; then
|
||||
RBD="$RBD --id ${CEPH_USER}"
|
||||
fi
|
||||
|
||||
if [ -n "$CEPH_CONF" ]; then
|
||||
RBD="$RBD --conf ${CEPH_CONF}"
|
||||
fi
|
||||
|
||||
if [ "$RBD_FORMAT" = "2" ]; then
|
||||
FORMAT_OPT="--image-format 2"
|
||||
fi
|
||||
|
||||
RBD_SOURCE="${POOL_NAME}/one-sys-${VM_ID}-checkpoint"
|
||||
|
||||
exec_and_log "$RBD export $RBD_SOURCE $FILE" "Error exporting checkpoint into from $RBD_SOURCE to $FILE"
|
||||
exec_and_log "$RBD rm $RBD_SOURCE" "Error removing checkpoint $RBD_SOURCE"
|
||||
|
||||
# Checkpoint file: /var/lib/one//datastores/<DS_ID>/<VM_ID>/checkpoint
|
||||
|
||||
DS_ID=$(basename $(dirname $(dirname $FILE)))
|
||||
DS_LOCATION=$(dirname $(dirname $(dirname $FILE)))
|
||||
@ -41,7 +85,7 @@ virsh --connect $LIBVIRT_URI save-image-dumpxml $FILE > $FILE_XML
|
||||
# DS_ID where the checkpoint is placed. This is done in case there was a
|
||||
# system DS migration
|
||||
|
||||
sed -i "s%$DS_LOCATION/[0-9]\+/$VMID/%$DS_LOCATION/$DS_ID/$VMID/%g" $FILE_XML
|
||||
sed -i "s%$DS_LOCATION/[0-9]\+/$VM_ID/%$DS_LOCATION/$DS_ID/$VM_ID/%g" $FILE_XML
|
||||
EOF
|
||||
)
|
||||
|
||||
|
@ -19,19 +19,68 @@
|
||||
source $(dirname $0)/kvmrc
|
||||
source $(dirname $0)/../../scripts_common.sh
|
||||
|
||||
deploy_id=$1
|
||||
file=$2
|
||||
DRIVER_PATH=$(dirname $0)
|
||||
|
||||
if [ -f $file ]; then
|
||||
log "Moving old checkpoint file $file"
|
||||
DEPLOY_ID=$1
|
||||
FILE=$2
|
||||
|
||||
VM_ID=$4
|
||||
DS_ID=$5
|
||||
|
||||
if [ -f "$FILE" ]; then
|
||||
log "Moving old checkpoint file $FILE"
|
||||
epoch=`date +%s`
|
||||
|
||||
exec_and_log "mv $file $file.$epoch" \
|
||||
"Could not move $file to $file.$epoch"
|
||||
exec_and_log "mv $FILE $FILE.$epoch" \
|
||||
"Could not move $FILE to $FILE.$epoch"
|
||||
fi
|
||||
|
||||
touch $file
|
||||
chmod 666 $file
|
||||
touch "$FILE"
|
||||
chmod 666 "$FILE"
|
||||
|
||||
exec_and_log "virsh --connect $LIBVIRT_URI save $deploy_id $file" \
|
||||
"Could not save $deploy_id to $file"
|
||||
exec_and_log "virsh --connect $LIBVIRT_URI save $DEPLOY_ID $FILE" \
|
||||
"Could not save $DEPLOY_ID to $FILE"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Ceph
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
source ${DRIVER_PATH}/../../datastore/ceph/ceph.conf
|
||||
|
||||
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
|
||||
|
||||
unset i j XPATH_ELEMENTS
|
||||
|
||||
while IFS= read -r -d '' element; do
|
||||
XPATH_ELEMENTS[i++]="$element"
|
||||
done < <(cat | $XPATH \
|
||||
/VMM_DRIVER_ACTION_DATA/DATASTORE/TM_MAD \
|
||||
/VMM_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/CEPH_USER \
|
||||
/VMM_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/CEPH_CONF \
|
||||
/VMM_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/POOL_NAME \
|
||||
/VMM_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RBD_FORMAT)
|
||||
|
||||
TM_MAD="${XPATH_ELEMENTS[j++]}"
|
||||
CEPH_USER="${XPATH_ELEMENTS[j++]}"
|
||||
CEPH_CONF="${XPATH_ELEMENTS[j++]}"
|
||||
POOL_NAME="${XPATH_ELEMENTS[j++]:-$POOL_NAME}"
|
||||
RBD_FORMAT="${XPATH_ELEMENTS[j++]:-$RBD_FORMAT}"
|
||||
|
||||
if [ -n "$CEPH_USER" ]; then
|
||||
RBD="$RBD --id ${CEPH_USER}"
|
||||
fi
|
||||
|
||||
if [ -n "$CEPH_CONF" ]; then
|
||||
RBD="$RBD --conf ${CEPH_CONF}"
|
||||
fi
|
||||
|
||||
if [ "$RBD_FORMAT" = "2" ]; then
|
||||
FORMAT_OPT="--image-format 2"
|
||||
fi
|
||||
|
||||
RBD_SOURCE="${POOL_NAME}/one-sys-${VM_ID}-checkpoint"
|
||||
|
||||
exec_and_log "$RBD import $FORMAT_OPT $FILE $RBD_SOURCE" "Error importing checkpoint into $RBD_SOURCE"
|
||||
exec_and_log "$RM -f $FILE" "Error removing checkpoint ($FILE)"
|
||||
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user