Page 1 of 1

Be able to do "storageattach" in WS

Posted: 15. Apr 2013, 17:40
by Grozeille
Hi,

I'm working on a VirtualBox driver for Cloudify: (virtualbox-cloudify-driver in github)
Cloudify is a tool to deploy your application on any IaaS.
Because I don't have an internet connection sometimes, I decided to develop this driver to simulate a cloud on my laptop.
It works fine, I'm using the WebService to do that, with the vboxjws.jar.

In Cloudify 2.5, you can now attach a "volume" to the VM. Ex: in EC2, you can attach an EBS to the VM, so when the VM crash, it creates a new VM and attach the EBS to it.

I started to implement this feature in my driver, but it's not working:
I saw that "storageattach" can attach (or detach) volumes to a running VM if it uses a SATA controller, but the WebService API doesn't allow me to do that (exception about "the state of the VM is running")

Is it a "feature request" ? How can I ask that ? Can I change it "quickly" by contributing to the vboxjw.jar (so you can merge my contribution latter) ? If so, do you have any hints?

Thanks by advance.
Regards.

Re: Be able to do "storageattach" in WS

Posted: 15. Apr 2013, 21:24
by noteirak
Are you positive the VM still has free SATA port available before attempting the attach?

Re: Be able to do "storageattach" in WS

Posted: 15. Apr 2013, 22:24
by Grozeille
Yes I'm sure (I already had this error before, now I put the maximum number of port: 30)

My error log is:

Code: Select all

2013-04-15 20:18:28,804 ESM SEVERE [org.openspaces.grid.gsm.machines.plugins.NonBlockingElasticMachineProvisioningAdapter] - Unexpected exception:VirtualBox error: The machine is not mutable (state is Running) (0x80BB0002); Caused by: org.virtualbox_4_2.VBoxException: VirtualBox error: The machine is not mutable (state is Running) (0x80BB0002)
    at org.virtualbox_4_2.IMachine.attachDevice(IMachine.java:2818)
As you can see, the WebService doesn't allow me to "hot plug" the disk.

In the WebService output (vboxwebsrv) I have the same error:

Code: Select all

32:39:36.660812 SQW01    API return code:            0x80BB0002 (VBOX_E_INVALID_VM_STATE)
32:39:36.660865 SQW01    COM error info result code: 0x80BB0002
32:39:36.660877 SQW01    COM error info text:        The machine is not mutable (state is Running)

Re: Be able to do "storageattach" in WS

Posted: 15. Apr 2013, 22:47
by noteirak
Do you actual get a mutable object before attempting this change?
Relevant part of your code would help here.

Re: Be able to do "storageattach" in WS

Posted: 15. Apr 2013, 23:15
by Grozeille
Thank you for your help!

Indeed, I forgot to use a mutable object (but I use mutable object somewhere lese in the code... really don't know this time I didn't).

So I changed:

Code: Select all

IMachine m = virtualBoxManager.getVBox().findMachine(machineGuid);
m.attachDevice(defaultController, controllerPort, 0, DeviceType.HardDisk, medium);
By:

Code: Select all

IMachine m = virtualBoxManager.getVBox().findMachine(machineGuid);
ISession session = virtualBoxManager.openMachineSession(m);
m = session.getMachine();

try {
    m.attachDevice(defaultController, controllerPort, 0, DeviceType.HardDisk, medium);
    
    m.saveSettings();
} finally{
    this.virtualBoxManager.closeMachineSession(session);
}

Re: Be able to do "storageattach" in WS

Posted: 21. Jun 2013, 09:07
by VBhardcore
Can u tell me which programming laguage it is?

Re: Be able to do "storageattach" in WS

Posted: 21. Jun 2013, 12:22
by mpack
.jar == Java.