Be able to do "storageattach" in WS

Discussion about using the VirtualBox API, Tutorials, Samples.

Be able to do "storageattach" in WS

Postby Grozeille » 15. Apr 2013, 17:40

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.
Grozeille
 
Posts: 3
Joined: 15. Apr 2013, 17:27

Re: Be able to do "storageattach" in WS

Postby noteirak » 15. Apr 2013, 21:24

Are you positive the VM still has free SATA port available before attempting the attach?
Hyperbox - Virtual Infrastructure Manager - https://kamax.io/hbox/
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
 
Posts: 5198
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7

Re: Be able to do "storageattach" in WS

Postby Grozeille » 15. Apr 2013, 22:24

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   Expand viewCollapse view
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   Expand viewCollapse view
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)
Grozeille
 
Posts: 3
Joined: 15. Apr 2013, 17:27

Re: Be able to do "storageattach" in WS

Postby noteirak » 15. Apr 2013, 22:47

Do you actual get a mutable object before attempting this change?
Relevant part of your code would help here.
Hyperbox - Virtual Infrastructure Manager - https://kamax.io/hbox/
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
 
Posts: 5198
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7

Re: Be able to do "storageattach" in WS

Postby Grozeille » 15. Apr 2013, 23:15

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   Expand viewCollapse view
IMachine m = virtualBoxManager.getVBox().findMachine(machineGuid);
m.attachDevice(defaultController, controllerPort, 0, DeviceType.HardDisk, medium);

By:
Code: Select all   Expand viewCollapse view
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);
}
Grozeille
 
Posts: 3
Joined: 15. Apr 2013, 17:27

Re: Be able to do "storageattach" in WS

Postby VBhardcore » 21. Jun 2013, 09:07

Can u tell me which programming laguage it is?
VBhardcore
 
Posts: 1
Joined: 21. Jun 2013, 08:42

Re: Be able to do "storageattach" in WS

Postby mpack » 21. Jun 2013, 12:22

.jar == Java.
mpack
Site Moderator
 
Posts: 29928
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP


Return to The VirtualBox API

Who is online

Users browsing this forum: No registered users and 2 guests