Do not prepare template when config_template is set

This commit is contained in:
kirby@puppetlabs.com 2018-07-02 14:12:17 -07:00
parent 1b17cceb01
commit 70156ba7f7
2 changed files with 16 additions and 5 deletions

View file

@ -628,12 +628,14 @@ module Vmpooler
prepare_template(pool, provider) prepare_template(pool, provider)
prepared_template = $redis.hget('vmpooler__template__prepared', pool['name']) prepared_template = $redis.hget('vmpooler__template__prepared', pool['name'])
end end
elsif not prepared_template == pool['template'] elsif prepared_template != pool['template']
if configured_template.nil?
mutex.synchronize do mutex.synchronize do
prepare_template(pool, provider) prepare_template(pool, provider)
prepared_template = $redis.hget('vmpooler__template__prepared', pool['name']) prepared_template = $redis.hget('vmpooler__template__prepared', pool['name'])
end end
end end
end
return if configured_template.nil? return if configured_template.nil?
return if configured_template == prepared_template return if configured_template == prepared_template
mutex.synchronize do mutex.synchronize do

View file

@ -1849,14 +1849,23 @@ EOT
context 'when the configured pool template does not match the prepared template' do context 'when the configured pool template does not match the prepared template' do
before(:each) do before(:each) do
config[:pools][0]['template'] = new_template config[:pools][0]['template'] = new_template
expect(redis).to receive(:hget).with('vmpooler__template__prepared', pool).and_return(current_template)
end end
it 'should prepare the template' do it 'should prepare the template' do
expect(redis).to receive(:hget).with('vmpooler__template__prepared', pool).and_return(current_template)
expect(subject).to receive(:prepare_template).with(config[:pools][0], provider) expect(subject).to receive(:prepare_template).with(config[:pools][0], provider)
subject.evaluate_template(config[:pools][0], provider) subject.evaluate_template(config[:pools][0], provider)
end end
context 'if configured_template is provided' do
it 'should not run prepare_template' do
expect(redis).to receive(:hget).with('vmpooler__config__template', pool).and_return(current_template)
expect(subject).to_not receive(:prepare_template)
subject.evaluate_template(config[:pools][0], provider)
end
end
end end
context 'when a new template is requested' do context 'when a new template is requested' do