VirtualBox

Opened 8 years ago

Last modified 8 years ago

#15036 new defect

SDK Python webserver bindings IMachine::setGroups() inconsistent signature

Reported by: Alberto Geniola Owned by:
Component: other Version: VirtualBox 5.0.12
Keywords: sdk, setGroups, python, webservice Cc:
Guest type: other Host type: other

Description

Hi everybody,

Virtualbox 5.0 introduced the Grouping feature, but the SDK api seems to be not aligned to the new feature. In particular I have experienced a problem with the VirtuaBox_wrappers.py generated from the Virtualbox.xidl for the IMachine::setGroups() method.

Indeed, the following code is generated:

def setGroups(self, value):
       req=IMachine_setGroupsRequestMsg()
       req._this=self.handle
       if type(value) in [int, bool, basestring, str]:
            req._groups = value
       else:
            req._groups = value.handle
       self.mgr.getPort().IMachine_setGroups(req)

According to the method signature, the user has to pass a list/array of groups to set. This code will fail in that case: passing an array will make control enter the else clause, causing invalid access to undefined "handle" attribute. The generated code should only accept list/tupes and not strings. This requires some modification to the xidl file so the generated code reflects the method signature.

Change History (5)

comment:1 by Alberto Geniola, 8 years ago

I found the problem.

The SDK bundle available as download from Virtualbox website contains correct definitions of wsdl but python libs have not been update.

To fix it, just execute the following code from cmd:

> wsdl2py -b --file vboxweb.wsdl
> wsdl2py -b --file vboxwebService.wsdl

then copy the two generated python files (VirtualBox_services.py and VirtualBox_services_types.py) into the libs folder of your python installation (mine is C:\Python27\Lib\site-packages\vboxapi).

This fixes this problem on windows.

I encourage Oracle to update the SDK bundle to fix this annoying problem.

comment:2 by Frank Mehnert, 8 years ago

I wonder what changed when you execute these commands yourself. The SDK from the website does already contain !VirtualBox_client.py and !VirtualBox_server.py. Which SDK did you actually download, are you sure you downloaded the SDK matching to your VirtualBox version?

comment:3 by Klaus Espenlaub, 8 years ago

This is really weird. With both python 2.6 and 2.7 (tested on Linux) the wsdl2py generates totally differently named files for me, the ones which are shipping with the SDK.

I really wonder which python version (and ZSI version) you're using...

In fact the SDK bundle we ship doesn't work for me, because it unconditionally imports !VirtualBox_services which isn't there and isn't generated by wsdl2py.

Last edited 8 years ago by Klaus Espenlaub (previous) (diff)

comment:4 by Klaus Espenlaub, 8 years ago

Checked the ZSI sources. They dropped the old _services naming style in early 2007 (when they moved from ZSI 1.x to 2.0). You must be using a real museum piece of ZSI in combination with a not terribly old python version (2.7, first release in 2010).

comment:5 by Klaus Espenlaub, 8 years ago

Working on fixing the generated wrappers and a SDK packaging bug in VirtualBox 5.0.

I can't make ANY sense out of your claim that putting some wsdl2py generated files into the SDK will fix the broken wrappers in any way. It works around the packaging bug in a very weird and not recommended way. Symptom of the packaging issue is a exception caused by a missing file which gets imported.

Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use