Python API for VirtualBox

Posted by jessica on Stack Overflow See other posts from Stack Overflow or by jessica
Published on 2010-02-20T08:07:21Z Indexed on 2010/05/03 2:08 UTC
Read the original article Hit count: 458

Filed under:
|
|

I have made a command-line interface for virtualbox such that the virtualbox can be controlled from a remote machine. now I am trying to implement the commmand-line interface using python virtualbox api. For that I have downloaded the pyvb package (python api documentation shows functions that can be used for implementing this under pyvb package). but when I give pyvb.vb.VB.startVM(instance of VB class,pyvb.vm.vbVM) SERVER SIDE CODE IS

from pyvb.constants import *

from pyvb.vm import *

from pyvb.vb import *

import xpcom

import pyvb

import os

import socket

import threading

class ClientThread ( threading.Thread ):

# Override Thread's init method to accept the parameters needed: def init ( self, channel, details ):

  self.channel = channel
  self.details = details
  threading.Thread.__init__ ( self )

def run ( self ):

  print 'Received connection:', self.details [ 0 ]
  while 1:     
     s= self.channel.recv ( 1024 )
     if(s!='end'):
        if(s=='start'):
          v=VB() 
          pyvb.vb.VB.startVM(v,pyvb.vm.vbVM)

     else:
       self.channel.close()
       break
  print 'Closed connection:', self.details [ 0 ]

server = socket.socket ( socket.AF_INET, socket.SOCK_STREAM ) server.bind ( ( '127.0.0.1', 2897 ) ) server.listen ( 5 )

while True: channel, details = server.accept() ClientThread ( channel, details ).start()

it shows an error Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.5/threading.py", line 486, in __bootstrap_inner self.run() File "news.py", line 27, in run pyvb.vb.VB.startVM(v,pyvb.vm.vbVM.getUUID(m)) File "/usr/lib/python2.5/site-packages/pyvb-0.0.2-py2.5.egg/pyvb/vb.py", line 65, in startVM cmd='%s %s'%(VB_COMMAND_STARTVM, vm.getUUID()) AttributeError: 'str' object has no attribute 'getUUID'

© Stack Overflow or respective owner

Related posts about python

Related posts about virtualbox