vmware / govmomi

Go library for the VMware vSphere API
Apache License 2.0
2.26k stars 896 forks source link

[BUG] govc.exe find . -type m -runtime.powerState poweredOn fails on Windows #3456

Open ralfgro opened 1 month ago

ralfgro commented 1 month ago

Describe the bug I'm trying to transfer govc from Linux to Windows and downloaded latest x86_64 binaries (it's says 0.37.2 on the download page, but v0.36.0 in the Changelog.md)

My existing Linux script breaks on Windows, even the basic example from the docs fails. The find without '-runtime.powerState poweredOn' runs fine.

PS D:\govc\govc_Windows_x86_64> .\govc.exe find . -type m -runtime.powerState poweredOn Usage: D:\govc\govc_Windows_x86_64\govc.exe find [OPTIONS] [ROOT] [KEY VAL]...

Find managed objects.

ROOT can be an inventory path or ManagedObjectReference. ROOT defaults to '.', an alias for the root folder or DC if set.

Optional KEY VAL pairs can be used to filter results against object instance properties. Use the govc 'object.collect' command to view possible object property keys. ...

To Reproduce Just download govc for Windows and run .\govc.exe find . -type m -runtime.powerState poweredOn

Expected behavior

On Linux....

$ govc find . -type m -runtime.powerState poweredOn /TR-Istanbul/vm/STRT2005 /TR-Istanbul/vm/STRT2004 /TR-Istanbul/vm/STRS0100 ...

Affected version

govc donwload from https://github.com/vmware/govmomi/releases/download/v0.37.2/govc_Windows_x86_64.zip

Screenshots/Debug Output If applicable, add screenshots or debug output to help explain your problem.

Additional context Add any other context about the problem here.

github-actions[bot] commented 1 month ago

Howdy 🖐   ralfgro ! Thank you for your interest in this project. We value your feedback and will respond soon.

If you want to contribute to this project, please make yourself familiar with the CONTRIBUTION guidelines.

ralfgro commented 1 month ago

I think the whole filter thing is broken in Windows or the syntax is different? I'm not a Windows guy and I did not find anything obvious in the readme/usage etc.

Windows

PS D:\govc\govc_Windows_x86_64> govc object.collect -type m /DE-WBE/host/vicluster_Lab runtime.powerState
VirtualMachine:vm-3281592  runtime.powerState  types.VirtualMachinePowerState  poweredOn
VirtualMachine:vm-2429189  runtime.powerState  types.VirtualMachinePowerState  poweredOn
VirtualMachine:vm-2429190  runtime.powerState  types.VirtualMachinePowerState  poweredOn
VirtualMachine:vm-2429184  runtime.powerState  types.VirtualMachinePowerState  poweredOff
VirtualMachine:vm-2429185  runtime.powerState  types.VirtualMachinePowerState  poweredOff
VirtualMachine:vm-934557  runtime.powerState  types.VirtualMachinePowerState  poweredOff
VirtualMachine:vm-1054922  runtime.powerState  types.VirtualMachinePowerState  poweredOff
VirtualMachine:vm-1310509  runtime.powerState  types.VirtualMachinePowerState  poweredOff

I can query the property runtime.powerState as expected, but I can't filter.

PS D:\govc\govc_Windows_x86_64> govc object.collect -type m /DE-WBE/host/vicluster_Lab -runtime.powerState poweredOn
govc : D:\govc\govc_Windows_x86_64\govc.exe: ServerFaultCode: InvalidProperty
At line:1 char:1
+ govc object.collect -type m /DE-WBE/host/vicluster_Lab -runtime.power ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (D:\govc\govc_Wi...InvalidProperty:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

On Linux its a no brainer and just works.

$ govc object.collect -type m /DE-WBE/host/vicluster_Lab -runtime.powerState poweredOn
VirtualMachine:vm-3281592  runtime.powerState  types.VirtualMachinePowerState  poweredOn
VirtualMachine:vm-2429189  runtime.powerState  types.VirtualMachinePowerState  poweredOn
VirtualMachine:vm-3280609  runtime.powerState  types.VirtualMachinePowerState  poweredOn
VirtualMachine:vm-2429190  runtime.powerState  types.VirtualMachinePowerState  poweredOn