mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-25 23:21:29 +03:00
Merge branch 'feature-1112' of git.opennebula.org:one into feature-1112
This commit is contained in:
commit
1a23808d67
@ -21,7 +21,7 @@
|
|||||||
# Several SRC types are supported
|
# Several SRC types are supported
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# -------- Set up the environment to source common tools & conf ------------
|
# -------- Set up the environment to source common tools & conf ------------
|
||||||
|
|
||||||
if [ -z "${ONE_LOCATION}" ]; then
|
if [ -z "${ONE_LOCATION}" ]; then
|
||||||
LIB_LOCATION=/usr/lib/one
|
LIB_LOCATION=/usr/lib/one
|
||||||
@ -34,7 +34,7 @@ fi
|
|||||||
DRIVER_PATH=$(dirname $0)
|
DRIVER_PATH=$(dirname $0)
|
||||||
source ${DRIVER_PATH}/../libfs.sh
|
source ${DRIVER_PATH}/../libfs.sh
|
||||||
|
|
||||||
# -------- Get cp and datastore arguments from OpenNebula core ------------
|
# -------- Get cp and datastore arguments from OpenNebula core ------------
|
||||||
|
|
||||||
DRV_ACTION=$1
|
DRV_ACTION=$1
|
||||||
ID=$2
|
ID=$2
|
||||||
@ -42,11 +42,11 @@ ID=$2
|
|||||||
set_up_datastore $DRV_ACTION
|
set_up_datastore $DRV_ACTION
|
||||||
|
|
||||||
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
||||||
eval "SRC=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/PATH`"
|
SRC=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/PATH`
|
||||||
|
|
||||||
DST=`generate_image_path`
|
DST=`generate_image_path`
|
||||||
|
|
||||||
# ------------ Copy the image to the repository -------------
|
# ------------ Copy the image to the repository -------------
|
||||||
|
|
||||||
case $SRC in
|
case $SRC in
|
||||||
http://*)
|
http://*)
|
||||||
@ -63,9 +63,9 @@ http://*)
|
|||||||
error_message "Not allowed to copy image file $SRC"
|
error_message "Not allowed to copy image file $SRC"
|
||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "Copying local image $SRC to the image repository"
|
log "Copying local image $SRC to the image repository"
|
||||||
|
|
||||||
exec_and_log "cp -f $SRC $DST" "Error copying $SRC to $DST"
|
exec_and_log "cp -f $SRC $DST" "Error copying $SRC to $DST"
|
||||||
|
|
||||||
exec_and_log "chmod 0660 $DST"
|
exec_and_log "chmod 0660 $DST"
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
# as (FS)
|
# as (FS)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# -------- Set up the environment to source common tools & conf ------------
|
# -------- Set up the environment to source common tools & conf ------------
|
||||||
|
|
||||||
if [ -z "${ONE_LOCATION}" ]; then
|
if [ -z "${ONE_LOCATION}" ]; then
|
||||||
LIB_LOCATION=/usr/lib/one
|
LIB_LOCATION=/usr/lib/one
|
||||||
@ -34,16 +34,22 @@ fi
|
|||||||
DRIVER_PATH=$(dirname $0)
|
DRIVER_PATH=$(dirname $0)
|
||||||
source ${DRIVER_PATH}/../libfs.sh
|
source ${DRIVER_PATH}/../libfs.sh
|
||||||
|
|
||||||
# -------- Get mkfs and datastore arguments from OpenNebula core ------------
|
# -------- Get mkfs and datastore arguments from OpenNebula core ------------
|
||||||
|
|
||||||
DRV_ACTION=$1
|
DRV_ACTION=$1
|
||||||
ID=$2
|
ID=$2
|
||||||
|
|
||||||
set_up_datastore $DRV_ACTION
|
set_up_datastore $DRV_ACTION
|
||||||
|
|
||||||
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
unset i XPATH_ELEMENTS
|
||||||
eval "FSTYPE=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE`"
|
|
||||||
eval "SIZE=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SIZE`"
|
while IFS= read -r -d '' element; do
|
||||||
|
XPATH_ELEMENTS[i++]="$element"
|
||||||
|
done < <($XPATH /DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE \
|
||||||
|
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
|
||||||
|
|
||||||
|
FSTYPE="${XPATH_ELEMENTS[0]}"
|
||||||
|
SIZE="${XPATH_ELEMENTS[1]}"
|
||||||
|
|
||||||
DST=`generate_image_path`
|
DST=`generate_image_path`
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
#--------------------------------------------------------------------------- #
|
#--------------------------------------------------------------------------- #
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# This script is used to remove a VM image (SRC) from the image repository
|
# This script is used to remove a VM image (SRC) from the image repository
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# ------------ Set up the environment to source common tools ------------
|
# ------------ Set up the environment to source common tools ------------
|
||||||
|
|
||||||
if [ -z "${ONE_LOCATION}" ]; then
|
if [ -z "${ONE_LOCATION}" ]; then
|
||||||
LIB_LOCATION=/usr/lib/one
|
LIB_LOCATION=/usr/lib/one
|
||||||
@ -33,15 +33,15 @@ fi
|
|||||||
DRIVER_PATH=$(dirname $0)
|
DRIVER_PATH=$(dirname $0)
|
||||||
source ${DRIVER_PATH}/../libfs.sh
|
source ${DRIVER_PATH}/../libfs.sh
|
||||||
|
|
||||||
# -------- Get rm and datastore arguments from OpenNebula core ------------
|
# -------- Get rm and datastore arguments from OpenNebula core ------------
|
||||||
|
|
||||||
DRV_ACTION=$1
|
DRV_ACTION=$1
|
||||||
ID=$2
|
ID=$2
|
||||||
|
|
||||||
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
||||||
eval "SRC=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE`"
|
SRC=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE`
|
||||||
|
|
||||||
# ------------ Remove the image from the repository ------------
|
# ------------ Remove the image from the repository ------------
|
||||||
|
|
||||||
if [ -e $SRC ] ; then
|
if [ -e $SRC ] ; then
|
||||||
log "Removing $SRC from the image repository"
|
log "Removing $SRC from the image repository"
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
# Several SRC types are supported
|
# Several SRC types are supported
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# -------- Set up the environment to source common tools & conf ------------
|
# -------- Set up the environment to source common tools & conf ------------
|
||||||
|
|
||||||
if [ -z "${ONE_LOCATION}" ]; then
|
if [ -z "${ONE_LOCATION}" ]; then
|
||||||
LIB_LOCATION=/usr/lib/one
|
LIB_LOCATION=/usr/lib/one
|
||||||
@ -34,7 +34,7 @@ fi
|
|||||||
DRIVER_PATH=$(dirname $0)
|
DRIVER_PATH=$(dirname $0)
|
||||||
source ${DRIVER_PATH}/../libfs.sh
|
source ${DRIVER_PATH}/../libfs.sh
|
||||||
|
|
||||||
# -------- Get cp and datastore arguments from OpenNebula core ------------
|
# -------- Get cp and datastore arguments from OpenNebula core ------------
|
||||||
|
|
||||||
DRV_ACTION=$1
|
DRV_ACTION=$1
|
||||||
ID=$2
|
ID=$2
|
||||||
@ -42,21 +42,13 @@ ID=$2
|
|||||||
set_up_datastore $DRV_ACTION
|
set_up_datastore $DRV_ACTION
|
||||||
|
|
||||||
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
||||||
eval "SRC=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/PATH`"
|
SRC=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/PATH`
|
||||||
|
|
||||||
DST=`generate_image_path`
|
DST=`generate_image_path`
|
||||||
|
|
||||||
# ------------ Copy the image to the repository -------------
|
# ------------ Copy the image to the repository -------------
|
||||||
|
|
||||||
case $SRC in
|
case $SRC in
|
||||||
http://*)
|
|
||||||
log "Downloading $SRC to the image repository"
|
|
||||||
|
|
||||||
exec_and_log "$WGET -O $DST $SRC" "Error downloading $SRC"
|
|
||||||
|
|
||||||
exec_and_log "chmod 0660 $DST"
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
*)
|
||||||
if [ `check_restricted $SRC` -eq 1 ]; then
|
if [ `check_restricted $SRC` -eq 1 ]; then
|
||||||
log_error "Not allowed to copy images from $RESTRICTED_DIRS"
|
log_error "Not allowed to copy images from $RESTRICTED_DIRS"
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
# as (FS)
|
# as (FS)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# -------- Set up the environment to source common tools & conf ------------
|
# -------- Set up the environment to source common tools & conf ------------
|
||||||
|
|
||||||
if [ -z "${ONE_LOCATION}" ]; then
|
if [ -z "${ONE_LOCATION}" ]; then
|
||||||
LIB_LOCATION=/usr/lib/one
|
LIB_LOCATION=/usr/lib/one
|
||||||
@ -34,7 +34,7 @@ fi
|
|||||||
DRIVER_PATH=$(dirname $0)
|
DRIVER_PATH=$(dirname $0)
|
||||||
source ${DRIVER_PATH}/../libfs.sh
|
source ${DRIVER_PATH}/../libfs.sh
|
||||||
|
|
||||||
# -------- Get mkfs and datastore arguments from OpenNebula core ------------
|
# -------- Get mkfs and datastore arguments from OpenNebula core ------------
|
||||||
|
|
||||||
DRV_ACTION=$1
|
DRV_ACTION=$1
|
||||||
ID=$2
|
ID=$2
|
||||||
@ -42,22 +42,46 @@ ID=$2
|
|||||||
set_up_datastore $DRV_ACTION
|
set_up_datastore $DRV_ACTION
|
||||||
|
|
||||||
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
||||||
eval "FSTYPE=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE`"
|
|
||||||
eval "SIZE=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SIZE`"
|
unset i XPATH_ELEMENTS
|
||||||
|
|
||||||
|
while IFS= read -r -d '' element; do
|
||||||
|
XPATH_ELEMENTS[i++]="$element"
|
||||||
|
done < <($XPATH /DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE \
|
||||||
|
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
|
||||||
|
|
||||||
|
FSTYPE="${XPATH_ELEMENTS[0]}"
|
||||||
|
SIZE="${XPATH_ELEMENTS[1]}"
|
||||||
|
|
||||||
DST=`generate_image_path`
|
DST=`generate_image_path`
|
||||||
|
|
||||||
|
DISK=$DST/disk.vmdk
|
||||||
|
DISK_TMP=$DISK.tmp
|
||||||
|
|
||||||
|
IMAGE_FORMAT=vmdk
|
||||||
|
|
||||||
|
umask 0007
|
||||||
# ------------ Create the image to the repository ------------
|
# ------------ Create the image to the repository ------------
|
||||||
|
|
||||||
MKFS_CMD=`mkfs_command $DST $FSTYPE`
|
MKFS_CMD=`mkfs_command $DISK_TMP $FSTYPE`
|
||||||
|
|
||||||
exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M" \
|
exec_and_log "mkdir -p $DST" \
|
||||||
"Could not create image $DST"
|
"Could not create disk directory $DST"
|
||||||
|
exec_and_log "$DD if=/dev/zero of=$DISK_TMP bs=1 count=1 seek=${SIZE}M" \
|
||||||
|
"Could not create temporary image $DISK_TMP"
|
||||||
exec_and_log "$MKFS_CMD" \
|
exec_and_log "$MKFS_CMD" \
|
||||||
"Unable to create filesystem $FSTYPE in $DST"
|
"Unable to create filesystem $FSTYPE in $DISK_TMP"
|
||||||
exec_and_log "chmod 0660 $DST"
|
exec_and_log "$QEMU_IMG convert -O $IMAGE_FORMAT $DISK_TMP $DISK" \
|
||||||
|
"Unable to convert to $IMAGE_FORMAT in $DISK_TMP"
|
||||||
|
exec_and_log "rm -f $DISK_TMP" \
|
||||||
|
"Unable to remove temporary disk $DISK_TMP"
|
||||||
|
exec_and_log "chmod 0660 $DISK"
|
||||||
|
|
||||||
# ---------------- Get the size of the image ------------
|
# ---------------- Get the size of the image ------------
|
||||||
SIZE=`fs_du $DST`
|
|
||||||
|
SIZE=`$QEMU_IMG info $DISK|grep "^virtual size:"|\
|
||||||
|
sed 's/^.*(\([0-9]\+\) bytes.*$/\1/g'`
|
||||||
|
|
||||||
|
SIZE=$(($SIZE/1048576))
|
||||||
|
|
||||||
echo "$DST $SIZE"
|
echo "$DST $SIZE"
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
#--------------------------------------------------------------------------- #
|
#--------------------------------------------------------------------------- #
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# This script is used to remove a VM image (SRC) from the image repository
|
# This script is used to remove a VM image (SRC) from the image repository
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
# ------------ Set up the environment to source common tools ------------
|
# ------------ Set up the environment to source common tools ------------
|
||||||
|
|
||||||
if [ -z "${ONE_LOCATION}" ]; then
|
if [ -z "${ONE_LOCATION}" ]; then
|
||||||
LIB_LOCATION=/usr/lib/one
|
LIB_LOCATION=/usr/lib/one
|
||||||
@ -33,15 +33,15 @@ fi
|
|||||||
DRIVER_PATH=$(dirname $0)
|
DRIVER_PATH=$(dirname $0)
|
||||||
source ${DRIVER_PATH}/../libfs.sh
|
source ${DRIVER_PATH}/../libfs.sh
|
||||||
|
|
||||||
# -------- Get rm and datastore arguments from OpenNebula core ------------
|
# -------- Get rm and datastore arguments from OpenNebula core ------------
|
||||||
|
|
||||||
DRV_ACTION=$1
|
DRV_ACTION=$1
|
||||||
ID=$2
|
ID=$2
|
||||||
|
|
||||||
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
||||||
eval "SRC=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE`"
|
SRC=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE`
|
||||||
|
|
||||||
# ------------ Remove the image from the repository ------------
|
# ------------ Remove the image from the repository ------------
|
||||||
|
|
||||||
if [ -e $SRC ] ; then
|
if [ -e $SRC ] ; then
|
||||||
log "Removing $SRC from the image repository"
|
log "Removing $SRC from the image repository"
|
||||||
|
@ -45,10 +45,11 @@ values = ""
|
|||||||
tmp = Base64::decode64(tmp64)
|
tmp = Base64::decode64(tmp64)
|
||||||
xml = REXML::Document.new(tmp).root
|
xml = REXML::Document.new(tmp).root
|
||||||
|
|
||||||
ARGV.each { |xpath|
|
ARGV.each do |xpath|
|
||||||
element = xml.elements[xpath]
|
element = xml.elements[xpath]
|
||||||
values << "\'#{element.text}\' " if !element.nil?
|
values << element.text if !element.nil?
|
||||||
}
|
values << "\0"
|
||||||
|
end
|
||||||
|
|
||||||
puts values
|
puts values
|
||||||
|
|
||||||
|
@ -29,12 +29,13 @@ MD5SUM=md5sum
|
|||||||
MKFS=mkfs
|
MKFS=mkfs
|
||||||
MKISOFS=mkisofs
|
MKISOFS=mkisofs
|
||||||
MKSWAP=mkswap
|
MKSWAP=mkswap
|
||||||
|
QEMU_IMG=qemu-img
|
||||||
|
READLINK=readlink
|
||||||
SCP=scp
|
SCP=scp
|
||||||
SED=sed
|
SED=sed
|
||||||
SSH=ssh
|
SSH=ssh
|
||||||
SUDO=sudo
|
SUDO=sudo
|
||||||
WGET=wget
|
WGET=wget
|
||||||
READLINK=readlink
|
|
||||||
|
|
||||||
# Used for log messages
|
# Used for log messages
|
||||||
SCRIPT_NAME=`basename $0`
|
SCRIPT_NAME=`basename $0`
|
||||||
|
Loading…
Reference in New Issue
Block a user