mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-27 02:18: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
b79c3bfb75
commit
b51ba35c18
2 changed files with 13 additions and 3 deletions
|
|
@ -61,8 +61,8 @@ module Vmpooler
|
||||||
backend.hget('vmpooler__token__' + request.env['HTTP_X_AUTH_TOKEN'], 'user')
|
backend.hget('vmpooler__token__' + request.env['HTTP_X_AUTH_TOKEN'], 'user')
|
||||||
)
|
)
|
||||||
|
|
||||||
if config['vm_lifetime_auth'].to_i > 0
|
if (pool['vm_lifetime_auth'] || config['vm_lifetime_auth']).to_i > 0
|
||||||
backend.hset('vmpooler__vm__' + vm, 'lifetime', config['vm_lifetime_auth'].to_i)
|
backend.hset('vmpooler__vm__' + vm, 'lifetime', (pool['vm_lifetime_auth'] || config['vm_lifetime_auth']).to_i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -429,7 +429,7 @@ module Vmpooler
|
||||||
result[params[:hostname]] = {}
|
result[params[:hostname]] = {}
|
||||||
|
|
||||||
result[params[:hostname]]['template'] = rdata['template']
|
result[params[:hostname]]['template'] = rdata['template']
|
||||||
result[params[:hostname]]['lifetime'] = (rdata['lifetime'] || config['vm_lifetime']).to_i
|
result[params[:hostname]]['lifetime'] = (rdata['lifetime'] || pool['vm_lifetime'] || config['vm_lifetime']).to_i
|
||||||
|
|
||||||
if rdata['destroy']
|
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)
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,14 @@
|
||||||
# - ready_ttl
|
# - ready_ttl
|
||||||
# How long (in minutes) to keep VMs in 'ready' queues before destroying.
|
# How long (in minutes) to keep VMs in 'ready' queues before destroying.
|
||||||
# (optional)
|
# (optional)
|
||||||
|
#
|
||||||
|
# - vm_lifetime
|
||||||
|
# How long (in hours) to keep VMs in 'running' queues before destroying.
|
||||||
|
# (optional; default: '24')
|
||||||
|
#
|
||||||
|
# - vm_lifetime_auth
|
||||||
|
# Same as vm_lifetime, but applied if a valid authentication token is
|
||||||
|
# included during the request.
|
||||||
|
|
||||||
# Example:
|
# Example:
|
||||||
|
|
||||||
|
|
@ -240,4 +248,6 @@
|
||||||
size: 5
|
size: 5
|
||||||
timeout: 15
|
timeout: 15
|
||||||
ready_ttl: 1440
|
ready_ttl: 1440
|
||||||
|
vm_lifetime: 1
|
||||||
|
vm_lifetime_auth: 4
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue