[vbox-dev] just trying to start a VM

Nikolay Igotti Nikolay.Igotti at Sun.COM
Thu Aug 6 16:18:06 GMT 2009


                   Frédéric,


 Following would be enough

#!/usr/bin/python

from vboxapi import VirtualBoxManager

style = None
g_virtualBoxManager = VirtualBoxManager(style, None)

def startMyMachine():
        vb = g_virtualBoxManager.vbox
        session = g_virtualBoxManager.mgr.getSessionObject(vb)
        mach = vb.findMachine("Windows")
       
        print "Starting VM",mach.id
        p = vb.openRemoteSession(session, mach.id, "gui", "")
        p.waitForCompletion(-1)

startMyMachine()


  Nikolay

Frédéric SOSSON wrote:
> Hello,
>
> I wrote those lines of python code trying to start a VM.
>
> Unfortunatly, I got this messge:
>
> Traceback (most recent call last):
>   File "./startmyvm.py", line 38, in <module>
>     startMyMachine()
>   File "./startmyvm.py", line 32, in startMyMachine
>     session = mgr.getSessionObject(vb)
>   File "/usr/lib/python2.6/dist-packages/vboxapi/__init__.py", line
> 466, in getSessionObject
>     return self.mgr.platform.getSessionObject(vbox)
> AttributeError: 'NoneType' object has no attribute 'getSessionObject'
>
> ######################################################################################
>
> #!/usr/bin/python
>
> import os,sys
> import traceback
> import shlex
> import time
>
> from vboxapi import VirtualBoxManager
>
> style = None
> g_virtualBoxManager = VirtualBoxManager(style, None)
> ctx = {'global':g_virtualBoxManager,
> 	'mgr':g_virtualBoxManager.mgr,
> 	'vb':g_virtualBoxManager.vbox,
> 	'ifaces':g_virtualBoxManager.constants,
> 	'remote':g_virtualBoxManager.remote,
> 	'type':g_virtualBoxManager.type,
> 	'run': lambda cmd,args: runCommandCb(ctx, cmd, args),
> 	'machById': lambda id: machById(ctx,id),
> 	'_machlist':None
> }
>
> g_virtualBoxManager.deinit()
> del g_virtualBoxManager
>
> def startMyMachine():
> 	mgr = ctx['mgr']
> 	vb = ctx['vb']
> #	perf = ctx['perf']
> #	uuid = mach.id
>
> 	session = mgr.getSessionObject(vb)
> 	uuid = vb.findMachine("Windows_XP_Config_Standard")
> 	progress = vb.openRemoteSession(session, uuid, "gui", "")
> 	
> 	print "Starting VM"
>
> startMyMachine()
>
> _______________________________________________
> vbox-dev mailing list
> vbox-dev at virtualbox.org
> http://vbox.innotek.de/mailman/listinfo/vbox-dev
>   





More information about the vbox-dev mailing list