VirtualBox COM interface with python

This is for discussing general topics about how to use VirtualBox.
Post Reply
adrianh
Posts: 46
Joined: 26. Aug 2009, 21:42
Primary OS: Other
VBox Version: OSE other
Guest OSses: Win7

VirtualBox COM interface with python

Post by adrianh »

Hi, I installed the latest of VirtualBox 4.1.16, python 2.7.3 (http://www.python.org/getit/) and win32 extensions (http://sourceforge.net/projects/pywin32 ... ild%20217/) and I am trying to access the host information.

So I type in the following in python:

Code: Select all

>>> import win32com.client
>>> VirtualBox = win32com.client.Dispatch("VirtualBox.VirtualBox")
>>> Host=VirtualBox.host
>>> Host.findHostNetworkInterfacesOfType(HostNetworkInterfaceType_Bridged, list)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'HostNetworkInterfaceType_Bridged' is not defined
Ok, so it can't find the enum, so I just try an give it a number, which probably shouldn't work, but whatev. And I get:

Code: Select all

>>> Host.findHostNetworkInterfacesOfType(0, list)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<COMObject <unknown>>", line 2, in findHostNetworkInterfacesOfType
TypeError: Objects of type 'type' can not be converted to a COM VARIANT
COMObject <unknown>? So I look at my objects:

Code: Select all

>>> VirtualBox
<COMObject VirtualBox.VirtualBox>
>>> Host
<COMObject <unknown>>
Host is of an unknown object type and is probably why it can't find findHostNetworkInterfacesOfType, I think.

Does anyone else have experience with this?
Technologov
Volunteer
Posts: 3342
Joined: 10. May 2007, 16:59
Location: Israel

Re: VirtualBox COM interface with python

Post by Technologov »

While I have not tried bridging code, the UDP Tunnel and Internal network modes are working fine.

(hint: see my GNS3 code in python, the "vboxwrapper". http://www.gns3.net)
Post Reply