vmware / pyvmomi-community-samples

A place for community contributed samples for the pyVmomi library.
Apache License 2.0
1.02k stars 928 forks source link

Sending keys to VM #532

Open ciscomonkey opened 5 years ago

ciscomonkey commented 5 years ago

I'm not finding anything in the pyvmomi documentation on sending keystrokes to a VM. In powerCLI this can be done using the Set-VMKeystrokes to send keypresses to the vm itself. Is there an example on how to do this using pyvmomi? Or has that functionality even made it into pyvmomi?

prziborowski commented 5 years ago

The functionality is there as VirtualMachine.PutUsbScanCodes() As far as examples, I can only find: http://key-value.blogspot.com/2017/11/vmware-keystroke-based-automation.html using it in python. The logic between PowerCLI should mostly translate the same though in which case I like this example: https://www.virtuallyghetto.com/2017/09/automating-vm-keystrokes-using-the-vsphere-api-powercli.html

ciscomonkey commented 5 years ago

Thanks. I have been using the virtually ghetto one for a while. Can't believe i haven't found that link before for the pythonic version.

ciscomonkey commented 5 years ago

Wondering if anyone knows how to simulate doing a keypress for X seconds with this though?