The following example outlines how to add sub-resources to a resource. In this example, a new disk with a size of '1073741824L', interface 'virtio' and format 'cow' are added to a virtual machine with the name 'test'.

Procedure
  1. Declare an instance of the resource to which sub-resources are to be added:

    VM vm = api.getVMs().get("test");
  2. Create parameters to define the attributes of the resource:

    Disk diskParam = new Disk();
    diskParam.setProvisionedSize(1073741824L);
    diskParam.setInterface("virtio");
    diskParam.setFormat("cow");
  3. Add the sub-resource:

    Disk disk = vm.getDisks().add(diskParam);