mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
F #2320 Migrate images to/from KVM / vCenter DS
* F #2320 Migrate images to/from KVM / vCenter DS * Update cp
This commit is contained in:
parent
e15cb51964
commit
7855c5e1df
@ -224,7 +224,7 @@ function get_rbd_cmd
|
||||
echo "ssh '$(esc_sq "$DST_HOST")' \"$RBD export '$(esc_sq "$SOURCE")' -\""
|
||||
}
|
||||
|
||||
TEMP=`getopt -o m:s:l:c:n -l md5:,sha1:,limit:,max-size:,nodecomp -- "$@"`
|
||||
TEMP=`getopt -o m:s:l:c:n -l md5:,sha1:,limit:,max-size:,convert:,nodecomp -- "$@"`
|
||||
|
||||
if [ $? != 0 ] ; then
|
||||
echo "Arguments error" >&2
|
||||
@ -257,6 +257,10 @@ while true; do
|
||||
export MAX_SIZE="$2"
|
||||
shift 2
|
||||
;;
|
||||
--convert)
|
||||
export CONVERT="$2"
|
||||
shift 2
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
@ -389,7 +393,24 @@ if [ -n "$HASH_TYPE" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
function convert_image
|
||||
{
|
||||
original_type=$(qemu-img info $TO | grep "^file format:" | awk '{print $3}' || :)
|
||||
if [ "$CONVERT" != "$original_type" ]; then
|
||||
tmpimage=$TO".tmp"
|
||||
qemu-img convert -f $original_type -O $CONVERT $TO $tmpimage
|
||||
mv $tmpimage $TO
|
||||
fi
|
||||
}
|
||||
|
||||
# Unarchive only if the destination is filesystem
|
||||
if [ "$TO" != "-" ]; then
|
||||
unarchive "$TO"
|
||||
fi
|
||||
|
||||
if [ -n "$CONVERT" ] && [ -f "$TO" ]; then
|
||||
convert_image
|
||||
fi
|
||||
|
||||
elif [ -n "$CONVERT" ]; then
|
||||
convert_image
|
||||
fi
|
@ -92,6 +92,7 @@ if VCenterDriver::FileHelper.is_remote_or_needs_unpack?(img_path)
|
||||
downsh_args << "--sha1 #{sha1} " if sha1 && !sha1.empty?
|
||||
downsh_args << "--nodecomp " if nodecomp && !nodecomp.empty?
|
||||
downsh_args << "--limit #{limit_bw} " if limit_bw && !limit_bw.empty?
|
||||
downsh_args << '--convert vmdk'
|
||||
|
||||
downloader = "#{File.dirname(__FILE__)}/../downloader.sh #{downsh_args}"
|
||||
|
||||
@ -164,6 +165,6 @@ files_to_upload.each_with_index do |f, index|
|
||||
FileUtils.rm_rf(temp_file) if temp_file
|
||||
exit(-1)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
FileUtils.rm_rf(temp_file) if temp_file
|
||||
|
@ -183,6 +183,7 @@ class Storage
|
||||
|
||||
def to_one(ds_hash, vcenter_uuid, dc_name, dc_ref)
|
||||
one = ""
|
||||
one << "DRIVER=\"vcenter\"\n"
|
||||
one << "NAME=\"#{ds_hash[:name]}\"\n"
|
||||
one << "TM_MAD=vcenter\n"
|
||||
one << "VCENTER_INSTANCE_ID=\"#{vcenter_uuid}\"\n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user