mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
Merge branch 'feature-1068'
This commit is contained in:
commit
9ab566b2d7
@ -77,7 +77,8 @@ public:
|
||||
{
|
||||
FILE = 0, /** < File-based disk */
|
||||
CD_ROM = 1, /** < An ISO9660 disk */
|
||||
BLOCK = 2 /** < Block-device disk */
|
||||
BLOCK = 2, /** < Block-device disk */
|
||||
RBD = 3 /** < CEPH RBD disk */
|
||||
};
|
||||
|
||||
/**
|
||||
@ -92,6 +93,7 @@ public:
|
||||
case FILE: return "FILE" ; break;
|
||||
case CD_ROM: return "CDROM" ; break;
|
||||
case BLOCK: return "BLOCK" ; break;
|
||||
case RBD: return "RBD" ; break;
|
||||
default: return "";
|
||||
}
|
||||
};
|
||||
|
20
install.sh
20
install.sh
@ -238,6 +238,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/tm/vmfs \
|
||||
$VAR_LOCATION/remotes/tm/iscsi \
|
||||
$VAR_LOCATION/remotes/tm/lvm \
|
||||
$VAR_LOCATION/remotes/tm/ceph \
|
||||
$VAR_LOCATION/remotes/hooks \
|
||||
$VAR_LOCATION/remotes/hooks/ft \
|
||||
$VAR_LOCATION/remotes/datastore \
|
||||
@ -247,6 +248,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/datastore/vmfs \
|
||||
$VAR_LOCATION/remotes/datastore/iscsi \
|
||||
$VAR_LOCATION/remotes/datastore/lvm \
|
||||
$VAR_LOCATION/remotes/datastore/ceph \
|
||||
$VAR_LOCATION/remotes/auth \
|
||||
$VAR_LOCATION/remotes/auth/plain \
|
||||
$VAR_LOCATION/remotes/auth/ssh \
|
||||
@ -440,6 +442,7 @@ INSTALL_FILES=(
|
||||
TM_VMFS_FILES:$VAR_LOCATION/remotes/tm/vmfs
|
||||
TM_ISCSI_FILES:$VAR_LOCATION/remotes/tm/iscsi
|
||||
TM_LVM_FILES:$VAR_LOCATION/remotes/tm/lvm
|
||||
TM_CEPH_FILES:$VAR_LOCATION/remotes/tm/ceph
|
||||
TM_DUMMY_FILES:$VAR_LOCATION/remotes/tm/dummy
|
||||
DATASTORE_DRIVER_COMMON_SCRIPTS:$VAR_LOCATION/remotes/datastore/
|
||||
DATASTORE_DRIVER_DUMMY_SCRIPTS:$VAR_LOCATION/remotes/datastore/dummy
|
||||
@ -448,6 +451,7 @@ INSTALL_FILES=(
|
||||
DATASTORE_DRIVER_VMFS_SCRIPTS:$VAR_LOCATION/remotes/datastore/vmfs
|
||||
DATASTORE_DRIVER_ISCSI_SCRIPTS:$VAR_LOCATION/remotes/datastore/iscsi
|
||||
DATASTORE_DRIVER_LVM_SCRIPTS:$VAR_LOCATION/remotes/datastore/lvm
|
||||
DATASTORE_DRIVER_CEPH_SCRIPTS:$VAR_LOCATION/remotes/datastore/ceph
|
||||
NETWORK_FILES:$VAR_LOCATION/remotes/vnm
|
||||
NETWORK_8021Q_FILES:$VAR_LOCATION/remotes/vnm/802.1Q
|
||||
NETWORK_DUMMY_FILES:$VAR_LOCATION/remotes/vnm/dummy
|
||||
@ -888,6 +892,7 @@ NETWORK_VMWARE_FILES="src/vnm_mad/remotes/vmware/clean \
|
||||
# - VMWARE TM, $VAR_LOCATION/tm/vmware
|
||||
# - ISCSI TM, $VAR_LOCATION/tm/iscsi
|
||||
# - LVM TM, $VAR_LOCATION/tm/lvm
|
||||
# - CEPH TM, $VAR_LOCATION/tm/ceph
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
TM_FILES="src/tm_mad/tm_common.sh"
|
||||
@ -963,6 +968,14 @@ TM_LVM_FILES="src/tm_mad/lvm/clone \
|
||||
src/tm_mad/lvm/postmigrate \
|
||||
src/tm_mad/lvm/delete"
|
||||
|
||||
TM_CEPH_FILES="src/tm_mad/ceph/clone \
|
||||
src/tm_mad/ceph/ln \
|
||||
src/tm_mad/ceph/mv \
|
||||
src/tm_mad/ceph/mvds \
|
||||
src/tm_mad/ceph/premigrate \
|
||||
src/tm_mad/ceph/postmigrate \
|
||||
src/tm_mad/ceph/delete"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Datastore drivers, to be installed under $REMOTES_LOCATION/datastore
|
||||
# - Dummy Image Repository, $REMOTES_LOCATION/datastore/dummy
|
||||
@ -1016,6 +1029,13 @@ DATASTORE_DRIVER_LVM_SCRIPTS="src/datastore_mad/remotes/lvm/cp \
|
||||
src/datastore_mad/remotes/lvm/clone \
|
||||
src/datastore_mad/remotes/lvm/lvm.conf"
|
||||
|
||||
DATASTORE_DRIVER_CEPH_SCRIPTS="src/datastore_mad/remotes/ceph/cp \
|
||||
src/datastore_mad/remotes/ceph/mkfs \
|
||||
src/datastore_mad/remotes/ceph/stat \
|
||||
src/datastore_mad/remotes/ceph/rm \
|
||||
src/datastore_mad/remotes/ceph/clone \
|
||||
src/datastore_mad/remotes/ceph/ceph.conf"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Migration scripts for onedb command, to be installed under $LIB_LOCATION
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -313,7 +313,7 @@ VM_MAD = [
|
||||
|
||||
TM_MAD = [
|
||||
executable = "one_tm",
|
||||
arguments = "-t 15 -d dummy,lvm,shared,qcow2,ssh,vmfs,iscsi" ]
|
||||
arguments = "-t 15 -d dummy,lvm,shared,qcow2,ssh,vmfs,iscsi,ceph" ]
|
||||
|
||||
#*******************************************************************************
|
||||
# Datastore Driver Configuration
|
||||
@ -330,7 +330,7 @@ TM_MAD = [
|
||||
|
||||
DATASTORE_MAD = [
|
||||
executable = "one_datastore",
|
||||
arguments = "-t 15 -d fs,vmware,vmfs,iscsi,lvm"
|
||||
arguments = "-t 15 -d fs,vmware,vmfs,iscsi,lvm,ceph"
|
||||
]
|
||||
|
||||
#*******************************************************************************
|
||||
|
@ -110,6 +110,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
|
||||
puts str % ["DS_MAD", datastore['DS_MAD']]
|
||||
puts str % ["TM_MAD", datastore['TM_MAD']]
|
||||
puts str % ["BASE PATH",datastore['BASE_PATH']]
|
||||
puts str % ["DISK_TYPE",Image::DISK_TYPES[datastore['DISK_TYPE'].to_i]]
|
||||
puts
|
||||
|
||||
CLIHelper.print_header(str_h1 % "PERMISSIONS",false)
|
||||
|
@ -102,14 +102,14 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
||||
{
|
||||
:name => "disk_type",
|
||||
:large => "--disk_type disk_type",
|
||||
:description => "Type of the image (BLOCK, CDROM or FILE)",
|
||||
:description => "Type of the image (BLOCK, CDROM, RBD or FILE)",
|
||||
:format => String,
|
||||
:proc => lambda do |o, options|
|
||||
type=o.strip.upcase
|
||||
if %w{BLOCK CDROM FILE}.include? type
|
||||
if %w{BLOCK CDROM FILE RBD}.include? type
|
||||
[0, type]
|
||||
else
|
||||
[-1, "Disk type must be BLOCK, CDROM or FILE"]
|
||||
[-1, "Disk type must be BLOCK, CDROM, RBD or FILE"]
|
||||
end
|
||||
end
|
||||
},
|
||||
|
@ -174,7 +174,7 @@ int Datastore::insert(SqlDB *db, string& error_str)
|
||||
|
||||
if ( type == IMAGE_DS )
|
||||
{
|
||||
get_template_attribute("DISK_TYPE", s_disk_type);
|
||||
erase_template_attribute("DISK_TYPE", s_disk_type);
|
||||
|
||||
if (s_disk_type == "BLOCK")
|
||||
{
|
||||
@ -184,6 +184,10 @@ int Datastore::insert(SqlDB *db, string& error_str)
|
||||
{
|
||||
disk_type = Image::CD_ROM;
|
||||
}
|
||||
else if (s_disk_type == "RBD")
|
||||
{
|
||||
disk_type = Image::RBD;
|
||||
}
|
||||
}
|
||||
|
||||
if ( tm_mad.empty() == true )
|
||||
|
27
src/datastore_mad/remotes/ceph/ceph.conf
Normal file
27
src/datastore_mad/remotes/ceph/ceph.conf
Normal file
@ -0,0 +1,27 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# Default POOL_NAME
|
||||
POOL_NAME=one
|
||||
|
||||
# Default Ceph server host. Storage operations will be performed in this host.
|
||||
HOST=localhost
|
||||
|
||||
# Staging directory
|
||||
# A directory in the Ceph server host where image will be transferred to
|
||||
# temporarily during the create/mkfs processes. This directoy MUST exist,
|
||||
# have enough space and be writeable by 'oneadmin'
|
||||
STAGING_DIR=/var/tmp
|
71
src/datastore_mad/remotes/ceph/clone
Executable file
71
src/datastore_mad/remotes/ceph/clone
Executable file
@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
###############################################################################
|
||||
# This script is used to copy a VM image (SRC) to the image repository as DST
|
||||
# Several SRC types are supported
|
||||
###############################################################################
|
||||
# -------- Set up the environment to source common tools & conf ------------
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
LIB_LOCATION=/usr/lib/one
|
||||
else
|
||||
LIB_LOCATION=$ONE_LOCATION/lib
|
||||
fi
|
||||
|
||||
. $LIB_LOCATION/sh/scripts_common.sh
|
||||
|
||||
DRIVER_PATH=$(dirname $0)
|
||||
source ${DRIVER_PATH}/../libfs.sh
|
||||
source ${DRIVER_PATH}/ceph.conf
|
||||
|
||||
# -------- Get cp and datastore arguments from OpenNebula core ------------
|
||||
|
||||
DRV_ACTION=$1
|
||||
ID=$2
|
||||
|
||||
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
||||
|
||||
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/UMASK \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/HOST \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/POOL_NAME \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/PATH \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
|
||||
|
||||
unset i
|
||||
|
||||
BASE_PATH="${XPATH_ELEMENTS[i++]}"
|
||||
UMASK="${XPATH_ELEMENTS[i++]}"
|
||||
DST_HOST="${XPATH_ELEMENTS[i++]:-$HOST}"
|
||||
POOL_NAME="${XPATH_ELEMENTS[i++]:-$POOL_NAME}"
|
||||
SRC="${XPATH_ELEMENTS[i++]}"
|
||||
SIZE="${XPATH_ELEMENTS[i++]}"
|
||||
|
||||
SAFE_DIRS=""
|
||||
|
||||
IMAGE_NAME="one-${ID}"
|
||||
RBD_DST="${POOL_NAME}/${IMAGE_NAME}"
|
||||
|
||||
ssh_exec_and_log "$DST_HOST" "$RBD copy $SRC $RBD_DST" \
|
||||
"Error cloning $SRC to $RBD_DST in $DST_HOST"
|
||||
|
||||
echo "$RBD_DST"
|
130
src/datastore_mad/remotes/ceph/cp
Executable file
130
src/datastore_mad/remotes/ceph/cp
Executable file
@ -0,0 +1,130 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
###############################################################################
|
||||
# This script is used to copy a VM image (SRC) to the image repository as DST
|
||||
# Several SRC types are supported
|
||||
###############################################################################
|
||||
|
||||
# -------- Set up the environment to source common tools & conf ------------
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
LIB_LOCATION=/usr/lib/one
|
||||
else
|
||||
LIB_LOCATION=$ONE_LOCATION/lib
|
||||
fi
|
||||
|
||||
. $LIB_LOCATION/sh/scripts_common.sh
|
||||
|
||||
DRIVER_PATH=$(dirname $0)
|
||||
source ${DRIVER_PATH}/../libfs.sh
|
||||
source ${DRIVER_PATH}/ceph.conf
|
||||
|
||||
# -------- Get cp and datastore arguments from OpenNebula core ------------
|
||||
|
||||
DRV_ACTION=$1
|
||||
ID=$2
|
||||
|
||||
UTILS_PATH="${DRIVER_PATH}/.."
|
||||
|
||||
XPATH="$UTILS_PATH/xpath.rb -b $DRV_ACTION"
|
||||
|
||||
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/RESTRICTED_DIRS \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/UMASK \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/HOST \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/POOL_NAME \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/STAGING_DIR \
|
||||
/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/DATASTORE/TEMPLATE/NO_DECOMPRESS \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/LIMIT_TRANSFER_BW)
|
||||
|
||||
unset i
|
||||
|
||||
BASE_PATH="${XPATH_ELEMENTS[i++]}"
|
||||
RESTRICTED_DIRS="${XPATH_ELEMENTS[i++]}"
|
||||
SAFE_DIRS="${XPATH_ELEMENTS[i++]}"
|
||||
UMASK="${XPATH_ELEMENTS[i++]}"
|
||||
DST_HOST="${XPATH_ELEMENTS[i++]:-$HOST}"
|
||||
POOL_NAME="${XPATH_ELEMENTS[i++]:-$POOL_NAME}"
|
||||
STAGING_DIR="${XPATH_ELEMENTS[i++]:-$STAGING_DIR}"
|
||||
SRC="${XPATH_ELEMENTS[i++]}"
|
||||
SIZE="${XPATH_ELEMENTS[i++]}"
|
||||
MD5="${XPATH_ELEMENTS[i++]}"
|
||||
SHA1="${XPATH_ELEMENTS[i++]}"
|
||||
NO_DECOMPRESS="${XPATH_ELEMENTS[i++]}"
|
||||
LIMIT_TRANSFER_BW="${XPATH_ELEMENTS[i++]}"
|
||||
|
||||
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
|
||||
|
||||
IMAGE_HASH=`generate_image_hash`
|
||||
TMP_DST="$STAGING_DIR/$IMAGE_HASH"
|
||||
|
||||
IMAGE_NAME="one-${ID}"
|
||||
RBD_SOURCE="${POOL_NAME}/${IMAGE_NAME}"
|
||||
|
||||
DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$LIMIT_TRANSFER_BW" "$SRC" -`
|
||||
|
||||
COPY_COMMAND="$UTILS_PATH/downloader.sh $DOWNLOADER_ARGS"
|
||||
|
||||
case $SRC in
|
||||
http://*|https://*)
|
||||
log "Downloading $SRC to the image repository"
|
||||
|
||||
DUMP="$COPY_COMMAND"
|
||||
;;
|
||||
|
||||
*)
|
||||
if [ `check_restricted $SRC` -eq 1 ]; then
|
||||
log_error "Not allowed to copy images from $RESTRICTED_DIRS"
|
||||
error_message "Not allowed to copy image file $SRC"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
log "Copying local image $SRC to the image repository"
|
||||
|
||||
DUMP="$COPY_COMMAND"
|
||||
;;
|
||||
esac
|
||||
|
||||
exec_and_log "eval $DUMP | $SSH $DST_HOST $SUDO $DD of=$TMP_DST bs=64k" \
|
||||
"Error dumping $SRC to $DST_HOST:$TMP_DST"
|
||||
|
||||
REGISTER_CMD=$(cat <<EOF
|
||||
set -e
|
||||
|
||||
# create rbd
|
||||
$QEMU_IMG convert -O rbd $TMP_DST rbd:$RBD_SOURCE
|
||||
|
||||
# remove original
|
||||
$RM -f $TMP_DST
|
||||
EOF
|
||||
)
|
||||
|
||||
ssh_exec_and_log "$DST_HOST" "$REGISTER_CMD" \
|
||||
"Error registering $RBD_SOURCE in $DST_HOST"
|
||||
|
||||
echo "$RBD_SOURCE"
|
108
src/datastore_mad/remotes/ceph/mkfs
Executable file
108
src/datastore_mad/remotes/ceph/mkfs
Executable file
@ -0,0 +1,108 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
###############################################################################
|
||||
# This script is used to create a VM image (SRC) of size (SIZE) and formatted
|
||||
# as (FS)
|
||||
###############################################################################
|
||||
|
||||
# -------- Set up the environment to source common tools & conf ------------
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
LIB_LOCATION=/usr/lib/one
|
||||
else
|
||||
LIB_LOCATION=$ONE_LOCATION/lib
|
||||
fi
|
||||
|
||||
. $LIB_LOCATION/sh/scripts_common.sh
|
||||
|
||||
DRIVER_PATH=$(dirname $0)
|
||||
source ${DRIVER_PATH}/../libfs.sh
|
||||
source ${DRIVER_PATH}/ceph.conf
|
||||
|
||||
# -------- Get mkfs and datastore arguments from OpenNebula core ------------
|
||||
|
||||
DRV_ACTION=$1
|
||||
ID=$2
|
||||
|
||||
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
||||
|
||||
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/RESTRICTED_DIRS \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/UMASK \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/HOST \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/POOL_NAME \
|
||||
/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/STAGING_DIR \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE \
|
||||
/DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
|
||||
|
||||
unset i
|
||||
|
||||
BASE_PATH="${XPATH_ELEMENTS[i++]}"
|
||||
RESTRICTED_DIRS="${XPATH_ELEMENTS[i++]}"
|
||||
SAFE_DIRS="${XPATH_ELEMENTS[i++]}"
|
||||
UMASK="${XPATH_ELEMENTS[i++]}"
|
||||
DST_HOST="${XPATH_ELEMENTS[i++]:-$HOST}"
|
||||
POOL_NAME="${XPATH_ELEMENTS[i++]:-$POOL_NAME}"
|
||||
STAGING_DIR="${XPATH_ELEMENTS[i++]:-$STAGING_DIR}"
|
||||
FSTYPE="${XPATH_ELEMENTS[i++]}"
|
||||
SIZE="${XPATH_ELEMENTS[i++]}"
|
||||
|
||||
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
|
||||
|
||||
IMAGE_HASH=`generate_image_hash`
|
||||
TMP_DST="$STAGING_DIR/$IMAGE_HASH"
|
||||
|
||||
IMAGE_NAME="one-${ID}"
|
||||
RBD_SOURCE="${POOL_NAME}/${IMAGE_NAME}"
|
||||
|
||||
# ------------ Image to save_as disk, no need to create a FS ------------
|
||||
|
||||
if [ "$FSTYPE" = "save_as" ]; then
|
||||
echo "$RBD_SOURCE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ------------ Create the image in the repository ------------
|
||||
|
||||
MKFS_CMD=`mkfs_command $TMP_DST $FSTYPE $SIZE`
|
||||
|
||||
REGISTER_CMD=$(cat <<EOF
|
||||
set -e
|
||||
|
||||
# create and format
|
||||
$DD if=/dev/zero of=$TMP_DST bs=1 count=1 seek=${SIZE}M
|
||||
$MKFS_CMD
|
||||
|
||||
# create rbd
|
||||
$QEMU_IMG convert -O rbd $TMP_DST rbd:$RBD_SOURCE
|
||||
|
||||
# remove original
|
||||
$RM -f $TMP_DST
|
||||
EOF
|
||||
)
|
||||
|
||||
ssh_exec_and_log "$DST_HOST" "$REGISTER_CMD" \
|
||||
"Error registering $RBD_SOURCE in $DST_HOST"
|
||||
|
||||
echo "$RBD_SOURCE"
|
60
src/datastore_mad/remotes/ceph/rm
Executable file
60
src/datastore_mad/remotes/ceph/rm
Executable file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
###############################################################################
|
||||
# This script is used to remove a VM image (SRC) from the image repository
|
||||
###############################################################################
|
||||
|
||||
# ------------ Set up the environment to source common tools ------------
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
LIB_LOCATION=/usr/lib/one
|
||||
else
|
||||
LIB_LOCATION=$ONE_LOCATION/lib
|
||||
fi
|
||||
|
||||
. $LIB_LOCATION/sh/scripts_common.sh
|
||||
|
||||
DRIVER_PATH=$(dirname $0)
|
||||
source ${DRIVER_PATH}/../libfs.sh
|
||||
source ${DRIVER_PATH}/ceph.conf
|
||||
|
||||
# -------- Get rm and datastore arguments from OpenNebula core ------------
|
||||
|
||||
DRV_ACTION=$1
|
||||
ID=$2
|
||||
|
||||
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
||||
|
||||
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/HOST)
|
||||
|
||||
unset i
|
||||
|
||||
SRC="${XPATH_ELEMENTS[i++]}"
|
||||
DST_HOST="${XPATH_ELEMENTS[i++]:-$HOST}"
|
||||
|
||||
log "Removing $SRC from the rbd image repository in $DST_HOST"
|
||||
|
||||
ssh_exec_and_log "$DST_HOST" "$RBD rm $SRC" \
|
||||
"Error removing $SRC in $DST_HOST"
|
||||
|
||||
exit 0
|
1
src/datastore_mad/remotes/ceph/stat
Symbolic link
1
src/datastore_mad/remotes/ceph/stat
Symbolic link
@ -0,0 +1 @@
|
||||
../common/stat
|
@ -61,10 +61,10 @@ function set_up_datastore {
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Generates an unique image path. Requires BASE_PATH to be set
|
||||
# @return path for the image (empty if error)
|
||||
# Generates an unique image hash. Requires BASE_PATH to be set
|
||||
# @return hash for the image (empty if error)
|
||||
#-------------------------------------------------------------------------------
|
||||
function generate_image_path {
|
||||
function generate_image_hash {
|
||||
|
||||
CANONICAL_STR="`$DATE +%s`:$ID"
|
||||
|
||||
@ -80,6 +80,15 @@ EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "${IMAGE_HASH}"
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Generates an unique image path. Requires BASE_PATH to be set
|
||||
# @return path for the image (empty if error)
|
||||
#-------------------------------------------------------------------------------
|
||||
function generate_image_path {
|
||||
IMAGE_HASH=`generate_image_hash`
|
||||
echo "${BASE_PATH}/${IMAGE_HASH}"
|
||||
}
|
||||
|
||||
|
@ -572,7 +572,8 @@ int Image::disk_attribute( VectorAttribute * disk,
|
||||
switch(type)
|
||||
{
|
||||
case OS:
|
||||
case DATABLOCK: //Type is FILE or BLOCK as inherited from the DS
|
||||
case DATABLOCK:
|
||||
case RBD: //Type is FILE or BLOCK as inherited from the DS
|
||||
disk_attr_type = disk_type_to_str(disk_type);
|
||||
break;
|
||||
|
||||
|
@ -35,7 +35,9 @@ MKFS=mkfs
|
||||
MKISOFS=genisoimage
|
||||
MKSWAP=mkswap
|
||||
QEMU_IMG=qemu-img
|
||||
RBD=rbd
|
||||
READLINK=readlink
|
||||
RM=rm
|
||||
SCP=scp
|
||||
SED=sed
|
||||
SSH=ssh
|
||||
|
@ -64,6 +64,8 @@ module OpenNebula
|
||||
"CONTEXT" => "CX"
|
||||
}
|
||||
|
||||
DISK_TYPES=%w{FILE CD_ROM BLOCK RBD}
|
||||
|
||||
# Creates an Image description with just its identifier
|
||||
# this method should be used to create plain Image objects.
|
||||
# +id+ the id of the image
|
||||
|
75
src/tm_mad/ceph/clone
Executable file
75
src/tm_mad/ceph/clone
Executable file
@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# clone fe:SOURCE host:remote_system_ds/disk.i size
|
||||
# - fe is the front-end hostname
|
||||
# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
|
||||
# - host is the target host to deploy the VM
|
||||
# - remote_system_ds is the path for the system datastore in the host
|
||||
|
||||
SRC=$1
|
||||
DST=$2
|
||||
VM_ID=$3
|
||||
DS_ID=$4
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
|
||||
else
|
||||
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
|
||||
fi
|
||||
|
||||
DRIVER_PATH=$(dirname $0)
|
||||
|
||||
source $TMCOMMON
|
||||
source ${DRIVER_PATH}/../../datastore/ceph/ceph.conf
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Get Image information
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
DISK_ID=$(echo "$DST_PATH" | $AWK -F. '{print $NF}')
|
||||
|
||||
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
|
||||
|
||||
unset i XPATH_ELEMENTS
|
||||
|
||||
while IFS= read -r -d '' element; do
|
||||
XPATH_ELEMENTS[i++]="$element"
|
||||
done < <(onedatastore show -x $DS_ID | $XPATH \
|
||||
/DATASTORE/TEMPLATE/HOST)
|
||||
|
||||
unset i
|
||||
|
||||
CEPH_HOST="${XPATH_ELEMENTS[i++]}"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Compute the destination image name
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
|
||||
DISK_ID=$(echo $DST|awk -F. '{print $NF}')
|
||||
RBD_DST="${SRC_PATH}-${VM_ID}-${DISK_ID}"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Clone the image
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
ssh_exec_and_log "$CEPH_HOST" "$RBD copy $SRC_PATH $RBD_DST" \
|
||||
"Error cloning $SRC_PATH to $RBD_DST in $CEPH_HOST"
|
||||
exit 0
|
93
src/tm_mad/ceph/delete
Executable file
93
src/tm_mad/ceph/delete
Executable file
@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# DELETE <host:remote_system_ds/disk.i|host:remote_system_ds/>
|
||||
# - host is the target host to deploy the VM
|
||||
# - remote_system_ds is the path for the system datastore in the host
|
||||
|
||||
DST=$1
|
||||
VM_ID=$2
|
||||
DS_ID=$3
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
|
||||
else
|
||||
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
|
||||
fi
|
||||
|
||||
DRIVER_PATH=$(dirname $0)
|
||||
|
||||
source $TMCOMMON
|
||||
source ${DRIVER_PATH}/../../datastore/ceph/ceph.conf
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Process destination
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Delete and exit if directory
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
if [ `is_disk $DST_PATH` -eq 0 ]; then
|
||||
# Directory
|
||||
log "Deleting $DST_PATH"
|
||||
ssh_exec_and_log "$DST_HOST" "rm -rf $DST_PATH" "Error deleting $DST_PATH"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Get Image information
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
DISK_ID=$(echo "$DST_PATH" | $AWK -F. '{print $NF}')
|
||||
|
||||
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
|
||||
|
||||
unset i j XPATH_ELEMENTS
|
||||
|
||||
while IFS= read -r -d '' element; do
|
||||
XPATH_ELEMENTS[i++]="$element"
|
||||
done < <(onevm show -x $VM_ID| $XPATH \
|
||||
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SOURCE \
|
||||
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/PERSISTENT)
|
||||
|
||||
SRC="${XPATH_ELEMENTS[j++]}"
|
||||
PERSISTENT="${XPATH_ELEMENTS[j++]}"
|
||||
|
||||
# Exit if persistent
|
||||
[ -n "$PERSISTENT" ] && exit 0
|
||||
|
||||
# non persistent, so the name will be "<pool>/one-<imageid>-<vmid>-<diskid>"
|
||||
RBD_SRC="${SRC}-${VM_ID}-${DISK_ID}"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Delete the device
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
log "Deleting $DST_PATH"
|
||||
|
||||
# Note that this command, as opposed to the rest of $RBD commands in this set of
|
||||
# drivers, is executed in the worker node and not in the CEPH frontend.
|
||||
|
||||
ssh_exec_and_log "$DST_HOST" "$RBD rm $RBD_SRC" \
|
||||
"Error deleting $RBD_SRC in $DST_HOST"
|
||||
|
||||
exit 0
|
25
src/tm_mad/ceph/ln
Executable file
25
src/tm_mad/ceph/ln
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# clone fe:SOURCE host:remote_system_ds/disk.i size
|
||||
# - fe is the front-end hostname
|
||||
# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
|
||||
# - host is the target host to deploy the VM
|
||||
# - remote_system_ds is the path for the system datastore in the host
|
||||
|
||||
exit 0
|
19
src/tm_mad/ceph/mv
Executable file
19
src/tm_mad/ceph/mv
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
exit 0
|
82
src/tm_mad/ceph/mvds
Executable file
82
src/tm_mad/ceph/mvds
Executable file
@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# mvds host:remote_system_ds/disk.i fe:SOURCE
|
||||
# - fe is the front-end hostname
|
||||
# - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
|
||||
# - host is the target host to deploy the VM
|
||||
# - remote_system_ds is the path for the system datastore in the host
|
||||
|
||||
SRC=$1
|
||||
DST=$2
|
||||
VM_ID=$3
|
||||
DS_ID=$4
|
||||
|
||||
if [ -z "${ONE_LOCATION}" ]; then
|
||||
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
|
||||
else
|
||||
TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
|
||||
fi
|
||||
|
||||
DRIVER_PATH=$(dirname $0)
|
||||
|
||||
source $TMCOMMON
|
||||
source ${DRIVER_PATH}/../../datastore/ceph/ceph.conf
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Set dst path and dir
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
SRC_HOST=`arg_host $SRC`
|
||||
SRC_PATH=`arg_path $SRC`
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Get Image information
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
DISK_ID=$(echo "$SRC_PATH" | $AWK -F. '{print $NF}')
|
||||
|
||||
XPATH="${DRIVER_PATH}/../../datastore/xpath.rb --stdin"
|
||||
|
||||
unset i j XPATH_ELEMENTS
|
||||
|
||||
while IFS= read -r -d '' element; do
|
||||
XPATH_ELEMENTS[i++]="$element"
|
||||
done < <(onevm show -x $VM_ID| $XPATH \
|
||||
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/SOURCE \
|
||||
/VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/PERSISTENT)
|
||||
|
||||
RBD_SRC="${XPATH_ELEMENTS[j++]}"
|
||||
PERSISTENT="${XPATH_ELEMENTS[j++]}"
|
||||
|
||||
# Exit if persistent
|
||||
[ -n "$PERSISTENT" ] && exit 0
|
||||
|
||||
# non persistent, so the name will be "<pool>/one-<imageid>-<vmid>-<diskid>"
|
||||
RBD_DST="${RBD_SRC}-${VM_ID}-${DISK_ID}"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Move the image back to the datastore
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
log "Dumping $RBD_DST to $DST"
|
||||
|
||||
ssh_exec_and_log "$SRC_HOST" "$RBD rename $RBD_DST $DST" \
|
||||
"Error saving $RBD_DST as $DST in $SRC_HOST"
|
||||
|
||||
exit 0
|
1
src/tm_mad/ceph/postmigrate
Symbolic link
1
src/tm_mad/ceph/postmigrate
Symbolic link
@ -0,0 +1 @@
|
||||
../common/postmigrate
|
1
src/tm_mad/ceph/premigrate
Symbolic link
1
src/tm_mad/ceph/premigrate
Symbolic link
@ -0,0 +1 @@
|
||||
../common/premigrate
|
@ -56,6 +56,9 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
string ro = "";
|
||||
string driver = "";
|
||||
string cache = "";
|
||||
string source = "";
|
||||
string clone = "";
|
||||
|
||||
int disk_id;
|
||||
string default_driver = "";
|
||||
string default_driver_cache = "";
|
||||
@ -305,7 +308,7 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
|
||||
if ( disk == 0 )
|
||||
{
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
type = disk->vector_value("TYPE");
|
||||
@ -313,6 +316,9 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
ro = disk->vector_value("READONLY");
|
||||
driver = disk->vector_value("DRIVER");
|
||||
cache = disk->vector_value("CACHE");
|
||||
source = disk->vector_value("SOURCE");
|
||||
clone = disk->vector_value("CLONE");
|
||||
|
||||
disk->vector_value_str("DISK_ID", disk_id);
|
||||
|
||||
if (target.empty())
|
||||
@ -342,6 +348,19 @@ int LibVirtDriver::deployment_description_kvm(
|
||||
<< "\t\t\t<source dev='" << vm->get_remote_system_dir()
|
||||
<< "/disk." << disk_id << "'/>" << endl;
|
||||
}
|
||||
else if ( type == "RBD" )
|
||||
{
|
||||
file << "\t\t<disk type='network' device='disk'>" << endl
|
||||
<< "\t\t\t<source protocol='rbd' name='"
|
||||
<< source;
|
||||
|
||||
if ( clone == "YES" )
|
||||
{
|
||||
file << "-" << vm->get_oid() << "-" << disk_id;
|
||||
}
|
||||
|
||||
file << "'/>" << endl;
|
||||
}
|
||||
else if ( type == "CDROM" )
|
||||
{
|
||||
file << "\t\t<disk type='file' device='cdrom'>" << endl
|
||||
|
Loading…
x
Reference in New Issue
Block a user