Skip to content

Commit

Permalink
Traverse resource pools in fetch_resource_pool
Browse files Browse the repository at this point in the history
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
BrianMMcClain committed May 8, 2012
1 parent 6be6579 commit 380099a
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions vsphere_cpi/lib/cloud/vsphere/resources.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 380099a

Please sign in to comment.