From a7e342422c4f271a642a67fd2771f0aa7e6e504f Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Tue, 25 Mar 2014 15:00:07 +0100 Subject: [PATCH] JCLOUDS-517: New ElasticHosts images and regions Added the new ElasticHosts regions. Updated the ElasticStack api to get the list of standard drives using an API call. All providers except ServerLove support the new API call, so the old logic in the ElasticStack api has been moved to that provider. The rest of providers will now extract all the OperatingSystem information by parsing the name of the StandardDrive. A unit test has been added to the ElasticStack api with all the images that were hardcoded, to make sure all names are still parsed as expected and all information in the existing providers is kept. Modified the default template for all ElasticHosts providers to match newer Ubuntu images and updated the Template*Live tests accordingly. Also refactored the WellKnownImage map to a supplier to lazy load it when needed and avoid unexpected errors when building the Guice injector if there are authentication errors or similar. --- apis/elasticstack/pom.xml | 12 + .../jclouds/elasticstack/ElasticStackApi.java | 22 ++ .../elasticstack/ElasticStackApiMetadata.java | 1 - .../ElasticStackComputeServiceAdapter.java | 28 +- ...asticStackComputeServiceContextModule.java | 58 +++- .../StandardDriveToWellKnownImage.java | 131 +++++++++ .../functions/WellKnownImageToImage.java | 18 +- .../elasticstack/domain/StandardDrive.java | 185 ++++++++++++ .../elasticstack/domain/WellKnownImage.java | 90 +++++- ...limitedByBlankLinesToStandardDriveSet.java | 60 ++++ .../functions/MapToDriveInfo.java | 2 +- .../functions/MapToStandardDrive.java | 78 +++++ .../elasticstack/functions/SplitNewlines.java | 7 +- .../handlers/ElasticStackErrorHandler.java | 17 +- .../suppliers/StandardDiskImageSupplier.java | 64 ++++ .../suppliers/WellKnownImageSupplier.java | 35 +++ .../elasticstack/preinstalled_images.json | 72 ----- .../main/resources/preinstalled_images.readme | 7 - .../elasticstack/ElasticStackApiLiveTest.java | 16 + .../elasticstack/ElasticStackApiTest.java | 15 + .../elasticstack/ElasticStackMockTest.java | 110 +++++++ .../StandardDriveToWellKnownImageTest.java | 121 ++++++++ ...tedByBlankLinesToStandardDriveSetTest.java | 47 +++ .../functions/MapToStandardDriveTest.java | 68 +++++ .../MockStandardDiskImageSupplier.java | 69 +++++ .../src/test/resources/standard_drive.txt | 8 + .../src/test/resources/standard_drives.txt | 275 ++++++++++++++++++ .../test/resources/standard_drives_uuids.txt | 36 +++ providers/elastichosts-ams-e/README.txt | 6 + providers/elastichosts-ams-e/pom.xml | 125 ++++++++ .../ElasticHostsAmsterdamMetadata.java | 86 ++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../ElasticHostsAmsterdamApiLiveTest.java | 30 ++ .../ElasticHostsAmsterdamProviderTest.java | 32 ++ ...cHostsAmsterdamComputeServiceLiveTest.java | 33 +++ ...HostsAmsterdamTemplateBuilderLiveTest.java | 85 ++++++ providers/elastichosts-hkg-e/README.txt | 5 + providers/elastichosts-hkg-e/pom.xml | 125 ++++++++ .../ElasticHostsHongKongProviderMetadata.java | 86 ++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../ElasticHostsHongKongApiLiveTest.java | 30 ++ .../ElasticHostsHongKongProviderTest.java | 32 ++ ...icHostsHongKongComputeServiceLiveTest.java | 33 +++ ...cHostsHongKongTemplateBuilderLiveTest.java | 85 ++++++ ...cHostsPeer1LosAngelesProviderMetadata.java | 3 + .../preinstalled_images.json | 65 ----- ...eer1LosAngelesTemplateBuilderLiveTest.java | 25 +- ...HostsBlueSquareLondonProviderMetadata.java | 3 + .../preinstalled_images.json | 65 ----- ...ueSquareLondonTemplateBuilderLiveTest.java | 31 +- ...asticHostsPeer1LondonProviderMetadata.java | 3 + .../preinstalled_images.json | 65 ----- ...stsPeer1LondonTemplateBuilderLiveTest.java | 26 +- ...cHostsPeer1SanAntonioProviderMetadata.java | 3 + .../preinstalled_images.json | 72 ----- ...eer1SanAntonioTemplateBuilderLiveTest.java | 25 +- providers/elastichosts-sjc-c/README.txt | 5 + providers/elastichosts-sjc-c/pom.xml | 125 ++++++++ .../ElasticHostsSanJoseProviderMetadata.java | 83 ++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../ElasticHostsSanJoseApiLiveTest.java | 30 ++ .../ElasticHostsSanJoseProviderTest.java | 32 ++ ...ticHostsSanJoseComputeServiceLiveTest.java | 33 +++ ...icHostsSanJoseTemplateBuilderLiveTest.java | 85 ++++++ providers/elastichosts-syd-v/README.txt | 5 + providers/elastichosts-syd-v/pom.xml | 125 ++++++++ .../ElasticHostsSydneyProviderMetadata.java | 83 ++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../ElasticHostsSydneyApiLiveTest.java | 30 ++ .../ElasticHostsSydneyProviderTest.java | 32 ++ ...sticHostsSydneyComputeServiceLiveTest.java | 33 +++ ...ticHostsSydneyTemplateBuilderLiveTest.java | 85 ++++++ ...sticHostsPeer1TorontoProviderMetadata.java | 3 + .../preinstalled_images.json | 65 ----- ...tsPeer1TorontoTemplateBuilderLiveTest.java | 25 +- .../go2cloud-jhb1/preinstalled_images.json | 30 -- .../preinstalled_images.json | 51 ---- providers/pom.xml | 4 + .../ServerloveManchesterProviderMetadata.java | 32 +- .../config/ServerloveImagesModule.java | 38 +++ .../FixedWellKnownImageSupplier.java | 67 +++++ .../ServerloveManchesterApiLiveTest.java | 13 + .../preinstalled_images.json | 98 ------- 83 files changed, 3326 insertions(+), 721 deletions(-) create mode 100644 apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/StandardDriveToWellKnownImage.java create mode 100644 apis/elasticstack/src/main/java/org/jclouds/elasticstack/domain/StandardDrive.java create mode 100644 apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSet.java create mode 100644 apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToStandardDrive.java create mode 100644 apis/elasticstack/src/main/java/org/jclouds/elasticstack/suppliers/StandardDiskImageSupplier.java create mode 100644 apis/elasticstack/src/main/java/org/jclouds/elasticstack/suppliers/WellKnownImageSupplier.java delete mode 100644 apis/elasticstack/src/main/resources/elasticstack/preinstalled_images.json delete mode 100644 apis/elasticstack/src/main/resources/preinstalled_images.readme create mode 100644 apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackMockTest.java create mode 100644 apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/functions/StandardDriveToWellKnownImageTest.java create mode 100644 apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSetTest.java create mode 100644 apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/MapToStandardDriveTest.java create mode 100644 apis/elasticstack/src/test/java/org/jclouds/elasticstack/suppliers/MockStandardDiskImageSupplier.java create mode 100644 apis/elasticstack/src/test/resources/standard_drive.txt create mode 100644 apis/elasticstack/src/test/resources/standard_drives.txt create mode 100644 apis/elasticstack/src/test/resources/standard_drives_uuids.txt create mode 100644 providers/elastichosts-ams-e/README.txt create mode 100644 providers/elastichosts-ams-e/pom.xml create mode 100644 providers/elastichosts-ams-e/src/main/java/org/jclouds/elastichosts/ElasticHostsAmsterdamMetadata.java create mode 100644 providers/elastichosts-ams-e/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/ElasticHostsAmsterdamApiLiveTest.java create mode 100644 providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/ElasticHostsAmsterdamProviderTest.java create mode 100644 providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsAmsterdamComputeServiceLiveTest.java create mode 100644 providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsAmsterdamTemplateBuilderLiveTest.java create mode 100644 providers/elastichosts-hkg-e/README.txt create mode 100644 providers/elastichosts-hkg-e/pom.xml create mode 100644 providers/elastichosts-hkg-e/src/main/java/org/jclouds/elastichosts/ElasticHostsHongKongProviderMetadata.java create mode 100644 providers/elastichosts-hkg-e/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/ElasticHostsHongKongApiLiveTest.java create mode 100644 providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/ElasticHostsHongKongProviderTest.java create mode 100644 providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsHongKongComputeServiceLiveTest.java create mode 100644 providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsHongKongTemplateBuilderLiveTest.java delete mode 100644 providers/elastichosts-lax-p/src/main/resources/elastichosts-lax-p/preinstalled_images.json delete mode 100644 providers/elastichosts-lon-b/src/main/resources/elastichosts-lon-b/preinstalled_images.json delete mode 100644 providers/elastichosts-lon-p/src/main/resources/elastichosts-lon-p/preinstalled_images.json delete mode 100644 providers/elastichosts-sat-p/src/main/resources/elastichosts-sat-p/preinstalled_images.json create mode 100644 providers/elastichosts-sjc-c/README.txt create mode 100644 providers/elastichosts-sjc-c/pom.xml create mode 100644 providers/elastichosts-sjc-c/src/main/java/org/jclouds/elastichosts/ElasticHostsSanJoseProviderMetadata.java create mode 100644 providers/elastichosts-sjc-c/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/ElasticHostsSanJoseApiLiveTest.java create mode 100644 providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/ElasticHostsSanJoseProviderTest.java create mode 100644 providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSanJoseComputeServiceLiveTest.java create mode 100644 providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSanJoseTemplateBuilderLiveTest.java create mode 100644 providers/elastichosts-syd-v/README.txt create mode 100644 providers/elastichosts-syd-v/pom.xml create mode 100644 providers/elastichosts-syd-v/src/main/java/org/jclouds/elastichosts/ElasticHostsSydneyProviderMetadata.java create mode 100644 providers/elastichosts-syd-v/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/ElasticHostsSydneyApiLiveTest.java create mode 100644 providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/ElasticHostsSydneyProviderTest.java create mode 100644 providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSydneyComputeServiceLiveTest.java create mode 100644 providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSydneyTemplateBuilderLiveTest.java delete mode 100644 providers/elastichosts-tor-p/src/main/resources/elastichosts-tor-p/preinstalled_images.json delete mode 100644 providers/go2cloud-jhb1/src/main/resources/go2cloud-jhb1/preinstalled_images.json delete mode 100644 providers/openhosting-east1/src/main/resources/openhosting-east1/preinstalled_images.json create mode 100644 providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/config/ServerloveImagesModule.java create mode 100644 providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/suppliers/FixedWellKnownImageSupplier.java delete mode 100644 providers/skalicloud-sdg-my/src/main/resources/skalicloud-sdg-my/preinstalled_images.json diff --git a/apis/elasticstack/pom.xml b/apis/elasticstack/pom.xml index 272497c6909..40b992d22f0 100644 --- a/apis/elasticstack/pom.xml +++ b/apis/elasticstack/pom.xml @@ -78,6 +78,18 @@ ${project.version} test + + com.squareup.okhttp + mockwebserver + test + + + + org.bouncycastle + bcprov-jdk15on + + + diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApi.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApi.java index bc6fe392abd..7e7b056fcf3 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApi.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApi.java @@ -38,10 +38,12 @@ import org.jclouds.elasticstack.domain.ImageConversionType; import org.jclouds.elasticstack.domain.Server; import org.jclouds.elasticstack.domain.ServerInfo; +import org.jclouds.elasticstack.domain.StandardDrive; import org.jclouds.elasticstack.functions.KeyValuesDelimitedByBlankLinesToDriveInfo; import org.jclouds.elasticstack.functions.KeyValuesDelimitedByBlankLinesToServerInfo; import org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet; import org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet; +import org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSet; import org.jclouds.elasticstack.functions.ReturnPayload; import org.jclouds.elasticstack.functions.SplitNewlines; import org.jclouds.http.filters.BasicAuthentication; @@ -201,6 +203,26 @@ ServerInfo setServerConfiguration(@PathParam("uuid") String uuid, @Path("/drives/info") @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class) Set listDriveInfo(); + + /** + * Lists standard drive UUIDs in your account + * + * @return or empty set if no standard drives are found + */ + @GET + @Path("/drives/list/standard") + @ResponseParser(SplitNewlines.class) + Set listStandardDrives(); + + /** + * Gets information about all standard drives + * + * @return or empty set if no standard drives are found + */ + @GET + @Path("/drives/info/standard") + @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSet.class) + Set listStandardDriveInfo(); /** * @param uuid diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java index 9625beba164..19c630903b0 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java @@ -62,7 +62,6 @@ public static Properties defaultProperties() { public static class Builder extends BaseHttpApiMetadata.Builder { - @SuppressWarnings("deprecation") protected Builder() { id("elasticstack") .name("ElasticStack API") diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java index a478cf49a62..e1364d05640 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java @@ -32,6 +32,7 @@ import javax.inject.Singleton; import org.jclouds.Constants; +import org.jclouds.collect.Memoized; import org.jclouds.compute.ComputeServiceAdapter; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.HardwareBuilder; @@ -57,6 +58,7 @@ import com.google.common.base.Function; import com.google.common.base.Predicate; +import com.google.common.base.Supplier; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.FluentIterable; @@ -70,7 +72,7 @@ /** * defines the connection between the {@link org.jclouds.elasticstack.ElasticStackApi} implementation - * and the jclouds {@link ComputeService} + * and the jclouds {@link org.jclouds.compute.ComputeService} * */ @Singleton @@ -78,7 +80,7 @@ public class ElasticStackComputeServiceAdapter implements ComputeServiceAdapter { private final ElasticStackApi client; private final Predicate driveNotClaimed; - private final Map preinstalledImages; + private final Supplier> preinstalledImages; private final LoadingCache cache; private final String defaultVncPassword; private final ListeningExecutorService userExecutor; @@ -89,7 +91,7 @@ public class ElasticStackComputeServiceAdapter implements @Inject public ElasticStackComputeServiceAdapter(ElasticStackApi client, Predicate driveNotClaimed, - Map preinstalledImages, LoadingCache cache, + @Memoized Supplier> preinstalledImages, LoadingCache cache, @Named(ElasticStackConstants.PROPERTY_VNC_PASSWORD) String defaultVncPassword, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) { this.client = checkNotNull(client, "client"); @@ -108,16 +110,22 @@ public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName( 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.getUuid()); + logger.debug("<< drive (%s)", drive); - logger.debug(">> imaging boot drive source(%s)", template.getImage().getId()); - client.imageDrive(template.getImage().getId(), drive.getUuid(), ImageConversionType.GUNZIP); boolean success = driveNotClaimed.apply(drive); - logger.debug("<< imaged (%s)", success); if (!success) { client.destroyDrive(drive.getUuid()); - throw new IllegalStateException("could not image drive in time!"); + 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); @@ -126,6 +134,7 @@ public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName( .tags(template.getOptions().getTags()).userMetadata(template.getOptions().getUserMetadata()).build(); ServerInfo from = client.createServer(toCreate); + client.startServer(from.getUuid()); from = client.getServerInfo(from.getUuid()); return new NodeAndInitialCredentials(from, from.getUuid(), LoginCredentials.builder() @@ -164,7 +173,7 @@ public String toString() { */ @Override public Iterable listImages() { - return FluentIterable.from(transformParallel(preinstalledImages.keySet(), + return FluentIterable.from(transformParallel(preinstalledImages.get().keySet(), new Function>() { @Override @@ -187,7 +196,6 @@ public String toString() { }, userExecutor, null, logger, "drives")).filter(notNull()); } - @SuppressWarnings("unchecked") @Override public Iterable listNodes() { return (Iterable) client.listServerInfo(); diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java index 4aba9afc734..9fd590a75e2 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java @@ -16,16 +16,22 @@ */ package org.jclouds.elasticstack.compute.config; +import static com.google.common.base.Suppliers.memoizeWithExpiration; import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.util.Predicates2.retry; import java.io.IOException; import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; +import javax.inject.Named; import javax.inject.Singleton; +import org.jclouds.collect.Memoized; import org.jclouds.compute.ComputeServiceAdapter; import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.Hardware; @@ -39,21 +45,24 @@ import org.jclouds.elasticstack.compute.functions.ServerInfoToNodeMetadata; import org.jclouds.elasticstack.compute.functions.ServerInfoToNodeMetadata.DeviceToVolume; import org.jclouds.elasticstack.compute.functions.ServerInfoToNodeMetadata.GetImageIdFromServer; +import org.jclouds.elasticstack.compute.functions.StandardDriveToWellKnownImage; import org.jclouds.elasticstack.compute.functions.WellKnownImageToImage; import org.jclouds.elasticstack.domain.Device; import org.jclouds.elasticstack.domain.DriveInfo; import org.jclouds.elasticstack.domain.Server; import org.jclouds.elasticstack.domain.ServerInfo; +import org.jclouds.elasticstack.domain.StandardDrive; import org.jclouds.elasticstack.domain.WellKnownImage; import org.jclouds.elasticstack.predicates.DriveClaimed; +import org.jclouds.elasticstack.suppliers.WellKnownImageSupplier; import org.jclouds.functions.IdentityFunction; -import org.jclouds.json.Json; -import org.jclouds.location.Provider; -import org.jclouds.util.Strings2; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; 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.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -66,7 +75,7 @@ * @author Adrian Cole */ public class ElasticStackComputeServiceContextModule extends - ComputeServiceAdapterContextModule { + ComputeServiceAdapterContextModule { @SuppressWarnings("unchecked") @Override @@ -88,8 +97,12 @@ protected void configure() { }).to(GetImageIdFromServer.class); bind(new TypeLiteral>() { }).to(WellKnownImageToImage.class); + bind(new TypeLiteral>() { + }).to(StandardDriveToWellKnownImage.class); + bind(new TypeLiteral>>() { + }).to(WellKnownImageSupplier.class); } - + @Provides @Singleton protected LoadingCache cache(GetDrive getDrive) { @@ -113,18 +126,33 @@ public DriveInfo load(String input) { @Singleton @Provides - protected Map provideImages(Json json, @Provider String providerName) throws IOException { - List wellKnowns = json.fromJson(Strings2.toStringAndClose(getClass().getResourceAsStream( - "/" + providerName + "/preinstalled_images.json")), new TypeLiteral>() { - }.getType()); - return Maps.uniqueIndex(wellKnowns, new Function() { - + @Memoized + protected Supplier> provideImages(@Named(PROPERTY_SESSION_INTERVAL) long seconds, + @Memoized final Supplier> wellKnownImageSupplier) throws IOException { + // The image map won't change. Memoize it during the session. + // This map can't be created directly as a singleton, as Guice needs it to construct the ElasticStackComputeServiceAdapter + // and a misconfiguration such as invalid credentials, etc would cause the Guice injection to fail + return memoizeWithExpiration(new Supplier>() { @Override - public String apply(WellKnownImage input) { - return input.getUuid(); + public Map get() { + return Maps.uniqueIndex(wellKnownImageSupplier.get(), new Function() { + @Override + public String apply(WellKnownImage input) { + return input.getUuid(); + } + }); } - - }); + }, seconds, TimeUnit.SECONDS); + } + + @Singleton + @Provides + @Memoized + protected Supplier> provideWellKnownImageSupplier(AtomicReference authException, + @Named(PROPERTY_SESSION_INTERVAL) long seconds, WellKnownImageSupplier uncached) + throws IOException { + return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, uncached, seconds, + TimeUnit.SECONDS); } @Provides diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/StandardDriveToWellKnownImage.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/StandardDriveToWellKnownImage.java new file mode 100644 index 00000000000..3480b30548c --- /dev/null +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/StandardDriveToWellKnownImage.java @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elasticstack.compute.functions; + +import static com.google.common.collect.Iterables.tryFind; +import static java.util.Arrays.asList; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.annotation.Resource; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.reference.ComputeServiceConstants; +import org.jclouds.elasticstack.domain.StandardDrive; +import org.jclouds.elasticstack.domain.WellKnownImage; +import org.jclouds.logging.Logger; + +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.base.Predicate; + +/** + * Transforms a standard drive into an image that can be used to create nodes. + * + * @author Ignasi Barrera + */ +@Singleton +public class StandardDriveToWellKnownImage implements Function { + + /* + * Expression to finds the version in a text string in a Unix OS: + * CentOS 6 => 6 + * CentOS Linux 6.5 => + * Debian Linux 7.4 (Wheezy) => 7.4 + * Ubuntu Linux 12.04.1 LTS (Precise Pangolin) => 12.04.1 + */ + private static final Pattern UNIX_VERSION_PATTERN = Pattern.compile("[^\\d]*(\\d+(?:\\.\\d+)*).*"); + + /* + * Expression to finds the version in a text string in a Windows OS: + * Windows Server 2012 => 2012 + * Windows Standard 2008 R2 => 2008 R2 + * Windows Standard 2008 R2 + SQL => 2008 R2 + SQL + */ + private static final Pattern WINDOWS_VERSION_PATTERN = Pattern.compile("[^\\d]*(\\d+.*)"); + + @Resource + @Named(ComputeServiceConstants.COMPUTE_LOGGER) + protected Logger logger = Logger.NULL; + + @Override + public WellKnownImage apply(StandardDrive input) { + WellKnownImage.Builder builder = WellKnownImage.builder(); + builder.uuid(input.getUuid()); + builder.size(toGb(input.getSize())); + builder.description(input.getName()); + + OsFamily family = extractOsFamily(input.getName()); + String version = extractOsVersion(family, input.getName()); + + builder.osFamily(family); + builder.osVersion(version); + builder.is64bit(is64bit(input.getName())); + + return builder.build(); + } + + private static boolean is64bit(String name) { + return !name.contains("32bit"); + } + + private OsFamily extractOsFamily(final String name) { + final String lowerCaseName = name.toLowerCase(); + Optional family = tryFind(asList(OsFamily.values()), new Predicate() { + @Override + public boolean apply(OsFamily input) { + return lowerCaseName.startsWith(input.name().toLowerCase()); + } + }); + + if (family.isPresent()) { + logger.warn("could not find the operating system family for image: %s", name); + } + + return family.or(OsFamily.UNRECOGNIZED); + } + + private String extractOsVersion(OsFamily family, String name) { + String version = null; + if (family == OsFamily.WINDOWS) { + // TODO: Find a way to restrict better the windows version + Matcher matcher = WINDOWS_VERSION_PATTERN.matcher(name); + if (matcher.matches()) { + version = matcher.group(1); + } + } else { + Matcher matcher = UNIX_VERSION_PATTERN.matcher(name); + if (matcher.matches()) { + version = matcher.group(1); + } + } + + if (version == null) { + logger.warn("could not find the operating system version for image: %s", name); + } + + return version; + } + + private static int toGb(long sizeInBytes) { + return (int) (sizeInBytes / (1024 * 1024 * 1024)); + } + +} diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/WellKnownImageToImage.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/WellKnownImageToImage.java index 1bbfb9cb23f..179ae2888af 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/WellKnownImageToImage.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/functions/WellKnownImageToImage.java @@ -16,15 +16,18 @@ */ package org.jclouds.elasticstack.compute.functions; +import static com.google.common.base.Preconditions.checkNotNull; + import java.util.Map; import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.collect.Memoized; import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.Image.Status; import org.jclouds.compute.domain.ImageBuilder; import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.Image.Status; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; import org.jclouds.domain.LoginCredentials; @@ -41,19 +44,20 @@ @Singleton public class WellKnownImageToImage implements Function { private final Supplier locationSupplier; - private final Map preinstalledImages; + private final Supplier> preinstalledImages; private final Map credentialStore; @Inject - public WellKnownImageToImage(Supplier locationSupplier, Map preinstalledImages, Map credentialStore) { - this.locationSupplier = locationSupplier; - this.preinstalledImages = preinstalledImages; - this.credentialStore = credentialStore; + public WellKnownImageToImage(Supplier locationSupplier, + @Memoized Supplier> preinstalledImages, Map credentialStore) { + this.locationSupplier = checkNotNull(locationSupplier, "locationSupplier cannot be null"); + this.preinstalledImages = checkNotNull(preinstalledImages, "preinstalledImages cannot be null"); + this.credentialStore = checkNotNull(credentialStore, "credentialStore cannot be null"); } @Override public Image apply(DriveInfo drive) { - WellKnownImage input = preinstalledImages.get(drive.getUuid()); + WellKnownImage input = preinstalledImages.get().get(drive.getUuid()); // set credentials in the store here, as opposed to directly modifying the image. we need to // set credentials on the image outside of this function so that they can be for example // overridden by properties diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/domain/StandardDrive.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/domain/StandardDrive.java new file mode 100644 index 00000000000..3a86701a341 --- /dev/null +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/domain/StandardDrive.java @@ -0,0 +1,185 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elasticstack.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Map; + +import org.jclouds.javax.annotation.Nullable; + +/** + * @author Ignasi Barrera + */ +public class StandardDrive extends Drive { + public static class Builder extends Drive.Builder { + + protected ImageConversionType format; + protected MediaType media; + protected long rawSize; + + public Builder format(ImageConversionType format) { + this.format = format; + return this; + } + + public Builder media(MediaType media) { + this.media = media; + return this; + } + + public Builder rawSize(long rawSize) { + this.rawSize = rawSize; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public Builder claimType(ClaimType claimType) { + return Builder.class.cast(super.claimType(claimType)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder readers(Iterable readers) { + return Builder.class.cast(super.readers(readers)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder size(long size) { + return Builder.class.cast(super.size(size)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder uuid(String uuid) { + return Builder.class.cast(super.uuid(uuid)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder name(String name) { + return Builder.class.cast(super.name(name)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder tags(Iterable tags) { + return Builder.class.cast(super.tags(tags)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder userMetadata(Map userMetadata) { + return Builder.class.cast(super.userMetadata(userMetadata)); + } + + public static Builder fromDriveInfo(StandardDrive driveInfo) { + return new Builder().uuid(driveInfo.getUuid()).name(driveInfo.getName()).size(driveInfo.getSize()) + .claimType(driveInfo.getClaimType()).readers(driveInfo.getReaders()).tags(driveInfo.getTags()) + .userMetadata(driveInfo.getUserMetadata()).media(driveInfo.getMedia()); + } + + /** + * {@inheritDoc} + */ + @Override + public StandardDrive build() { + return new StandardDrive(uuid, name, size, claimType, readers, tags, userMetadata, format, media, rawSize); + } + + } + + protected final ImageConversionType format; + protected final MediaType media; + protected final long rawSize; + + public StandardDrive(String uuid, String name, long size, ClaimType claimType, Iterable readers, + Iterable tags, Map userMetadata, @Nullable ImageConversionType format, + MediaType media, long rawSize) { + super(uuid, name, size, claimType, readers, tags, userMetadata); + this.format = format; + this.media = checkNotNull(media, "media"); + this.rawSize = rawSize; + } + + public MediaType getMedia() { + return media; + } + + public ImageConversionType getFormat() { + return format; + } + + public long getRawSize() { + return rawSize; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((format == null) ? 0 : format.hashCode()); + result = prime * result + ((media == null) ? 0 : media.hashCode()); + result = prime * result + (int) (rawSize ^ (rawSize >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + StandardDrive other = (StandardDrive) obj; + if (format != other.format) + return false; + if (media == null) { + if (other.media != null) + return false; + } else if (!media.equals(other.media)) + return false; + if (rawSize != other.rawSize) + return false; + return true; + } + + @Override + public String toString() { + return "StandardDrive [format=" + format + ", media=" + media + ", rawSize=" + rawSize + ", size=" + size + + ", claimType=" + claimType + ", readers=" + readers + ", uuid=" + uuid + ", name=" + name + ", tags=" + + tags + ", userMetadata=" + userMetadata + "]"; + } + +} diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/domain/WellKnownImage.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/domain/WellKnownImage.java index 9af9329d3fb..affd88e167c 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/domain/WellKnownImage.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/domain/WellKnownImage.java @@ -16,7 +16,11 @@ */ package org.jclouds.elasticstack.domain; +import static com.google.common.base.Objects.firstNonNull; +import static com.google.common.base.Preconditions.checkNotNull; + import org.jclouds.compute.domain.OsFamily; +import org.jclouds.javax.annotation.Nullable; import com.google.common.base.Objects; @@ -25,20 +29,80 @@ * @author Adrian Cole */ public class WellKnownImage { - private String loginUser = "toor"; - private String uuid; - private String description; - private OsFamily osFamily; - private String osVersion; - private int size; - private boolean is64bit = true; - // intended only for serialization - WellKnownImage() { + public static Builder builder() { + return new Builder(); + } + public static class Builder { + private String loginUser; + private String uuid; + private String description; + private OsFamily osFamily; + private String osVersion; + private int size; + private boolean is64bit; + + public Builder loginUser(String loginUser) { + this.loginUser = loginUser; + return this; + } + + public Builder uuid(String uuid) { + this.uuid = uuid; + return this; + } + + public Builder description(String description) { + this.description = description; + return this; + } + + public Builder osFamily(OsFamily osFamily) { + this.osFamily = osFamily; + return this; + } + + public Builder osVersion(String osVersion) { + this.osVersion = osVersion; + return this; + } + + public Builder size(int size) { + this.size = size; + return this; + } + + public Builder is64bit(boolean is64bit) { + this.is64bit = is64bit; + return this; + } + + public WellKnownImage build() { + return new WellKnownImage(loginUser, uuid, description, osFamily, osVersion, size, is64bit); + } } - // performance isn't a concern on a infrequent object like this, so using shortcuts; + public static final String DEFAULT_USER = "toor"; + + private final String loginUser; + private final String uuid; + private final String description; + private final OsFamily osFamily; + private final String osVersion; + private final int size; + private final boolean is64bit; + + public WellKnownImage(@Nullable String loginUser, String uuid, String description, OsFamily osFamily, + @Nullable String osVersion, int size, @Nullable Boolean is64bit) { + this.loginUser = firstNonNull(loginUser, DEFAULT_USER); + this.uuid = checkNotNull(uuid, "uuid cannot be null"); + this.description = checkNotNull(description, "description cannot be null"); + this.osFamily = checkNotNull(osFamily, "osFamily cannot be null"); + this.osVersion = osVersion; + this.size = size; + this.is64bit = firstNonNull(is64bit, Boolean.TRUE); + } public String getUuid() { return uuid; @@ -82,9 +146,9 @@ public boolean equals(Object that) { @Override public String toString() { - return Objects.toStringHelper(this).add("uuid", uuid).add("description", description).add("osFamily", osFamily) - .add("osVersion", osVersion).add("size", size).add("is64bit", is64bit).add("loginUser", loginUser) - .toString(); + return Objects.toStringHelper(this).omitNullValues().add("uuid", uuid).add("description", description) + .add("osFamily", osFamily).add("osVersion", osVersion).add("size", size).add("is64bit", is64bit) + .add("loginUser", loginUser).toString(); } } diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSet.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSet.java new file mode 100644 index 00000000000..19e3f336e77 --- /dev/null +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSet.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elasticstack.functions; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Strings.nullToEmpty; + +import java.util.Set; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.elasticstack.domain.StandardDrive; +import org.jclouds.http.HttpResponse; +import org.jclouds.http.functions.ReturnStringIf2xx; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; + +/** + * @author Ignasi Barrera + */ +@Singleton +public class ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSet implements Function> { + private final ReturnStringIf2xx returnStringIf2xx; + private final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter; + private final MapToStandardDrive mapToStandardDrive; + + @Inject + ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSet(ReturnStringIf2xx returnStringIf2xx, + ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter, MapToStandardDrive mapToStandardDrive) { + this.returnStringIf2xx = checkNotNull(returnStringIf2xx, "returnStringIf2xx"); + this.mapConverter = checkNotNull(mapConverter, "mapConverter"); + this.mapToStandardDrive = checkNotNull(mapToStandardDrive, "mapToStandardDrive"); + } + + @Override + public Set apply(HttpResponse response) { + String text = nullToEmpty(returnStringIf2xx.apply(response)); + if (text.trim().equals("")) { + return ImmutableSet. of(); + } + return ImmutableSet.copyOf(Iterables.transform(mapConverter.apply(text), mapToStandardDrive)); + } +} diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDriveInfo.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDriveInfo.java index c8e969d9973..778cb7be992 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDriveInfo.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDriveInfo.java @@ -73,7 +73,7 @@ public DriveInfo apply(Map from) { try { return builder.build(); } catch (NullPointerException e) { - logger.trace("entry missing data: %s; %s", e.getMessage(), from); + logger.warn("entry missing data: %s; %s", e.getMessage(), from); return null; } } diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToStandardDrive.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToStandardDrive.java new file mode 100644 index 00000000000..c947ff5f61d --- /dev/null +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToStandardDrive.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elasticstack.functions; + +import java.util.Map; +import java.util.Map.Entry; + +import javax.annotation.Resource; +import javax.inject.Singleton; + +import org.jclouds.elasticstack.domain.ClaimType; +import org.jclouds.elasticstack.domain.ImageConversionType; +import org.jclouds.elasticstack.domain.MediaType; +import org.jclouds.elasticstack.domain.StandardDrive; +import org.jclouds.logging.Logger; + +import com.google.common.base.Function; +import com.google.common.base.Splitter; +import com.google.common.collect.Maps; + +/** + * @author Ignasi Barrera + */ +@Singleton +public class MapToStandardDrive implements Function, StandardDrive> { + + @Resource + protected Logger logger = Logger.NULL; + + @Override + public StandardDrive apply(Map from) { + if (from.isEmpty()) + return null; + StandardDrive.Builder builder = new StandardDrive.Builder(); + builder.name(from.get("name")); + builder.media(MediaType.fromValue(from.get("media"))); + if (from.containsKey("tags")) + builder.tags(Splitter.on(' ').split(from.get("tags"))); + builder.uuid(from.get("drive")); + if (from.containsKey("claim:type")) + builder.claimType(ClaimType.fromValue(from.get("claim:type"))); + if (from.containsKey("readers")) + builder.readers(Splitter.on(' ').split(from.get("readers"))); + if (from.containsKey("size")) + builder.size(Long.valueOf(from.get("size"))); + if (from.containsKey("rawsize")) + builder.rawSize(Long.valueOf(from.get("rawsize"))); + if (from.containsKey("format")) + builder.format(ImageConversionType.fromValue(from.get("format"))); + Map metadata = Maps.newLinkedHashMap(); + for (Entry entry : from.entrySet()) { + String key = entry.getKey(); + if (key.startsWith("user:")) + metadata.put(key.substring(key.indexOf(':') + 1), entry.getValue()); + } + builder.userMetadata(metadata); + try { + return builder.build(); + } catch (NullPointerException e) { + logger.warn("entry missing data: %s; %s", e.getMessage(), from); + return null; + } + } +} diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/SplitNewlines.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/SplitNewlines.java index 48858fb20f8..0b53d92c1f2 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/SplitNewlines.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/SplitNewlines.java @@ -16,8 +16,6 @@ */ package org.jclouds.elasticstack.functions; -import static com.google.common.collect.Sets.newTreeSet; - import java.util.Set; import javax.inject.Inject; @@ -28,6 +26,7 @@ import com.google.common.base.Function; import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; /** * @@ -44,6 +43,8 @@ public class SplitNewlines implements Function> { @Override public Set apply(HttpResponse response) { - return newTreeSet(Splitter.on('\n').omitEmptyStrings().split(returnStringIf200.apply(response))); + String payload = returnStringIf200.apply(response); + return payload == null ? ImmutableSet. of() : ImmutableSet.copyOf(Splitter.on('\n').omitEmptyStrings() + .split(payload)); } } diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/handlers/ElasticStackErrorHandler.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/handlers/ElasticStackErrorHandler.java index 5b6e1a4ed14..af85ad324d6 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/handlers/ElasticStackErrorHandler.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/handlers/ElasticStackErrorHandler.java @@ -16,6 +16,8 @@ */ package org.jclouds.elasticstack.handlers; +import static org.jclouds.http.HttpUtils.releasePayload; + import java.io.IOException; import javax.annotation.Resource; @@ -28,10 +30,9 @@ import org.jclouds.logging.Logger; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ResourceNotFoundException; -import org.jclouds.util.Closeables2; import org.jclouds.util.Strings2; -import com.google.common.base.Throwables; +import com.google.common.io.Closeables; /** * This will parse and set an appropriate exception on the command object. @@ -80,7 +81,11 @@ public void handleError(HttpCommand command, HttpResponse response) { break; } } finally { - Closeables2.closeQuietly(response.getPayload()); + try { + Closeables.close(response.getPayload(), true); + } catch (IOException e) { + // Unreachable code + } command.setException(exception); } } @@ -93,11 +98,7 @@ public String parseMessage(HttpResponse response) { } catch (IOException e) { throw new RuntimeException(e); } finally { - try { - response.getPayload().getInput().close(); - } catch (IOException e) { - Throwables.propagate(e); - } + releasePayload(response); } } } diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/suppliers/StandardDiskImageSupplier.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/suppliers/StandardDiskImageSupplier.java new file mode 100644 index 00000000000..9e5fb9194ae --- /dev/null +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/suppliers/StandardDiskImageSupplier.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elasticstack.suppliers; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.elasticstack.ElasticStackApi; +import org.jclouds.elasticstack.domain.MediaType; +import org.jclouds.elasticstack.domain.StandardDrive; +import org.jclouds.elasticstack.domain.WellKnownImage; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableList; + +/** + * Supplies the pre-installed images. + * + * @author Ignasi Barrera + * + */ +@Singleton +public class StandardDiskImageSupplier implements WellKnownImageSupplier { + + private final ElasticStackApi api; + + private final Function standardDriveToWellKnownImage; + + @Inject + StandardDiskImageSupplier(ElasticStackApi api, Function standardDriveToWellKnownImage) { + this.api = checkNotNull(api, "api"); + this.standardDriveToWellKnownImage = checkNotNull(standardDriveToWellKnownImage, "standardDriveToWellKnownImage"); + } + + @Override + public List get() { + ImmutableList.Builder images = ImmutableList.builder(); + for (StandardDrive drive : api.listStandardDriveInfo()) { + if (drive.getMedia() == MediaType.DISK) { + images.add(standardDriveToWellKnownImage.apply(drive)); + } + } + return images.build(); + } + +} diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/suppliers/WellKnownImageSupplier.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/suppliers/WellKnownImageSupplier.java new file mode 100644 index 00000000000..8d95612d5a4 --- /dev/null +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/suppliers/WellKnownImageSupplier.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elasticstack.suppliers; + +import java.util.List; + +import org.jclouds.elasticstack.domain.WellKnownImage; + +import com.google.common.base.Supplier; +import com.google.inject.ImplementedBy; + +/** + * Supplies the well known images + * + * @author Ignasi Barrera + * + */ +@ImplementedBy(StandardDiskImageSupplier.class) +public interface WellKnownImageSupplier extends Supplier> { + +} diff --git a/apis/elasticstack/src/main/resources/elasticstack/preinstalled_images.json b/apis/elasticstack/src/main/resources/elasticstack/preinstalled_images.json deleted file mode 100644 index dadd7b74412..00000000000 --- a/apis/elasticstack/src/main/resources/elasticstack/preinstalled_images.json +++ /dev/null @@ -1,72 +0,0 @@ -[ - { - "uuid": "38df0986-4d85-4b76-b502-3878ffc80161", - "description": "CentOS Linux 5.5", - "osFamily": "CENTOS", - "osVersion": "5.5", - "size": "3" - }, - { - "uuid": "980cf63c-f21e-4382-997b-6541d5809629", - "description": "Debian Linux 5.0", - "osFamily": "DEBIAN", - "osVersion": "5.0", - "size": "1" - }, - { - "uuid": "aee5589a-88c3-43ef-bb0a-9cab6e64192d", - "description": "Ubuntu Linux 10.04", - "osFamily": "UBUNTU", - "osVersion": "10.04", - "size": "1" - }, - { - "uuid": "bf1d943e-2a55-46bb-a8c7-6099e44a3dde", - "description": "Ubuntu Linux 8.10: Base system with X", - "osFamily": "UBUNTU", - "osVersion": "8.10", - "size": "3" - }, - { - "uuid": "757586d5-f1e9-4d9c-b215-5a391c9a24bf", - "description": "Ubuntu Linux 9.04: Base system with X", - "osFamily": "UBUNTU", - "osVersion": "9.04", - "size": "3" - }, - { - "uuid": "b9d0eb72-d273-43f1-98e3-0d4b87d372c0", - "description": "Windows Web Server 2008", - "osFamily": "WINDOWS", - "osVersion": "2008", - "size": "13" - }, - { - "uuid": "b405b598-4ae4-4ba8-8a2b-a9487d693f34", - "description": "Windows Web Server 2008 R2", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "9397d327-3bf6-46a2-abf6-69553dbb6927", - "description": "Windows Web Server 2008 R2 + SQL Server", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "10a88d1c-6575-46e3-8d2c-7744065ea530", - "description": "Windows Server 2008 Standard R2", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "662c5b3f-9828-4aa2-a866-7cfa53798cdf", - "description": "Windows Server 2008 Standard R2 + SQL Server", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - } -] diff --git a/apis/elasticstack/src/main/resources/preinstalled_images.readme b/apis/elasticstack/src/main/resources/preinstalled_images.readme deleted file mode 100644 index 5f6bb69979d..00000000000 --- a/apis/elasticstack/src/main/resources/preinstalled_images.readme +++ /dev/null @@ -1,7 +0,0 @@ -the images collection listed in the computeservice api is populated from preinstalled_images.json in a resource path corresponding to the provider name. There's no way to list standard images via api in cloudstack installs. This is the process: - 1. log into the portal - 2. View Source - 3. look for the image you want ex 'Debian Linux 6.0.1' - 4. find the UUID, which will look like: 6aa953cc-3395-4e8d-938e-65c74fd20334 - -Other details can be found by contacting the provider and asking them diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiLiveTest.java index f18f2f91eef..f482d89a6e8 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiLiveTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiLiveTest.java @@ -18,6 +18,7 @@ import static java.util.concurrent.TimeUnit.SECONDS; import static org.jclouds.util.Predicates2.retry; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import java.io.IOException; @@ -38,6 +39,7 @@ import org.jclouds.elasticstack.domain.Server; import org.jclouds.elasticstack.domain.ServerInfo; import org.jclouds.elasticstack.domain.ServerStatus; +import org.jclouds.elasticstack.domain.StandardDrive; import org.jclouds.elasticstack.predicates.DriveClaimed; import org.jclouds.elasticstack.util.Servers; import org.jclouds.io.Payloads; @@ -114,12 +116,26 @@ public void testListDrives() throws Exception { Set drives = client.listDrives(); assertNotNull(drives); } + + @Test + public void testListStandardDrives() throws Exception { + Set drives = client.listStandardDrives(); + assertNotNull(drives); + assertFalse(drives.isEmpty(), "standard drive list should not be empty"); + } @Test public void testListDriveInfo() throws Exception { Set drives = client.listDriveInfo(); assertNotNull(drives); } + + @Test + public void testListStandardDriveInfo() throws Exception { + Set drives = client.listStandardDriveInfo(); + assertNotNull(drives); + assertFalse(drives.isEmpty(), "standard drive list should not be empty"); + } @Test public void testGetDrive() throws Exception { diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiTest.java index aa62b831e36..9618826500f 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiTest.java @@ -38,6 +38,8 @@ import org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet; import org.jclouds.elasticstack.functions.ReturnPayload; import org.jclouds.elasticstack.functions.SplitNewlines; +import org.jclouds.elasticstack.suppliers.MockStandardDiskImageSupplier; +import org.jclouds.elasticstack.suppliers.WellKnownImageSupplier; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.filters.BasicAuthentication; @@ -51,6 +53,9 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.reflect.Invokable; +import com.google.inject.AbstractModule; +import com.google.inject.Module; +import com.google.inject.Scopes; /** * Tests behavior of {@code ElasticStackApi} * @@ -448,4 +453,14 @@ protected ApiMetadata createApiMetadata() { return new ElasticStackApiMetadata(); } + @Override + protected Module createModule() { + return new AbstractModule() { + @Override + protected void configure() { + bind(WellKnownImageSupplier.class).to(MockStandardDiskImageSupplier.class).in(Scopes.SINGLETON); + } + }; + } + } diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackMockTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackMockTest.java new file mode 100644 index 00000000000..e6abbb4900b --- /dev/null +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackMockTest.java @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elasticstack; + +import static org.jclouds.Constants.PROPERTY_CREDENTIAL; +import static org.jclouds.Constants.PROPERTY_IDENTITY; +import static org.jclouds.util.Strings2.toStringAndClose; +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Properties; +import java.util.Set; + +import javax.ws.rs.core.HttpHeaders; + +import org.jclouds.elasticstack.domain.StandardDrive; +import org.jclouds.http.BaseMockWebServerTest; +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; +import org.testng.annotations.Test; + +import com.google.common.base.Charsets; +import com.google.common.base.Throwables; +import com.google.inject.Module; +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; +import com.squareup.okhttp.mockwebserver.RecordedRequest; + +/** + * Mock tests for the {@link ElasticStackApi} class. + * + * @author Ignasi Barrera + */ +@Test(groups = "unit", testName = "ElasticStackMockTest") +public class ElasticStackMockTest extends BaseMockWebServerTest { + + public void testListStandardDrives() throws IOException, InterruptedException { + MockWebServer server = mockWebServer(new MockResponse() + .setBody(payloadFromResource("/standard_drives_uuids.txt"))); + ElasticStackApi api = api(ElasticStackApi.class, server.getUrl("/").toString()); + + try { + Set standardDrives = api.listStandardDrives(); + assertEquals(standardDrives.size(), 36); + + RecordedRequest request = server.takeRequest(); + assertAuthentication(request); + assertEquals(request.getRequestLine(), + String.format("GET /drives/list/standard HTTP/1.1", server.getUrl("/").toString())); + } finally { + api.close(); + server.shutdown(); + } + } + + public void testListStandardDriveInfo() throws IOException, InterruptedException { + MockWebServer server = mockWebServer(new MockResponse().setBody(payloadFromResource("/standard_drives.txt"))); + ElasticStackApi api = api(ElasticStackApi.class, server.getUrl("/").toString()); + + try { + Set standardDrives = api.listStandardDriveInfo(); + assertEquals(standardDrives.size(), 36); + + RecordedRequest request = server.takeRequest(); + assertAuthentication(request); + assertEquals(request.getRequestLine(), + String.format("GET /drives/info/standard HTTP/1.1", server.getUrl("/").toString())); + } finally { + api.close(); + server.shutdown(); + } + } + + private static void assertAuthentication(final RecordedRequest request) throws InterruptedException { + assertEquals(request.getHeader(HttpHeaders.AUTHORIZATION), "Basic dXVpZDphcGlrZXk="); + } + + private byte[] payloadFromResource(String resource) { + try { + return toStringAndClose(getClass().getResourceAsStream(resource)).getBytes(Charsets.UTF_8); + } catch (IOException e) { + throw Throwables.propagate(e); + } + } + + @Override + protected void addOverrideProperties(Properties props) { + props.setProperty(PROPERTY_IDENTITY, "uuid"); + props.setProperty(PROPERTY_CREDENTIAL, "apikey"); + } + + @Override + protected Module createConnectionModule() { + return new JavaUrlHttpCommandExecutorServiceModule(); + } + +} diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/functions/StandardDriveToWellKnownImageTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/functions/StandardDriveToWellKnownImageTest.java new file mode 100644 index 00000000000..9593aeef93d --- /dev/null +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/functions/StandardDriveToWellKnownImageTest.java @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elasticstack.compute.functions; + +import static org.testng.Assert.assertEquals; + +import java.util.UUID; + +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.elasticstack.domain.MediaType; +import org.jclouds.elasticstack.domain.StandardDrive; +import org.jclouds.elasticstack.domain.WellKnownImage; +import org.testng.annotations.Test; + +/** + * Unit tests for the {@link StandardDriveToWellKnownImage} class. + * + * @author Ignasi Barrera + */ +@Test(groups = "unit", testName = "StandardDriveToWellKnownImageTest") +public class StandardDriveToWellKnownImageTest { + + private StandardDriveToWellKnownImage function = new StandardDriveToWellKnownImage(); + + public void testUnknownOperatingSystemParsing() { + assertOS("Foo Linux 6.5", OsFamily.UNRECOGNIZED, "6.5", true); + } + + public void testOperatingSystemWithoutVersionParsing() { + assertOS("Ubuntu Linux", OsFamily.UBUNTU, null, true); + } + + public void testKnownOperatingSystemParsing() { + + // Elastichosts + assertOS("centOS Linux 6.5", OsFamily.CENTOS, "6.5", true); + assertOS("Debian Linux 7.4 (Wheezy)", OsFamily.DEBIAN, "7.4", true); + assertOS("Ubuntu Linux 12.04.1 LTS (Precise Pangolin)", OsFamily.UBUNTU, "12.04.1", true); + assertOS("Ubuntu Linux 13.10 (Saucy Salamander)", OsFamily.UBUNTU, "13.10", true); + assertOS("Ubuntu 14.04 LTS (Trusty Tahr)", OsFamily.UBUNTU, "14.04", true); + assertOS("Windows Server 2012", OsFamily.WINDOWS, "2012", true); + assertOS("Windows Server 2012 + SQL", OsFamily.WINDOWS, "2012 + SQL", true); + assertOS("Windows Server 2012 R2", OsFamily.WINDOWS, "2012 R2", true); + assertOS("Windows Standard 2008 R2", OsFamily.WINDOWS, "2008 R2", true); + assertOS("Windows Standard 2008 R2 + SQL", OsFamily.WINDOWS, "2008 R2 + SQL", true); + assertOS("Windows Web Server 2008 R2", OsFamily.WINDOWS, "2008 R2", true); + assertOS("Windows Web Server 2008 R2 + SQL", OsFamily.WINDOWS, "2008 R2 + SQL", true); + + // Go2Cloud + assertOS("Ubuntu 10.10", OsFamily.UBUNTU, "10.10", true); + assertOS("Debian 6.0.2.1", OsFamily.DEBIAN, "6.0.2.1", true); + assertOS("Windows 2008 R2 (x64) with SP1", OsFamily.WINDOWS, "2008 R2 (x64) with SP1", true); + assertOS("Windows 8 Developer Preview (x64)", OsFamily.WINDOWS, "8 Developer Preview (x64)", true); + + // OpenHosting + assertOS("CentOS Linux 5.5 64", OsFamily.CENTOS, "5.5", true); + assertOS("CentOS Linux 5.6 64", OsFamily.CENTOS, "5.6", true); + assertOS("CentOS Linux 5.7 64", OsFamily.CENTOS, "5.7", true); + assertOS("Debian Linux 5.0", OsFamily.DEBIAN, "5.0", true); + assertOS("Debian Linux 6 (Squeeze) 64", OsFamily.DEBIAN, "6", true); + assertOS("Ubuntu 10.04.3 LTS (lucid) Server 64", OsFamily.UBUNTU, "10.04.3", true); + assertOS("Windows 2008 R2 Standard Edition", OsFamily.WINDOWS, "2008 R2 Standard Edition", true); + + // Skalicloud + assertOS("CentOS 5.5 -32bit", OsFamily.CENTOS, "5.5", false); + assertOS("CentOS 5.5 -64bit", OsFamily.CENTOS, "5.5", true); + assertOS("CentOS 5.6 -32bit", OsFamily.CENTOS, "5.6", false); + assertOS("CentOS 5.6 -64bit", OsFamily.CENTOS, "5.6", true); + assertOS("Debian 5 -32bit", OsFamily.DEBIAN, "5", false); + assertOS("Debian 5 -64bit", OsFamily.DEBIAN, "5", true); + assertOS("Debian 6 -64bit -Experimental", OsFamily.DEBIAN, "6", true); + assertOS("Ubuntu Server 10.04 -32bit", OsFamily.UBUNTU, "10.04", false); + assertOS("Ubuntu Server 10.04 -64bit", OsFamily.UBUNTU, "10.04", true); + assertOS("Ubuntu Server 10.10 -32bit", OsFamily.UBUNTU, "10.10", false); + assertOS("Ubuntu Server 10.10 -64bit", OsFamily.UBUNTU, "10.10", true); + assertOS("Windows 2008R2 Web Edition", OsFamily.WINDOWS, "2008R2 Web Edition", true); + assertOS("Windows Server 2008R2 Standard", OsFamily.WINDOWS, "2008R2 Standard", true); + + // ServerLove + assertOS("CentOS Linux 5.7", OsFamily.CENTOS, "5.7", true); + assertOS("CentOS Linux 6.2", OsFamily.CENTOS, "6.2", true); + assertOS("Debian Linux 6.0", OsFamily.DEBIAN, "6.0", true); + assertOS("Ubuntu 10.04 LTS", OsFamily.UBUNTU, "10.04", true); + assertOS("Ubuntu 12.04 LTS", OsFamily.UBUNTU, "12.04", true); + assertOS("Windows Server 2008 R2 Standard", OsFamily.WINDOWS, "2008 R2 Standard", true); + assertOS("Windows Server 2008 R2 Standard SP1 with SQL Server 2008 R2 Web Edition", OsFamily.WINDOWS, + "2008 R2 Standard SP1 with SQL Server 2008 R2 Web Edition", true); + assertOS("Windows Server 2012 Standard", OsFamily.WINDOWS, "2012 Standard", true); + assertOS("Windows Web Server 2008 R2", OsFamily.WINDOWS, "2008 R2", true); + assertOS("Windows Web Server 2008 R2 SP1 with SQL Server 2008 R2 Web Edition", OsFamily.WINDOWS, + "2008 R2 SP1 with SQL Server 2008 R2 Web Edition", true); + } + + private void assertOS(String name, OsFamily expectedFamily, String expectedVersion, boolean expectedIs64bit) { + StandardDrive drive = standardDrive(name); + WellKnownImage image = function.apply(drive); + + assertEquals(image.getOsFamily(), expectedFamily, String.format("Parsing family for [%s]:", name)); + assertEquals(image.getOsVersion(), expectedVersion, String.format("Parsing version for [%s]:", name)); + assertEquals(image.is64bit(), expectedIs64bit, String.format("Parsing arch for [%s]:", name)); + } + + private static StandardDrive standardDrive(String name) { + return new StandardDrive.Builder().uuid(UUID.randomUUID().toString()).size(1).name(name).media(MediaType.DISK) + .build(); + } +} diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSetTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSetTest.java new file mode 100644 index 00000000000..35e1fabbadc --- /dev/null +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSetTest.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elasticstack.functions; + +import static org.testng.Assert.assertEquals; + +import org.jclouds.elasticstack.domain.StandardDrive; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Guice; + +/** + * @author Ignasi Barrera + */ +@Test(groups = { "unit" }) +public class ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSetTest { + + private static final ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSet FN = Guice.createInjector().getInstance( + ListOfKeyValuesDelimitedByBlankLinesToStandardDriveSet.class); + + public void testNone() { + assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), ImmutableSet. of()); + assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), ImmutableSet. of()); + assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), ImmutableSet. of()); + } + + public void testOne() { + assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToStandardDriveTest.class + .getResourceAsStream("/standard_drive.txt")).build()), ImmutableSet. of(MapToStandardDriveTest.ONE)); + } +} diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/MapToStandardDriveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/MapToStandardDriveTest.java new file mode 100644 index 00000000000..0205ad5ad2c --- /dev/null +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/MapToStandardDriveTest.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elasticstack.functions; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Map; + +import org.jclouds.elasticstack.domain.ClaimType; +import org.jclouds.elasticstack.domain.ImageConversionType; +import org.jclouds.elasticstack.domain.MediaType; +import org.jclouds.elasticstack.domain.StandardDrive; +import org.jclouds.util.Strings2; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; + +/** + * @author Ignasi Barrera + */ +@Test(groups = { "unit" }) +public class MapToStandardDriveTest { + public static StandardDrive ONE = new StandardDrive.Builder() + .name("Windows Web Server 2008 R2") + .uuid("11b84345-7169-4279-8038-18d6ba1a7712")// + .claimType(ClaimType.SHARED) + .readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))// + .size(4743757824L)// + .rawSize(11811160064L)// + .format(ImageConversionType.GZIP)// + .media(MediaType.DISK)// + .build(); + + private static final MapToStandardDrive MAP_TO_STANDARD_DRIVE = new MapToStandardDrive(); + + public void testEmptyMapReturnsNull() { + assertEquals(MAP_TO_STANDARD_DRIVE.apply(ImmutableMap. of()), null); + } + + public void testBasics() { + StandardDrive expects = new StandardDrive.Builder().name("foo").size(100l).media(MediaType.DISK) + .format(ImageConversionType.GZIP).rawSize(5l).build(); + assertEquals(MAP_TO_STANDARD_DRIVE.apply(ImmutableMap.of("name", "foo", "size", "100", "format", "gzip", "media", + "disk", "rawsize", "5")), expects); + } + + public void testComplete() throws IOException { + Map input = new ListOfKeyValuesDelimitedByBlankLinesToListOfMaps().apply( + Strings2.toStringAndClose(MapToStandardDriveTest.class.getResourceAsStream("/standard_drive.txt"))).get(0); + assertEquals(MAP_TO_STANDARD_DRIVE.apply(input), ONE); + } +} diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/suppliers/MockStandardDiskImageSupplier.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/suppliers/MockStandardDiskImageSupplier.java new file mode 100644 index 00000000000..cf91cfb3941 --- /dev/null +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/suppliers/MockStandardDiskImageSupplier.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elasticstack.suppliers; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.transform; +import static org.jclouds.util.Strings2.toStringAndClose; + +import java.io.IOException; +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.elasticstack.domain.StandardDrive; +import org.jclouds.elasticstack.domain.WellKnownImage; +import org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToListOfMaps; +import org.jclouds.elasticstack.functions.MapToStandardDrive; + +import com.google.common.base.Function; +import com.google.common.base.Throwables; +import com.google.common.collect.ImmutableList; + +/** + * Mock {@link WellKnownImageSupplier} to be used in tests. + * + * @author Ignasi Barrera + */ +@Singleton +public class MockStandardDiskImageSupplier implements WellKnownImageSupplier { + + private final Function standardDriveToWellKnownImage; + private final ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter; + private final MapToStandardDrive mapToStandardDrive; + + @Inject + public MockStandardDiskImageSupplier(Function standardDriveToWellKnownImage, + ListOfKeyValuesDelimitedByBlankLinesToListOfMaps mapConverter, MapToStandardDrive mapToStandardDrive) { + this.standardDriveToWellKnownImage = checkNotNull(standardDriveToWellKnownImage, "standardDriveToWellKnownImage cannot be null"); + this.mapConverter = checkNotNull(mapConverter, "mapConverter cannot be null"); + this.mapToStandardDrive = checkNotNull(mapToStandardDrive, "mapToStandardDrive cannot be null"); + } + + @Override + public List get() { + try { + String mockDrives = toStringAndClose(getClass().getResourceAsStream("/standard_drives.txt")); + Iterable parsedDrives = transform(mapConverter.apply(mockDrives), mapToStandardDrive); + return ImmutableList.copyOf(transform(parsedDrives, standardDriveToWellKnownImage)); + } catch (IOException ex) { + throw Throwables.propagate(ex); + } + } + +} diff --git a/apis/elasticstack/src/test/resources/standard_drive.txt b/apis/elasticstack/src/test/resources/standard_drive.txt new file mode 100644 index 00000000000..01fb5cd7ca5 --- /dev/null +++ b/apis/elasticstack/src/test/resources/standard_drive.txt @@ -0,0 +1,8 @@ +claim:type shared +drive 11b84345-7169-4279-8038-18d6ba1a7712 +format gzip +media disk +name Windows Web Server 2008 R2 +rawsize 11811160064 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 4743757824 \ No newline at end of file diff --git a/apis/elasticstack/src/test/resources/standard_drives.txt b/apis/elasticstack/src/test/resources/standard_drives.txt new file mode 100644 index 00000000000..c3161a61e50 --- /dev/null +++ b/apis/elasticstack/src/test/resources/standard_drives.txt @@ -0,0 +1,275 @@ +claim:type shared +drive ce85ef47-9794-4ed7-a8bd-af902ec0eddc +format gzip +media disk +name Debian Linux 7.4 (Wheezy) +rawsize 1073741824 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 184549376 + +claim:type shared +drive 82890da7-a036-4427-ac24-caea6c644a2f +format gzip +media disk +name Ubuntu 14.04 LTS (Trusty Tahr) +rawsize 1073741824 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 264241152 + +claim:type shared +drive 62f512cd-82c7-498e-88d8-a09ac2ef20e7 +format gzip +media disk +name Ubuntu Linux 12.04.1 LTS (Precise Pangolin) +rawsize 1073741824 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 201326592 + +claim:type shared +drive 4f31382b-5098-4610-8993-bbebb844febd +format gzip +media disk +name Ubuntu Linux 13.10 (Saucy Salamander) +rawsize 1073741824 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 230686720 + +claim:type shared +drive cdea53be-2511-4c91-9779-f6421f623a49 +format gzip +media disk +name Windows Server 2012 +rawsize 15032385536 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 7671382016 + +claim:type shared +drive 7b9807cc-3c92-425f-878c-1d45927f3f9c +format gzip +media disk +name Windows Server 2012 + SQL +rawsize 32212254720 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 17192452096 + +claim:type shared +drive 61ef248d-6616-4378-9702-9101870741d2 +format gzip +media disk +name Windows Server 2012 R2 +rawsize 10737418240 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 5368709120 + +claim:type shared +drive 6c0c3072-f55f-4dd2-9308-951dacf41ce3 +format gzip +media disk +name Windows Standard 2008 R2 +rawsize 9663676416 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 4345298944 + +claim:type shared +drive 63677762-4423-464f-92fd-5c43d449a716 +format gzip +media disk +name Windows Standard 2008 R2 + SQL +rawsize 20401094656 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 14050918400 + +claim:type shared +drive 11b84345-7169-4279-8038-18d6ba1a7712 +format gzip +media disk +name Windows Web Server 2008 R2 +rawsize 11811160064 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 4743757824 + +claim:type shared +drive b23e81b9-103e-4f9d-8ce5-b57bb529007c +format gzip +media disk +name Windows Web Server 2008 R2 + SQL +rawsize 20401094656 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 14357102592 + +claim:type shared +drive 8d5c93b8-e4e4-4943-b41e-873576b7fcd1 +format gzip +media disk +name centOS Linux 6.5 +rawsize 1073741824 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 218103808 + +claim:type shared +drive 65cb106c-3dff-4f27-9607-f25bbe0a3fc6 +media cdrom +name Debian 7.4 DVD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 3955228672 + +claim:type shared +drive 8eeaa0d5-9696-4fb2-b34e-ccca28f54138 +media cdrom +name Fedora 19 Install DVD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 4445962240 + +claim:type shared +drive 4d0971b5-9780-4b42-a0a0-ea06a0669b8b +media cdrom +name Fedora 20 Install DVD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 4605345792 + +claim:type shared +drive 07a08d47-1f24-4c99-a080-ea6b38502c66 +media cdrom +name FreeBSD 10.0 DVD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 2487222272 + +claim:type shared +drive 321eaeb7-a5a5-4ffd-9a62-db1d0ffd133f +media cdrom +name FreeBSD 9.2 DVD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 2554331136 + +claim:type shared +drive cf0dfc73-2ab2-4317-a515-698ed4097c90 +media cdrom +name Knoppix 7.2 DVD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 4114612224 + +claim:type shared +drive 696a3dee-c29d-4bd2-afb9-06e995702b65 +media cdrom +name Linux Mint 16 (Petra) DVD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 1329594368 + +claim:type shared +drive 3f9ddec5-0f9e-4879-85fb-e412abe0cb37 +media cdrom +name Microsoft SQL Express 2012 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 5507121152 + +claim:type shared +drive e58ad21f-c53f-47a1-95bd-c6d614a59d2d +media cdrom +name System Rescue CD 4.0.1 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 473956352 + +claim:type shared +drive 7fed7f41-7af7-42d9-bbf6-d96427757bc4 +media cdrom +name Ubuntu 12.04.4 Desktop DVD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 771751936 + +claim:type shared +drive 50f8aa7a-090e-413a-8be9-e0ef498b7012 +media cdrom +name Ubuntu 12.04.4 Server DVD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 713031680 + +claim:type shared +drive a8e87123-1d88-4bd4-ba60-3a42248f7bc0 +media cdrom +name Ubuntu 13.10 Desktop DVD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 926941184 + +claim:type shared +drive 00798d0a-1081-4590-8b6c-af1f927e209c +media cdrom +name Ubuntu 13.10 Server DVD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 704643072 + +claim:type shared +drive 92f4a7e9-daa2-45f1-967c-cf460cf5bca1 +media cdrom +name Ubuntu 14.04 LTS Desktop Live CD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 1010827264 + +claim:type shared +drive 9dfbbe29-5352-415a-9f7c-70ec7409b684 +media cdrom +name Ubuntu 14.04 LTS Server Install CD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 591396864 + +claim:type shared +drive 5a4419f8-6c39-490c-87e9-21e33a1c8add +media cdrom +name Virtio Drivers 1.74 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 62914560 + +claim:type shared +drive 554f5ed7-811a-400d-9f96-3f829a2bc145 +media cdrom +name Windows 2012 R2 Evaluation CD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 5368709120 + +claim:type shared +drive 6cf6b5e4-f54f-4525-876b-d07123791880 +media cdrom +name Windows Server 2008 R2 Trial Install CD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 3170893824 + +claim:type shared +drive f89af28e-ff00-4fc9-a7ed-22e7fa5a88db +media cdrom +name Windows Server 2008 Trial Install CD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 2663383040 + +claim:type shared +drive 0cc82095-a967-4e93-af04-9e265fbb4251 +media cdrom +name Windows Server 2012 Install CD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 3695181824 + +claim:type shared +drive dde6f196-a4bd-4ca7-b631-4d84d69b9490 +media cdrom +name Windows Server 2012 R2 Install CD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 4479516672 + +claim:type shared +drive 7aead6d3-c3e6-4940-85c7-f5ee61f6ef2b +media cdrom +name Windows Web Server 2008 Trial Install CD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 2248146944 + +claim:type shared +drive 312ccda0-c3b2-4cac-911b-68b82a498075 +media cdrom +name arch Linux 2014-03-01 +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 553648128 + +claim:type shared +drive f42919f6-f535-44cd-bc9f-6bb6e44d05d8 +media cdrom +name centOS 6.5 Live DVD +readers ffffffff-ffff-ffff-ffff-ffffffffffff +size 1874853888 \ No newline at end of file diff --git a/apis/elasticstack/src/test/resources/standard_drives_uuids.txt b/apis/elasticstack/src/test/resources/standard_drives_uuids.txt new file mode 100644 index 00000000000..f4909048d61 --- /dev/null +++ b/apis/elasticstack/src/test/resources/standard_drives_uuids.txt @@ -0,0 +1,36 @@ +ce85ef47-9794-4ed7-a8bd-af902ec0eddc +82890da7-a036-4427-ac24-caea6c644a2f +62f512cd-82c7-498e-88d8-a09ac2ef20e7 +4f31382b-5098-4610-8993-bbebb844febd +cdea53be-2511-4c91-9779-f6421f623a49 +7b9807cc-3c92-425f-878c-1d45927f3f9c +61ef248d-6616-4378-9702-9101870741d2 +6c0c3072-f55f-4dd2-9308-951dacf41ce3 +63677762-4423-464f-92fd-5c43d449a716 +11b84345-7169-4279-8038-18d6ba1a7712 +b23e81b9-103e-4f9d-8ce5-b57bb529007c +8d5c93b8-e4e4-4943-b41e-873576b7fcd1 +65cb106c-3dff-4f27-9607-f25bbe0a3fc6 +8eeaa0d5-9696-4fb2-b34e-ccca28f54138 +4d0971b5-9780-4b42-a0a0-ea06a0669b8b +07a08d47-1f24-4c99-a080-ea6b38502c66 +321eaeb7-a5a5-4ffd-9a62-db1d0ffd133f +cf0dfc73-2ab2-4317-a515-698ed4097c90 +696a3dee-c29d-4bd2-afb9-06e995702b65 +3f9ddec5-0f9e-4879-85fb-e412abe0cb37 +e58ad21f-c53f-47a1-95bd-c6d614a59d2d +7fed7f41-7af7-42d9-bbf6-d96427757bc4 +50f8aa7a-090e-413a-8be9-e0ef498b7012 +a8e87123-1d88-4bd4-ba60-3a42248f7bc0 +00798d0a-1081-4590-8b6c-af1f927e209c +92f4a7e9-daa2-45f1-967c-cf460cf5bca1 +9dfbbe29-5352-415a-9f7c-70ec7409b684 +5a4419f8-6c39-490c-87e9-21e33a1c8add +554f5ed7-811a-400d-9f96-3f829a2bc145 +6cf6b5e4-f54f-4525-876b-d07123791880 +f89af28e-ff00-4fc9-a7ed-22e7fa5a88db +0cc82095-a967-4e93-af04-9e265fbb4251 +dde6f196-a4bd-4ca7-b631-4d84d69b9490 +7aead6d3-c3e6-4940-85c7-f5ee61f6ef2b +312ccda0-c3b2-4cac-911b-68b82a498075 +f42919f6-f535-44cd-bc9f-6bb6e44d05d8 \ No newline at end of file diff --git a/providers/elastichosts-ams-e/README.txt b/providers/elastichosts-ams-e/README.txt new file mode 100644 index 00000000000..87adb57233a --- /dev/null +++ b/providers/elastichosts-ams-e/README.txt @@ -0,0 +1,6 @@ +# +# The jclouds provider for ElasticHosts' Amsterdam ElasticStack (http://www.elastichosts.com/). +# +# Expects the jclouds elasticstack API to be present on your application's classpath. +# + diff --git a/providers/elastichosts-ams-e/pom.xml b/providers/elastichosts-ams-e/pom.xml new file mode 100644 index 00000000000..9463e088dea --- /dev/null +++ b/providers/elastichosts-ams-e/pom.xml @@ -0,0 +1,125 @@ + + + + 4.0.0 + + org.apache.jclouds + jclouds-project + 1.8.0-SNAPSHOT + ../../project/pom.xml + + org.apache.jclouds.provider + elastichosts-ams-e + jclouds ElasticHosts Amsterdam provider + ElasticHosts implementation targeted to Amsterdam + bundle + + + https://api-ams-e.elastichosts.com + 2.0 + + FIXME_IDENTITY + FIXME_CREDENTIAL + + + org.jclouds.elastichosts*;version="${project.version}" + + org.jclouds.compute.internal;version="${project.version}", + org.jclouds.rest.internal;version="${project.version}", + org.jclouds*;version="${project.version}", + * + + + + + + org.apache.jclouds.api + elasticstack + ${project.version} + + + org.apache.jclouds.api + elasticstack + ${project.version} + test-jar + test + + + org.apache.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.apache.jclouds + jclouds-compute + ${project.version} + test-jar + test + + + org.apache.jclouds.driver + jclouds-log4j + ${project.version} + test + + + org.apache.jclouds.driver + jclouds-sshj + ${project.version} + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + ${test.elastichosts-ams-e.endpoint} + ${test.elastichosts-ams-e.api-version} + ${test.elastichosts-ams-e.build-version} + ${test.elastichosts-ams-e.identity} + ${test.elastichosts-ams-e.credential} + ${test.elastichosts-ams-e.template} + + + + + + + + + + + diff --git a/providers/elastichosts-ams-e/src/main/java/org/jclouds/elastichosts/ElasticHostsAmsterdamMetadata.java b/providers/elastichosts-ams-e/src/main/java/org/jclouds/elastichosts/ElasticHostsAmsterdamMetadata.java new file mode 100644 index 00000000000..ffac7001143 --- /dev/null +++ b/providers/elastichosts-ams-e/src/main/java/org/jclouds/elastichosts/ElasticHostsAmsterdamMetadata.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts; + +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.elasticstack.ElasticStackApiMetadata; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts Amsterdam. + * + * @author Ignasi Barrera + */ +public class ElasticHostsAmsterdamMetadata extends BaseProviderMetadata { + + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public ElasticHostsAmsterdamMetadata() { + super(builder()); + } + + public ElasticHostsAmsterdamMetadata(Builder builder) { + super(builder); + } + + public static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[01234].[01][04].[0-9]*,os64Bit=true"); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder { + + protected Builder() { + id("elastichosts-ams-e") + .name("ElasticHosts Amsterdam") + .apiMetadata(new ElasticStackApiMetadata().toBuilder().version("2.0").build()) + .homepage(URI.create("https://ams-e.elastichosts.com")) + .console(URI.create("https://ams-e.elastichosts.com/accounts")) + .iso3166Codes("NL-NH") + .endpoint("https://api-ams-e.elastichosts.com") + .defaultProperties(ElasticHostsAmsterdamMetadata.defaultProperties()); + } + + @Override + public ElasticHostsAmsterdamMetadata build() { + return new ElasticHostsAmsterdamMetadata(this); + } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata in) { + super.fromProviderMetadata(in); + return this; + } + + } +} diff --git a/providers/elastichosts-ams-e/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/elastichosts-ams-e/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 00000000000..508e627af66 --- /dev/null +++ b/providers/elastichosts-ams-e/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.elastichosts.ElasticHostsAmsterdamMetadata diff --git a/providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/ElasticHostsAmsterdamApiLiveTest.java b/providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/ElasticHostsAmsterdamApiLiveTest.java new file mode 100644 index 00000000000..d83702f0fa6 --- /dev/null +++ b/providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/ElasticHostsAmsterdamApiLiveTest.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts; + +import org.jclouds.elasticstack.ElasticStackApiLiveTest; +import org.testng.annotations.Test; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsAmsterdamApiLiveTest") +public class ElasticHostsAmsterdamApiLiveTest extends ElasticStackApiLiveTest { + public ElasticHostsAmsterdamApiLiveTest() { + provider = "elastichosts-ams-e"; + } +} diff --git a/providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/ElasticHostsAmsterdamProviderTest.java b/providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/ElasticHostsAmsterdamProviderTest.java new file mode 100644 index 00000000000..4ee239286d4 --- /dev/null +++ b/providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/ElasticHostsAmsterdamProviderTest.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts; + +import org.jclouds.elasticstack.ElasticStackApiMetadata; +import org.jclouds.providers.internal.BaseProviderMetadataTest; +import org.testng.annotations.Test; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "unit", testName = "ElasticHostsAmsterdamProviderTest") +public class ElasticHostsAmsterdamProviderTest extends BaseProviderMetadataTest { + + public ElasticHostsAmsterdamProviderTest() { + super(new ElasticHostsAmsterdamMetadata(), new ElasticStackApiMetadata()); + } +} diff --git a/providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsAmsterdamComputeServiceLiveTest.java b/providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsAmsterdamComputeServiceLiveTest.java new file mode 100644 index 00000000000..ba577ea8dd6 --- /dev/null +++ b/providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsAmsterdamComputeServiceLiveTest.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts.compute; + +import org.jclouds.elasticstack.compute.ElasticStackComputeServiceLiveTest; +import org.testng.annotations.Test; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "live", testName = "ElasticHostsAmsterdamComputeServiceLiveTest") +public class ElasticHostsAmsterdamComputeServiceLiveTest extends ElasticStackComputeServiceLiveTest { + + public ElasticHostsAmsterdamComputeServiceLiveTest() { + provider = "elastichosts-ams-e"; + group = "elastichosts"; + } + +} diff --git a/providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsAmsterdamTemplateBuilderLiveTest.java b/providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsAmsterdamTemplateBuilderLiveTest.java new file mode 100644 index 00000000000..1c8121fe575 --- /dev/null +++ b/providers/elastichosts-ams-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsAmsterdamTemplateBuilderLiveTest.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts.compute; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.io.IOException; +import java.util.Set; + +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableSet; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "live", testName = "ElasticHostsAmsterdamTemplateBuilderLiveTest") +public class ElasticHostsAmsterdamTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + + public ElasticHostsAmsterdamTemplateBuilderLiveTest() { + provider = "elastichosts-ams-e"; + } + + @Override + protected Predicate defineUnsupportedOperatingSystems() { + return Predicates.not(new Predicate() { + + @Override + public boolean apply(final OsFamilyVersion64Bit input) { + switch (input.family) { + case UBUNTU: + return (input.version.equals("") || input.version.equals("12.04.1") || input.version.equals("13.10") || input.version + .equals("14.04")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.matches("7.4")) && input.is64Bit; + case CENTOS: + return (input.version.equals("") || input.version.equals("6.5")) && input.is64Bit; + case WINDOWS: + return (input.version.equals("") || input.version.equals("2008 R2") + || input.version.equals("2008 R2 + SQL") || input.version.equals("2012") || input.version + .equals("2012 R2 + SQL")) && input.is64Bit; + default: + return false; + } + } + + }); + } + + @Override + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = view.getComputeService().templateBuilder().build(); + assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[01234].[01][04].[0-9]*")); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("NL-NH"); + } +} diff --git a/providers/elastichosts-hkg-e/README.txt b/providers/elastichosts-hkg-e/README.txt new file mode 100644 index 00000000000..8bde54b9091 --- /dev/null +++ b/providers/elastichosts-hkg-e/README.txt @@ -0,0 +1,5 @@ +# +# The jclouds provider for ElasticHosts' Hong Kong ElasticStack (http://www.elastichosts.com/). +# +# Expects the jclouds elasticstack API to be present on your application's classpath. +# \ No newline at end of file diff --git a/providers/elastichosts-hkg-e/pom.xml b/providers/elastichosts-hkg-e/pom.xml new file mode 100644 index 00000000000..00b38380779 --- /dev/null +++ b/providers/elastichosts-hkg-e/pom.xml @@ -0,0 +1,125 @@ + + + + 4.0.0 + + org.apache.jclouds + jclouds-project + 1.8.0-SNAPSHOT + ../../project/pom.xml + + org.apache.jclouds.provider + elastichosts-hkg-e + jclouds ElasticHosts Hong Kong provider + ElasticHosts implementation targeted to Hong Kong + bundle + + + https://api-hkg-e.elastichosts.com + 2.0 + + FIXME_IDENTITY + FIXME_CREDENTIAL + + + org.jclouds.elastichosts*;version="${project.version}" + + org.jclouds.compute.internal;version="${project.version}", + org.jclouds.rest.internal;version="${project.version}", + org.jclouds*;version="${project.version}", + * + + + + + + org.apache.jclouds.api + elasticstack + ${project.version} + + + org.apache.jclouds.api + elasticstack + ${project.version} + test-jar + test + + + org.apache.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.apache.jclouds + jclouds-compute + ${project.version} + test-jar + test + + + org.apache.jclouds.driver + jclouds-log4j + ${project.version} + test + + + org.apache.jclouds.driver + jclouds-sshj + ${project.version} + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + ${test.elastichosts-hkg-e.endpoint} + ${test.elastichosts-hkg-e.api-version} + ${test.elastichosts-hkg-e.build-version} + ${test.elastichosts-hkg-e.identity} + ${test.elastichosts-hkg-e.credential} + ${test.elastichosts-hkg-e.template} + + + + + + + + + + + diff --git a/providers/elastichosts-hkg-e/src/main/java/org/jclouds/elastichosts/ElasticHostsHongKongProviderMetadata.java b/providers/elastichosts-hkg-e/src/main/java/org/jclouds/elastichosts/ElasticHostsHongKongProviderMetadata.java new file mode 100644 index 00000000000..e08d573d6d3 --- /dev/null +++ b/providers/elastichosts-hkg-e/src/main/java/org/jclouds/elastichosts/ElasticHostsHongKongProviderMetadata.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts; + +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.elasticstack.ElasticStackApiMetadata; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts Hong Kong. + * + * @author Ignasi Barrera + */ +public class ElasticHostsHongKongProviderMetadata extends BaseProviderMetadata { + + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public ElasticHostsHongKongProviderMetadata() { + super(builder()); + } + + public ElasticHostsHongKongProviderMetadata(Builder builder) { + super(builder); + } + + public static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[01234].[01][04].[0-9]*,os64Bit=true"); + return properties; + } + + public static class Builder + extends + BaseProviderMetadata.Builder { + + protected Builder() { + id("elastichosts-hkg-e") + .name("ElasticHosts Hong Kong") + .apiMetadata(new ElasticStackApiMetadata().toBuilder().version("2.0").build()) + .homepage(URI.create("https://hkg-e.elastichosts.com")) + .console(URI.create("https://hkg-e.elastichosts.com/accounts")) + .iso3166Codes("HK") + .endpoint("https://api-hkg-e.elastichosts.com") + .defaultProperties(ElasticHostsHongKongProviderMetadata.defaultProperties()); + } + + @Override + public ElasticHostsHongKongProviderMetadata build() { + return new ElasticHostsHongKongProviderMetadata(this); + } + + @Override + public Builder fromProviderMetadata( + ProviderMetadata in) { + super.fromProviderMetadata(in); + return this; + } + + } +} diff --git a/providers/elastichosts-hkg-e/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/elastichosts-hkg-e/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 00000000000..067e3bb0434 --- /dev/null +++ b/providers/elastichosts-hkg-e/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.elastichosts.ElasticHostsHongKongProviderMetadata diff --git a/providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/ElasticHostsHongKongApiLiveTest.java b/providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/ElasticHostsHongKongApiLiveTest.java new file mode 100644 index 00000000000..85fac2e9ba5 --- /dev/null +++ b/providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/ElasticHostsHongKongApiLiveTest.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts; + +import org.jclouds.elasticstack.ElasticStackApiLiveTest; +import org.testng.annotations.Test; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsHongKongApiLiveTest") +public class ElasticHostsHongKongApiLiveTest extends ElasticStackApiLiveTest { + public ElasticHostsHongKongApiLiveTest() { + provider = "elastichosts-hkg-e"; + } +} diff --git a/providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/ElasticHostsHongKongProviderTest.java b/providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/ElasticHostsHongKongProviderTest.java new file mode 100644 index 00000000000..748c5b19a13 --- /dev/null +++ b/providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/ElasticHostsHongKongProviderTest.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts; + +import org.jclouds.elasticstack.ElasticStackApiMetadata; +import org.jclouds.providers.internal.BaseProviderMetadataTest; +import org.testng.annotations.Test; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "unit", testName = "ElasticHostsHongKongProviderTest") +public class ElasticHostsHongKongProviderTest extends BaseProviderMetadataTest { + + public ElasticHostsHongKongProviderTest() { + super(new ElasticHostsHongKongProviderMetadata(), new ElasticStackApiMetadata()); + } +} diff --git a/providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsHongKongComputeServiceLiveTest.java b/providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsHongKongComputeServiceLiveTest.java new file mode 100644 index 00000000000..4dd6d617d12 --- /dev/null +++ b/providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsHongKongComputeServiceLiveTest.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts.compute; + +import org.jclouds.elasticstack.compute.ElasticStackComputeServiceLiveTest; +import org.testng.annotations.Test; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "live", testName = "ElasticHostsHongKongComputeServiceLiveTest") +public class ElasticHostsHongKongComputeServiceLiveTest extends ElasticStackComputeServiceLiveTest { + + public ElasticHostsHongKongComputeServiceLiveTest() { + provider = "elastichosts-hkg-e"; + group = "elastichosts"; + } + +} diff --git a/providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsHongKongTemplateBuilderLiveTest.java b/providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsHongKongTemplateBuilderLiveTest.java new file mode 100644 index 00000000000..4276e745616 --- /dev/null +++ b/providers/elastichosts-hkg-e/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsHongKongTemplateBuilderLiveTest.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts.compute; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.io.IOException; +import java.util.Set; + +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableSet; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "live", testName = "ElasticHostsHongKongTemplateBuilderLiveTest") +public class ElasticHostsHongKongTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + + public ElasticHostsHongKongTemplateBuilderLiveTest() { + provider = "elastichosts-hkg-e"; + } + + @Override + protected Predicate defineUnsupportedOperatingSystems() { + return Predicates.not(new Predicate() { + + @Override + public boolean apply(final OsFamilyVersion64Bit input) { + switch (input.family) { + case UBUNTU: + return (input.version.equals("") || input.version.equals("12.04.1") || input.version.equals("13.10") || input.version + .equals("14.04")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.matches("7.4")) && input.is64Bit; + case CENTOS: + return (input.version.equals("") || input.version.equals("6.5")) && input.is64Bit; + case WINDOWS: + return (input.version.equals("") || input.version.equals("2008 R2") + || input.version.equals("2008 R2 + SQL") || input.version.equals("2012") || input.version + .equals("2012 R2 + SQL")) && input.is64Bit; + default: + return false; + } + } + + }); + } + + @Override + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = view.getComputeService().templateBuilder().build(); + assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[01234].[01][04].[0-9]*")); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("HK"); + } +} diff --git a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java index 4eaf49b0cd6..78a22306a54 100644 --- a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java +++ b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java @@ -16,6 +16,8 @@ */ package org.jclouds.elastichosts; +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; + import java.net.URI; import java.util.Properties; @@ -50,6 +52,7 @@ public ElasticHostsPeer1LosAngelesProviderMetadata(Builder builder) { public static Properties defaultProperties() { Properties properties = new Properties(); + properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[01234].[01][04].[0-9]*,os64Bit=true"); return properties; } diff --git a/providers/elastichosts-lax-p/src/main/resources/elastichosts-lax-p/preinstalled_images.json b/providers/elastichosts-lax-p/src/main/resources/elastichosts-lax-p/preinstalled_images.json deleted file mode 100644 index 2e405895193..00000000000 --- a/providers/elastichosts-lax-p/src/main/resources/elastichosts-lax-p/preinstalled_images.json +++ /dev/null @@ -1,65 +0,0 @@ -[ - { - "uuid": "73f7cc6a-1c48-418a-80de-886b28a56a4d", - "description": "CentOS Linux 6.0", - "osFamily": "CENTOS", - "osVersion": "6.0", - "size": "3" - }, - { - "uuid": "9405cddf-8d01-472c-b7e3-e8c062dcde51", - "description": "Debian Linux 6.0", - "osFamily": "DEBIAN", - "osVersion": "6.0", - "size": "1" - }, - { - "uuid": "aee5589a-88c3-43ef-bb0a-9cab6e64192d", - "description": "Ubuntu Linux 10.04", - "osFamily": "UBUNTU", - "osVersion": "10.04", - "size": "1" - }, - { - "uuid": "8d8aee18-8744-452c-94b2-69a2a34b8460", - "description": "Ubuntu Linux 11.10", - "osFamily": "UBUNTU", - "osVersion": "11.10", - "size": "1" - }, - { - "uuid": "b9d0eb72-d273-43f1-98e3-0d4b87d372c0", - "description": "Windows Web Server 2008", - "osFamily": "WINDOWS", - "osVersion": "2008", - "size": "13" - }, - { - "uuid": "b405b598-4ae4-4ba8-8a2b-a9487d693f34", - "description": "Windows Web Server 2008 R2", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "9397d327-3bf6-46a2-abf6-69553dbb6927", - "description": "Windows Web Server 2008 R2 + SQL Server", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "b17ebce6-61b4-4dcc-9654-41c9fc847e01", - "description": "Windows Server 2008 Standard R2", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "662c5b3f-9828-4aa2-a866-7cfa53798cdf", - "description": "Windows Server 2008 Standard R2 + SQL Server", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - } -] diff --git a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java index 3cf12864bc3..5fe8bf5f0f5 100644 --- a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java @@ -18,7 +18,9 @@ import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import java.io.IOException; import java.util.Set; import org.jclouds.compute.domain.OsFamily; @@ -47,17 +49,19 @@ protected Predicate defineUnsupportedOperatingSystems() { return Predicates.not(new Predicate() { @Override - public boolean apply(OsFamilyVersion64Bit input) { + public boolean apply(final OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return (input.version.equals("") || ImmutableSet.of("11.10", "10.04").contains(input.version)) && input.is64Bit; + return (input.version.equals("") || input.version.equals("12.04.1") || input.version.equals("13.10") || input.version + .equals("14.04")) && input.is64Bit; case DEBIAN: - return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; + return (input.version.equals("") || input.version.matches("7.4")) && input.is64Bit; case CENTOS: - return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; + return (input.version.equals("") || input.version.equals("6.5")) && input.is64Bit; case WINDOWS: - return (input.version.equals("") || input.version.equals("2008 R2") || input.version.equals("2008")) - && input.is64Bit; + return (input.version.equals("") || input.version.equals("2008 R2") + || input.version.equals("2008 R2 + SQL") || input.version.equals("2012") || input.version + .equals("2012 R2 + SQL")) && input.is64Bit; default: return false; } @@ -66,13 +70,12 @@ public boolean apply(OsFamilyVersion64Bit input) { }); } - @Test - public void testTemplateBuilder() { - Template defaultTemplate = this.view.getComputeService().templateBuilder().build(); + @Override + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = view.getComputeService().templateBuilder().build(); + assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[01234].[01][04].[0-9]*")); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(defaultTemplate.getLocation().getId(), "elastichosts-lax-p"); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); } diff --git a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java index b78a534e107..5bea58cf5e9 100644 --- a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java +++ b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java @@ -16,6 +16,8 @@ */ package org.jclouds.elastichosts; +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; + import java.net.URI; import java.util.Properties; @@ -49,6 +51,7 @@ public ElasticHostsBlueSquareLondonProviderMetadata(Builder builder) { public static Properties defaultProperties() { Properties properties = new Properties(); + properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[01234].[01][04].[0-9]*,os64Bit=true"); return properties; } diff --git a/providers/elastichosts-lon-b/src/main/resources/elastichosts-lon-b/preinstalled_images.json b/providers/elastichosts-lon-b/src/main/resources/elastichosts-lon-b/preinstalled_images.json deleted file mode 100644 index 3ece03baccc..00000000000 --- a/providers/elastichosts-lon-b/src/main/resources/elastichosts-lon-b/preinstalled_images.json +++ /dev/null @@ -1,65 +0,0 @@ -[ - { - "uuid": "e994eedf-ce5c-4efd-9d0d-a16f690004f7", - "description": "CentOS Linux 6.0", - "osFamily": "CENTOS", - "osVersion": "6.0", - "size": "3" - }, - { - "uuid": "e97e0a2a-08d7-4624-b796-708f2adfc6b0", - "description": "Debian Linux 6.0", - "osFamily": "DEBIAN", - "osVersion": "6.0", - "size": "1" - }, - { - "uuid": "aee5589a-88c3-43ef-bb0a-9cab6e64192d", - "description": "Ubuntu Linux 10.04 LTS", - "osFamily": "UBUNTU", - "osVersion": "10.04", - "size": "1" - }, - { - "uuid": "13f9f85d-ed1c-4fb0-aa26-3e84da826faf", - "description": "Ubuntu Linux 11.10", - "osFamily": "UBUNTU", - "osVersion": "11.10", - "size": "1" - }, - { - "uuid": "b9d0eb72-d273-43f1-98e3-0d4b87d372c0", - "description": "Windows Web Server 2008", - "osFamily": "WINDOWS", - "osVersion": "2008", - "size": "13" - }, - { - "uuid": "30824e97-05a4-410c-946e-2ba5a92b07cb", - "description": "Windows Web Server 2008 R2", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "9ecf810e-6ad1-40ef-b360-d606f0444671", - "description": "Windows Web Server 2008 R2 + SQL Server", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "10a88d1c-6575-46e3-8d2c-7744065ea530", - "description": "Windows Server 2008 Standard R2", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "2567f25c-8fb8-45c7-95fc-bfe3c3d84c47", - "description": "Windows Server 2008 Standard R2 + SQL Server", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - } -] \ No newline at end of file diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java index 1a275b9bb78..1a143385c9d 100644 --- a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java @@ -18,7 +18,9 @@ import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import java.io.IOException; import java.util.Set; import org.jclouds.compute.domain.OsFamily; @@ -32,7 +34,6 @@ import com.google.common.collect.ImmutableSet; /** - * * @author Adrian Cole */ @Test(groups = "live") @@ -47,18 +48,19 @@ protected Predicate defineUnsupportedOperatingSystems() { return Predicates.not(new Predicate() { @Override - public boolean apply(OsFamilyVersion64Bit input) { + public boolean apply(final OsFamilyVersion64Bit input) { switch (input.family) { - case UBUNTU: - return (input.version.equals("") || input.version.equals("10.04") || input.version.equals("11.10")) - && input.is64Bit; - case DEBIAN: - return (input.version.equals("") || input.version.matches("6.0")) && input.is64Bit; + case UBUNTU: + return (input.version.equals("") || input.version.equals("12.04.1") || input.version.equals("13.10") || input.version + .equals("14.04")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.matches("7.4")) && input.is64Bit; case CENTOS: - return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; + return (input.version.equals("") || input.version.equals("6.5")) && input.is64Bit; case WINDOWS: - return (input.version.equals("") || input.version.equals("2008 R2") || input.version.equals("2008")) - && input.is64Bit; + return (input.version.equals("") || input.version.equals("2008 R2") + || input.version.equals("2008 R2 + SQL") || input.version.equals("2012") || input.version + .equals("2012 R2 + SQL")) && input.is64Bit; default: return false; } @@ -67,13 +69,12 @@ public boolean apply(OsFamilyVersion64Bit input) { }); } - @Test - public void testTemplateBuilder() { - Template defaultTemplate = this.view.getComputeService().templateBuilder().build(); + @Override + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = view.getComputeService().templateBuilder().build(); + assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[01234].[01][04].[0-9]*")); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(defaultTemplate.getLocation().getId(), "elastichosts-lon-b"); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); } diff --git a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java index 3b4ae19d870..8e4419584c0 100644 --- a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java +++ b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java @@ -16,6 +16,8 @@ */ package org.jclouds.elastichosts; +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; + import java.net.URI; import java.util.Properties; @@ -49,6 +51,7 @@ public ElasticHostsPeer1LondonProviderMetadata(Builder builder) { public static Properties defaultProperties() { Properties properties = new Properties(); + properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[01234].[01][04].[0-9]*,os64Bit=true"); return properties; } diff --git a/providers/elastichosts-lon-p/src/main/resources/elastichosts-lon-p/preinstalled_images.json b/providers/elastichosts-lon-p/src/main/resources/elastichosts-lon-p/preinstalled_images.json deleted file mode 100644 index 4e156e6fb79..00000000000 --- a/providers/elastichosts-lon-p/src/main/resources/elastichosts-lon-p/preinstalled_images.json +++ /dev/null @@ -1,65 +0,0 @@ -[ - { - "uuid": "6acfe7ea-1bb0-466e-992d-3830966e9da8", - "description": "CentOS Linux 6.0", - "osFamily": "CENTOS", - "osVersion": "6.0", - "size": "3" - }, - { - "uuid": "ff7c5f7b-1cc8-42e5-afe1-ca00c5faaaa6", - "description": "Debian Linux 6.0", - "osFamily": "DEBIAN", - "osVersion": "6.0", - "size": "1" - }, - { - "uuid": "aee5589a-88c3-43ef-bb0a-9cab6e64192d", - "description": "Ubuntu Linux 10.04 LTS", - "osFamily": "UBUNTU", - "osVersion": "10.04", - "size": "1" - }, - { - "uuid": "24ea9dad-f014-4836-bcb0-f03184c74e7a", - "description": "Ubuntu Linux 11.10", - "osFamily": "UBUNTU", - "osVersion": "11.10", - "size": "1" - }, - { - "uuid": "b9d0eb72-d273-43f1-98e3-0d4b87d372c0", - "description": "Windows Web Server 2008", - "osFamily": "WINDOWS", - "osVersion": "2008", - "size": "13" - }, - { - "uuid": "b405b598-4ae4-4ba8-8a2b-a9487d693f34", - "description": "Windows Web Server 2008 R2", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "9397d327-3bf6-46a2-abf6-69553dbb6927", - "description": "Windows Web Server 2008 R2 + SQL Server", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "b17ebce6-61b4-4dcc-9654-41c9fc847e01", - "description": "Windows Server 2008 Standard R2", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "662c5b3f-9828-4aa2-a866-7cfa53798cdf", - "description": "Windows Server 2008 Standard R2 + SQL Server", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - } -] diff --git a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java index 47cfb9c3dd4..bf5b6929795 100644 --- a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java @@ -18,7 +18,9 @@ import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import java.io.IOException; import java.util.Set; import org.jclouds.compute.domain.OsFamily; @@ -47,18 +49,19 @@ protected Predicate defineUnsupportedOperatingSystems() { return Predicates.not(new Predicate() { @Override - public boolean apply(OsFamilyVersion64Bit input) { + public boolean apply(final OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return (input.version.equals("") || input.version.equals("10.04") || input.version.equals("11.10")) - && input.is64Bit; + return (input.version.equals("") || input.version.equals("12.04.1") || input.version.equals("13.10") || input.version + .equals("14.04")) && input.is64Bit; case DEBIAN: - return (input.version.equals("") || input.version.matches("6.0")) && input.is64Bit; + return (input.version.equals("") || input.version.matches("7.4")) && input.is64Bit; case CENTOS: - return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; + return (input.version.equals("") || input.version.equals("6.5")) && input.is64Bit; case WINDOWS: - return (input.version.equals("") || input.version.equals("2008 R2") || input.version.equals("2008")) - && input.is64Bit; + return (input.version.equals("") || input.version.equals("2008 R2") + || input.version.equals("2008 R2 + SQL") || input.version.equals("2012") || input.version + .equals("2012 R2 + SQL")) && input.is64Bit; default: return false; } @@ -67,13 +70,12 @@ public boolean apply(OsFamilyVersion64Bit input) { }); } - @Test - public void testTemplateBuilder() { - Template defaultTemplate = this.view.getComputeService().templateBuilder().build(); + @Override + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = view.getComputeService().templateBuilder().build(); + assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[01234].[01][04].[0-9]*")); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(defaultTemplate.getLocation().getId(), "elastichosts-lon-p"); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); } diff --git a/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java b/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java index 7ea104a9ad5..3644ec685ce 100644 --- a/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java +++ b/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java @@ -16,6 +16,8 @@ */ package org.jclouds.elastichosts; +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; + import java.net.URI; import java.util.Properties; @@ -49,6 +51,7 @@ public ElasticHostsPeer1SanAntonioProviderMetadata(Builder builder) { public static Properties defaultProperties() { Properties properties = new Properties(); + properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[01234].[01][04].[0-9]*,os64Bit=true"); return properties; } diff --git a/providers/elastichosts-sat-p/src/main/resources/elastichosts-sat-p/preinstalled_images.json b/providers/elastichosts-sat-p/src/main/resources/elastichosts-sat-p/preinstalled_images.json deleted file mode 100644 index a806fb51e78..00000000000 --- a/providers/elastichosts-sat-p/src/main/resources/elastichosts-sat-p/preinstalled_images.json +++ /dev/null @@ -1,72 +0,0 @@ -[ - { - "uuid": "73f7cc6a-1c48-418a-80de-886b28a56a4d", - "description": "CentOS Linux 6.0", - "osFamily": "CENTOS", - "osVersion": "6.0", - "size": "3" - }, - { - "uuid": "9405cddf-8d01-472c-b7e3-e8c062dcde51", - "description": "Debian Linux 6.0", - "osFamily": "DEBIAN", - "osVersion": "6.0", - "size": "1" - }, - { - "uuid": "6aa953cc-3395-4e8d-938e-65c74fd20334", - "description": "Debian Linux 6.0.1", - "osFamily": "DEBIAN", - "osVersion": "6.0", - "size": "1" - }, - { - "uuid": "aee5589a-88c3-43ef-bb0a-9cab6e64192d", - "description": "Ubuntu Linux 10.04", - "osFamily": "UBUNTU", - "osVersion": "10.04", - "size": "1" - }, - { - "uuid": "8d8aee18-8744-452c-94b2-69a2a34b8460", - "description": "Ubuntu Linux 11.10", - "osFamily": "UBUNTU", - "osVersion": "11.10", - "size": "1" - }, - { - "uuid": "b9d0eb72-d273-43f1-98e3-0d4b87d372c0", - "description": "Windows Web Server 2008", - "osFamily": "WINDOWS", - "osVersion": "2008", - "size": "13" - }, - { - "uuid": "b405b598-4ae4-4ba8-8a2b-a9487d693f34", - "description": "Windows Web Server 2008 R2", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "9397d327-3bf6-46a2-abf6-69553dbb6927", - "description": "Windows Web Server 2008 R2 + SQL Server", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "b17ebce6-61b4-4dcc-9654-41c9fc847e01", - "description": "Windows Server 2008 Standard R2", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "662c5b3f-9828-4aa2-a866-7cfa53798cdf", - "description": "Windows Server 2008 Standard R2 + SQL Server", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - } -] diff --git a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java index 69e6a95d389..1988ec7c13e 100644 --- a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java +++ b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java @@ -18,7 +18,9 @@ import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import java.io.IOException; import java.util.Set; import org.jclouds.compute.domain.OsFamily; @@ -47,17 +49,19 @@ protected Predicate defineUnsupportedOperatingSystems() { return Predicates.not(new Predicate() { @Override - public boolean apply(OsFamilyVersion64Bit input) { + public boolean apply(final OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return (input.version.equals("") || ImmutableSet.of("11.10", "10.04").contains(input.version)) && input.is64Bit; + return (input.version.equals("") || input.version.equals("12.04.1") || input.version.equals("13.10") || input.version + .equals("14.04")) && input.is64Bit; case DEBIAN: - return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; + return (input.version.equals("") || input.version.matches("7.4")) && input.is64Bit; case CENTOS: - return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; + return (input.version.equals("") || input.version.equals("6.5")) && input.is64Bit; case WINDOWS: - return (input.version.equals("") || input.version.equals("2008 R2") || input.version.equals("2008")) - && input.is64Bit; + return (input.version.equals("") || input.version.equals("2008 R2") + || input.version.equals("2008 R2 + SQL") || input.version.equals("2012") || input.version + .equals("2012 R2 + SQL")) && input.is64Bit; default: return false; } @@ -66,13 +70,12 @@ public boolean apply(OsFamilyVersion64Bit input) { }); } - @Test - public void testTemplateBuilder() { - Template defaultTemplate = this.view.getComputeService().templateBuilder().build(); + @Override + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = view.getComputeService().templateBuilder().build(); + assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[01234].[01][04].[0-9]*")); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(defaultTemplate.getLocation().getId(), "elastichosts-sat-p"); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); } diff --git a/providers/elastichosts-sjc-c/README.txt b/providers/elastichosts-sjc-c/README.txt new file mode 100644 index 00000000000..5324488de3a --- /dev/null +++ b/providers/elastichosts-sjc-c/README.txt @@ -0,0 +1,5 @@ +# +# The jclouds provider for ElasticHosts' San Jose ElasticStack (http://www.elastichosts.com/). +# +# Expects the jclouds elasticstack API to be present on your application's classpath. +# \ No newline at end of file diff --git a/providers/elastichosts-sjc-c/pom.xml b/providers/elastichosts-sjc-c/pom.xml new file mode 100644 index 00000000000..df0da118b20 --- /dev/null +++ b/providers/elastichosts-sjc-c/pom.xml @@ -0,0 +1,125 @@ + + + + 4.0.0 + + org.apache.jclouds + jclouds-project + 1.8.0-SNAPSHOT + ../../project/pom.xml + + org.apache.jclouds.provider + elastichosts-sjc-c + jclouds ElasticHosts San Jose provider + ElasticHosts implementation targeted to San Jose + bundle + + + https://api-sjc-c.elastichosts.com + 2.0 + + FIXME_IDENTITY + FIXME_CREDENTIAL + + + org.jclouds.elastichosts*;version="${project.version}" + + org.jclouds.compute.internal;version="${project.version}", + org.jclouds.rest.internal;version="${project.version}", + org.jclouds*;version="${project.version}", + * + + + + + + org.apache.jclouds.api + elasticstack + ${project.version} + + + org.apache.jclouds.api + elasticstack + ${project.version} + test-jar + test + + + org.apache.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.apache.jclouds + jclouds-compute + ${project.version} + test-jar + test + + + org.apache.jclouds.driver + jclouds-log4j + ${project.version} + test + + + org.apache.jclouds.driver + jclouds-sshj + ${project.version} + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + ${test.elastichosts-sjc-c.endpoint} + ${test.elastichosts-sjc-c.api-version} + ${test.elastichosts-sjc-c.build-version} + ${test.elastichosts-sjc-c.identity} + ${test.elastichosts-sjc-c.credential} + ${test.elastichosts-sjc-c.template} + + + + + + + + + + + diff --git a/providers/elastichosts-sjc-c/src/main/java/org/jclouds/elastichosts/ElasticHostsSanJoseProviderMetadata.java b/providers/elastichosts-sjc-c/src/main/java/org/jclouds/elastichosts/ElasticHostsSanJoseProviderMetadata.java new file mode 100644 index 00000000000..1c591ee1f36 --- /dev/null +++ b/providers/elastichosts-sjc-c/src/main/java/org/jclouds/elastichosts/ElasticHostsSanJoseProviderMetadata.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts; + +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.elasticstack.ElasticStackApiMetadata; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts San Jose. + * + * @author Ignasi Barrera + */ +public class ElasticHostsSanJoseProviderMetadata extends BaseProviderMetadata { + + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public ElasticHostsSanJoseProviderMetadata() { + super(builder()); + } + + public ElasticHostsSanJoseProviderMetadata(Builder builder) { + super(builder); + } + + public static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[01234].[01][04].[0-9]*,os64Bit=true"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder { + + protected Builder() { + id("elastichosts-sjc-c") + .name("ElasticHosts San Jose") + .apiMetadata(new ElasticStackApiMetadata().toBuilder().version("2.0").build()) + .homepage(URI.create("https://sjc-c.elastichosts.com")) + .console(URI.create("https://sjc-c.elastichosts.com/accounts")) + .iso3166Codes("US-CA") + .endpoint("https://api-sjc-c.elastichosts.com") + .defaultProperties(ElasticHostsSanJoseProviderMetadata.defaultProperties()); + } + + @Override + public ElasticHostsSanJoseProviderMetadata build() { + return new ElasticHostsSanJoseProviderMetadata(this); + } + + @Override + public Builder fromProviderMetadata(ProviderMetadata in) { + super.fromProviderMetadata(in); + return this; + } + + } +} diff --git a/providers/elastichosts-sjc-c/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/elastichosts-sjc-c/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 00000000000..e739bdd17b8 --- /dev/null +++ b/providers/elastichosts-sjc-c/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.elastichosts.ElasticHostsSanJoseProviderMetadata diff --git a/providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/ElasticHostsSanJoseApiLiveTest.java b/providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/ElasticHostsSanJoseApiLiveTest.java new file mode 100644 index 00000000000..4c52db2142c --- /dev/null +++ b/providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/ElasticHostsSanJoseApiLiveTest.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts; + +import org.jclouds.elasticstack.ElasticStackApiLiveTest; +import org.testng.annotations.Test; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsSanJoseApiLiveTest") +public class ElasticHostsSanJoseApiLiveTest extends ElasticStackApiLiveTest { + public ElasticHostsSanJoseApiLiveTest() { + provider = "elastichosts-sjc-c"; + } +} diff --git a/providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/ElasticHostsSanJoseProviderTest.java b/providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/ElasticHostsSanJoseProviderTest.java new file mode 100644 index 00000000000..226758c4d2b --- /dev/null +++ b/providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/ElasticHostsSanJoseProviderTest.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts; + +import org.jclouds.elasticstack.ElasticStackApiMetadata; +import org.jclouds.providers.internal.BaseProviderMetadataTest; +import org.testng.annotations.Test; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "unit", testName = "ElasticHostsSanJoseProviderTest") +public class ElasticHostsSanJoseProviderTest extends BaseProviderMetadataTest { + + public ElasticHostsSanJoseProviderTest() { + super(new ElasticHostsSanJoseProviderMetadata(), new ElasticStackApiMetadata()); + } +} diff --git a/providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSanJoseComputeServiceLiveTest.java b/providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSanJoseComputeServiceLiveTest.java new file mode 100644 index 00000000000..e7ecdcb4392 --- /dev/null +++ b/providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSanJoseComputeServiceLiveTest.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts.compute; + +import org.jclouds.elasticstack.compute.ElasticStackComputeServiceLiveTest; +import org.testng.annotations.Test; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "live", testName = "ElasticHostsSanJoseComputeServiceLiveTest") +public class ElasticHostsSanJoseComputeServiceLiveTest extends ElasticStackComputeServiceLiveTest { + + public ElasticHostsSanJoseComputeServiceLiveTest() { + provider = "elastichosts-sjc-c"; + group = "elastichosts"; + } + +} diff --git a/providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSanJoseTemplateBuilderLiveTest.java b/providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSanJoseTemplateBuilderLiveTest.java new file mode 100644 index 00000000000..85f54b436cc --- /dev/null +++ b/providers/elastichosts-sjc-c/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSanJoseTemplateBuilderLiveTest.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts.compute; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.io.IOException; +import java.util.Set; + +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableSet; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "live", testName = "ElasticHostsSanJoseTemplateBuilderLiveTest") +public class ElasticHostsSanJoseTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + + public ElasticHostsSanJoseTemplateBuilderLiveTest() { + provider = "elastichosts-sjc-c"; + } + + @Override + protected Predicate defineUnsupportedOperatingSystems() { + return Predicates.not(new Predicate() { + + @Override + public boolean apply(final OsFamilyVersion64Bit input) { + switch (input.family) { + case UBUNTU: + return (input.version.equals("") || input.version.equals("12.04.1") || input.version.equals("13.10") || input.version + .equals("14.04")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.matches("7.4")) && input.is64Bit; + case CENTOS: + return (input.version.equals("") || input.version.equals("6.5")) && input.is64Bit; + case WINDOWS: + return (input.version.equals("") || input.version.equals("2008 R2") + || input.version.equals("2008 R2 + SQL") || input.version.equals("2012") || input.version + .equals("2012 R2 + SQL")) && input.is64Bit; + default: + return false; + } + } + + }); + } + + @Override + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = view.getComputeService().templateBuilder().build(); + assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[01234].[01][04].[0-9]*")); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("US-CA"); + } +} diff --git a/providers/elastichosts-syd-v/README.txt b/providers/elastichosts-syd-v/README.txt new file mode 100644 index 00000000000..1697a0e1344 --- /dev/null +++ b/providers/elastichosts-syd-v/README.txt @@ -0,0 +1,5 @@ +# +# The jclouds provider for ElasticHosts' Sydney ElasticStack (http://www.elastichosts.com/). +# +# Expects the jclouds elasticstack API to be present on your application's classpath. +# \ No newline at end of file diff --git a/providers/elastichosts-syd-v/pom.xml b/providers/elastichosts-syd-v/pom.xml new file mode 100644 index 00000000000..97d626692ca --- /dev/null +++ b/providers/elastichosts-syd-v/pom.xml @@ -0,0 +1,125 @@ + + + + 4.0.0 + + org.apache.jclouds + jclouds-project + 1.8.0-SNAPSHOT + ../../project/pom.xml + + org.apache.jclouds.provider + elastichosts-syd-v + jclouds ElasticHosts Sydney provider + ElasticHosts implementation targeted to Sydney + bundle + + + https://api-syd-v.elastichosts.com + 2.0 + + FIXME_IDENTITY + FIXME_CREDENTIAL + + + org.jclouds.elastichosts*;version="${project.version}" + + org.jclouds.compute.internal;version="${project.version}", + org.jclouds.rest.internal;version="${project.version}", + org.jclouds*;version="${project.version}", + * + + + + + + org.apache.jclouds.api + elasticstack + ${project.version} + + + org.apache.jclouds.api + elasticstack + ${project.version} + test-jar + test + + + org.apache.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.apache.jclouds + jclouds-compute + ${project.version} + test-jar + test + + + org.apache.jclouds.driver + jclouds-log4j + ${project.version} + test + + + org.apache.jclouds.driver + jclouds-sshj + ${project.version} + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + ${test.elastichosts-syd-v.endpoint} + ${test.elastichosts-syd-v.api-version} + ${test.elastichosts-syd-v.build-version} + ${test.elastichosts-syd-v.identity} + ${test.elastichosts-syd-v.credential} + ${test.elastichosts-syd-v.template} + + + + + + + + + + + diff --git a/providers/elastichosts-syd-v/src/main/java/org/jclouds/elastichosts/ElasticHostsSydneyProviderMetadata.java b/providers/elastichosts-syd-v/src/main/java/org/jclouds/elastichosts/ElasticHostsSydneyProviderMetadata.java new file mode 100644 index 00000000000..41b4ae55a1b --- /dev/null +++ b/providers/elastichosts-syd-v/src/main/java/org/jclouds/elastichosts/ElasticHostsSydneyProviderMetadata.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts; + +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.elasticstack.ElasticStackApiMetadata; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts Sydney. + * + * @author Ignasi Barrera + */ +public class ElasticHostsSydneyProviderMetadata extends BaseProviderMetadata { + + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public ElasticHostsSydneyProviderMetadata() { + super(builder()); + } + + public ElasticHostsSydneyProviderMetadata(Builder builder) { + super(builder); + } + + public static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[01234].[01][04].[0-9]*,os64Bit=true"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder { + + protected Builder() { + id("elastichosts-syd-v") + .name("ElasticHosts Sydney") + .apiMetadata(new ElasticStackApiMetadata().toBuilder().version("2.0").build()) + .homepage(URI.create("https://syd-v.elastichosts.com")) + .console(URI.create("https://syd-v.elastichosts.com/accounts")) + .iso3166Codes("AU-NSW") + .endpoint("https://api-syd-v.elastichosts.com") + .defaultProperties(ElasticHostsSydneyProviderMetadata.defaultProperties()); + } + + @Override + public ElasticHostsSydneyProviderMetadata build() { + return new ElasticHostsSydneyProviderMetadata(this); + } + + @Override + public Builder fromProviderMetadata(ProviderMetadata in) { + super.fromProviderMetadata(in); + return this; + } + + } +} diff --git a/providers/elastichosts-syd-v/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/elastichosts-syd-v/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 00000000000..256bcdc4e5d --- /dev/null +++ b/providers/elastichosts-syd-v/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.elastichosts.ElasticHostsSydneyProviderMetadata diff --git a/providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/ElasticHostsSydneyApiLiveTest.java b/providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/ElasticHostsSydneyApiLiveTest.java new file mode 100644 index 00000000000..1a6d7e5acf2 --- /dev/null +++ b/providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/ElasticHostsSydneyApiLiveTest.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts; + +import org.jclouds.elasticstack.ElasticStackApiLiveTest; +import org.testng.annotations.Test; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsSydneyApiLiveTest") +public class ElasticHostsSydneyApiLiveTest extends ElasticStackApiLiveTest { + public ElasticHostsSydneyApiLiveTest() { + provider = "elastichosts-syd-v"; + } +} diff --git a/providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/ElasticHostsSydneyProviderTest.java b/providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/ElasticHostsSydneyProviderTest.java new file mode 100644 index 00000000000..0fbed337db6 --- /dev/null +++ b/providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/ElasticHostsSydneyProviderTest.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts; + +import org.jclouds.elasticstack.ElasticStackApiMetadata; +import org.jclouds.providers.internal.BaseProviderMetadataTest; +import org.testng.annotations.Test; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "unit", testName = "ElasticHostsSydneyProviderTest") +public class ElasticHostsSydneyProviderTest extends BaseProviderMetadataTest { + + public ElasticHostsSydneyProviderTest() { + super(new ElasticHostsSydneyProviderMetadata(), new ElasticStackApiMetadata()); + } +} diff --git a/providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSydneyComputeServiceLiveTest.java b/providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSydneyComputeServiceLiveTest.java new file mode 100644 index 00000000000..5a035778db8 --- /dev/null +++ b/providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSydneyComputeServiceLiveTest.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts.compute; + +import org.jclouds.elasticstack.compute.ElasticStackComputeServiceLiveTest; +import org.testng.annotations.Test; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "live", testName = "ElasticHostsSydneyComputeServiceLiveTest") +public class ElasticHostsSydneyComputeServiceLiveTest extends ElasticStackComputeServiceLiveTest { + + public ElasticHostsSydneyComputeServiceLiveTest() { + provider = "elastichosts-syd-v"; + group = "elastichosts"; + } + +} diff --git a/providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSydneyTemplateBuilderLiveTest.java b/providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSydneyTemplateBuilderLiveTest.java new file mode 100644 index 00000000000..ceaf2691dac --- /dev/null +++ b/providers/elastichosts-syd-v/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsSydneyTemplateBuilderLiveTest.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.elastichosts.compute; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.io.IOException; +import java.util.Set; + +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableSet; + +/** + * @author Ignasi Barrera + */ +@Test(groups = "live", testName = "ElasticHostsSydneyTemplateBuilderLiveTest") +public class ElasticHostsSydneyTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + + public ElasticHostsSydneyTemplateBuilderLiveTest() { + provider = "elastichosts-syd-v"; + } + + @Override + protected Predicate defineUnsupportedOperatingSystems() { + return Predicates.not(new Predicate() { + + @Override + public boolean apply(final OsFamilyVersion64Bit input) { + switch (input.family) { + case UBUNTU: + return (input.version.equals("") || input.version.equals("12.04.1") || input.version.equals("13.10") || input.version + .equals("14.04")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.matches("7.4")) && input.is64Bit; + case CENTOS: + return (input.version.equals("") || input.version.equals("6.5")) && input.is64Bit; + case WINDOWS: + return (input.version.equals("") || input.version.equals("2008 R2") + || input.version.equals("2008 R2 + SQL") || input.version.equals("2012") || input.version + .equals("2012 R2 + SQL")) && input.is64Bit; + default: + return false; + } + } + + }); + } + + @Override + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = view.getComputeService().templateBuilder().build(); + assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[01234].[01][04].[0-9]*")); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("AU-NSW"); + } +} diff --git a/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java b/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java index 3f112b00d5c..32593545342 100644 --- a/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java +++ b/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java @@ -16,6 +16,8 @@ */ package org.jclouds.elastichosts; +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; + import java.net.URI; import java.util.Properties; @@ -49,6 +51,7 @@ public ElasticHostsPeer1TorontoProviderMetadata(Builder builder) { public static Properties defaultProperties() { Properties properties = new Properties(); + properties.setProperty(TEMPLATE, "osFamily=UBUNTU,osVersionMatches=1[01234].[01][04].[0-9]*,os64Bit=true"); return properties; } diff --git a/providers/elastichosts-tor-p/src/main/resources/elastichosts-tor-p/preinstalled_images.json b/providers/elastichosts-tor-p/src/main/resources/elastichosts-tor-p/preinstalled_images.json deleted file mode 100644 index 2e405895193..00000000000 --- a/providers/elastichosts-tor-p/src/main/resources/elastichosts-tor-p/preinstalled_images.json +++ /dev/null @@ -1,65 +0,0 @@ -[ - { - "uuid": "73f7cc6a-1c48-418a-80de-886b28a56a4d", - "description": "CentOS Linux 6.0", - "osFamily": "CENTOS", - "osVersion": "6.0", - "size": "3" - }, - { - "uuid": "9405cddf-8d01-472c-b7e3-e8c062dcde51", - "description": "Debian Linux 6.0", - "osFamily": "DEBIAN", - "osVersion": "6.0", - "size": "1" - }, - { - "uuid": "aee5589a-88c3-43ef-bb0a-9cab6e64192d", - "description": "Ubuntu Linux 10.04", - "osFamily": "UBUNTU", - "osVersion": "10.04", - "size": "1" - }, - { - "uuid": "8d8aee18-8744-452c-94b2-69a2a34b8460", - "description": "Ubuntu Linux 11.10", - "osFamily": "UBUNTU", - "osVersion": "11.10", - "size": "1" - }, - { - "uuid": "b9d0eb72-d273-43f1-98e3-0d4b87d372c0", - "description": "Windows Web Server 2008", - "osFamily": "WINDOWS", - "osVersion": "2008", - "size": "13" - }, - { - "uuid": "b405b598-4ae4-4ba8-8a2b-a9487d693f34", - "description": "Windows Web Server 2008 R2", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "9397d327-3bf6-46a2-abf6-69553dbb6927", - "description": "Windows Web Server 2008 R2 + SQL Server", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "b17ebce6-61b4-4dcc-9654-41c9fc847e01", - "description": "Windows Server 2008 Standard R2", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "662c5b3f-9828-4aa2-a866-7cfa53798cdf", - "description": "Windows Server 2008 Standard R2 + SQL Server", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - } -] diff --git a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java index 3c070d490c9..75bd1d08f8a 100644 --- a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java +++ b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java @@ -18,7 +18,9 @@ import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import java.io.IOException; import java.util.Set; import org.jclouds.compute.domain.OsFamily; @@ -47,17 +49,19 @@ protected Predicate defineUnsupportedOperatingSystems() { return Predicates.not(new Predicate() { @Override - public boolean apply(OsFamilyVersion64Bit input) { + public boolean apply(final OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return (input.version.equals("") || ImmutableSet.of("11.10", "10.04").contains(input.version)) && input.is64Bit; + return (input.version.equals("") || input.version.equals("12.04.1") || input.version.equals("13.10") || input.version + .equals("14.04")) && input.is64Bit; case DEBIAN: - return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; + return (input.version.equals("") || input.version.matches("7.4")) && input.is64Bit; case CENTOS: - return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; + return (input.version.equals("") || input.version.equals("6.5")) && input.is64Bit; case WINDOWS: - return (input.version.equals("") || input.version.equals("2008 R2") || input.version.equals("2008")) - && input.is64Bit; + return (input.version.equals("") || input.version.equals("2008 R2") + || input.version.equals("2008 R2 + SQL") || input.version.equals("2012") || input.version + .equals("2012 R2 + SQL")) && input.is64Bit; default: return false; } @@ -66,13 +70,12 @@ public boolean apply(OsFamilyVersion64Bit input) { }); } - @Test - public void testTemplateBuilder() { - Template defaultTemplate = this.view.getComputeService().templateBuilder().build(); + @Override + public void testDefaultTemplateBuilder() throws IOException { + Template defaultTemplate = view.getComputeService().templateBuilder().build(); + assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[01234].[01][04].[0-9]*")); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(defaultTemplate.getLocation().getId(), "elastichosts-tor-p"); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); } diff --git a/providers/go2cloud-jhb1/src/main/resources/go2cloud-jhb1/preinstalled_images.json b/providers/go2cloud-jhb1/src/main/resources/go2cloud-jhb1/preinstalled_images.json deleted file mode 100644 index 564c0ba91b3..00000000000 --- a/providers/go2cloud-jhb1/src/main/resources/go2cloud-jhb1/preinstalled_images.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "uuid": "14c88d27-1f5e-4ad5-9f3a-28e5d2282f61", - "description": "Ubuntu 10.10", - "osFamily": "UBUNTU", - "osVersion": "10.10", - "size": "1" - }, - { - "uuid": "cc54132d-4912-4106-a91a-7a27e6866c8b", - "description": "Debian 6.0.2.1", - "osFamily": "DEBIAN", - "osVersion": "6.0", - "size": "1" - }, - { - "uuid": "77ad0ffe-9537-4c64-a8e3-10db185261c0", - "description": "Windows 2008 R2 (x64) with SP1", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "d971ddfb-7a69-48f7-8d14-a76ef61b01d8", - "description": "Windows 8 Developer Preview (x64)", - "osFamily": "WINDOWS", - "osVersion": "8", - "size": "13" - } -] \ No newline at end of file diff --git a/providers/openhosting-east1/src/main/resources/openhosting-east1/preinstalled_images.json b/providers/openhosting-east1/src/main/resources/openhosting-east1/preinstalled_images.json deleted file mode 100644 index 9e558cf7571..00000000000 --- a/providers/openhosting-east1/src/main/resources/openhosting-east1/preinstalled_images.json +++ /dev/null @@ -1,51 +0,0 @@ -[ - { - "uuid": "1fc52c4b-f08d-4f9f-8821-7fdd073a32d6", - "description": "CentOS Linux 5.5 64", - "osFamily": "CENTOS", - "osVersion": "5.5", - "size": "3" - }, - { - "uuid": "4d67096a-c2b5-4be7-9716-d4b2f9e2d4b5", - "description": "CentOS Linux 5.6 64", - "osFamily": "CENTOS", - "osVersion": "5.6", - "size": "3" - }, - { - "uuid": "61e04f61-a39e-494f-bcf6-b17d3eba0df7", - "description": "CentOS Linux 5.7 64", - "osFamily": "CENTOS", - "osVersion": "5.7", - "size": "3" - }, - { - "uuid": "9c1a506a-5d2b-496b-9ebc-26cfeae76f42", - "description": "Debian Linux 5.0", - "osFamily": "DEBIAN", - "osVersion": "5.0", - "size": "1" - }, - { - "uuid": "13658a54-4086-47a4-89cb-ae21da7afb0c", - "description": "Debian Linux 6 (Squeeze) 64", - "osFamily": "DEBIAN", - "osVersion": "6.0", - "size": "1" - }, - { - "uuid": "8023b089-7b0e-4fcb-8016-01e82f2a9716", - "description": "Ubuntu 10.04.3 LTS (lucid) Server 64", - "osFamily": "UBUNTU", - "osVersion": "10.04", - "size": "1" - }, - { - "uuid": "d7826937-a160-4f70-ab5a-7ee9d78f7404", - "description": "Windows 2008 R2 Standard Edition", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "10" - } -] diff --git a/providers/pom.xml b/providers/pom.xml index 1899e5c8a69..7d2163be8d5 100644 --- a/providers/pom.xml +++ b/providers/pom.xml @@ -46,6 +46,10 @@ elastichosts-lon-b elastichosts-tor-p elastichosts-lax-p + elastichosts-ams-e + elastichosts-sjc-c + elastichosts-hkg-e + elastichosts-syd-v openhosting-east1 serverlove-z1-man skalicloud-sdg-my diff --git a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java index 7c2e6c9ca16..e53daf6a30c 100644 --- a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java +++ b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java @@ -22,6 +22,10 @@ import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; +import org.jclouds.serverlove.config.ServerloveImagesModule; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Serverlove Manchester. @@ -52,19 +56,22 @@ public static Properties defaultProperties() { return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { - id("serverlove-z1-man") - .name("Serverlove Manchester") - .apiMetadata(new ElasticStackApiMetadata().toBuilder().version("2.0").build()) - .homepage(URI.create("http://www.serverlove.com")) - .console(URI.create("http://www.serverlove.com/accounts")) - .iso3166Codes("GB-MAN") - .endpoint("https://api.z1-man.serverlove.com") - .defaultProperties(ServerloveManchesterProviderMetadata.defaultProperties()); + ElasticStackApiMetadata apiMedatada = new ElasticStackApiMetadata(); + + ImmutableSet.Builder> modules = ImmutableSet.builder(); + modules.addAll(apiMedatada.getDefaultModules()); + modules.add(ServerloveImagesModule.class); // Custom image supplier binding + + id("serverlove-z1-man").name("Serverlove Manchester") + .apiMetadata(apiMedatada.toBuilder().version("2.0").defaultModules(modules.build()).build()) + .homepage(URI.create("http://www.serverlove.com")) + .console(URI.create("http://www.serverlove.com/accounts")) + .iso3166Codes("GB-MAN") + .endpoint("https://api.z1-man.serverlove.com") + .defaultProperties(ServerloveManchesterProviderMetadata.defaultProperties()); } @Override @@ -73,8 +80,7 @@ public ServerloveManchesterProviderMetadata build() { } @Override - public Builder fromProviderMetadata( - ProviderMetadata in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/config/ServerloveImagesModule.java b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/config/ServerloveImagesModule.java new file mode 100644 index 00000000000..034fa10d7d9 --- /dev/null +++ b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/config/ServerloveImagesModule.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.serverlove.config; + +import static com.google.inject.Scopes.SINGLETON; + +import org.jclouds.elasticstack.suppliers.WellKnownImageSupplier; +import org.jclouds.serverlove.suppliers.FixedWellKnownImageSupplier; + +import com.google.inject.AbstractModule; + +/** + * Custom configuration for the Serverlove provider. + * + * @author Ignasi Barrera + */ +public class ServerloveImagesModule extends AbstractModule { + + @Override + protected void configure() { + bind(WellKnownImageSupplier.class).to(FixedWellKnownImageSupplier.class).in(SINGLETON); + } + +} diff --git a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/suppliers/FixedWellKnownImageSupplier.java b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/suppliers/FixedWellKnownImageSupplier.java new file mode 100644 index 00000000000..23409a47d57 --- /dev/null +++ b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/suppliers/FixedWellKnownImageSupplier.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.serverlove.suppliers; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.IOException; +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.elasticstack.domain.WellKnownImage; +import org.jclouds.elasticstack.suppliers.WellKnownImageSupplier; +import org.jclouds.json.Json; +import org.jclouds.location.Provider; +import org.jclouds.util.Strings2; + +import com.google.common.base.Throwables; +import com.google.inject.TypeLiteral; + +/** + * Supplies the pre-installed images. + * + * @author Ignasi Barrera + * + */ +@Singleton +public class FixedWellKnownImageSupplier implements WellKnownImageSupplier { + + private final Json json; + + private final String providerName; + + @Inject + FixedWellKnownImageSupplier(Json json, @Provider String providerName) { + this.json = checkNotNull(json, "json"); + this.providerName = checkNotNull(providerName, "providerName"); + } + + @Override + public List get() { + try { + return json.fromJson( + Strings2.toStringAndClose(getClass().getResourceAsStream( + "/" + providerName + "/preinstalled_images.json")), new TypeLiteral>() { + }.getType()); + } catch (IOException ex) { + throw Throwables.propagate(ex); + } + } + +} diff --git a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterApiLiveTest.java b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterApiLiveTest.java index 85c993d9b3b..132dee96760 100644 --- a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterApiLiveTest.java +++ b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterApiLiveTest.java @@ -35,4 +35,17 @@ public ServerloveManchesterApiLiveTest() { protected LoginCredentials getSshCredentials(Server server) { return LoginCredentials.builder().user("root").password(server.getVnc().getPassword()).build(); } + + @Override + @Test(enabled = false, description = "Standard drive API still not supported") + public void testListStandardDrives() throws Exception { + + } + + @Override + @Test(enabled = false, description = "Standard drive API still not supported") + public void testListStandardDriveInfo() throws Exception { + + } + } diff --git a/providers/skalicloud-sdg-my/src/main/resources/skalicloud-sdg-my/preinstalled_images.json b/providers/skalicloud-sdg-my/src/main/resources/skalicloud-sdg-my/preinstalled_images.json deleted file mode 100644 index c826fc32d3a..00000000000 --- a/providers/skalicloud-sdg-my/src/main/resources/skalicloud-sdg-my/preinstalled_images.json +++ /dev/null @@ -1,98 +0,0 @@ -[ - { - "uuid": "1cf47918-4280-4bbc-8f5f-7c7b2a0c3b3a", - "description": "CentOS 5.5 -32bit", - "osFamily": "CENTOS", - "osVersion": "5.5", - "is64bit": false, - "size": "1" - }, - { - "uuid": "90aa51f2-15c0-4cff-81ee-e93aa20b9468", - "description": "CentOS 5.5 -64bit", - "osFamily": "CENTOS", - "osVersion": "5.5", - "size": "1" - }, - { - "uuid": "0a4ef5e8-83d2-4b61-8fbe-0ff0232265f5", - "description": "CentOS 5.6 -32bit", - "osFamily": "CENTOS", - "osVersion": "5.6", - "is64bit": false, - "size": "1" - }, - { - "uuid": "66bc99a9-dfd4-4624-948a-57784e2cc411", - "description": "CentOS 5.6 -64bit", - "osFamily": "CENTOS", - "osVersion": "5.6", - "size": "1" - }, - { - "uuid": "c144d7a7-e24b-48ab-954b-6b6ec514ed6f", - "description": "Debian 5 -64bit", - "osFamily": "DEBIAN", - "osVersion": "5.0", - "size": "1" - }, - { - "uuid": "0178c66a-fc5b-43c6-bec5-3315fef924d2", - "description": "Debian 5 -32bit", - "osFamily": "DEBIAN", - "osVersion": "5.0", - "is64bit": false, - "size": "1" - }, - { - "uuid": "88cd1475-b6a0-4121-b9c2-97ddd652b410", - "description": "Debian 6 -64bit -Experimental", - "osFamily": "DEBIAN", - "osVersion": "6.0", - "size": "1" - }, - { - "uuid": "53e4b089-d35d-4aca-a95e-ff72774d3750", - "description": "Ubuntu Server 10.04 -64bit", - "osFamily": "UBUNTU", - "osVersion": "10.04", - "size": "1" - }, - { - "uuid": "877ea99b-7d42-4be7-9cf6-88b8daad9a8c", - "description": "Ubuntu Server 10.04 -32bit", - "osFamily": "UBUNTU", - "osVersion": "10.04", - "is64bit": false, - "size": "1" - }, - { - "uuid": "3051699a-a536-4220-aeb5-67f2ec101a09", - "description": "Ubuntu Server 10.10 -64bit", - "osFamily": "UBUNTU", - "osVersion": "10.10", - "size": "1" - }, - { - "uuid": "4d5656b5-74d3-4aa0-9308-6b7377552204", - "description": "Ubuntu Server 10.10 -32bit", - "osFamily": "UBUNTU", - "osVersion": "10.10", - "is64bit": false, - "size": "1" - }, - { - "uuid": "11c4c922-5ff8-4094-b06c-eb8ffaec1ea9", - "description": "Windows 2008R2 Web Edition", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - }, - { - "uuid": "93bf390e-4f46-4252-a8bc-9d6d80e3f955", - "description": "Windows Server 2008R2 Standard", - "osFamily": "WINDOWS", - "osVersion": "2008 R2", - "size": "13" - } -] \ No newline at end of file