From af6c7c90bc5987387952003025037c66be6d8729 Mon Sep 17 00:00:00 2001 From: Shlomi Zadok Date: Wed, 12 Nov 2014 09:01:31 +0200 Subject: [PATCH] [vSphere] Support clusters that are located below folders --- lib/fog/vsphere/requests/compute/list_clusters.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/fog/vsphere/requests/compute/list_clusters.rb b/lib/fog/vsphere/requests/compute/list_clusters.rb index 96d113b3a..80747b4f4 100644 --- a/lib/fog/vsphere/requests/compute/list_clusters.rb +++ b/lib/fog/vsphere/requests/compute/list_clusters.rb @@ -11,11 +11,22 @@ module Fog end def raw_clusters(datacenter) - find_raw_datacenter(datacenter).hostFolder.childEntity.grep(RbVmomi::VIM::ClusterComputeResource) + folder ||= find_raw_datacenter(datacenter).hostFolder + @raw_clusters = get_raw_clusters_from_folder(folder) end protected + def get_raw_clusters_from_folder(folder) + folder.childEntity.map do |child_entity| + if child_entity.is_a? RbVmomi::VIM::ClusterComputeResource + child_entity + elsif child_entity.is_a? RbVmomi::VIM::Folder + get_raw_clusters_from_folder(child_entity) + end + end.flatten + end + def cluster_attributes cluster, datacenter_name { :id => managed_obj_id(cluster),