Be able to do "storageattach" in WS

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
Grozeille
Posts: 3
Joined: 15. Apr 2013, 17:27

Be able to do "storageattach" in WS

Post 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.
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Be able to do "storageattach" in WS

Post by noteirak »

Are you positive the VM still has free SATA port available before attempting the attach?
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Grozeille
Posts: 3
Joined: 15. Apr 2013, 17:27

Re: Be able to do "storageattach" in WS

Post 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)
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Be able to do "storageattach" in WS

Post by noteirak »

Do you actual get a mutable object before attempting this change?
Relevant part of your code would help here.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Grozeille
Posts: 3
Joined: 15. Apr 2013, 17:27

Re: Be able to do "storageattach" in WS

Post 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);
}
VBhardcore
Posts: 1
Joined: 21. Jun 2013, 08:42

Re: Be able to do "storageattach" in WS

Post by VBhardcore »

Can u tell me which programming laguage it is?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Be able to do "storageattach" in WS

Post by mpack »

.jar == Java.
Post Reply