Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Traverse resource pools in fetch_resource_pool

Currently, BOSH will only look at resource pools in the top level of a cluster. This allows bosh to traverse the resource pool tree to search for a resource pool

Change-Id: I7942464947184d6f225008f5bfc1110d5f8724c7
  • Loading branch information...
commit 380099a322403220cc70620b09db1fd94a899958 1 parent 6be6579
@BrianMMcClain BrianMMcClain authored
Showing with 18 additions and 6 deletions.
  1. +18 −6 vsphere_cpi/lib/cloud/vsphere/resources.rb
View
24 vsphere_cpi/lib/cloud/vsphere/resources.rb
@@ -218,23 +218,35 @@ def fetch_resource_pool(requested_resource_pool, cluster_properties)
return root_resource_pool if requested_resource_pool.nil?
- # Get list of resource pools under this cluster
- properties = @client.get_properties(root_resource_pool, Vim::ResourcePool, ["resourcePool"])
+ return traverse_resource_pool(requested_resource_pool, root_resource_pool)
+ end
+
+ def traverse_resource_pool(requested_resource_pool, resource_pool)
+ # Get list of resource pools under this resource pool
+ properties = @client.get_properties(resource_pool, Vim::ResourcePool, ["resourcePool"])
+
if properties && properties["resourcePool"] && properties["resourcePool"].size != 0
- # Get the name of each resource pool under this cluster
+ # Get the name of each resource pool under this resource pool
child_properties = @client.get_properties(properties["resourcePool"], Vim::ResourcePool, ["name"])
if child_properties
child_properties.each_value do | resource_pool |
if resource_pool["name"] == requested_resource_pool
- @logger.info("Found requested resource pool #{requested_resource_pool} under cluster #{cluster_properties["name"]}")
+ @logger.info("Found requested resource pool #{requested_resource_pool}")
return resource_pool[:obj]
end
end
+
+ child_properties.each_value do | resource_pool |
+ pool = traverse_resource_pool(requested_resource_pool, resource_pool[:obj])
+ return pool if pool != nil
+ end
end
+
+ return nil
end
- @logger.info("Could not find requested resource pool #{requested_resource_pool} under cluster #{cluster_properties["name"]}")
- nil
+
+ return nil
end
def fetch_datastores(datacenter, datastore_mobs, match_pattern)
Please sign in to comment.
Something went wrong with that request. Please try again.