Skip to content

Commit

Permalink
Merge pull request #196 from glennsarti/ticket/master/POOLER-73-vsphe…
Browse files Browse the repository at this point in the history
…re-helper

(POOLER-73) Add spec tests for vsphere_helper
  • Loading branch information
Morgan Rhodes authored Mar 21, 2017
2 parents 42b7d2d + bcaad0a commit 4dbe7ef
Show file tree
Hide file tree
Showing 4 changed files with 2,836 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/vmpooler/vsphere_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,10 @@ def find_folder(foldername)
base = datacenter.vmFolder
folders = foldername.split('/')
folders.each do |folder|
case base
when RbVmomi::VIM::Folder
base = base.childEntity.find { |f| f.name == folder }
else
abort "Unexpected object type encountered (#{base.class}) while finding folder"
if base.is_a? RbVmomi::VIM::Folder
base = base.childEntity.find { |f| f.name == folder }
else
raise(RuntimeError, "Unexpected object type encountered (#{base.class}) while finding folder")
end
end

Expand Down Expand Up @@ -277,15 +276,15 @@ def find_pool(poolname)
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"
raise(RuntimeError, "Unexpected object type encountered (#{base.class}) while finding resource pool")
end
end

Expand Down
Loading

0 comments on commit 4dbe7ef

Please sign in to comment.