(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:
Glenn Sarti 2017-03-17 10:42:07 -07:00
parent 88052ac85a
commit 07eb4f579a

View file

@ -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"