1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-20 14:03:36 +03:00

Merge branch 'feature-3215'

This commit is contained in:
Ruben S. Montero 2014-10-10 10:38:36 +02:00
commit 96faa90dc8
9 changed files with 83 additions and 12 deletions

View File

@ -48,7 +48,8 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/POOL_NAME \
/DS_DRIVER_ACTION_DATA/IMAGE/PATH \
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/CEPH_USER)
unset i
@ -57,6 +58,7 @@ BRIDGE_LIST="${XPATH_ELEMENTS[i++]}"
POOL_NAME="${XPATH_ELEMENTS[i++]:-$POOL_NAME}"
SRC="${XPATH_ELEMENTS[i++]}"
SIZE="${XPATH_ELEMENTS[i++]}"
CEPH_USER="${XPATH_ELEMENTS[i++]}"
DST_HOST=`get_destination_host $ID`
@ -65,6 +67,10 @@ if [ -z "$DST_HOST" ]; then
exit -1
fi
if [ -n "$CEPH_USER" ]; then
RBD="$RBD --id ${CEPH_USER}"
fi
SAFE_DIRS=""
IMAGE_NAME="one-${ID}"
@ -73,4 +79,5 @@ RBD_DST="${POOL_NAME}/${IMAGE_NAME}"
ssh_exec_and_log "$DST_HOST" "$RBD copy $SRC $RBD_DST" \
"Error cloning $SRC to $RBD_DST in $DST_HOST"
echo "$RBD_DST"

View File

@ -60,7 +60,8 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/LIMIT_TRANSFER_BW)
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/LIMIT_TRANSFER_BW \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/CEPH_USER)
unset i
@ -77,6 +78,7 @@ MD5="${XPATH_ELEMENTS[i++]}"
SHA1="${XPATH_ELEMENTS[i++]}"
NO_DECOMPRESS="${XPATH_ELEMENTS[i++]}"
LIMIT_TRANSFER_BW="${XPATH_ELEMENTS[i++]}"
CEPH_USER="${XPATH_ELEMENTS[i++]}"
DST_HOST=`get_destination_host $ID`
@ -85,6 +87,10 @@ if [ -z "$DST_HOST" ]; then
exit -1
fi
if [ -n "$CEPH_USER" ]; then
RBD="$RBD --id ${CEPH_USER}"
fi
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS"
IMAGE_HASH=`generate_image_hash`

View File

@ -54,7 +54,8 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/STAGING_DIR \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RBD_FORMAT \
/DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE \
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/CEPH_USER)
unset i
@ -67,6 +68,7 @@ STAGING_DIR="${XPATH_ELEMENTS[i++]:-$STAGING_DIR}"
RBD_FORMAT="${XPATH_ELEMENTS[i++]:-$RBD_FORMAT}"
FSTYPE="${XPATH_ELEMENTS[i++]}"
SIZE="${XPATH_ELEMENTS[i++]}"
CEPH_USER="${XPATH_ELEMENTS[i++]}"
DST_HOST=`get_destination_host $ID`
@ -75,6 +77,10 @@ if [ -z "$DST_HOST" ]; then
exit -1
fi
if [ -n "$CEPH_USER" ]; then
RBD="$RBD --id ${CEPH_USER}"
fi
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS"
IMAGE_HASH=`generate_image_hash`

View File

@ -46,10 +46,12 @@ unset i j XPATH_ELEMENTS
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/POOL_NAME)
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/POOL_NAME \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/CEPH_USER)
BRIDGE_LIST="${XPATH_ELEMENTS[j++]}"
POOL_NAME="${XPATH_ELEMENTS[j++]:-$POOL_NAME}"
CEPH_USER="${XPATH_ELEMENTS[j++]}"
HOST=`get_destination_host`
@ -58,10 +60,14 @@ if [ -z "$HOST" ]; then
exit -1
fi
if [ -n "$CEPH_USER" ]; then
RADOS="$RADOS --id ${CEPH_USER}"
fi
# ------------ Compute datastore usage -------------
MONITOR_SCRIPT=$(cat <<EOF
$RADOS df | $AWK '{
$RADOS df -p ${POOL_NAME}| $AWK '{
if (\$1 == "total") {
space = int(\$3/1024)

View File

@ -45,10 +45,12 @@ unset i j XPATH_ELEMENTS
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <($XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST)
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/CEPH_USER)
SRC="${XPATH_ELEMENTS[j++]}"
BRIDGE_LIST="${XPATH_ELEMENTS[j++]}"
CEPH_USER="${XPATH_ELEMENTS[j++]}"
DST_HOST=`get_destination_host $ID`
@ -57,6 +59,11 @@ if [ -z "$DST_HOST" ]; then
exit -1
fi
if [ -n "$CEPH_USER" ]; then
RBD="$RBD --id ${CEPH_USER}"
fi
# -------- Remove Image from Datastore ------------
log "Removing $SRC from the rbd image repository in $DST_HOST"

View File

@ -49,14 +49,34 @@ DISK_ID=$(echo $DST|awk -F. '{print $NF}')
RBD_DST="${SRC_PATH}-${VM_ID}-${DISK_ID}"
RBD_SNAP="${VM_ID}-${DISK_ID}"
#-------------------------------------------------------------------------------
# Get Image information
#-------------------------------------------------------------------------------
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
unset i j XPATH_ELEMENTS
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <(onevm show -x $VM_ID| $XPATH \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CEPH_USER)
CEPH_USER="${XPATH_ELEMENTS[j++]}"
#-------------------------------------------------------------------------------
# Clone the image
#-------------------------------------------------------------------------------
if [ -n "$CEPH_USER" ]; then
RBD="$RBD --id ${CEPH_USER}"
fi
CLONE_CMD=$(cat <<EOF
set -e
RBD_FORMAT=\$(rbd info $SRC_PATH | sed -n 's/.*format: // p')
RBD_FORMAT=\$($RBD info $SRC_PATH | sed -n 's/.*format: // p')
if [ "\$RBD_FORMAT" = "2" ]; then
$RBD snap create "$SRC_PATH@$RBD_SNAP"

View File

@ -59,10 +59,12 @@ while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <(onevm show -x $VM_ID| $XPATH \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SOURCE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CLONE)
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CLONE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CEPH_USER)
RBD_SRC="${XPATH_ELEMENTS[j++]}"
CLONE="${XPATH_ELEMENTS[j++]}"
CEPH_USER="${XPATH_ELEMENTS[j++]}"
#-------------------------------------------------------------------------------
# Copy Image back to the datastore
@ -74,6 +76,11 @@ else
RBD_DST="${RBD_SRC}-${VM_ID}-${DISK_ID}"
fi
if [ -n "$CEPH_USER" ]; then
RBD="$RBD --id ${CEPH_USER}"
fi
ssh_exec_and_log "$SRC_HOST" "$RBD copy $RBD_DST $DST" \
"Error cloning $RBD_DST to $DST in $SRC_HOST"

View File

@ -67,16 +67,22 @@ while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <(onevm show -x $VM_ID| $XPATH \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SOURCE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CLONE)
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CLONE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CEPH_USER)
SRC="${XPATH_ELEMENTS[j++]}"
CLONE="${XPATH_ELEMENTS[j++]}"
CEPH_USER="${XPATH_ELEMENTS[j++]}"
# No need to delete no cloned images
if [ "$CLONE" = "NO" ]; then
exit 0
fi
if [ -n "$CEPH_USER" ]; then
RBD="$RBD --id ${CEPH_USER}"
fi
# cloned, so the name will be "<pool>/one-<imageid>-<vmid>-<diskid>"
RBD_SRC="${SRC}-${VM_ID}-${DISK_ID}"
RBD_SNAP="${VM_ID}-${DISK_ID}"
@ -93,7 +99,7 @@ log "Deleting $DST_PATH"
DELETE_CMD=$(cat <<EOF
set -e
RBD_FORMAT=\$(rbd info $RBD_SRC | sed -n 's/.*format: // p')
RBD_FORMAT=\$($RBD info $RBD_SRC | sed -n 's/.*format: // p')
$RBD rm $RBD_SRC

View File

@ -59,16 +59,22 @@ while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <(onevm show -x $VM_ID| $XPATH \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SOURCE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CLONE)
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CLONE \
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/CEPH_USER)
RBD_SRC="${XPATH_ELEMENTS[j++]}"
CLONE="${XPATH_ELEMENTS[j++]}"
CEPH_USER="${XPATH_ELEMENTS[j++]}"
# No need to copy back to datastore no cloned images
if [ "$CLONE" = "NO" ]; then
exit 0
fi
if [ -n "$CEPH_USER" ]; then
RBD="$RBD --id ${CEPH_USER}"
fi
# cloned, so the name will be "<pool>/one-<imageid>-<vmid>-<diskid>"
RBD_DST="${RBD_SRC}-${VM_ID}-${DISK_ID}"
RBD_SNAP="${VM_ID}-${DISK_ID}"
@ -82,7 +88,7 @@ log "Dumping $RBD_DST to $DST"
DUMP_CMD=$(cat <<EOF
set -e
RBD_FORMAT=\$(rbd info $RBD_DST | sed -n 's/.*format: // p')
RBD_FORMAT=\$($RBD info $RBD_DST | sed -n 's/.*format: // p')
if [ "\${RBD_FORMAT}" = "2" ]; then
$RBD flatten $RBD_DST