diff --git a/src/datastore_mad/remotes/vcenter/cp b/src/datastore_mad/remotes/vcenter/cp index 9f0892a49a..ec4ccaba7d 100755 --- a/src/datastore_mad/remotes/vcenter/cp +++ b/src/datastore_mad/remotes/vcenter/cp @@ -106,8 +106,9 @@ if VCenterDriver::FileHelper.is_remote_or_needs_unpack?(img_path) downsh_args << '--convert vmdk' downloader = "#{File.dirname(__FILE__)}/../downloader.sh #{downsh_args}" + b64 = Base64.encode64(drv_action.to_xml).gsub!("\n", '') - rc = system("#{downloader} #{img_path} #{temp_file}") + rc = system("DRV_ACTION=#{b64} #{downloader} #{img_path} #{temp_file}") if there_is_not_system_error?(rc) STDERR.puts "Error downloading #{img_path}" @@ -171,17 +172,18 @@ files_to_upload.each_with_index do |f, index| cmd = "#{File.dirname(__FILE__)}/../vcenter_uploader.rb #{uploader_args}" - stdout_str, status = Open3.capture2(cmd) + target, stderr, status = Open3.capture3(cmd) + + if !status.success? + STDERR.puts "Cannot upload file #{f}: #{stderr}" + FileUtils.rm_rf(temp_file) if temp_file + exit(-1) + end if last_file_to_upload?(index, files_to_upload) puts stdout_str + puts "#{target.gsub("\n", '')} vmdk" end - - next if status.success? - - STDERR.puts "Cannot upload file #{f}" - FileUtils.rm_rf(temp_file) if temp_file - exit(-1) end FileUtils.rm_rf(temp_file) if temp_file diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/file_helper.rb b/src/vmm_mad/remotes/lib/vcenter_driver/file_helper.rb index 8d797bf91a..7dcdb322f9 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/file_helper.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/file_helper.rb @@ -52,8 +52,8 @@ class FileHelper return !is_remote?(file).nil? || needs_unpack?(file) end - def self.is_remote?(file) - file.match(%r{^https?://}) + def self.remote?(file) + file.match(%r{^https?://}) || file.match(%r{^s3?://}) end def self.is_vmdk?(file) @@ -203,7 +203,7 @@ class FileHelper descriptor_name = File.basename vcenter_url.path temp_folder = VAR_LOCATION + "/vcenter/" + descriptor_name + "/" FileUtils.mkdir_p(temp_folder) if !File.directory?(temp_folder) - + image_path = File.dirname(vcenter_url.host+vcenter_url.path) self.download_vmdks(files_to_download, image_path, temp_folder, ds)