mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
(POOLER-70) Add get_pool_name_for_vm for VM Provider
Previously there was no simple way to calculate which pool a VM was a member of. This commit adds a helper method which queries redis for the pool name for a given VM.
This commit is contained in:
parent
c7b37dec75
commit
c09035cfcb
2 changed files with 23 additions and 0 deletions
|
|
@ -348,6 +348,11 @@ module Vmpooler
|
|||
result
|
||||
end
|
||||
|
||||
def get_pool_name_for_vm(vm_name)
|
||||
# the 'template' is a bad name. Should really be 'poolname'
|
||||
$redis.hget('vmpooler__vm__' + vm_name, 'template')
|
||||
end
|
||||
|
||||
def check_disk_queue(maxloop = 0, loop_delay = 5)
|
||||
$logger.log('d', "[*] [disk_manager] starting worker thread")
|
||||
|
||||
|
|
|
|||
|
|
@ -1000,6 +1000,24 @@ EOT
|
|||
end
|
||||
end
|
||||
|
||||
describe '#get_pool_name_for_vm' do
|
||||
context 'Given a valid VM' do
|
||||
before(:each) do
|
||||
create_running_vm(pool, vm, token)
|
||||
end
|
||||
|
||||
it 'should return the pool name' do
|
||||
expect(subject.get_pool_name_for_vm(vm)).to eq(pool)
|
||||
end
|
||||
end
|
||||
|
||||
context 'Given an invalid VM' do
|
||||
it 'should return nil' do
|
||||
expect(subject.get_pool_name_for_vm('does_not_exist')).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#check_disk_queue' do
|
||||
let(:threads) {[]}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue