govmomi cluster name on mo.MirtualMachine

54 Views Asked by At

In my function, i have fetched all my needed VM's from the vCenter - when looping through them i would like to fetch the cluster that the virtualmachine is running under. Is this possible without further lookups to the vCenter API for each VM?


            vcenterResponse := []mo.VirtualMachine{}

    
            err = v.Retrieve(ctx, []string{"VirtualMachine"}, []string{"summary", "name", "network", "guest", "config", "resourcePool"}, &vcenterResponse)
            if err != nil {
                return
            }

            for i, vm := range vcenterResponse {

              ...

            }

0

There are 0 best solutions below