mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Merge pull request #21 from sschneid/clone_target
Allow a 'clone_target' configuration setting
This commit is contained in:
commit
cddf7e77e6
3 changed files with 34 additions and 0 deletions
|
|
@ -195,9 +195,15 @@ module Vmpooler
|
|||
})
|
||||
)
|
||||
|
||||
# Choose a clone target
|
||||
if ($config[:config]['clone_target'])
|
||||
$clone_target = $vsphere[vm['template']].find_least_used_host($config[:config]['clone_target'])
|
||||
end
|
||||
|
||||
# Put the VM in the specified folder and resource pool
|
||||
relocateSpec = RbVmomi::VIM.VirtualMachineRelocateSpec(
|
||||
:datastore => $vsphere[vm['template']].find_datastore(datastore),
|
||||
:host => $clone_target,
|
||||
:diskMoveType => :moveChildMostDiskBacking
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,30 @@ module Vmpooler
|
|||
|
||||
|
||||
|
||||
def find_least_used_host cluster
|
||||
begin
|
||||
@connection.serviceInstance.CurrentTime
|
||||
rescue
|
||||
initialize()
|
||||
end
|
||||
|
||||
hosts = Hash.new
|
||||
hosts_sort = Hash.new
|
||||
|
||||
datacenter = @connection.serviceInstance.find_datacenter
|
||||
datacenter.hostFolder.children.each do |folder|
|
||||
next unless folder.name == cluster
|
||||
folder.host.each do |host|
|
||||
hosts[host.name] = host
|
||||
hosts_sort[host.name] = host.vm.length
|
||||
end
|
||||
end
|
||||
|
||||
hosts[hosts_sort.sort_by { |k,v| v }[0][0]]
|
||||
end
|
||||
|
||||
|
||||
|
||||
def find_pool poolname
|
||||
begin
|
||||
@connection.serviceInstance.CurrentTime
|
||||
|
|
|
|||
|
|
@ -83,6 +83,10 @@
|
|||
# The path to vmpooler's log file.
|
||||
# (optional; default: '/var/log/vmpooler.log')
|
||||
#
|
||||
# - clone_target
|
||||
# The target cluster VMs are cloned into (host with least VMs chosen)
|
||||
# (optional; default: same cluster/host as origin template)
|
||||
#
|
||||
# - task_limit
|
||||
# The number of concurrent VMware vSphere tasks to perform.
|
||||
# (optional; default: '10')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue