>  
>        InstanceTemplate instanceTemplate = InstanceTemplate.builder()
> -              .forMachineType(machineType);
> +              .forMachineType(hardware.getUri());
> +
> +      if (hardware.getUserMetadata().get("imageSpaceGb").equals("0")) {
> +         // The machine needs a boot disk - create a 1GB drive for this 
> purpose
> +         // TODO need to delete it at end!
> +         Operation operation = 
> api.getDiskApiForProject(userProject.get()).createInZone(name + "-disk", 10,
> +                 template.getLocation().getId());
> +         waitOperationDone(operation);
> +         
> instanceTemplate.addDisk(InstanceTemplate.PersistentDisk.Mode.READ_WRITE, 
> operation.getTargetLink());
> +      }

I changed my version to do something different, as this was causing far more 
trouble than it was worth. I experimented with changing listHardwareProfile to 
filter out machine types that did not have disks, on the basis that the compute 
service cannot create them, but this caused problems when non-jclouds instances 
existed using one of the filtered-out types - jclouds threw exceptions when it 
couldn't find the hardware type in use by an instance.

In the end I did something with the supportImage() property of Hardware 
instances - I made it so the diskless Hardwares refused to support *any* image. 
This is true, because a diskless machine type needs to be given a disk, and 
when a disk is given, it's not permitted to give an image. See 
https://github.com/richardcloudsoft/jclouds-labs/commit/d554fd65495b5181a686b89e61fe9c483a9426c6

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/16/files#r5394042

Reply via email to