List Tanzu virtual machines #3012
-
Hello everyone, Do you know if it's possible to list Virtual Machines in a Tanzu cluster with govmomi? I tried via the virtual machine finder:
And via the property collector on the HostSystem object:
I see "standard" VMs but no Tanzu managed VMs. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @pablo-ruth , the TKC VMs are in their own folders underneath Namespaces: % govc tree -p /DC/vm/Namespaces
/DC/vm/Namespaces
├── [Folder] test-gc-e2e-demo-ns
│ ├── [Folder] dev
│ │ ├── [VirtualMachine] dev-9qqlr-rnk98
│ │ ├── [VirtualMachine] dev-9qqlr-rtphr
│ │ ├── [VirtualMachine] dev-nodepool-1-s64bx-5c9b7bf498-7fpnl
│ │ ├── [VirtualMachine] dev-nodepool-1-s64bx-5c9b7bf498-fs2wg
│ │ └── [VirtualMachine] dev-nodepool-1-s64bx-5c9b7bf498-s9mvf
│ └── [Folder] example
│ ├── [VirtualMachine] example-lpwlf-j7wt7
│ └── [VirtualMachine] example-nodepool-1-rjt7q-7f949db78b-7997d
├── [VirtualMachine] SupervisorControlPlaneVM (1)
├── [VirtualMachine] SupervisorControlPlaneVM (2)
└── [VirtualMachine] SupervisorControlPlaneVM (3) % govc ls -l '/DC/vm/Namespaces/*'
/DC/vm/Namespaces/SupervisorControlPlaneVM (3) (VirtualMachine)
/DC/vm/Namespaces/SupervisorControlPlaneVM (1) (VirtualMachine)
/DC/vm/Namespaces/SupervisorControlPlaneVM (2) (VirtualMachine)
/DC/vm/Namespaces/test-gc-e2e-demo-ns/dev/
/DC/vm/Namespaces/test-gc-e2e-demo-ns/example/ With % govc ls -t VirtualMachine '/DC/vm/Namespaces/*'
/DC/vm/Namespaces/SupervisorControlPlaneVM (3)
/DC/vm/Namespaces/SupervisorControlPlaneVM (1)
/DC/vm/Namespaces/SupervisorControlPlaneVM (2) Changing the path to % govc ls -t VirtualMachine /DC/vm/Namespaces/...
/DC/vm/Namespaces/SupervisorControlPlaneVM (3)
/DC/vm/Namespaces/SupervisorControlPlaneVM (1)
/DC/vm/Namespaces/SupervisorControlPlaneVM (2)
/DC/vm/Namespaces/test-gc-e2e-demo-ns/dev/dev-9qqlr-rtphr
/DC/vm/Namespaces/test-gc-e2e-demo-ns/dev/dev-nodepool-1-s64bx-5c9b7bf498-fs2wg
/DC/vm/Namespaces/test-gc-e2e-demo-ns/dev/dev-nodepool-1-s64bx-5c9b7bf498-s9mvf
/DC/vm/Namespaces/test-gc-e2e-demo-ns/dev/dev-9qqlr-rnk98
/DC/vm/Namespaces/test-gc-e2e-demo-ns/dev/dev-nodepool-1-s64bx-5c9b7bf498-7fpnl
/DC/vm/Namespaces/test-gc-e2e-demo-ns/example/example-nodepool-1-rjt7q-7f949db78b-7997d
/DC/vm/Namespaces/test-gc-e2e-demo-ns/example/example-lpwlf-j7wt7 If you want to filter out the SV VMs: % govc find /DC/vm/Namespaces -type m -summary.config.managedBy.extensionKey com.vmware.vcenter.wcp
/DC/vm/Namespaces/test-gc-e2e-demo-ns/example/example-lpwlf-j7wt7
/DC/vm/Namespaces/test-gc-e2e-demo-ns/dev/dev-9qqlr-rnk98
/DC/vm/Namespaces/test-gc-e2e-demo-ns/dev/dev-nodepool-1-s64bx-5c9b7bf498-7fpnl
/DC/vm/Namespaces/test-gc-e2e-demo-ns/example/example-nodepool-1-rjt7q-7f949db78b-7997d
/DC/vm/Namespaces/test-gc-e2e-demo-ns/dev/dev-9qqlr-rtphr To do the above in Go, it's simpler and more efficient to use a ContainerView. Below is a modified an example: func main() {
examples.Run(func(ctx context.Context, c *vim25.Client) error {
f, err := find.NewFinder(c).Folder(ctx, "/DC/vm/Namespaces")
if err != nil {
return err
}
// Create view of VirtualMachine objects
m := view.NewManager(c)
v, err := m.CreateContainerView(ctx, f.Reference(), []string{"VirtualMachine"}, true)
if err != nil {
return err
}
defer v.Destroy(ctx)
// Retrieve summary property for all machines
// Reference: http://pubs.vmware.com/vsphere-60/topic/com.vmware.wssdk.apiref.doc/vim.VirtualMachine.html
filter := property.Filter{"summary.config.managedBy.extensionKey": "com.vmware.vcenter.wcp"}
var vms []mo.VirtualMachine
err = v.RetrieveWithFilter(ctx, []string{"VirtualMachine"}, []string{"summary"}, &vms, filter)
if err != nil {
return err
}
// Print summary per vm (see also: govc/vm/info.go)
for _, vm := range vms {
fmt.Printf("%s: %s\n", vm.Summary.Config.Name, vm.Summary.Config.GuestFullName)
}
return nil
})
} |
Beta Was this translation helpful? Give feedback.
-
Hello @dougm, Thanks. I tried govc commands and didn't see Tanzu nodes either, so I've taken another look and found that it was a permission issue with the user I was using in my code... I thought it had Administrator role set via "Global Permissions" tab in Administration page, but it didn't seem enough. So instead I added it to group "Administrators" in the "Users and Groups" tab and it now shows all VMs including Tanzu ones. Sorry for wrong interpretation, and thanks for your very detailed answer, I will rewrite my code with your advice on ContainerView and I'm sure it will help someone in the future ;) Have a good day, |
Beta Was this translation helpful? Give feedback.
Hi @pablo-ruth , the TKC VMs are in their own folders underneath Namespaces: