Search code examples
javagoogle-compute-enginejclouds

JClouds: Customizing volumes with Google Compute Engine


I am not able to find documentation or code examples for the following tasks using JClouds and Google Compute Engine:

  • When you are creating an instance, how can you choose SSD instead Standard Disk ?
  • How can you customize the size of the root volume ?
  • How can you add additional volumes ?

I hope someone can provide me some code samples.

Thanks in advance,


Solution

  • This has been already answered in the jclouds mailing list, but here is a summary:

    Currently there is no way to do that using the ComputeService, but the GCE provider specific API supports it. The InstanceApi has the "create" and "attachDisk" method, that can be used to create instances with custom disks and attach disks to existing ones.

    The former gets a NewInstance object that has a list of AttachDisk objects. There you cans et the size of the disk and their type. The same applies to the "attachDisk" method, thich gets an AttachDisk object. Using those methods you should be able to create instances with custom disks.

    If you have the ComputeServiceContext instance, you can get the InstanceApi as follows:

    GoogleComputeEngineApi gce = context.unwrapApi(GoogleComputeEngineApi.class);
    InstanceApi instanceApi = gce.instancesInZone("zone name");