VMware Cloud Community
stucky101
Contributor
Contributor

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

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.

Any insight ?

0 Kudos
0 Replies