mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-27 10:28:41 -05:00
(QENG-3376) Allow lifetime to be set per-pool
At current vm_lifetime and vm_lifetime_auth are configured globally only. This change allows that value to be set/overridden per pool.
This commit is contained in:
parent
063d45c60b
commit
8a22434629
4 changed files with 84 additions and 8 deletions
|
|
@ -66,8 +66,9 @@ module Vmpooler
|
|||
backend.hget('vmpooler__token__' + request.env['HTTP_X_AUTH_TOKEN'], 'user')
|
||||
)
|
||||
|
||||
if config['vm_lifetime_auth'].to_i > 0
|
||||
backend.hset('vmpooler__vm__' + vm, 'lifetime', config['vm_lifetime_auth'].to_i)
|
||||
pool_lifetime_auth = pools.find {|p| p["name"] == template }['vm_lifetime_auth']
|
||||
if (pool_lifetime_auth || config['vm_lifetime_auth']).to_i > 0
|
||||
backend.hset('vmpooler__vm__' + vm, 'lifetime', (pool_lifetime_auth || config['vm_lifetime_auth']).to_i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -455,13 +456,14 @@ module Vmpooler
|
|||
result[params[:hostname]] = {}
|
||||
|
||||
result[params[:hostname]]['template'] = rdata['template']
|
||||
result[params[:hostname]]['lifetime'] = (rdata['lifetime'] || config['vm_lifetime']).to_i
|
||||
pool_auth = pools.find {|p| p["name"] == rdata['template'] }['vm_lifetime']
|
||||
result[params[:hostname]]['lifetime'] = (rdata['lifetime'] || pool_auth || config['vm_lifetime']).to_i
|
||||
|
||||
if rdata['destroy']
|
||||
result[params[:hostname]]['running'] = ((Time.parse(rdata['destroy']) - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
|
||||
result[params[:hostname]]['running'] = ((Time.parse(rdata['destroy']) - Time.parse(rdata['checkout'])) / 60 / 60).round(2).to_f
|
||||
result[params[:hostname]]['state'] = 'destroyed'
|
||||
elsif rdata['checkout']
|
||||
result[params[:hostname]]['running'] = ((Time.now - Time.parse(rdata['checkout'])) / 60 / 60).round(2)
|
||||
result[params[:hostname]]['running'] = ((Time.now - Time.parse(rdata['checkout'])) / 60 / 60).round(2).to_f
|
||||
result[params[:hostname]]['state'] = 'running'
|
||||
elsif rdata['check']
|
||||
result[params[:hostname]]['state'] = 'ready'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue