mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-27 02:18:41 -05:00
Merge 2e5fdc5200 into ae91077494
This commit is contained in:
commit
dc8f0936cd
4 changed files with 20 additions and 1 deletions
|
|
@ -544,6 +544,9 @@ module Vmpooler
|
|||
arg.keys.each do |tag|
|
||||
backend.hset('vmpooler__vm__' + params[:hostname], 'tag:' + tag, arg[tag])
|
||||
backend.hset('vmpooler__tag__' + Date.today.to_s, params[:hostname] + ':' + tag, arg[tag])
|
||||
|
||||
# Auto-expire summary index
|
||||
backend.expire('vmpooler__tag__' + Date.today.to_s, (Vmpooler::API.settings.config[:redis]['data_ttl'].to_i * 60 * 60))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ module Vmpooler
|
|||
$redis.smove('vmpooler__pending__' + pool, 'vmpooler__ready__' + pool, vm)
|
||||
$redis.hset('vmpooler__boot__' + Date.today.to_s, pool + ':' + vm, finish)
|
||||
|
||||
# Auto-expire summary index
|
||||
$redis.expire('vmpooler__boot__' + Date.today.to_s, ($config[:redis]['data_ttl'].to_i * 60 * 60))
|
||||
|
||||
$logger.log('s', "[>] [#{pool}] '#{vm}' moved to 'ready' queue")
|
||||
end
|
||||
end
|
||||
|
|
@ -236,6 +239,9 @@ module Vmpooler
|
|||
$redis.hset('vmpooler__clone__' + Date.today.to_s, vm['template'] + ':' + vm['hostname'], finish)
|
||||
$redis.hset('vmpooler__vm__' + vm['hostname'], 'clone_time', finish)
|
||||
|
||||
# Auto-expire summary index
|
||||
$redis.expire('vmpooler__clone__' + Date.today.to_s, ($config[:redis]['data_ttl'].to_i * 60 * 60))
|
||||
|
||||
$logger.log('s', "[+] [#{vm['template']}] '#{vm['hostname']}' cloned from '#{vm['template']}' in #{finish} seconds")
|
||||
rescue
|
||||
$logger.log('s', "[!] [#{vm['template']}] '#{vm['hostname']}' clone appears to have failed")
|
||||
|
|
|
|||
|
|
@ -302,7 +302,10 @@ describe Vmpooler::API::V1 do
|
|||
pools: [
|
||||
{'name' => 'pool1', 'size' => 5},
|
||||
{'name' => 'pool2', 'size' => 10}
|
||||
]
|
||||
],
|
||||
redis: {
|
||||
'data_ttl' => '168'
|
||||
}
|
||||
} }
|
||||
|
||||
before do
|
||||
|
|
@ -310,6 +313,7 @@ describe Vmpooler::API::V1 do
|
|||
app.settings.set :redis, redis
|
||||
|
||||
allow(redis).to receive(:exists).and_return '1'
|
||||
allow(redis).to receive(:expire).with('vmpooler__tag__' + Date.today.to_s, 604800).and_return '1'
|
||||
allow(redis).to receive(:hset).and_return '1'
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -82,11 +82,17 @@ describe 'Pool Manager' do
|
|||
end
|
||||
|
||||
context 'a host with proper summary' do
|
||||
let(:config) { {
|
||||
redis: { 'data_ttl' => '168' }
|
||||
} }
|
||||
|
||||
|
||||
before do
|
||||
allow(host).to receive(:summary).and_return true
|
||||
allow(host).to receive_message_chain(:summary, :guest).and_return true
|
||||
allow(host).to receive_message_chain(:summary, :guest, :hostName).and_return vm
|
||||
|
||||
allow(redis).to receive(:expire).with('vmpooler__boot__' + Date.today.to_s, 604800).and_return '1'
|
||||
allow(redis).to receive(:hget)
|
||||
allow(redis).to receive(:smove)
|
||||
allow(redis).to receive(:hset)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue