mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 18:08:42 -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
|
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
|
# Clone a VM
|
||||||
def clone_vm template, pool, folder, datastore
|
def clone_vm template, pool, folder, datastore
|
||||||
Thread.new {
|
Thread.new {
|
||||||
|
|
@ -186,6 +199,10 @@ pools.each do |pool|
|
||||||
if (! inventory[vm])
|
if (! inventory[vm])
|
||||||
$redis.srem('vmware_host_pool__ready__'+pool['name'], vm)
|
$redis.srem('vmware_host_pool__ready__'+pool['name'], vm)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (pool['ttl'])
|
||||||
|
check_ready_vm(vm, pool['name'], pool['ttl'])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# PENDING
|
# PENDING
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue