API - create container view further down the mob tree rather than rootFolder

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

API - create container view further down the mob tree rather than rootFolder

stucky101
Everyone

I know I can create a container view and list all VMs like so

sc = si.content
co = sc.rootFolder
vt = [vim.VirtualMachine]
recursive = True
cv = sc.viewManager.CreateContainerView(co, vt, recursive)
ch = cv.view
for c in ch:
  print c.name

 
Isn't there a way to set the container view to start at the level of a given cluster and only list VMs in that cluster ?
Otherwise I have to get all cluster names, match to the one that was passed, find all hosts in it, then find all vms in each host.

 That seems awkward and I thought a view was there to avoid exactly that but it seems I cannot drill any further than rootFolder.

What would be the pyvmomi way of getting a list of just VMs of a given cluster ?

Thx
 

Any insight ?
Loading...