1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

M #-: fix S3 download in vCenter DS (#252)

Co-authored-by: Tino Vázquez <cvazquez@opennebula.io>
(cherry picked from commit e43e62503292d0d90137f6db53b5e40d0c6bb088)
This commit is contained in:
Alejandro Huertas Herrero 2020-09-28 14:05:45 +02:00 committed by Tino Vazquez
parent cfb8f823d8
commit eced77806d
No known key found for this signature in database
GPG Key ID: 2FE9C32E94AEABBE
2 changed files with 13 additions and 11 deletions

View File

@ -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

View File

@ -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)