mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Auto-delete hosts in 'completed' queues
This commit is contained in:
parent
aec1e3ea16
commit
32fee4e0b1
1 changed files with 23 additions and 1 deletions
|
|
@ -109,6 +109,28 @@ loop do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Check 'completed' pool
|
||||||
|
$redis.smembers('vmware_host_pool__completed__'+pool['name']).each do |vm|
|
||||||
|
if ! inventory[vm]
|
||||||
|
$redis.srem('vmware_host_pool__completed__'+pool['name'], vm)
|
||||||
|
end
|
||||||
|
|
||||||
|
start = Time.now
|
||||||
|
host = vsphere_helper.find_vms(vm)[vm]
|
||||||
|
|
||||||
|
if host.runtime
|
||||||
|
if host.runtime.powerState == 'poweredOn'
|
||||||
|
logger.log('d', "[ ] '#{vm}' is being shut down")
|
||||||
|
host.PowerOffVM_Task.wait_for_completion
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
host.Destroy_Task.wait_for_completion
|
||||||
|
finish = '%.2f' % (Time.now-start)
|
||||||
|
|
||||||
|
logger.log('s', "[-] '#{vm}' destroyed in #{finish} seconds")
|
||||||
|
end
|
||||||
|
|
||||||
# Bring the pool up to the desired size
|
# Bring the pool up to the desired size
|
||||||
if total < pool['size']
|
if total < pool['size']
|
||||||
|
|
||||||
|
|
@ -168,7 +190,7 @@ loop do
|
||||||
end
|
end
|
||||||
|
|
||||||
# ZZZzzz...
|
# ZZZzzz...
|
||||||
sleep(5)
|
sleep(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue