diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java index f5cf735d57..fb8e669544 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java @@ -18,9 +18,6 @@ */ package org.jclouds.cloudsigma.compute.config; -import static org.jclouds.compute.domain.OsFamily.UBUNTU; - -import java.util.Map; import java.util.concurrent.TimeUnit; import javax.inject.Inject; @@ -58,7 +55,9 @@ import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.base.Supplier; -import com.google.common.collect.MapMaker; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; import com.google.inject.Injector; import com.google.inject.Provides; import com.google.inject.TypeLiteral; @@ -77,7 +76,11 @@ public class CloudSigmaComputeServiceContextModule @Override protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { - return template.osFamily(UBUNTU).osVersionMatches("1[10].[10][04]").os64Bit(true).minRam(1024); + // until there is a way to query by drive info that can suggest which + // drives are ssh boot + return template.imageId("a3011b07-3f04-467e-9390-f9a85d859de1").minRam(1024); + // return + // template.osFamily(UBUNTU).osVersionMatches("1[10].[10][04]").os64Bit(true).minRam(1024); } @SuppressWarnings({ "unchecked", "rawtypes" }) @@ -108,12 +111,12 @@ public class CloudSigmaComputeServiceContextModule @Provides @Singleton - protected Map cache(GetDrive getDrive) { - return new MapMaker().makeComputingMap(getDrive); + protected Cache cache(GetDrive getDrive) { + return CacheBuilder.newBuilder().build(getDrive); } @Singleton - public static class GetDrive implements Function { + public static class GetDrive extends CacheLoader { private final CloudSigmaClient client; @Inject @@ -122,7 +125,7 @@ public class CloudSigmaComputeServiceContextModule } @Override - public DriveInfo apply(String input) { + public DriveInfo load(String input) { return client.getDriveInfo(input); } } diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java index 0c832ffd93..0633c60fd4 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java @@ -53,7 +53,8 @@ public class ParseOsFamilyVersion64BitFromImageName implements Function { String description = drive.getDescription() != null ? drive.getDescription() : drive.getName(); Builder builder = OperatingSystem.builder(); OsFamilyVersion64Bit parsed = imageParser.apply(drive.getName()); - builder.name(drive.getName()).description(description).is64Bit(parsed.is64Bit).version(parsed.version).family( - parsed.family); + builder.name(drive.getName()).description(description) + .is64Bit(drive.getBits() != null ? drive.getBits() == 64 : parsed.is64Bit).version(parsed.version) + .family(parsed.family); return new ImageBuilder().ids(drive.getUuid()).adminPassword("cloudsigma").userMetadata( ImmutableMap. of("size", drive.getSize() / 1024 / 1024 / 1024 + "")).defaultCredentials( new Credentials("cloudsigma", "cloudsigma")).location(locationSupplier.get()).name(drive.getName()) diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderLiveTest.java index 21cfdbd919..09ec32c06d 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderLiveTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderLiveTest.java @@ -52,16 +52,18 @@ public class CloudSigmaTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTe public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !input.version.equals("11.10") - && ((input.version.equals("") || input.version.equals("10.04")) || !(input.version - .matches("^[89].*")) - && input.is64Bit); + return input.version.equals("11.04") || (input.version.equals("11.04") && !input.is64Bit) + || !input.version.equals("11.10") + && (input.version.equals("") || !(input.version.matches("^[89].*")) && input.is64Bit); + case SOLARIS: + return !input.is64Bit; case DEBIAN: return input.is64Bit; case CENTOS: - return (input.version.equals("") || input.version.matches("5.[05]")) && input.is64Bit; + return input.version.equals("5.0") || input.version.equals("") + || (input.version.matches("5.[5]") && input.is64Bit); case WINDOWS: - return (input.version.equals("2008 R2") && input.is64Bit) + return input.version.equals("2008 R2") || (input.version.equals("2008") && !input.is64Bit) || input.version.equals("") || (input.version.equals("2003")); default: diff --git a/providers/cloudsigma-zrh/src/test/resources/osmatches.json b/providers/cloudsigma-zrh/src/test/resources/osmatches.json index 9ff751bbcc..7b0b1fadda 100644 --- a/providers/cloudsigma-zrh/src/test/resources/osmatches.json +++ b/providers/cloudsigma-zrh/src/test/resources/osmatches.json @@ -1,5 +1,28 @@ { + "Ubuntu-10.04-20110917 pub": { + "family": "UBUNTU", + "version": "10.04", + "is64Bit": true + }, + + "Ubuntu-11.04-20110917 pub": { + "family": "UBUNTU", + "version": "11.04", + "is64Bit": true + }, + + "Centos-6.0-20110917 pub": { + "family": "CENTOS", + "version": "6.0", + "is64Bit": true + }, + "Centos-5.6-20110917 pub": { + "family": "CENTOS", + "version": "5.6", + "is64Bit": true + }, + "Ubuntu 10.04.1 LTS Desktop Edition 32bit Preinstalled System": { "family": "UBUNTU", "version": "10.04",