Page 1 of 1

Python SDK Question (3.0.4): openHardDisk() create UUID

Posted: 10. Aug 2009, 01:30
by vwelch
Hello - is this the right place for SDK questions? Not clear to me where is.

My question is about vbox.openHardDisk() using python. I'm trying to get it to create a new UUID automatically by setting setImageId=True and imageId to an "empty string", but setting ImageId to None or "" both return errors. Details appended.

What constitutes an "empty string" in python?

TIA.

Code: Select all

        disk = vbox.openHardDisk(hddPath,
                                 manager.constants.AccessMode_ReadWrite,
                                 True, # SetImageId
                                 "",
                                 True, # SetParentId
                                 ""
                                 )
Results in:

Code: Select all

File "<XPCOMObject method 'openHardDisk'>", line 3, in openHardDisk
xpcom.Exception: 0x80070057 (Argument aImageId is empty)
Using None instead of "' results in:

Code: Select all

  File "<XPCOMObject method 'openHardDisk'>", line 3, in openHardDisk
xpcom.Exception: 0x80070057 (Argument aImageId is NULL)

Re: Python SDK Question (3.0.4): openHardDisk() create UUID

Posted: 10. Aug 2009, 11:59
by TerryE
what does hddpath contain? Sounds like "" to me?

Re: Python SDK Question (3.0.4): openHardDisk() create UUID

Posted: 20. Aug 2009, 04:11
by vwelch
TerryE wrote:what does hddpath contain? Sounds like "" to me?
hddPath contains a string with a relative path to the .vdi file, specially in this case "Ubuntu-Desktop.vdi".

Re: Python SDK Question (3.0.4): openHardDisk() create UUID

Posted: 20. Aug 2009, 11:45
by xasx
This is the code that produces the output:

Code: Select all

    if (aSetImageId)
    {
        imageId = Guid(aImageId);
        if (imageId.isEmpty())
            return setError (E_INVALIDARG, tr ("Argument %s is empty"), "aImageId");
    }
    if (aSetParentId)
        parentId = Guid(aParentId);
So I'd suggest you to provide a value for aImageId or set the booleans to false.
But I don't know whether this will work.

EDIT: the set* booleans seem to indicate that YOU specify the values. Perhaps this is the misunderstanding.

Re: Python SDK Question (3.0.4): openHardDisk() create UUID

Posted: 28. Aug 2009, 00:34
by vwelch
xasx wrote:This is the code that produces the output:
Could you tell me where I could find this code? It would be useful for future debugging.
xasx wrote:EDIT: the set* booleans seem to indicate that YOU specify the values. Perhaps this is the misunderstanding.
Thank you, that was the problem, I had those values reversed and setting them to False let me work through this.

For anyone else trying to do this, I still had to pass empty strings, as opposed to None, for imageId and parentId otherwise I got (e.g.) "Argument aParentId is NULL" errors:

Code: Select all

        disk = vbox.openHardDisk(hddPath,
                                 manager.constants.AccessMode_ReadWrite,
                                 False, # SetImageId
                                 "",
                                 False, # SetParentId
                                 ""
                                 )

Re: Python SDK Question (3.0.4): openHardDisk() create UUID

Posted: 28. Aug 2009, 01:00
by xasx
vwelch wrote:Could you tell me where I could find this code? It would be useful for future debugging.
It is VBox/Main/VirtualBoxImpl.cpp