mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-06 12:58:18 +03:00
Feature #1112: New datastore drivers for vmware
This commit is contained in:
parent
30f981e92f
commit
a107c22734
11
install.sh
11
install.sh
@ -237,6 +237,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/hooks/ft \
|
||||
$VAR_LOCATION/remotes/datastore \
|
||||
$VAR_LOCATION/remotes/datastore/fs \
|
||||
$VAR_LOCATION/remotes/datastore/vmware \
|
||||
$VAR_LOCATION/remotes/auth \
|
||||
$VAR_LOCATION/remotes/auth/plain \
|
||||
$VAR_LOCATION/remotes/auth/ssh \
|
||||
@ -387,6 +388,7 @@ INSTALL_FILES=(
|
||||
LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm
|
||||
DATASTORE_DRIVER_COMMON_SCRIPTS:$VAR_LOCATION/remotes/datastore/
|
||||
DATASTORE_DRIVER_FS_SCRIPTS:$VAR_LOCATION/remotes/datastore/fs
|
||||
DATASTORE_DRIVER_VMWARE_SCRIPTS:$VAR_LOCATION/remotes/datastore/vmware
|
||||
NETWORK_FILES:$VAR_LOCATION/remotes/vnm
|
||||
NETWORK_8021Q_FILES:$VAR_LOCATION/remotes/vnm/802.1Q
|
||||
NETWORK_DUMMY_FILES:$VAR_LOCATION/remotes/vnm/dummy
|
||||
@ -526,6 +528,7 @@ INSTALL_ETC_FILES=(
|
||||
VMM_EC2_ETC_FILES:$ETC_LOCATION/vmm_ec2
|
||||
VMM_EXEC_ETC_FILES:$ETC_LOCATION/vmm_exec
|
||||
DATASTORE_DRIVER_FS_ETC_FILES:$ETC_LOCATION/datastore/
|
||||
DATASTORE_DRIVER_VMWARE_ETC_FILES:$ETC_LOCATION/datastore/
|
||||
IM_EC2_ETC_FILES:$ETC_LOCATION/im_ec2
|
||||
TM_SHARED_ETC_FILES:$ETC_LOCATION/tm_shared
|
||||
TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh
|
||||
@ -798,10 +801,13 @@ VMWARE_TM_COMMANDS_LIB_FILES="src/tm_mad/vmware/tm_clone.sh \
|
||||
#-------------------------------------------------------------------------------
|
||||
# Datastore drivers, to be installed under $REMOTES_LOCATION/datastore
|
||||
# - FS based Image Repository, $REMOTES_LOCATION/datastore/fs
|
||||
# - VMware based Image Repository, $REMOTES_LOCATION/datastore/vmware
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
DATASTORE_DRIVER_FS_ETC_FILES="src/datastore_mad/remotes/fs/fs.conf"
|
||||
|
||||
DATASTORE_DRIVER_VMWARE_ETC_FILES="src/datastore_mad/remotes/vmware/vmware.conf"
|
||||
|
||||
DATASTORE_DRIVER_COMMON_SCRIPTS="src/datastore_mad/remotes/xpath.rb \
|
||||
src/datastore_mad/remotes/libfs.sh"
|
||||
|
||||
@ -810,6 +816,11 @@ DATASTORE_DRIVER_FS_SCRIPTS="src/datastore_mad/remotes/fs/cp \
|
||||
src/datastore_mad/remotes/fs/mv \
|
||||
src/datastore_mad/remotes/fs/rm"
|
||||
|
||||
DATASTORE_DRIVER_VMWARE_SCRIPTS="src/datastore_mad/remotes/vmware/cp \
|
||||
src/datastore_mad/remotes/vmware/mkfs \
|
||||
src/datastore_mad/remotes/vmware/mv \
|
||||
src/datastore_mad/remotes/vmware/rm"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Migration scripts for onedb command, to be installed under $LIB_LOCATION
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -350,7 +350,9 @@ TM_MAD = [
|
||||
|
||||
DATASTORE_MAD = [
|
||||
executable = "one_datastore",
|
||||
arguments = "-t 15 -d fs" ]
|
||||
arguments = "-t 15 -d fs"
|
||||
# arguments = "-t 15 -d fs,vmware"
|
||||
]
|
||||
|
||||
#*******************************************************************************
|
||||
# Hook Manager Configuration
|
||||
|
@ -57,29 +57,6 @@ http://*)
|
||||
exec_and_log "chmod 0660 $DST"
|
||||
;;
|
||||
|
||||
vmware://*)
|
||||
SRC=`echo $SRC|sed 's/vmware:\/\///g'`
|
||||
|
||||
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 disk folder $SRC to the image repository"
|
||||
|
||||
exec_and_log "cp -rf $SRC $DST" "Error copying $SRC to $DST"
|
||||
|
||||
if [ ! -f $DST/disk.vmdk ]; then
|
||||
BASE_DISK_FILE=`ls $DST | grep -v '.*-s[0-9]*\.vmdk'`
|
||||
|
||||
exec_and_log "mv -f $DST/$BASE_DISK_FILE $DST/disk.vmdk" \
|
||||
"Error renaming disk file $BASE_DISK_FILE to disk.vmdk"
|
||||
fi
|
||||
|
||||
exec_and_log "chmod 0770 $DST"
|
||||
;;
|
||||
|
||||
*)
|
||||
if [ `check_restricted $SRC` -eq 1 ]; then
|
||||
log_error "Not allowed to copy images from $RESTRICTED_DIRS"
|
||||
|
86
src/datastore_mad/remotes/vmware/cp
Executable file
86
src/datastore_mad/remotes/vmware/cp
Executable file
@ -0,0 +1,86 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# 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
|
||||
|
||||
# -------- Get cp and datastore arguments from OpenNebula core ------------
|
||||
|
||||
DRV_ACTION=$1
|
||||
ID=$2
|
||||
|
||||
set_up_datastore $DRV_ACTION
|
||||
|
||||
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
||||
eval "SRC=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/PATH`"
|
||||
|
||||
DST=`generate_image_path`
|
||||
|
||||
# ------------ Copy the image to the repository -------------
|
||||
|
||||
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
|
||||
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 disk folder $SRC to the image repository"
|
||||
|
||||
exec_and_log "cp -rf $SRC $DST" "Error copying $SRC to $DST"
|
||||
|
||||
if [ ! -f $DST/disk.vmdk ]; then
|
||||
BASE_DISK_FILE=`ls $DST | grep -v '.*-s[0-9]*\.vmdk'`
|
||||
|
||||
exec_and_log "mv -f $DST/$BASE_DISK_FILE $DST/disk.vmdk" \
|
||||
"Error renaming disk file $BASE_DISK_FILE to disk.vmdk"
|
||||
fi
|
||||
|
||||
exec_and_log "chmod 0770 $DST"
|
||||
;;
|
||||
esac
|
||||
|
||||
# ---------------- Get the size of the image ------------
|
||||
|
||||
SIZE=`fs_du $DST`
|
||||
|
||||
echo "$DST $SIZE"
|
63
src/datastore_mad/remotes/vmware/mkfs
Executable file
63
src/datastore_mad/remotes/vmware/mkfs
Executable file
@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# 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
|
||||
|
||||
# -------- Get mkfs and datastore arguments from OpenNebula core ------------
|
||||
|
||||
DRV_ACTION=$1
|
||||
ID=$2
|
||||
|
||||
set_up_datastore $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`"
|
||||
|
||||
DST=`generate_image_path`
|
||||
|
||||
# ------------ Create the image to the repository ------------
|
||||
|
||||
MKFS_CMD=`mkfs_command $DST $FSTYPE`
|
||||
|
||||
exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M" \
|
||||
"Could not create image $DST"
|
||||
exec_and_log "$MKFS_CMD" \
|
||||
"Unable to create filesystem $FSTYPE in $DST"
|
||||
exec_and_log "chmod 0660 $DST"
|
||||
|
||||
# ---------------- Get the size of the image ------------
|
||||
SIZE=`fs_du $DST`
|
||||
|
||||
echo "$DST $SIZE"
|
75
src/datastore_mad/remotes/vmware/mv
Executable file
75
src/datastore_mad/remotes/vmware/mv
Executable file
@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# 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 move a VM image (SRC) to the image repository as DST
|
||||
# Several SRC types are supported
|
||||
###############################################################################
|
||||
|
||||
# ------------ 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
|
||||
source $(dirname $0)/fsrc
|
||||
|
||||
SRC=$1
|
||||
DST=$2
|
||||
ID=$3
|
||||
|
||||
# ------------ Generate a filename for the image ------------
|
||||
|
||||
if [ "$DST" = "-" ] ; then
|
||||
DST=`generate_image_path`
|
||||
fi
|
||||
|
||||
# ------------ Move the image to the repository ------------
|
||||
|
||||
case $SRC in
|
||||
http://*)
|
||||
log "Downloading $SRC to the image repository"
|
||||
exec_and_log "$WGET -O $DST $SRC" \
|
||||
"Error downloading $SRC"
|
||||
;;
|
||||
|
||||
*)
|
||||
log "Moving local image $SRC to the image repository"
|
||||
|
||||
if [ \( -L $SRC \) -a \
|
||||
\( "`$READLINK -f $SRC`" = "`$READLINK -f $DST`" \) ] ; then
|
||||
log "Not moving files to image repo, they are the same"
|
||||
else
|
||||
exec_and_log "mv -f $SRC $DST" "Could not move $SRC to $DST"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -d $DST ]; then
|
||||
exec_and_log "chmod 0770 $DST"
|
||||
else
|
||||
exec_and_log "chmod 0660 $DST"
|
||||
fi
|
||||
|
||||
# ---------------- Get the size of the image ------------
|
||||
SIZE=`fs_du $DST`
|
||||
|
||||
echo "$DST $SIZE"
|
50
src/datastore_mad/remotes/vmware/rm
Executable file
50
src/datastore_mad/remotes/vmware/rm
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# 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
|
||||
|
||||
# -------- Get rm and datastore arguments from OpenNebula core ------------
|
||||
|
||||
DRV_ACTION=$1
|
||||
ID=$2
|
||||
|
||||
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
|
||||
eval "SRC=`$XPATH /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE`"
|
||||
|
||||
# ------------ Remove the image from the repository ------------
|
||||
|
||||
if [ -e $SRC ] ; then
|
||||
log "Removing $SRC from the image repository"
|
||||
exec_and_log "rm -r $SRC" \
|
||||
"Error deleting $SRC"
|
||||
fi
|
38
src/datastore_mad/remotes/vmware/vmware.conf
Normal file
38
src/datastore_mad/remotes/vmware/vmware.conf
Normal file
@ -0,0 +1,38 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# PRESERVE BASH SYNTAX
|
||||
|
||||
#*******************************************************************************
|
||||
# DEFAULT Configuration File for File-System based Datastores
|
||||
#-------------------------------------------------------------------------------
|
||||
# BASE_PATH: Path where the images will be stored. If not defined
|
||||
# defaults to /var/lib/one/images or $ONE_LOCATION/var/images
|
||||
#
|
||||
# RESTRICTED_DIRS: Paths that can not be used to register images. A space
|
||||
# separated list of paths. This prevents users to access important files like
|
||||
# oned.db or /etc/shadow. OpenNebula will automatically add its configuration
|
||||
# dirs:/var/lib/one, /etc/one and oneadmin's home ($HOME).
|
||||
#
|
||||
# SAFE_DIRS: Paths that are safe to specify image paths. A space separated list
|
||||
# of paths.This will allow you to open specific paths within RESTRICTED_DIRS
|
||||
#*******************************************************************************
|
||||
|
||||
#BASE_PATH=/var/lib/one/images
|
||||
|
||||
RESTRICTED_DIRS="/etc/"
|
||||
|
||||
SAFE_DIRS="$HOME/public/"
|
Loading…
x
Reference in New Issue
Block a user