diff --git a/src/datastore_mad/remotes/downloader.sh b/src/datastore_mad/remotes/downloader.sh index dcdee6ac79..dc927270cb 100755 --- a/src/datastore_mad/remotes/downloader.sh +++ b/src/datastore_mad/remotes/downloader.sh @@ -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 \ No newline at end of file diff --git a/src/datastore_mad/remotes/vcenter/cp b/src/datastore_mad/remotes/vcenter/cp index 2c26df49f7..32c675fbd0 100755 --- a/src/datastore_mad/remotes/vcenter/cp +++ b/src/datastore_mad/remotes/vcenter/cp @@ -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 diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb b/src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb index 48d7739ad7..1c7ee0aa30 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/datastore.rb @@ -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"