@Override
public ListenableFuture<Image> createImage(ImageTemplate template) {
checkState(template instanceof CloneImageTemplate,
" openstack-nova only supports creating images through cloning.");
CloneImageTemplate cloneTemplate = (CloneImageTemplate) template;
RegionAndId sourceImageRegionAndId = RegionAndId.fromSlashEncoded(cloneTemplate.getSourceNodeId());
String newImageId = novaApi.getServerApi(sourceImageRegionAndId.getRegion()).createImageFromServer(
cloneTemplate.getName(), sourceImageRegionAndId.getId());
final RegionAndId targetImageRegionAndId = RegionAndId.fromRegionAndId(sourceImageRegionAndId.getRegion(), newImageId);
logger.info(">> Registered new Image %s, waiting for it to become available.", newImageId);
final AtomicReference<Image> image = Atomics.newReference(new ImageBuilder()
.location(find(locations.get(), idEquals(targetImageRegionAndId.getRegion())))
.id(targetImageRegionAndId.slashEncode())
.providerId(targetImageRegionAndId.getId())
.description(cloneTemplate.getName())
.operatingSystem(OperatingSystem.builder().description(cloneTemplate.getName()).build())
.status(Image.Status.PENDING).build());
return userExecutor.submit(new Callable<Image>() {