mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-24 21:34:01 +03:00
Merge branch 'feature-1352'
This commit is contained in:
commit
bc62b678f2
@ -20,9 +20,13 @@
|
||||
# to determine the file type
|
||||
function get_type
|
||||
{
|
||||
command=$1
|
||||
if [ "$NO_DECOMPRESS" = "yes" ]; then
|
||||
echo "application/octet-stream"
|
||||
else
|
||||
command=$1
|
||||
|
||||
( $command | head -n 1024 | file -b --mime-type - ) 2>/dev/null
|
||||
( $command | head -n 1024 | file -b --mime-type - ) 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
# Gets the command needed to decompress an stream.
|
||||
@ -113,7 +117,7 @@ function unarchive
|
||||
fi
|
||||
}
|
||||
|
||||
TEMP=`getopt -o m:s: -l md5:,sha1: -- "$@"`
|
||||
TEMP=`getopt -o m:s:n -l md5:,sha1:,nodecomp -- "$@"`
|
||||
|
||||
if [ $? != 0 ] ; then
|
||||
echo "Arguments error"
|
||||
@ -134,6 +138,10 @@ while true; do
|
||||
HASH=$2
|
||||
shift 2
|
||||
;;
|
||||
-n|--nodecomp)
|
||||
export NO_DECOMPRESS="yes"
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
|
@ -53,7 +53,8 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/UMASK \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/PATH \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1)
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS)
|
||||
|
||||
BASE_PATH="${XPATH_ELEMENTS[0]}"
|
||||
RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}"
|
||||
@ -62,23 +63,17 @@ UMASK="${XPATH_ELEMENTS[3]}"
|
||||
SRC="${XPATH_ELEMENTS[4]}"
|
||||
MD5="${XPATH_ELEMENTS[5]}"
|
||||
SHA1="${XPATH_ELEMENTS[6]}"
|
||||
NO_DECOMPRESS="${XPATH_ELEMENTS[7]}"
|
||||
|
||||
mkdir -p "$BASE_PATH"
|
||||
|
||||
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
|
||||
|
||||
DST=`generate_image_path`
|
||||
|
||||
HASHES=""
|
||||
DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$SRC" "$DST"`
|
||||
|
||||
if [ -n "$MD5" ]; then
|
||||
HASHES="$HASHES --md5 $MD5"
|
||||
fi
|
||||
|
||||
if [ -n "$SHA1" ]; then
|
||||
HASHES="$HASHES --sha1 $SHA1"
|
||||
fi
|
||||
|
||||
COPY_COMMAND="$UTILS_PATH/downloader.sh $HASHES $SRC $DST"
|
||||
COPY_COMMAND="$UTILS_PATH/downloader.sh $DOWNLOADER_ARGS"
|
||||
|
||||
# ------------ Copy the image to the repository -------------
|
||||
|
||||
|
@ -58,7 +58,8 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/PATH \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1)
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS)
|
||||
|
||||
BASE_PATH="${XPATH_ELEMENTS[0]}"
|
||||
RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}"
|
||||
@ -71,6 +72,7 @@ SRC="${XPATH_ELEMENTS[7]}"
|
||||
SIZE="${XPATH_ELEMENTS[8]}"
|
||||
MD5="${XPATH_ELEMENTS[9]}"
|
||||
SHA1="${XPATH_ELEMENTS[10]}"
|
||||
NO_DECOMPRESS="${XPATH_ELEMENTS[11]}"
|
||||
|
||||
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
|
||||
|
||||
@ -93,17 +95,9 @@ REGISTER_CMD=$(cat <<EOF
|
||||
EOF
|
||||
)
|
||||
|
||||
HASHES=""
|
||||
DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$SRC" -`
|
||||
|
||||
if [ -n "$MD5" ]; then
|
||||
HASHES="$HASHES --md5 $MD5"
|
||||
fi
|
||||
|
||||
if [ -n "$SHA1" ]; then
|
||||
HASHES="$HASHES --sha1 $SHA1"
|
||||
fi
|
||||
|
||||
COPY_COMMAND="$UTILS_PATH/downloader.sh $HASHES $SRC -"
|
||||
COPY_COMMAND="$UTILS_PATH/downloader.sh $DOWNLOADER_ARGS"
|
||||
|
||||
case $SRC in
|
||||
http://*|https://*)
|
||||
|
@ -83,6 +83,33 @@ EOF
|
||||
echo "${BASE_PATH}/${IMAGE_HASH}"
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Set up the arguments for the downloader script
|
||||
# @param $1 - MD5 string
|
||||
# @param $2 - SHA1 string
|
||||
# @param $3 - NO_DECOMPRESS
|
||||
# @param $4 - SRC
|
||||
# @param $5 - DST
|
||||
# @return downloader.sh util arguments
|
||||
#-------------------------------------------------------------------------------
|
||||
function set_downloader_args {
|
||||
HASHES=" "
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
HASHES="--md5 $1"
|
||||
fi
|
||||
|
||||
if [ -n "$2" ]; then
|
||||
HASHES="$HASHES --sha1 $2"
|
||||
fi
|
||||
|
||||
if [ "$3" = "yes" -o "$3" = "Yes" -o "$3" = "YES" ]; then
|
||||
HASHES="$HASHES --nodecomp"
|
||||
fi
|
||||
|
||||
echo "$HASHES $4 $5"
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Computes the size of an image
|
||||
# @param $1 - Path to the image
|
||||
|
@ -57,7 +57,8 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/PATH \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1)
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS)
|
||||
|
||||
BASE_PATH="${XPATH_ELEMENTS[0]}"
|
||||
RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}"
|
||||
@ -69,6 +70,7 @@ SRC="${XPATH_ELEMENTS[6]}"
|
||||
SIZE="${XPATH_ELEMENTS[7]}"
|
||||
MD5="${XPATH_ELEMENTS[8]}"
|
||||
SHA1="${XPATH_ELEMENTS[9]}"
|
||||
NO_DECOMPRESS="${XPATH_ELEMENTS[10]}"
|
||||
|
||||
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
|
||||
|
||||
@ -82,17 +84,9 @@ REGISTER_CMD=$(cat <<EOF
|
||||
EOF
|
||||
)
|
||||
|
||||
HASHES=""
|
||||
DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$SRC" -`
|
||||
|
||||
if [ -n "$MD5" ]; then
|
||||
HASHES="$HASHES --md5 $MD5"
|
||||
fi
|
||||
|
||||
if [ -n "$SHA1" ]; then
|
||||
HASHES="$HASHES --sha1 $SHA1"
|
||||
fi
|
||||
|
||||
COPY_COMMAND="$UTILS_PATH/downloader.sh $HASHES $SRC -"
|
||||
COPY_COMMAND="$UTILS_PATH/downloader.sh $DOWNLOADER_ARGS"
|
||||
|
||||
case $SRC in
|
||||
http://*|https://*)
|
||||
|
@ -61,7 +61,8 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/PATH \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/ID)
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/ID \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS)
|
||||
|
||||
BASE_PATH="${XPATH_ELEMENTS[0]}"
|
||||
DS_ID="${XPATH_ELEMENTS[1]}"
|
||||
@ -75,6 +76,7 @@ SRC="${XPATH_ELEMENTS[8]}"
|
||||
MD5="${XPATH_ELEMENTS[9]}"
|
||||
SHA1="${XPATH_ELEMENTS[10]}"
|
||||
IMAGE_ID="${XPATH_ELEMENTS[11]}"
|
||||
NO_DECOMPRESS="${XPATH_ELEMENTS[12]}"
|
||||
|
||||
FE_DST=`generate_image_path`
|
||||
DST_FOLDER=`basename $FE_DST`
|
||||
@ -92,21 +94,13 @@ vmfs_create_remote_path $DS_ID
|
||||
|
||||
# ------------ Prepare for a possible download in the front-end -------------
|
||||
|
||||
if [ ! -d $TMP_DIR ]; then
|
||||
if [ ! -d $TMP_DIR ]; then
|
||||
mkdir -p $TMP_DIR
|
||||
fi
|
||||
|
||||
HASHES=""
|
||||
DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$SRC" "$TMP_DIR/$IMAGE_HASH"`
|
||||
|
||||
if [ -n "$MD5" ]; then
|
||||
HASHES="$HASHES --md5 $MD5"
|
||||
fi
|
||||
|
||||
if [ -n "$SHA1" ]; then
|
||||
HASHES="$HASHES --sha1 $SHA1"
|
||||
fi
|
||||
|
||||
COPY_COMMAND="$UTILS_PATH/downloader.sh $HASHES $SRC $TMP_DIR/$IMAGE_HASH"
|
||||
COPY_COMMAND="$UTILS_PATH/downloader.sh $DOWNLOADER_ARGS"
|
||||
|
||||
# ------------ Copy the image to the repository -------------
|
||||
|
||||
|
@ -53,7 +53,8 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/UMASK \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/PATH \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1)
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS)
|
||||
|
||||
BASE_PATH="${XPATH_ELEMENTS[0]}"
|
||||
RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}"
|
||||
@ -62,23 +63,16 @@ UMASK="${XPATH_ELEMENTS[3]}"
|
||||
SRC="${XPATH_ELEMENTS[4]}"
|
||||
MD5="${XPATH_ELEMENTS[5]}"
|
||||
SHA1="${XPATH_ELEMENTS[6]}"
|
||||
NO_DECOMPRESS="${XPATH_ELEMENTS[7]}"
|
||||
|
||||
mkdir -p "$BASE_PATH"
|
||||
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
|
||||
|
||||
DST=`generate_image_path`
|
||||
|
||||
HASHES=""
|
||||
DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$SRC" "$DST"`
|
||||
|
||||
if [ -n "$MD5" ]; then
|
||||
HASHES="$HASHES --md5 $MD5"
|
||||
fi
|
||||
|
||||
if [ -n "$SHA1" ]; then
|
||||
HASHES="$HASHES --sha1 $SHA1"
|
||||
fi
|
||||
|
||||
COPY_COMMAND="$UTILS_PATH/downloader.sh $HASHES $SRC $DST"
|
||||
COPY_COMMAND="$UTILS_PATH/downloader.sh $DOWNLOADER_ARGS"
|
||||
|
||||
# ------------ Copy the image to the repository -------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user