mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
(POOLER-73) Update find_pool in vsphere_helper.rb to enable testing
Previously, it was not able to mock objects to impersonate various RBVMOMI objects. This commit changes the case statement to use `base.is_a?` which can be mocked and allow mocked objects to mimic real objects.
This commit is contained in:
parent
88052ac85a
commit
07eb4f579a
1 changed files with 4 additions and 4 deletions
|
|
@ -276,12 +276,12 @@ module Vmpooler
|
|||
base = datacenter.hostFolder
|
||||
pools = poolname.split('/')
|
||||
pools.each do |pool|
|
||||
case base
|
||||
when RbVmomi::VIM::Folder
|
||||
case
|
||||
when base.is_a?(RbVmomi::VIM::Folder)
|
||||
base = base.childEntity.find { |f| f.name == pool }
|
||||
when RbVmomi::VIM::ClusterComputeResource
|
||||
when base.is_a?(RbVmomi::VIM::ClusterComputeResource)
|
||||
base = base.resourcePool.resourcePool.find { |f| f.name == pool }
|
||||
when RbVmomi::VIM::ResourcePool
|
||||
when base.is_a?(RbVmomi::VIM::ResourcePool)
|
||||
base = base.resourcePool.find { |f| f.name == pool }
|
||||
else
|
||||
abort "Unexpected object type encountered (#{base.class}) while finding resource pool"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue