@Override
public NodeAndInitialCredentials<ServerInfo> createNodeWithGroupEncodedIntoName(String tag, String name, Template template) {
long bootSize = (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l);
logger.debug(">> creating boot drive bytes(%d)", bootSize);
DriveInfo drive = client
.createDrive(new Drive.Builder().name(template.getImage().getId()).size(bootSize).build());
logger.debug("<< drive (%s)", drive);
boolean success = driveNotClaimed.apply(drive);
if (!success) {
client.destroyDrive(drive.getUuid());
throw new IllegalStateException(String.format("could not create drive %s in time!", drive));
}
logger.debug(">> imaging boot drive source(%s)", template.getImage().getId());
client.imageDrive(template.getImage().getId(), drive.getUuid(), ImageConversionType.GUNZIP);
boolean ready = driveNotClaimed.apply(drive);
if (!ready) {
client.destroyDrive(drive.getUuid());
throw new IllegalStateException(String.format("could not image drive %s in time!", drive));
}
logger.debug("<< imaged (%s)", drive);
template.getOptions().userMetadata(ComputeServiceConstants.NODE_GROUP_KEY, tag);
Server toCreate = small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam())
.cpu((int) (template.getHardware().getProcessors().get(0).getSpeed()))
.tags(template.getOptions().getTags()).userMetadata(template.getOptions().getUserMetadata()).build();
ServerInfo from = client.createServer(toCreate);