mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
Merge branch 'configurable_vm_lifetimes'
This commit is contained in:
commit
fa3486a0ca
1 changed files with 7 additions and 3 deletions
|
|
@ -30,6 +30,7 @@ end
|
||||||
|
|
||||||
# Set some defaults
|
# Set some defaults
|
||||||
$config[:config]['task_limit'] ||= 10
|
$config[:config]['task_limit'] ||= 10
|
||||||
|
$config[:config]['vm_lifetime'] ||= 24
|
||||||
|
|
||||||
# Connect to Redis
|
# Connect to Redis
|
||||||
$redis = Redis.new
|
$redis = Redis.new
|
||||||
|
|
@ -350,10 +351,13 @@ def check_pool pool
|
||||||
$redis.smembers('vmware_host_pool__running__'+pool['name']).each do |vm|
|
$redis.smembers('vmware_host_pool__running__'+pool['name']).each do |vm|
|
||||||
if ($redis.hget('vmware_host_pool__active__'+pool['name'], vm))
|
if ($redis.hget('vmware_host_pool__active__'+pool['name'], vm))
|
||||||
running = (Time.now - Time.parse($redis.hget('vmware_host_pool__active__'+pool['name'], vm)))/60/60
|
running = (Time.now - Time.parse($redis.hget('vmware_host_pool__active__'+pool['name'], vm)))/60/60
|
||||||
if (running > 12)
|
if (
|
||||||
|
($config[:config]['vm_lifetime'] > 0) and
|
||||||
|
(running > $config[:config]['vm_lifetime'])
|
||||||
|
)
|
||||||
$redis.smove('vmware_host_pool__running__'+pool['name'], 'vmware_host_pool__completed__'+pool['name'], vm)
|
$redis.smove('vmware_host_pool__running__'+pool['name'], 'vmware_host_pool__completed__'+pool['name'], vm)
|
||||||
|
|
||||||
$logger.log('d', "[!] [#{pool['name']}] '#{vm}' reached end of TTL after 12 hours")
|
$logger.log('d', "[!] [#{pool['name']}] '#{vm}' reached end of TTL after #{$config[:config]['vm_lifetime']} hours")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue