Can't create HDD through python + OOWS

This is for discussing general topics about how to use VirtualBox.
Post Reply
NicklasE
Posts: 3
Joined: 25. Feb 2012, 16:01

Can't create HDD through python + OOWS

Post by NicklasE »

Hey!

I have got python (2.7.1) + VirtualBox XPCOM (4.1.12) to work on my host (Ubuntu 10.04 Server), now I wanted to add another host and control it over OOWS (web service) and python. I'm using vboxshell.py that comes with the SDK and follow the instructions in the SDK "Programmimng Guid and Reference". I got so far that I can create the virtual machine on the other host but when I run:

Code: Select all

 createHdd 125829120000 /home/user/VMs/machine/machine.vdi 
I get

%d format: a number is required, not str

I tried to create new python files by running:

Code: Select all

 wsdl2py vboxweb.wsdl 
I get this:
Traceback (most recent call last):
File "/usr/bin/wsdl2py", line 9, in <module>
wsdl2py()
File "/usr/lib/pymodules/python2.7/ZSI/generate/commands.py", line 148, in wsdl2py
files.append(_wsdl2dispatch(options, wsdl))
File "/usr/lib/pymodules/python2.7/ZSI/generate/commands.py", line 263, in _wsdl2dispatch
ss.fromWSDL(wsdl)
File "/usr/lib/pymodules/python2.7/ZSI/generate/wsdl2dispatch.py", line 281, in fromWSDL
raise WsdlGeneratorError, 'No service defined'
ZSI.generate.WsdlGeneratorError: No service defined

What should I do to create HDD with python over OOWS?

/Nicklas
NicklasE
Posts: 3
Joined: 25. Feb 2012, 16:01

Re: Can't create HDD through python + OOWS

Post by NicklasE »

Found out that when I run

Code: Select all

g_virtualBoxManager.constants.MediumVariant_Standard
In XPCOM I get 0
In OOWS i get 'Standard'

Does not work:

Code: Select all

progress = hdd.createBaseStorage(size, ctx['global'].constants.MediumVariant_Standard)
Works:

Code: Select all

progress = hdd.createBaseStorage(size, 0)

How can I make python use the XPCOM constants instead of OOWS, that does not seems to work?
NicklasE
Posts: 3
Joined: 25. Feb 2012, 16:01

Re: Can't create HDD through python + OOWS

Post by NicklasE »

Solved the problem with this code:

Code: Select all

from vboxapi import VirtualBoxManager, VirtualBox_constants
g_virtualBoxManager = VirtualBoxManager(binding_type, binding_options)
g_virtualBoxManager.constants = VirtualBox_constants.VirtualBoxReflectionInfo(False)
Dirty fix, but it works...
Post Reply