mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 10:08:40 -05:00
(POOLER-70) Update move_pending_vm_to_ready for VM Provider
Previously the Pool Manager would use vSphere objects directly. This commit - Modifies the pool_manager to use the VM provider methods instead
This commit is contained in:
parent
9f4fc903b9
commit
760dc1c67e
2 changed files with 7 additions and 17 deletions
|
|
@ -70,13 +70,9 @@ module Vmpooler
|
|||
end
|
||||
|
||||
def move_pending_vm_to_ready(vm, pool, host)
|
||||
if (host.summary) &&
|
||||
(host.summary.guest) &&
|
||||
(host.summary.guest.hostName) &&
|
||||
(host.summary.guest.hostName == vm)
|
||||
|
||||
if host['hostname'] == vm
|
||||
begin
|
||||
Socket.getaddrinfo(vm, nil) # WTF?
|
||||
Socket.getaddrinfo(vm, nil) # WTF? I assume this is just priming the local DNS resolver cache?!?!
|
||||
rescue
|
||||
end
|
||||
|
||||
|
|
@ -86,7 +82,7 @@ module Vmpooler
|
|||
$redis.smove('vmpooler__pending__' + pool, 'vmpooler__ready__' + pool, vm)
|
||||
$redis.hset('vmpooler__boot__' + Date.today.to_s, pool + ':' + vm, finish)
|
||||
|
||||
$logger.log('s', "[>] [#{pool}] '#{vm}' moved to 'ready' queue")
|
||||
$logger.log('s', "[>] [#{pool}] '#{vm}' moved from 'pending' to 'ready' queue")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -157,6 +157,8 @@ EOT
|
|||
end
|
||||
|
||||
describe '#move_pending_vm_to_ready' do
|
||||
let(:host) { { 'hostname' => vm }}
|
||||
|
||||
before do
|
||||
expect(subject).not_to be_nil
|
||||
allow(Socket).to receive(:getaddrinfo)
|
||||
|
|
@ -171,21 +173,13 @@ EOT
|
|||
expect(logger).to receive(:log).exactly(0).times
|
||||
expect(Socket).to receive(:getaddrinfo).exactly(0).times
|
||||
|
||||
allow(host).to receive(:summary).and_return( double('summary') )
|
||||
allow(host).to receive_message_chain(:summary, :guest).and_return( double('guest') )
|
||||
allow(host).to receive_message_chain(:summary, :guest, :hostName).and_return ('different_name')
|
||||
host['hostname'] = 'different_name'
|
||||
|
||||
subject.move_pending_vm_to_ready(vm, pool, host)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when hostname matches VM name' do
|
||||
before do
|
||||
allow(host).to receive(:summary).and_return( double('summary') )
|
||||
allow(host).to receive_message_chain(:summary, :guest).and_return( double('guest') )
|
||||
allow(host).to receive_message_chain(:summary, :guest, :hostName).and_return (vm)
|
||||
end
|
||||
|
||||
it 'should move the VM from pending to ready pool' do
|
||||
expect(redis.sismember("vmpooler__pending__#{pool}", vm)).to be(true)
|
||||
expect(redis.sismember("vmpooler__ready__#{pool}", vm)).to be(false)
|
||||
|
|
@ -195,7 +189,7 @@ EOT
|
|||
end
|
||||
|
||||
it 'should log a message' do
|
||||
expect(logger).to receive(:log).with('s', "[>] [#{pool}] '#{vm}' moved to 'ready' queue")
|
||||
expect(logger).to receive(:log).with('s', "[>] [#{pool}] '#{vm}' moved from 'pending' to 'ready' queue")
|
||||
|
||||
subject.move_pending_vm_to_ready(vm, pool, host)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue