mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Expire hosts in 'ready' pool with uptimes exceeding TTL
This commit is contained in:
parent
0a0177e226
commit
29ad2b9e09
1 changed files with 17 additions and 0 deletions
|
|
@ -63,6 +63,19 @@ def check_pending_vm vm, pool, timeout
|
|||
}
|
||||
end
|
||||
|
||||
def check_ready_vm vm, pool, ttl
|
||||
Thread.new {
|
||||
host = $vsphere_helper.find_vms(vm)[vm]
|
||||
|
||||
if ((((Time.now - host.runtime.bootTime)/60).to_s[/^\d+\.\d{1}/].to_f) > ttl)
|
||||
$redis.srem('vmware_host_pool__ready__'+pool, vm)
|
||||
$redis.sadd('vmware_host_pool__completed__'+pool, vm)
|
||||
|
||||
$logger.log('d', "[!] [#{pool}] '#{vm}' reached end of TTL after #{ttl} minutes")
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
# Clone a VM
|
||||
def clone_vm template, pool, folder, datastore
|
||||
Thread.new {
|
||||
|
|
@ -186,6 +199,10 @@ pools.each do |pool|
|
|||
if (! inventory[vm])
|
||||
$redis.srem('vmware_host_pool__ready__'+pool['name'], vm)
|
||||
end
|
||||
|
||||
if (pool['ttl'])
|
||||
check_ready_vm(vm, pool['name'], pool['ttl'])
|
||||
end
|
||||
end
|
||||
|
||||
# PENDING
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue