mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
F #4913: Fix folder and filename for image upload in datastore cp action
This commit is contained in:
parent
54ae0257a2
commit
cd70c16d38
@ -62,8 +62,8 @@ target_path = "#{ds_image_dir}/#{id}"
|
||||
# or if is a zipped file it has to be unzipped in a temp folder
|
||||
|
||||
if VCenterDriver::FileHelper.is_remote_or_needs_unpack?(img_path)
|
||||
temp_folder = File.join(VAR_LOCATION, "vcenter")
|
||||
temp_file = File.join(temp_folder, File.basename(target_path))
|
||||
temp_folder = File.join(VAR_LOCATION, "vcenter/#{target_path}")
|
||||
temp_file = File.join(temp_folder, File.basename(img_path))
|
||||
|
||||
# Create tmp directory
|
||||
FileUtils.mkdir_p(temp_folder)
|
||||
@ -120,13 +120,18 @@ files_to_upload.each_with_index do |f, index|
|
||||
end
|
||||
end
|
||||
|
||||
# Change path if vmdk is part of filename
|
||||
# but it's not the extension'
|
||||
# Change path if vmdk is part of filename but it's not the extension
|
||||
if /[^.]+vmdk$/.match(path) && VCenterDriver::FileHelper.is_vmdk?(f)
|
||||
path.gsub!(/vmdk$/,'')
|
||||
extension = '.vmdk'
|
||||
end
|
||||
|
||||
# Add iso extension if file is an ISO file
|
||||
if VCenterDriver::FileHelper.is_iso?(f)
|
||||
path = "#{File.dirname(path)}/#{File.basename(path,".*")}"
|
||||
extension = '.iso'
|
||||
end
|
||||
|
||||
if index == files_to_upload.size - 1
|
||||
uploader_args = host_id + " " + ds_ref + " " +
|
||||
"#{path}#{extension}" + " " + f
|
||||
|
@ -10,13 +10,10 @@ class FileHelper
|
||||
return disk["SOURCE"]
|
||||
else
|
||||
disk_id = disk["DISK_ID"]
|
||||
if disk["SOURCE"]
|
||||
image_name = disk["SOURCE"].split(".").first
|
||||
return "#{image_name}-#{vm_id}-#{disk_id}.vmdk"
|
||||
else
|
||||
ds_volatile_dir = disk["VCENTER_DS_VOLATILE_DIR"] || "one-volatile"
|
||||
return "#{ds_volatile_dir}/#{vm_id}/one-#{vm_id}-#{disk_id}.vmdk"
|
||||
end
|
||||
return disk["SOURCE"] if disk["SOURCE"]
|
||||
|
||||
ds_volatile_dir = disk["VCENTER_DS_VOLATILE_DIR"] || "one-volatile"
|
||||
return "#{ds_volatile_dir}/#{vm_id}/one-#{vm_id}-#{disk_id}.vmdk"
|
||||
end
|
||||
end
|
||||
|
||||
@ -38,6 +35,12 @@ class FileHelper
|
||||
type.include? "VMware"
|
||||
end
|
||||
|
||||
def self.is_iso?(file)
|
||||
type = %x{file #{file}}
|
||||
|
||||
type.include? "ISO"
|
||||
end
|
||||
|
||||
def self.get_type(file)
|
||||
type = %x{file -b --mime-type #{file}}
|
||||
if $?.exitstatus != 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user