mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
TM shared drivers compatibility with VMware
This commit is contained in:
parent
f2e6303c3e
commit
961e368116
@ -27,6 +27,7 @@ ISCSIADM=iscsiadm
|
||||
LVCREATE=lvcreate
|
||||
LVREMOVE=lvremove
|
||||
LVS=lvs
|
||||
LN=ln
|
||||
MD5SUM=md5sum
|
||||
MKFS=mkfs
|
||||
MKISOFS=mkisofs
|
||||
|
@ -73,6 +73,9 @@ exec_and_log "$MKISOFS -o $ISO_FILE -J -R $ISO_DIR" "Error creating iso fs"
|
||||
|
||||
exec_and_log "$SCP $ISO_FILE $DST" "Error copying context ISO to $DST"
|
||||
|
||||
# Creates symbolic link to add a .iso suffix, needed for VMware CDROMs
|
||||
ssh_exec_and_log $DST_HOST "$LN -s $DST_PATH $DST_PATH.iso" "Error creating ISO symbolic link"
|
||||
|
||||
rm -rf $ISO_DIR > /dev/null 2>&1
|
||||
|
||||
exit 0
|
||||
|
@ -16,7 +16,7 @@
|
||||
# limitations under the License. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# ln fe:SOURCE host:remote_system_ds/disk.i size
|
||||
# ln fe:SOURCE host:remote_system_ds/disk.i
|
||||
# - 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
|
||||
@ -43,16 +43,41 @@ DST_PATH=`arg_path $DST`
|
||||
DST_HOST=`arg_host $DST`
|
||||
DST_DIR=`dirname $DST_PATH`
|
||||
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Link (ln) SRC into DST
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
log "Linking $SRC_PATH in $DST"
|
||||
# Is it a file or a folder (VMware)?
|
||||
if [ -d `arg_path $SRC` ]; then
|
||||
ssh_make_path $DST_HOST $DST_PATH
|
||||
|
||||
# It's a folder, make links for all elements
|
||||
SRC_FOLDER_NAME=`basename $SRC_PATH`
|
||||
SRC_WITH_NO_FOLDER=`dirname $SRC_PATH`
|
||||
SRC_DS_NAME=`basename $SRC_WITH_NO_FOLDER`
|
||||
REL_SRC_PATH="../../../$SRC_DS_NAME/$SRC_FOLDER_NAME"
|
||||
|
||||
log "Link all files in $SRC_PATH to $DST_PATH"
|
||||
|
||||
LINK_SCRIPT=$(cat <<EOF
|
||||
for file in \$(cd $DST_DIR ; find $SRC_PATH -type f); do
|
||||
FNAME=\$(basename \$file)
|
||||
(cd $DST_PATH ; ln -sf $REL_SRC_PATH/\$FNAME $DST_PATH/$FNAME)
|
||||
done
|
||||
EOF
|
||||
)
|
||||
ssh_exec_and_log $DST_HOST "$LINK_SCRIPT" "Could not link dir files from source DS to system DS"
|
||||
else
|
||||
ssh_make_path $DST_HOST $DST_DIR
|
||||
|
||||
# Just link a file
|
||||
log "Linking $SRC_PATH in $DST"
|
||||
|
||||
ssh_exec_and_log $DST_HOST \
|
||||
"cd $DST_DIR; ln -s $SRC_PATH $DST_PATH" \
|
||||
"Error linking $SRC to $DST"
|
||||
fi
|
||||
|
||||
ssh_exec_and_log $DST_HOST \
|
||||
"cd $DST_DIR; ln -s $SRC_PATH $DST_PATH" \
|
||||
"Error linking $SRC to $DST"
|
||||
|
||||
exit 0
|
||||
|
||||
|
@ -70,3 +70,18 @@ function is_disk
|
||||
echo "0"
|
||||
fi
|
||||
}
|
||||
|
||||
#Makes path src ($1) relative to dst ($2)
|
||||
function make_relative {
|
||||
src=$1
|
||||
dst=$2
|
||||
|
||||
common=$dst
|
||||
|
||||
while [ -z "`echo $src | grep -E "^$common"`" ]; do
|
||||
common=`dirname $common`
|
||||
dots="../$dots"
|
||||
done
|
||||
|
||||
echo $dots${src#$common/}
|
||||
}
|
||||
|
@ -222,19 +222,19 @@ int LibVirtDriver::deployment_description_vmware(
|
||||
{
|
||||
file << "\t\t<disk type='block' device='disk'>" << endl;
|
||||
file << "\t\t\t<source file=[" << datastore << "] " << vm->get_oid()
|
||||
<< "/images/disk." << i << "'/>" << endl;
|
||||
<< "/disk." << i << "'/>" << endl;
|
||||
}
|
||||
else if ( type == "CDROM" )
|
||||
{
|
||||
file << "\t\t<disk type='file' device='cdrom'>" << endl;
|
||||
file << "\t\t\t<source file=[" << datastore << "] " << vm->get_oid()
|
||||
<< "/images/disk." << i << ".iso'/>" << endl;
|
||||
<< "/disk." << i << ".iso'/>" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
file << "\t\t<disk type='file' device='disk'>" << endl
|
||||
<< "\t\t\t<source file='[" << datastore <<"] " << vm->get_oid()
|
||||
<< "/images/disk." << i << "/disk.vmdk'/>" << endl;
|
||||
<< "/disk." << i << "/disk.vmdk'/>" << endl;
|
||||
}
|
||||
|
||||
file << "\t\t\t<target dev='" << target << "'";
|
||||
|
@ -28,8 +28,9 @@ MEMORY = 256
|
||||
OS = [ ARCH = i686 ]
|
||||
DISK = [ DRIVER = file ]
|
||||
|
||||
# Name of the datastore in the remote VMware hypervisors
|
||||
# mounting $ONE_LOCATION/var exported as a nfs share
|
||||
# by the OpenNebula front-end
|
||||
# Name of the system datastore in the remote VMware hypervisors
|
||||
# mounting DATASTORE_LOCATION/var/datastore/0 exported as a nfs share
|
||||
# by the OpenNebula front-end. This would need to be changed
|
||||
# *only* with custom TM drivers
|
||||
|
||||
DATASTORE = images
|
||||
DATASTORE = 0
|
||||
|
@ -165,7 +165,8 @@ class VMwareDriver
|
||||
def restore(checkpoint)
|
||||
begin
|
||||
# Define the VM
|
||||
dfile = File.dirname(File.dirname(checkpoint)) + "/deployment.0"
|
||||
dfile = VAR_LOCATION + "/" +
|
||||
File.basename(File.dirname(checkpoint)) + "/deployment.0"
|
||||
rescue => e
|
||||
OpenNebula.log_error("Cannot open checkpoint #{e.message}")
|
||||
exit -1
|
||||
|
Loading…
x
Reference in New Issue
Block a user