}
@Override
public ListenableFuture<Image> createImage(ImageTemplate template) {
checkState(template instanceof CloneImageTemplate, " ec2 only supports creating images through cloning.");
CloneImageTemplate cloneTemplate = (CloneImageTemplate) template;
String[] parts = AWSUtils.parseHandle(cloneTemplate.getSourceNodeId());
String region = parts[0];
String instanceId = parts[1];
String imageId = ec2Api.getAMIApi().get().createImageInRegion(region, cloneTemplate.getName(), instanceId,
CreateImageOptions.NONE);
final AtomicReference<Image> image = Atomics.newReference(new ImageBuilder()
.location(find(locations.get(), idEquals(region)))
.id(region + "/" + imageId)
.providerId(imageId)
.description(cloneTemplate.getName())
.operatingSystem(OperatingSystem.builder().description(cloneTemplate.getName()).build())
.status(Image.Status.PENDING).build());
return userExecutor.submit(new Callable<Image>() {
@Override
public Image call() throws Exception {