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
Made requested changes and typo fix. Added backwards compatibility for options['path'] on vm_clone(). New recommended option is options['template_path'].
This commit is contained in:
parent
7c27d843e6
commit
a9eb189f7a
1 changed files with 6 additions and 3 deletions
|
@ -34,13 +34,16 @@ module Fog
|
||||||
# Option handling
|
# Option handling
|
||||||
options = vm_clone_check_options(options)
|
options = vm_clone_check_options(options)
|
||||||
|
|
||||||
|
# Added for people still using options['path']
|
||||||
|
template_path = options['path'] || options['template_path']
|
||||||
|
|
||||||
notfound = lambda { raise Fog::Compute::Vsphere::NotFound, "Could not find VM template" }
|
notfound = lambda { raise Fog::Compute::Vsphere::NotFound, "Could not find VM template" }
|
||||||
|
|
||||||
# Find the template in the folder. This is more efficient than
|
# Find the template in the folder. This is more efficient than
|
||||||
# searching ALL VM's looking for the template.
|
# searching ALL VM's looking for the template.
|
||||||
# Tap gets rid of the leading empty string and "Datacenters" element
|
# Tap gets rid of the leading empty string and "Datacenters" element
|
||||||
# and returns the array.
|
# and returns the array.
|
||||||
path_elements = options['template_location'].split('/').tap { |ary| ary.shift 2 }
|
path_elements = template_path.split('/').tap { |ary| ary.shift 2 }
|
||||||
# The DC name itself.
|
# The DC name itself.
|
||||||
template_dc = path_elements.shift
|
template_dc = path_elements.shift
|
||||||
# If the first path element contains "vm" this denotes the vmFolder
|
# If the first path element contains "vm" this denotes the vmFolder
|
||||||
|
@ -115,10 +118,10 @@ module Fog
|
||||||
vm_mob_ref.ReconfigVM_Task(:spec => disk_spec).wait_for_completion
|
vm_mob_ref.ReconfigVM_Task(:spec => disk_spec).wait_for_completion
|
||||||
end
|
end
|
||||||
# Next, create a Relocation Spec instance
|
# Next, create a Relocation Spec instance
|
||||||
relocation_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(:pool => option.has_key?('resource_pool') ? options['resource_pool'] : resource_pool,
|
relocation_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(:pool => options.has_key?('resource_pool') ? options['resource_pool'] : resource_pool,
|
||||||
:diskMoveType => :moveChildMostDiskBacking)
|
:diskMoveType => :moveChildMostDiskBacking)
|
||||||
else
|
else
|
||||||
relocation_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(:pool => option.has_key?('resource_pool') ? options['resource_pool'] : resource_pool,
|
relocation_spec = RbVmomi::VIM.VirtualMachineRelocateSpec(:pool => options.has_key?('resource_pool') ? options['resource_pool'] : resource_pool,
|
||||||
:transform => options['transform'] || 'sparse')
|
:transform => options['transform'] || 'sparse')
|
||||||
end
|
end
|
||||||
# And the clone specification
|
# And the clone specification
|
||||||
|
|
Loading…
Reference in a new issue