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
|
end
|
||||||
|
|
||||||
def move_pending_vm_to_ready(vm, pool, host)
|
def move_pending_vm_to_ready(vm, pool, host)
|
||||||
if (host.summary) &&
|
if host['hostname'] == vm
|
||||||
(host.summary.guest) &&
|
|
||||||
(host.summary.guest.hostName) &&
|
|
||||||
(host.summary.guest.hostName == vm)
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Socket.getaddrinfo(vm, nil) # WTF?
|
Socket.getaddrinfo(vm, nil) # WTF? I assume this is just priming the local DNS resolver cache?!?!
|
||||||
rescue
|
rescue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -86,7 +82,7 @@ module Vmpooler
|
||||||
$redis.smove('vmpooler__pending__' + pool, 'vmpooler__ready__' + pool, vm)
|
$redis.smove('vmpooler__pending__' + pool, 'vmpooler__ready__' + pool, vm)
|
||||||
$redis.hset('vmpooler__boot__' + Date.today.to_s, pool + ':' + vm, finish)
|
$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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,8 @@ EOT
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#move_pending_vm_to_ready' do
|
describe '#move_pending_vm_to_ready' do
|
||||||
|
let(:host) { { 'hostname' => vm }}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
expect(subject).not_to be_nil
|
expect(subject).not_to be_nil
|
||||||
allow(Socket).to receive(:getaddrinfo)
|
allow(Socket).to receive(:getaddrinfo)
|
||||||
|
|
@ -171,21 +173,13 @@ EOT
|
||||||
expect(logger).to receive(:log).exactly(0).times
|
expect(logger).to receive(:log).exactly(0).times
|
||||||
expect(Socket).to receive(:getaddrinfo).exactly(0).times
|
expect(Socket).to receive(:getaddrinfo).exactly(0).times
|
||||||
|
|
||||||
allow(host).to receive(:summary).and_return( double('summary') )
|
host['hostname'] = 'different_name'
|
||||||
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')
|
|
||||||
|
|
||||||
subject.move_pending_vm_to_ready(vm, pool, host)
|
subject.move_pending_vm_to_ready(vm, pool, host)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when hostname matches VM name' do
|
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
|
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__pending__#{pool}", vm)).to be(true)
|
||||||
expect(redis.sismember("vmpooler__ready__#{pool}", vm)).to be(false)
|
expect(redis.sismember("vmpooler__ready__#{pool}", vm)).to be(false)
|
||||||
|
|
@ -195,7 +189,7 @@ EOT
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should log a message' do
|
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)
|
subject.move_pending_vm_to_ready(vm, pool, host)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue