1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Update lib/fog/vsphere/requests/compute/vm_clone.rb

Added more options for destination folder to copy new clone to. (No Checks on if new dest_folder exists). ln 128 - 130
Added resource_pool option is mentioned needing revisit in source. ln 118 & 121
This commit is contained in:
endzyme 2012-10-18 15:31:42 -06:00
parent a48432a3db
commit 7c27d843e6

View file

@ -40,7 +40,7 @@ module Fog
# searching ALL VM's looking for the template.
# Tap gets rid of the leading empty string and "Datacenters" element
# and returns the array.
path_elements = options['path'].split('/').tap { |ary| ary.shift 2 }
path_elements = options['template_location'].split('/').tap { |ary| ary.shift 2 }
# The DC name itself.
template_dc = path_elements.shift
# If the first path element contains "vm" this denotes the vmFolder
@ -115,17 +115,19 @@ module Fog
vm_mob_ref.ReconfigVM_Task(:spec => disk_spec).wait_for_completion
end
# Next, create a Relocation Spec instance
relocation_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(:pool => resource_pool,
relocation_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(:pool => option.has_key?('resource_pool') ? options['resource_pool'] : resource_pool,
:diskMoveType => :moveChildMostDiskBacking)
else
relocation_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(:pool => resource_pool,
relocation_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(:pool => option.has_key?('resource_pool') ? options['resource_pool'] : resource_pool,
:transform => options['transform'] || 'sparse')
end
# And the clone specification
clone_spec = RbVmomi::VIM.VirtualMachineCloneSpec(:location => relocation_spec,
:powerOn => options.has_key?('power_on') ? options['power_on'] : true,
:template => false)
task = vm_mob_ref.CloneVM_Task(:folder => vm_mob_ref.parent, :name => options['name'], :spec => clone_spec)
task = vm_mob_ref.CloneVM_Task(:folder => options.has_key?('dest_folder') ? options['dest_folder'] : vm_mob_ref.parent,
:name => options['name'],
:spec => clone_spec)
# Waiting for the VM to complete allows us to get the VirtulMachine
# object of the new machine when it's done. It is HIGHLY recommended
# to set 'wait' => true if your app wants to wait. Otherwise, you're