mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 18:08:42 -05:00
Pass pool_check_response to create_inventory
Ensure that pool_check_response is passed in to create_inventory. Start base for running pool vms.
This commit is contained in:
parent
ec07f04d95
commit
fa988470a7
2 changed files with 24 additions and 23 deletions
|
|
@ -695,7 +695,7 @@ module Vmpooler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_inventory(pool, provider)
|
def create_inventory(pool, provider, pool_check_response)
|
||||||
inventory = {}
|
inventory = {}
|
||||||
begin
|
begin
|
||||||
provider.vms_in_pool(pool['name']).each do |vm|
|
provider.vms_in_pool(pool['name']).each do |vm|
|
||||||
|
|
@ -721,6 +721,10 @@ module Vmpooler
|
||||||
inventory
|
inventory
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_running_pool_vms(pool, provider, pool_check_response)
|
||||||
|
# do stuff here
|
||||||
|
end
|
||||||
|
|
||||||
def _check_pool(pool, provider)
|
def _check_pool(pool, provider)
|
||||||
pool_check_response = {
|
pool_check_response = {
|
||||||
discovered_vms: 0,
|
discovered_vms: 0,
|
||||||
|
|
@ -731,9 +735,20 @@ module Vmpooler
|
||||||
migrated_vms: 0,
|
migrated_vms: 0,
|
||||||
cloned_vms: 0
|
cloned_vms: 0
|
||||||
}
|
}
|
||||||
inventory = create_inventory(pool, provider)
|
|
||||||
|
begin
|
||||||
|
inventory = create_inventory(pool, provider, pool_check_response)
|
||||||
|
rescue => err
|
||||||
|
return(pool_check_response)
|
||||||
|
end
|
||||||
|
|
||||||
# RUNNING
|
# RUNNING
|
||||||
|
begin
|
||||||
|
check_running_pool_vms(pool, provider, pool_check_response)
|
||||||
|
rescue => err
|
||||||
|
return(pool_check_response)
|
||||||
|
end
|
||||||
|
|
||||||
$redis.smembers("vmpooler__running__#{pool['name']}").each do |vm|
|
$redis.smembers("vmpooler__running__#{pool['name']}").each do |vm|
|
||||||
if inventory[vm]
|
if inventory[vm]
|
||||||
begin
|
begin
|
||||||
|
|
|
||||||
|
|
@ -2729,29 +2729,15 @@ EOT
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not perform any other actions if an error occurs' do
|
it 'should not perform any other actions if an error occurs' do
|
||||||
# Add VMs into redis
|
allow(subject).to receive(:create_inventory).and_raise(
|
||||||
create_running_vm(pool_name, 'vm1')
|
RuntimeError,'Mock Error'
|
||||||
create_ready_vm(pool_name, 'vm2')
|
)
|
||||||
create_completed_vm('vm3', pool_name)
|
|
||||||
create_discovered_vm('vm4', pool_name)
|
|
||||||
create_migrating_vm('vm5', pool_name)
|
|
||||||
|
|
||||||
expect(subject).to receive(:move_vm_queue).exactly(0).times
|
expect {
|
||||||
expect(subject).to receive(:check_running_vm).exactly(0).times
|
subject._check_pool(pool_object, provider)
|
||||||
expect(subject).to receive(:check_pending_vm).exactly(0).times
|
}.to raise_error(RuntimeError, /Mock Error/)
|
||||||
expect(subject).to receive(:destroy_vm).exactly(0).times
|
|
||||||
expect(redis).to receive(:srem).exactly(0).times
|
|
||||||
expect(redis).to receive(:del).exactly(0).times
|
|
||||||
expect(redis).to receive(:hdel).exactly(0).times
|
|
||||||
expect(redis).to receive(:smove).exactly(0).times
|
|
||||||
expect(subject).to receive(:migrate_vm).exactly(0).times
|
|
||||||
expect(redis).to receive(:set).exactly(0).times
|
|
||||||
expect(redis).to receive(:incr).exactly(0).times
|
|
||||||
expect(subject).to receive(:clone_vm).exactly(0).times
|
|
||||||
expect(redis).to receive(:decr).exactly(0).times
|
|
||||||
|
|
||||||
expect(provider).to receive(:vms_in_pool).and_raise(RuntimeError,'Mock Error')
|
expect(subject).to_not receive(:check_running_pool_vms)
|
||||||
subject._check_pool(pool_object,provider)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return that no actions were taken' do
|
it 'should return that no actions were taken' do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue