@Singleton
public class ImageToImage implements Function<Image, org.jclouds.compute.domain.Image> {
@Override
public org.jclouds.compute.domain.Image apply(final Image input) {
ImageBuilder builder = new ImageBuilder();
// Private images don't have a slug
builder.id(input.getSlug() != null ? input.getSlug() : String.valueOf(input.getId()));
builder.providerId(String.valueOf(input.getId()));
builder.name(input.getName());
builder.description(input.getName());
builder.status(Status.AVAILABLE);
OperatingSystem os = input.getOs();
builder.operatingSystem(builder()
.name(input.getName())
.family(os.getDistribution().getOsFamily())
.description(input.getName())
.arch(os.getArch())
.version(os.getVersion())
.is64Bit(os.is64bit())
.build());
ImmutableMap.Builder<String, String> metadata = ImmutableMap.builder();
metadata.put("publicImage", String.valueOf(input.isPublicImage()));
builder.userMetadata(metadata.build());
return builder.build();
}