mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-20 10:50:08 +03:00
B #2667: vCenter ds_mad can clone isos
This commit is contained in:
parent
ab1a05b69b
commit
896035c0fc
src
@ -53,10 +53,9 @@ source_ds = VCenterDriver::VIHelper.one_item(OpenNebula::Datastore, source_ds_id
|
||||
source_ds_ref = source_ds['TEMPLATE/VCENTER_DS_REF']
|
||||
|
||||
# Generate target path
|
||||
target_path = "#{ds_image_dir}/#{id}/one-#{id}.vmdk"
|
||||
target_path = "#{ds_image_dir}/#{id}/one-#{id}"
|
||||
|
||||
begin
|
||||
|
||||
vi_client = VCenterDriver::VIClient.new_from_datastore(source_ds_id)
|
||||
|
||||
ds = VCenterDriver::Datastore.new_from_ref(source_ds_ref, vi_client)
|
||||
@ -65,6 +64,10 @@ begin
|
||||
|
||||
target_ds_name = target_ds_vc['name']
|
||||
|
||||
ext = File.extname(src_path)
|
||||
ext = '.vmdk' if ext.empty?
|
||||
target_path << ext
|
||||
|
||||
puts ds.copy_virtual_disk(src_path, target_ds_vc, target_path)
|
||||
|
||||
rescue Exception => e
|
||||
|
@ -351,22 +351,27 @@ class Datastore < Storage
|
||||
end
|
||||
|
||||
copy_params = {
|
||||
:sourceName => "[#{source_ds_name}] #{src_path}",
|
||||
:sourceDatacenter => get_dc.item,
|
||||
:destName => "[#{target_ds_name}] #{target_path}"
|
||||
:sourceName => "[#{source_ds_name}] #{src_path}",
|
||||
:sourceDatacenter => get_dc.item
|
||||
}
|
||||
|
||||
get_vdm.CopyVirtualDisk_Task(copy_params).wait_for_completion
|
||||
if File.extname(src_path) == '.vmdk'
|
||||
copy_params[:destName] = "[#{target_ds_name}] #{target_path}"
|
||||
get_vdm.CopyVirtualDisk_Task(copy_params).wait_for_completion
|
||||
|
||||
if new_size
|
||||
resize_spec = {
|
||||
:name => "[#{target_ds_name}] #{target_path}",
|
||||
:datacenter => target_ds.get_dc.item,
|
||||
:newCapacityKb => new_size,
|
||||
:eagerZero => false
|
||||
}
|
||||
if new_size
|
||||
resize_spec = {
|
||||
:name => "[#{target_ds_name}] #{target_path}",
|
||||
:datacenter => target_ds.get_dc.item,
|
||||
:newCapacityKb => new_size,
|
||||
:eagerZero => false
|
||||
}
|
||||
|
||||
get_vdm.ExtendVirtualDisk_Task(resize_spec).wait_for_completion
|
||||
get_vdm.ExtendVirtualDisk_Task(resize_spec).wait_for_completion
|
||||
end
|
||||
else
|
||||
copy_params[:destinationName] = "[#{target_ds_name}] #{target_path}"
|
||||
get_fm.CopyDatastoreFile_Task(copy_params)
|
||||
end
|
||||
|
||||
target_path
|
||||
|
Loading…
x
Reference in New Issue
Block a user