Reputation: 19
How do I list the names of available VirtualBox virtual machines with pyvb modules?
Upvotes: 2
Views: 1643
Reputation: 1675
To complete the answer from Findekano, I will add the last line:
import vboxapi
virtualBoxManager = vboxapi.VirtualBoxManager(None, None)
vbox = virtualBoxManager.vbox
vboxVMList = virtualBoxManager.getArray(vbox, 'machines')
vboxNameList = [mach.name for mach in vboxVMList]
Upvotes: 1
Reputation: 1672
A good resource to learn VBox Python API is read the implementation of vboxweb
For your specific question, you can take a look at line 289 of VBoxWebSrv.py to see how virtual machines are populated.
In a nut shell, the code could be like below:
import vboxapi
virtualBoxManager = vboxapi.VirtualBoxManager(None, None)
vbox = virtualBoxManager.vbox
vboxVMList=virtualBoxManager.getArray(vbox, 'machines')
Upvotes: 4