1

I am trying to run a VirtualBox machine using the python sdk.

I ran the following commands (based on the documentation page 32):

from vboxapi import VirtualBoxManager
manager = VirtualBoxManager(None, None)
vbox = manager.vbox
name = "myVM"
mach = vbox.findMachine(name)
session = manager.mgr.getSessionObject(vbox)
progress = mach.launchVMProcess(session, "gui", "")

progress.waitForCompletion(-1) #successfully fires up myVM w/ GUI

manager.closeMachineSession(session) #error, see below

The error I get is:

raise AttributeError, "XPCOM component '%s' has no attribute '%s'" % (self._object_name_, attr) AttributeError: XPCOM component '@virtualbox.org/Session;1' has no attribute 'close'

I am trying to shutdown and close the VM from python.

Question:
How can I resolve this error and shut down the VM using python?

4

1 回答 1

1

session.console.powerDown() did the trick (I had to rtfm). I am still interested in knowing what the intention of that line is from the docs.

于 2012-05-07T14:13:14.787 回答