mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-11 05:17:41 +03:00
Feature #4217: Refactor the code remove market specific code from the
ds/cp action and move it to the downloader.sh
This commit is contained in:
parent
880d31bc78
commit
ac9990ddc1
@ -40,6 +40,8 @@ source ${DRIVER_PATH}/ceph.conf
|
|||||||
DRV_ACTION=$1
|
DRV_ACTION=$1
|
||||||
ID=$2
|
ID=$2
|
||||||
|
|
||||||
|
export DRV_ACTION
|
||||||
|
|
||||||
UTILS_PATH="${DRIVER_PATH}/.."
|
UTILS_PATH="${DRIVER_PATH}/.."
|
||||||
|
|
||||||
XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION"
|
XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION"
|
||||||
|
@ -39,6 +39,8 @@ source ${DRIVER_PATH}/../libfs.sh
|
|||||||
DRV_ACTION=$1
|
DRV_ACTION=$1
|
||||||
ID=$2
|
ID=$2
|
||||||
|
|
||||||
|
export DRV_ACTION
|
||||||
|
|
||||||
UTILS_PATH="${DRIVER_PATH}/.."
|
UTILS_PATH="${DRIVER_PATH}/.."
|
||||||
|
|
||||||
XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION"
|
XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION"
|
||||||
|
@ -127,7 +127,24 @@ function unarchive
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function s3_request
|
function s3_env
|
||||||
|
{
|
||||||
|
XPATH="$DRIVER_PATH/xpath.rb -b $DRV_ACTION"
|
||||||
|
|
||||||
|
unset i j XPATH_ELEMENTS
|
||||||
|
|
||||||
|
while IFS= read -r -d '' element; do
|
||||||
|
XPATH_ELEMENTS[i++]="$element"
|
||||||
|
done < <($XPATH /DS_DRIVER_ACTION_DATA/MARKETPLACE/TEMPLATE/ACCESS_KEY_ID \
|
||||||
|
/DS_DRIVER_ACTION_DATA/MARKETPLACE/TEMPLATE/SECRET_ACCESS_KEY \
|
||||||
|
/DS_DRIVER_ACTION_DATA/MARKETPLACE/TEMPLATE/ENDPOINT)
|
||||||
|
|
||||||
|
S3_ACCESS_KEY_ID="${XPATH_ELEMENTS[j++]}"
|
||||||
|
S3_SECRET_ACCESS_KEY="${XPATH_ELEMENTS[j++]}"
|
||||||
|
S3_ENDPOINT="${XPATH_ELEMENTS[j++]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function s3_curl_args
|
||||||
{
|
{
|
||||||
FROM="$1"
|
FROM="$1"
|
||||||
|
|
||||||
@ -262,12 +279,17 @@ ssh://*)
|
|||||||
command="ssh ${ssh_arg[0]} $rmt_cmd"
|
command="ssh ${ssh_arg[0]} $rmt_cmd"
|
||||||
;;
|
;;
|
||||||
s3://*)
|
s3://*)
|
||||||
|
|
||||||
|
# Read s3 environment
|
||||||
|
s3_env
|
||||||
|
|
||||||
if [ -z "$S3_ACCESS_KEY_ID" -o -z "$S3_SECRET_ACCESS_KEY" ]; then
|
if [ -z "$S3_ACCESS_KEY_ID" -o -z "$S3_SECRET_ACCESS_KEY" ]; then
|
||||||
echo "S3_ACCESS_KEY_ID and S3_SECRET_ACCESS_KEY are required" >&2
|
echo "S3_ACCESS_KEY_ID and S3_SECRET_ACCESS_KEY are required" >&2
|
||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
curl_args="$(s3_request $FROM)"
|
curl_args="$(s3_curl_args $FROM)"
|
||||||
|
|
||||||
command="curl $GLOBAL_CURL_ARGS $curl_args"
|
command="curl $GLOBAL_CURL_ARGS $curl_args"
|
||||||
;;
|
;;
|
||||||
rbd://*)
|
rbd://*)
|
||||||
|
@ -39,6 +39,8 @@ source ${DRIVER_PATH}/../libfs.sh
|
|||||||
DRV_ACTION=$1
|
DRV_ACTION=$1
|
||||||
ID=$2
|
ID=$2
|
||||||
|
|
||||||
|
export DRV_ACTION
|
||||||
|
|
||||||
UTILS_PATH="${DRIVER_PATH}/.."
|
UTILS_PATH="${DRIVER_PATH}/.."
|
||||||
|
|
||||||
XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION"
|
XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION"
|
||||||
@ -57,10 +59,7 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
|
|||||||
/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \
|
/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 \
|
/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/MARKETPLACE/TEMPLATE/ACCESS_KEY_ID \
|
|
||||||
/DS_DRIVER_ACTION_DATA/MARKETPLACE/TEMPLATE/SECRET_ACCESS_KEY \
|
|
||||||
/DS_DRIVER_ACTION_DATA/MARKETPLACE/TEMPLATE/ENDPOINT)
|
|
||||||
|
|
||||||
unset i
|
unset i
|
||||||
|
|
||||||
@ -75,14 +74,6 @@ MD5="${XPATH_ELEMENTS[i++]}"
|
|||||||
SHA1="${XPATH_ELEMENTS[i++]}"
|
SHA1="${XPATH_ELEMENTS[i++]}"
|
||||||
NO_DECOMPRESS="${XPATH_ELEMENTS[i++]}"
|
NO_DECOMPRESS="${XPATH_ELEMENTS[i++]}"
|
||||||
LIMIT_TRANSFER_BW="${XPATH_ELEMENTS[i++]}"
|
LIMIT_TRANSFER_BW="${XPATH_ELEMENTS[i++]}"
|
||||||
S3_ACCESS_KEY_ID="${XPATH_ELEMENTS[i++]}"
|
|
||||||
S3_SECRET_ACCESS_KEY="${XPATH_ELEMENTS[i++]}"
|
|
||||||
S3_ENDPOINT="${XPATH_ELEMENTS[i++]}"
|
|
||||||
|
|
||||||
# Must be made available to downloader.sh
|
|
||||||
export S3_ACCESS_KEY_ID
|
|
||||||
export S3_SECRET_ACCESS_KEY
|
|
||||||
export S3_ENDPOINT
|
|
||||||
|
|
||||||
DST=`generate_image_path`
|
DST=`generate_image_path`
|
||||||
IMAGE_HASH=`basename $DST`
|
IMAGE_HASH=`basename $DST`
|
||||||
|
@ -40,6 +40,8 @@ source ${DRIVER_PATH}/lvm.conf
|
|||||||
DRV_ACTION=$1
|
DRV_ACTION=$1
|
||||||
ID=$2
|
ID=$2
|
||||||
|
|
||||||
|
export DRV_ACTION
|
||||||
|
|
||||||
UTILS_PATH="${DRIVER_PATH}/.."
|
UTILS_PATH="${DRIVER_PATH}/.."
|
||||||
|
|
||||||
XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION"
|
XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION"
|
||||||
|
@ -43,6 +43,8 @@ source ${DRIVER_PATH}/vmfs.conf
|
|||||||
DRV_ACTION=$1
|
DRV_ACTION=$1
|
||||||
ID=$2
|
ID=$2
|
||||||
|
|
||||||
|
export DRV_ACTION
|
||||||
|
|
||||||
UTILS_PATH="${DRIVER_PATH}/.."
|
UTILS_PATH="${DRIVER_PATH}/.."
|
||||||
|
|
||||||
XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION"
|
XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION"
|
||||||
|
Loading…
Reference in New Issue
Block a user