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

Feature #3574: adds BRIDGE_LIST support for the fs

DS_MAD actions: clone, cp, mkfs and rm
This commit is contained in:
Jaime Melis 2015-02-20 19:20:58 +01:00
parent 5d530dd70c
commit 697fd4e3f8
4 changed files with 70 additions and 29 deletions

View File

@ -46,20 +46,29 @@ unset i XPATH_ELEMENTS
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \
/DS_DRIVER_ACTION_DATA/IMAGE/PATH)
BASE_PATH="${XPATH_ELEMENTS[0]}"
SRC="${XPATH_ELEMENTS[1]}"
unset i
BASE_PATH="${XPATH_ELEMENTS[i++]}"
BRIDGE_LIST="${XPATH_ELEMENTS[i++]}"
SRC="${XPATH_ELEMENTS[i++]}"
mkdir -p "$BASE_PATH"
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS"
DST=`generate_image_path`
# ------------ Copy the image to the repository -------------
log "Copying local image $SRC to the image repository"
exec_and_log "cp -f $SRC $DST" "Error copying $SRC to $DST"
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"
else
log "Copying local image $SRC to the image repository"
mkdir -p "$BASE_PATH"
exec_and_log "cp -f $SRC $DST" "Error copying $SRC to $DST"
fi
echo "$DST"

View File

@ -71,12 +71,11 @@ SHA1="${XPATH_ELEMENTS[i++]}"
NO_DECOMPRESS="${XPATH_ELEMENTS[i++]}"
LIMIT_TRANSFER_BW="${XPATH_ELEMENTS[i++]}"
mkdir -p "$BASE_PATH"
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS"
DST=`generate_image_path`
IMAGE_HASH=`basename $DST`
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS"
if [ -n "$BRIDGE_LIST" ]; then
DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$LIMIT_TRANSFER_BW" "$SRC" -`
else
@ -107,6 +106,7 @@ if [ -n "$BRIDGE_LIST" ]; then
ssh_exec_and_log "$DST_HOST" "mkdir -p $BASE_PATH; mv -f $TMP_DST $DST" \
"Error moving $TMP_DST to $DST in $DST_HOST"
else
mkdir -p "$BASE_PATH"
exec_and_log "$COPY_COMMAND" "Error copying $SRC to $DST"
fi

View File

@ -48,17 +48,19 @@ while IFS= read -r -d '' element; do
done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RESTRICTED_DIRS \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \
/DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE \
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
unset i
BASE_PATH="${XPATH_ELEMENTS[0]}"
RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}"
SAFE_DIRS="${XPATH_ELEMENTS[2]}"
FSTYPE="${XPATH_ELEMENTS[3]}"
SIZE="${XPATH_ELEMENTS[4]}"
BASE_PATH="${XPATH_ELEMENTS[i++]}"
RESTRICTED_DIRS="${XPATH_ELEMENTS[i++]}"
SAFE_DIRS="${XPATH_ELEMENTS[i++]}"
BRIDGE_LIST="${XPATH_ELEMENTS[i++]}"
FSTYPE="${XPATH_ELEMENTS[i++]}"
SIZE="${XPATH_ELEMENTS[i++]}"
mkdir -p "$BASE_PATH"
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS"
DST=`generate_image_path`
@ -74,9 +76,29 @@ fi
MKFS_CMD=`mkfs_command $DST $FSTYPE $SIZE`
exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M" \
"Could not create image $DST"
exec_and_log "$MKFS_CMD" \
"Unable to create filesystem $FSTYPE in $DST"
REMOTE_REGISTER_CMD=$(cat <<EOF
set -e
export PATH=/usr/sbin:/sbin:\$PATH
mkdir -p $BASE_PATH
$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M
$MKFS_CMD
EOF
)
if [ -n "$BRIDGE_LIST" ]; then
DST_HOST=`get_destination_host $ID`
ssh_exec_and_log "$DST_HOST" "$REMOTE_REGISTER_CMD" \
"Error registering $RBD_SOURCE in $DST_HOST"
else
mkdir -p "$BASE_PATH"
exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M" \
"Could not create image $DST"
exec_and_log "$MKFS_CMD" \
"Unable to create filesystem $FSTYPE in $DST"
fi
echo "$DST"

View File

@ -45,22 +45,32 @@ unset i 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/BASE_PATH)
SRC="${XPATH_ELEMENTS[0]}"
BASE_PATH="${XPATH_ELEMENTS[1]}"
unset i
BASENAME_SRC=`basename "${SRC##$BASE_PATH}"`
SRC="${XPATH_ELEMENTS[i++]}"
BRIDGE_LIST="${XPATH_ELEMENTS[i++]}"
BASE_PATH="${XPATH_ELEMENTS[i++]}"
# ------------ Remove the image from the repository ------------
if [ -f "$SRC" -a `dirname "$SRC"` = "$BASE_PATH" -a -n "$BASENAME_SRC" ]
then
log "Removing $SRC from the image repository"
if [ -n "$BRIDGE_LIST" ]; then
DST_HOST=`get_destination_host $ID`
exec_and_log "rm -f $SRC" \
"Error deleting $SRC"
ssh_exec_and_log "$DST_HOST" "rm -f $SRC" \
"Error deleting $SRC in $DST_HOST"
else
log_error "Bad formed or unavailable Image source: ${SRC}"
exit 1
BASENAME_SRC=`basename "${SRC##$REMOTE_RM_CMD}"`
if [ -f "$SRC" -a `dirname "$SRC"` = "$BASE_PATH" -a -n "$BASENAME_SRC" ]
then
log "Removing $SRC from the image repository"
exec_and_log "rm -f $SRC" \
"Error deleting $SRC"
else
log_error "Bad formed or unavailable Image source: ${SRC}"
exit 1
fi
fi