VirtualBox Python API - 远程访问

时间:2014-04-14 19:12:45

标签: python virtualbox

我正在尝试在我的上网本(Ubuntu系统)上使用Windows 7(我的主笔记本电脑)在计算机上运行虚拟机。 在Ubuntu上我准备了python脚本:

from vboxapi import VirtualBoxManager
import sys
sys.path.append("/home/myLogin/Downloads/sdk/bindings/webservice/python/lib")

mgr = VirtualBoxManager("WEBSERVICE", {'url':'myIP', 'user':'myServerLogin', 'password':'myPassthere'})
vbox = mgr.vbox
name = "Muszelek"
mach = vbox.findMachine(name)
session = mgr.mgr.getSessionObject(vbox)
progress = mach.launchVMProcess(session, "gui", "")
progress.waitForCompletion(-1)
mgr.closeMachineSession(session)

我收到错误:

Installation problem: check that appropriate libs in place
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/vboxapi/__init__.py", line 981, in __init__
    self.vbox = self.platform.getVirtualBox()
  File "/usr/local/lib/python2.7/dist-packages/vboxapi/__init__.py", line 856, in getVirtualBox
    return self.connect(self.url, self.user, self.password)
  File "/usr/local/lib/python2.7/dist-packages/vboxapi/__init__.py", line 910, in connect
    self.vbox = self.wsmgr.logon(self.user, self.password)
  File "/home/karolinka/Downloads/sdk/bindings/webservice/python/lib/VirtualBox_wrappers.py", line 11790, in logon
    req=IWebsessionManager_logonRequestMsg()
NameError: global name 'IWebsessionManager_logonRequestMsg' is not defined
Traceback (most recent call last):
  File "vmmach.py", line 5, in <module>
    mgr = VirtualBoxManager("WEBSERVICE", {'url':'myIP', 'user':'myComputerLogin', 'password':'myPass'})
  File "/usr/local/lib/python2.7/dist-packages/vboxapi/__init__.py", line 985, in __init__
    raise ne
NameError: global name 'IWebsessionManager_logonRequestMsg' is not defined

任何想法我怎么能解决这个问题? 我的Windows机器上的库有问题吗?

2 个答案:

答案 0 :(得分:0)

我在Mac上遇到了完全相同的问题。问题是VirtualBox_wrappers.py在try块中导入VirtualBox_client.py(它定义了有问题的全局名称),如果无法导入则继续(传递)

try: from VirtualBox_client import * except: pass

问题是VirtualBox_client.py依赖于未安装的ZSI,因此导入失败。一旦我做了

easy_install zsi

一切都按预期工作。

答案 1 :(得分:0)

似乎找不到课程!您是否尝试过查找webservice api? 我有一个类似的问题,我看了/ usr / lib / virtualbox / sdk / bindings,我没有找到只有xpcom在那里的webservice文件夹,所以我只是从sdk中包含了webservice文件夹,一切正常