mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Support nested host folders in find_cluster()
Search the root and any subfolders for cluster or host resources.
This commit is contained in:
parent
114cb9f398
commit
f6fdfe42d7
3 changed files with 81 additions and 14 deletions
|
|
@ -24,7 +24,29 @@ MockContainerView = Struct.new(
|
|||
# https://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.view.ContainerView.html
|
||||
# From ContainerView
|
||||
:container, :recursive, :type
|
||||
)
|
||||
) do
|
||||
def _search_tree(layer)
|
||||
results = []
|
||||
|
||||
layer.children.each do |child|
|
||||
if type.any? { |t| child.is_a?(RbVmomi::VIM.const_get(t)) }
|
||||
results << child
|
||||
end
|
||||
|
||||
if recursive && child.respond_to?(:children)
|
||||
results += _search_tree(child)
|
||||
end
|
||||
end
|
||||
results
|
||||
end
|
||||
|
||||
def view
|
||||
_search_tree(container)
|
||||
end
|
||||
|
||||
def DestroyView
|
||||
end
|
||||
end
|
||||
|
||||
MockDatacenter = Struct.new(
|
||||
# https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.Datacenter.html
|
||||
|
|
@ -384,6 +406,10 @@ def mock_RbVmomi_VIM_ComputeResource(options = {})
|
|||
mock.host << mock_host
|
||||
end
|
||||
|
||||
allow(mock).to receive(:is_a?) do |expected_type|
|
||||
expected_type == RbVmomi::VIM::ComputeResource
|
||||
end
|
||||
|
||||
mock
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue