Skip to content

Instantly share code, notes, and snippets.

@FlorianHeigl
Last active June 30, 2020 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FlorianHeigl/163b21f8abce1c5b29b37416b0c4f6dd to your computer and use it in GitHub Desktop.
Save FlorianHeigl/163b21f8abce1c5b29b37416b0c4f6dd to your computer and use it in GitHub Desktop.
one ds driver component template
#!/usr/bin/env bash
#action: description from doc
#mkfs: creates a new empty image in the datastore
#ARGUMENTS: datastore_image_dump image_id
#datastore_image_dump is an XML dump of the driver action encoded in Base 64.
#image_source is the image source which will be later sent to the transfer manager.
#ARGUMENTS: list of args by space
#arg1 content
#arg2 content
#PHASE: INIT
set -u
[[ $# != 2 ]] || exit 1
DRV_ACTION="${1}"
ID="${2}"
if [ -z "${ONE_LOCATION}" ]; then
LIB_LOCATION=/usr/lib/one
else
LIB_LOCATION=$ONE_LOCATION/lib
fi
DRV_PATH=$(dirname "$0")
DRV_TASK=$(basename "$0")
# source opennebula tools and eternus scripts
for lib in ${LIB_LOCATION}/sh/scripts_common.sh ${DRV_PATH}/../libfs.sh ${DRV_PATH}/scripts_eternus.sh; do
bash -eun "$lib" && source "$lib" || { echo "Error: failed to set up driver"; exit 1; }
done
# parse XML Data from DRV_ACTION
get_xpath_info
if [[ $DEBUG = "YES" ]]; then
echo "$DRV_ACTION" > /var/tmp/one/eternus-"${DRV_TASK}".params
exec &> >(tee -a /var/tmp/one/eternus-"${DRV_TASK}.log")
fi
#PHASE: PREP
DST_HOST=$( get_destination_host "$ID" )
#PHASE: RUN
#PHASE: POST
#RETURNS: image_source size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment