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

This is for discussing general topics about how to use VirtualBox.
Post Reply
vwelch
Posts: 4
Joined: 21. Jun 2009, 05:37
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: WinXP, Ubuntu

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

Post 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)
TerryE
Volunteer
Posts: 3572
Joined: 28. May 2008, 08:40
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu 10.04 & 11.10, both Svr&Wstn, Debian, CentOS
Contact:

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

Post by TerryE »

what does hddpath contain? Sounds like "" to me?
Read the Forum Posting Guide
Google your Q site:VirtualBox.org or search for the answer before posting.
vwelch
Posts: 4
Joined: 21. Jun 2009, 05:37
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: WinXP, Ubuntu

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

Post 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".
xasx
Posts: 49
Joined: 17. Jul 2007, 17:11
Primary OS: MS Windows other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP/Server 2008R2/7/8/2012, Gentoo, Ubuntu, OpenSUSE, Oracle Linux, Fedora, Arch
Location: Karlsruhe
Contact:

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

Post 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.
vwelch
Posts: 4
Joined: 21. Jun 2009, 05:37
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: WinXP, Ubuntu

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

Post 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
                                 ""
                                 )
xasx
Posts: 49
Joined: 17. Jul 2007, 17:11
Primary OS: MS Windows other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP/Server 2008R2/7/8/2012, Gentoo, Ubuntu, OpenSUSE, Oracle Linux, Fedora, Arch
Location: Karlsruhe
Contact:

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

Post 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
Post Reply