From 2776d120930cbe275dbc84bafe26636a560d7902 Mon Sep 17 00:00:00 2001 From: "adrian.f.cole" Date: Sat, 16 Jan 2010 17:35:59 +0000 Subject: [PATCH] corrected ssl errors in blobstore and normalized context factories git-svn-id: http://jclouds.googlecode.com/svn/trunk@2663 3d8758e0-26b5-11de-8745-db77d3ebf521 --- .../AtmosStorageTestInitializer.java | 17 +- .../org/jclouds/aws/s3/S3AsyncClient.java | 7 +- .../jclouds/aws/s3/S3PropertiesBuilder.java | 3 + ...turnFalseOn404OrSSLHandshakeException.java | 25 --- .../compute/EC2ComputeServiceLiveTest.java | 3 +- .../org/jclouds/aws/s3/S3AsyncClientTest.java | 11 +- .../integration/S3TestInitializer.java | 15 +- .../integration/AzureBlobTestInitializer.java | 17 +- .../java/org/jclouds/blobstore/BlobStore.java | 57 ++++++- .../blobstore/BlobStoreContextFactory.java | 88 ++-------- .../internal/BaseTestInitializer.java | 4 +- .../compute/ComputeServiceContextFactory.java | 92 +++------- .../jclouds/http/HttpPropertiesBuilder.java | 12 +- .../JavaUrlHttpCommandExecutorService.java | 11 +- .../org/jclouds/rest/RestContextFactory.java | 158 ++++++++++++++++++ .../CloudFilesTestInitializer.java | 17 +- .../RimuHostingComputeClientLiveTest.java | 7 +- .../RimuHostingComputeServiceLiveTest.java | 3 +- tools/antcontrib/samples/compute/build.xml | 14 +- .../ant/taskdefs/compute/ComputeTask.java | 36 ++-- .../blobstore/BlobStoreFileProvider.java | 5 +- .../vcloud/VCloudComputeClientLiveTest.java | 2 +- .../HostingDotComVCloudClient.java | 2 +- .../HostingDotComVCloudComputeClient.java | 16 +- .../HostingDotComVCloudClientLiveTest.java | 2 +- ...tingDotComVCloudComputeClientLiveTest.java | 2 +- .../terremark/InternetServiceLiveTest.java | 2 +- .../TerremarkVCloudClientLiveTest.java | 2 +- .../TerremarkVCloudComputeClientLiveTest.java | 2 +- 29 files changed, 388 insertions(+), 244 deletions(-) delete mode 100644 aws/core/src/main/java/org/jclouds/aws/s3/functions/ReturnFalseOn404OrSSLHandshakeException.java create mode 100644 core/src/main/java/org/jclouds/rest/RestContextFactory.java diff --git a/atmos/src/test/java/org/jclouds/atmosonline/saas/blobstore/integration/AtmosStorageTestInitializer.java b/atmos/src/test/java/org/jclouds/atmosonline/saas/blobstore/integration/AtmosStorageTestInitializer.java index 866f5dc159..c63b155973 100644 --- a/atmos/src/test/java/org/jclouds/atmosonline/saas/blobstore/integration/AtmosStorageTestInitializer.java +++ b/atmos/src/test/java/org/jclouds/atmosonline/saas/blobstore/integration/AtmosStorageTestInitializer.java @@ -18,16 +18,19 @@ */ package org.jclouds.atmosonline.saas.blobstore.integration; +import java.io.IOException; +import java.util.Properties; + import org.jclouds.atmosonline.saas.AtmosStorageAsyncClient; import org.jclouds.atmosonline.saas.AtmosStorageClient; -import org.jclouds.atmosonline.saas.AtmosStoragePropertiesBuilder; -import org.jclouds.atmosonline.saas.blobstore.AtmosBlobStoreContextBuilder; import org.jclouds.atmosonline.saas.blobstore.AtmosBlobStoreContextFactory; import org.jclouds.atmosonline.saas.config.AtmosStorageStubClientModule; import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; import org.jclouds.blobstore.integration.internal.BaseTestInitializer; import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** @@ -37,12 +40,14 @@ import com.google.inject.Module; public class AtmosStorageTestInitializer extends BaseTestInitializer { + @SuppressWarnings("unchecked") @Override protected BlobStoreContext createLiveContext( - Module configurationModule, String url, String app, String account, String key) { - return new AtmosBlobStoreContextBuilder(new AtmosStoragePropertiesBuilder(account, key) - .relaxSSLHostname().build()).withModules(configurationModule, - new Log4JLoggingModule()).buildContext(); + Module configurationModule, String url, String app, String account, String key) + throws IOException { + return (BlobStoreContext) new BlobStoreContextFactory() + .createContext("atmos", account, key, ImmutableSet.of(configurationModule, + new Log4JLoggingModule()), new Properties()); } @Override diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/S3AsyncClient.java b/aws/core/src/main/java/org/jclouds/aws/s3/S3AsyncClient.java index 59f113eb3a..12535a455e 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/S3AsyncClient.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/S3AsyncClient.java @@ -48,7 +48,6 @@ import org.jclouds.aws.s3.functions.BindRegionToXmlPayload; import org.jclouds.aws.s3.functions.ObjectKey; import org.jclouds.aws.s3.functions.ParseObjectFromHeadersAndHttpContent; import org.jclouds.aws.s3.functions.ParseObjectMetadataFromHeaders; -import org.jclouds.aws.s3.functions.ReturnFalseOn404OrSSLHandshakeException; import org.jclouds.aws.s3.functions.ReturnTrueIfBucketAlreadyOwnedByYou; import org.jclouds.aws.s3.functions.ReturnTrueOn404FalseIfNotEmpty; import org.jclouds.aws.s3.options.CopyObjectOptions; @@ -69,6 +68,7 @@ import org.jclouds.blobstore.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404; import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404; import org.jclouds.http.functions.ParseETagHeader; +import org.jclouds.http.functions.ReturnFalseOn404; import org.jclouds.http.options.GetOptions; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Endpoint; @@ -156,7 +156,8 @@ public interface S3AsyncClient { @PUT @Path("/") @ExceptionParser(ReturnTrueIfBucketAlreadyOwnedByYou.class) - ListenableFuture putBucketInRegion(//TODO endpoint based on region + ListenableFuture putBucketInRegion( + // TODO endpoint based on region @BinderParam(BindRegionToXmlPayload.class) Region region, @HostPrefixParam String bucketName, PutBucketOptions... options); @@ -174,7 +175,7 @@ public interface S3AsyncClient { @HEAD @Path("/") @QueryParams(keys = "max-keys", values = "0") - @ExceptionParser(ReturnFalseOn404OrSSLHandshakeException.class) + @ExceptionParser(ReturnFalseOn404.class) ListenableFuture bucketExists(@HostPrefixParam String bucketName); /** diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/S3PropertiesBuilder.java b/aws/core/src/main/java/org/jclouds/aws/s3/S3PropertiesBuilder.java index f9cb7eda78..84d0babc4c 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/S3PropertiesBuilder.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/S3PropertiesBuilder.java @@ -28,6 +28,7 @@ import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_SESSIONINTERV import static org.jclouds.aws.s3.reference.S3Constants.PROPERTY_S3_TIMEOUT; import static org.jclouds.blobstore.reference.BlobStoreConstants.DIRECTORY_SUFFIX_FOLDER; import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX; +import static org.jclouds.http.HttpConstants.PROPERTY_HTTP_RELAX_HOSTNAME; import java.net.URI; import java.util.Properties; @@ -44,6 +45,7 @@ public class S3PropertiesBuilder extends HttpPropertiesBuilder { @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); + properties.setProperty(PROPERTY_HTTP_RELAX_HOSTNAME, "true"); properties.setProperty(PROPERTY_S3_ENDPOINT, "https://s3.amazonaws.com"); properties.setProperty(PROPERTY_S3_METADATA_PREFIX, "x-amz-meta-"); properties.setProperty(PROPERTY_S3_SESSIONINTERVAL, "60"); @@ -60,6 +62,7 @@ public class S3PropertiesBuilder extends HttpPropertiesBuilder { withCredentials(id, secret); } + @Override public S3PropertiesBuilder withCredentials(String id, String secret) { properties.setProperty(PROPERTY_AWS_ACCESSKEYID, checkNotNull(id, "awsAccessKeyId")); properties.setProperty(PROPERTY_AWS_SECRETACCESSKEY, checkNotNull(secret, diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/functions/ReturnFalseOn404OrSSLHandshakeException.java b/aws/core/src/main/java/org/jclouds/aws/s3/functions/ReturnFalseOn404OrSSLHandshakeException.java deleted file mode 100644 index 24a5b86cc3..0000000000 --- a/aws/core/src/main/java/org/jclouds/aws/s3/functions/ReturnFalseOn404OrSSLHandshakeException.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.jclouds.aws.s3.functions; - -import javax.inject.Singleton; -import javax.net.ssl.SSLHandshakeException; - -import org.jclouds.http.functions.ReturnFalseOn404; - -/** - * S3 buckets are dns names. When we attempt to resolve them, it could throw a misleading - * SSLHandshakeException when the bucket isn't found. - * - * @author Adrian Cole - */ -@Singleton -public class ReturnFalseOn404OrSSLHandshakeException extends ReturnFalseOn404 { - - public Boolean apply(Exception from) { - Boolean returnVal = super.apply(from); - if (returnVal == null && from instanceof SSLHandshakeException) { - return false; - } - return returnVal; - } - -} diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2ComputeServiceLiveTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2ComputeServiceLiveTest.java index 4c3cd8f648..b0604f8256 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2ComputeServiceLiveTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2ComputeServiceLiveTest.java @@ -24,6 +24,7 @@ import static org.testng.Assert.assertNotNull; import java.io.IOException; import java.net.InetSocketAddress; +import java.util.Properties; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -74,7 +75,7 @@ public class EC2ComputeServiceLiveTest { String user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); context = new ComputeServiceContextFactory().createContext("ec2", user, password, - ImmutableSet.of(new Log4JLoggingModule())); + ImmutableSet.of(new Log4JLoggingModule()), new Properties()); Injector injector = Guice.createInjector(new JschSshClientModule()); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); diff --git a/aws/core/src/test/java/org/jclouds/aws/s3/S3AsyncClientTest.java b/aws/core/src/test/java/org/jclouds/aws/s3/S3AsyncClientTest.java index c482c1a42b..0d0da7aa8f 100644 --- a/aws/core/src/test/java/org/jclouds/aws/s3/S3AsyncClientTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/s3/S3AsyncClientTest.java @@ -39,7 +39,6 @@ import org.jclouds.aws.s3.domain.AccessControlList.Permission; import org.jclouds.aws.s3.filters.RequestAuthorizeSignature; import org.jclouds.aws.s3.functions.ParseObjectFromHeadersAndHttpContent; import org.jclouds.aws.s3.functions.ParseObjectMetadataFromHeaders; -import org.jclouds.aws.s3.functions.ReturnFalseOn404OrSSLHandshakeException; import org.jclouds.aws.s3.functions.ReturnTrueIfBucketAlreadyOwnedByYou; import org.jclouds.aws.s3.functions.ReturnTrueOn404FalseIfNotEmpty; import org.jclouds.aws.s3.options.CopyObjectOptions; @@ -63,6 +62,7 @@ import org.jclouds.blobstore.reference.BlobStoreConstants; import org.jclouds.date.TimeStamp; import org.jclouds.http.functions.ParseETagHeader; import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.ReturnFalseOn404; import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.http.functions.ReturnVoidIf2xx; import org.jclouds.http.options.GetOptions; @@ -186,7 +186,7 @@ public class S3AsyncClientTest extends RestClientTest { assertResponseParserClassEquals(method, httpMethod, ReturnTrueIf2xx.class); assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnFalseOn404OrSSLHandshakeException.class); + assertExceptionParserClassEquals(method, ReturnFalseOn404.class); checkFilters(httpMethod); } @@ -379,8 +379,11 @@ public class S3AsyncClientTest extends RestClientTest { Region.EU_WEST_1, "bucket"); assertRequestLineEquals(httpMethod, "PUT http://bucket.stub:8080/ HTTP/1.1"); - assertHeadersEqual(httpMethod, "Content-Length: 98\nContent-Type: application/unknown\nHost: bucket.stub\n"); - assertPayloadEquals(httpMethod, "EU"); + assertHeadersEqual(httpMethod, + "Content-Length: 98\nContent-Type: application/unknown\nHost: bucket.stub\n"); + assertPayloadEquals( + httpMethod, + "EU"); assertResponseParserClassEquals(method, httpMethod, ReturnTrueIf2xx.class); assertSaxResponseParserClassEquals(method, null); diff --git a/aws/core/src/test/java/org/jclouds/aws/s3/blobstore/integration/S3TestInitializer.java b/aws/core/src/test/java/org/jclouds/aws/s3/blobstore/integration/S3TestInitializer.java index f1f1220d0d..7a95c5778f 100644 --- a/aws/core/src/test/java/org/jclouds/aws/s3/blobstore/integration/S3TestInitializer.java +++ b/aws/core/src/test/java/org/jclouds/aws/s3/blobstore/integration/S3TestInitializer.java @@ -18,17 +18,20 @@ */ package org.jclouds.aws.s3.blobstore.integration; +import java.io.IOException; +import java.util.Properties; + import org.jclouds.aws.s3.S3AsyncClient; import org.jclouds.aws.s3.S3Client; -import org.jclouds.aws.s3.S3PropertiesBuilder; -import org.jclouds.aws.s3.blobstore.S3BlobStoreContextBuilder; import org.jclouds.aws.s3.blobstore.S3BlobStoreContextFactory; import org.jclouds.aws.s3.config.S3StubClientModule; import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; import org.jclouds.blobstore.integration.internal.BaseTestInitializer; import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** @@ -37,12 +40,14 @@ import com.google.inject.Module; */ public class S3TestInitializer extends BaseTestInitializer { + @SuppressWarnings("unchecked") @Override protected BlobStoreContext createLiveContext( - Module configurationModule, String url, String app, String account, String key) { + Module configurationModule, String url, String app, String account, String key) throws IOException { BaseBlobStoreIntegrationTest.SANITY_CHECK_RETURNED_BUCKET_NAME = true; - return new S3BlobStoreContextBuilder(new S3PropertiesBuilder(account, key) - .build()).withModules(configurationModule, new Log4JLoggingModule()).buildContext(); + return (BlobStoreContext) new BlobStoreContextFactory() + .createContext("s3", account, key, ImmutableSet.of(configurationModule, + new Log4JLoggingModule()), new Properties()); } @Override diff --git a/azure/src/test/java/org/jclouds/azure/storage/blob/blobstore/integration/AzureBlobTestInitializer.java b/azure/src/test/java/org/jclouds/azure/storage/blob/blobstore/integration/AzureBlobTestInitializer.java index 921334c6e8..8ce035c20e 100644 --- a/azure/src/test/java/org/jclouds/azure/storage/blob/blobstore/integration/AzureBlobTestInitializer.java +++ b/azure/src/test/java/org/jclouds/azure/storage/blob/blobstore/integration/AzureBlobTestInitializer.java @@ -18,16 +18,19 @@ */ package org.jclouds.azure.storage.blob.blobstore.integration; +import java.io.IOException; +import java.util.Properties; + import org.jclouds.azure.storage.blob.AzureBlobAsyncClient; import org.jclouds.azure.storage.blob.AzureBlobClient; -import org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder; -import org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextBuilder; import org.jclouds.azure.storage.blob.blobstore.AzureBlobStoreContextFactory; import org.jclouds.azure.storage.blob.config.AzureBlobStubClientModule; import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; import org.jclouds.blobstore.integration.internal.BaseTestInitializer; import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** @@ -37,12 +40,14 @@ import com.google.inject.Module; public class AzureBlobTestInitializer extends BaseTestInitializer { + @SuppressWarnings("unchecked") @Override protected BlobStoreContext createLiveContext( - Module configurationModule, String url, String app, String account, String key) { - return new AzureBlobStoreContextBuilder(new AzureBlobPropertiesBuilder(account, key) - .relaxSSLHostname().build()).withModules(configurationModule, - new Log4JLoggingModule()).buildContext(); + Module configurationModule, String url, String app, String account, String key) + throws IOException { + return (BlobStoreContext) new BlobStoreContextFactory() + .createContext("azureblob", account, key, ImmutableSet.of(configurationModule, + new Log4JLoggingModule()), new Properties()); } @Override diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java index c87e714b9d..ad519bcdd3 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java @@ -71,13 +71,62 @@ public interface BlobStore { * @param container */ void clearContainer(String container); - + + /** + * Adds a {@code Blob} representing the data at location {@code container/blob.metadata.name} + * + * @param container + * container to place the blob. + * @param blob + * fully qualified name relative to the container. + * @param options + * byte range or condition options + * @return etag of the blob you uploaded, possibly null where etags are unsupported + * @throws ContainerNotFoundException + * if the container doesn't exist + */ String putBlob(String container, Blob blob); - Blob getBlob(String container, String key, GetOptions... options); + /** + * Retrieves a {@code Blob} representing the data at location {@code container/name} + * + * @param container + * container where this exists. + * @param name + * fully qualified name relative to the container. + * @param options + * byte range or condition options + * @return the blob you intended to receive. + * @throws ContainerNotFoundException + * if the container doesn't exist + * @throws KeyNotFoundException + * if the container doesn't exist + */ + Blob getBlob(String container, String name, GetOptions... options); - BlobMetadata blobMetadata(String container, String key); + /** + * Retrieves the metadata of a {@code Blob} at location {@code container/name} + * + * @param container + * container where this exists. + * @param name + * fully qualified name relative to the container. + * @return null if name isn't present or the blob you intended to receive. + * @throws ContainerNotFoundException + * if the container doesn't exist + */ + BlobMetadata blobMetadata(String container, String name); - void removeBlob(String container, String key); + /** + * Deletes a {@code Blob} representing the data at location {@code container/name} + * + * @param container + * container where this exists. + * @param name + * fully qualified name relative to the container. + * @throws ContainerNotFoundException + * if the container doesn't exist + */ + void removeBlob(String container, String name); } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java index 90922fb180..6b2d805abf 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java @@ -18,91 +18,39 @@ */ package org.jclouds.blobstore; -import static com.google.common.base.Preconditions.checkNotNull; - import java.io.IOException; -import java.net.URI; import java.util.Properties; import javax.inject.Inject; -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpPropertiesBuilder; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.io.Resources; -import com.google.inject.Module; +import org.jclouds.rest.RestContextFactory; /** + * Helper class to instantiate {@code BlobStoreContext} instances. * * @author Adrian Cole */ -public class BlobStoreContextFactory { - private final Properties properties; +public class BlobStoreContextFactory extends + RestContextFactory, BlobStoreContextBuilder> { + /** + * Initializes with the default properties built-in to jclouds. This is typically stored in the + * classpath resource {@code blobstore.properties} + * + * @throws IOException + * if the default properties file cannot be loaded + * @see #init + */ public BlobStoreContextFactory() throws IOException { - this(init()); - } - - static Properties init() throws IOException { - Properties properties = new Properties(); - properties.load(Resources.newInputStreamSupplier( - Resources.getResource("blobstore.properties")).getInput()); - return properties; + super("blobstore.properties"); } + /** + * + * Initializes the {@code BlobStoreContext) definitions from the specified properties. + */ @Inject public BlobStoreContextFactory(Properties properties) { - this.properties = properties; - } - - public BlobStoreContext createContext(URI blobStore, Iterable modules) { - return createContext(blobStore, Credentials.parse(blobStore), modules); - } - - public BlobStoreContext createContext(URI blobStore) { - return createContext(blobStore, ImmutableSet. of()); - } - - public BlobStoreContext createContext(URI blobStore, Credentials creds, - Iterable modules) { - return createContext(checkNotNull(blobStore.getHost(), "host"), checkNotNull(creds.account, - "account"), creds.key, modules); - } - - public BlobStoreContext createContext(URI blobStore, Credentials creds) { - return createContext(blobStore, creds, ImmutableSet. of()); - } - - public BlobStoreContext createContext(String hint, String account, String key) { - return createContext(hint, account, key, ImmutableSet. of()); - } - - @SuppressWarnings("unchecked") - public BlobStoreContext createContext(String hint, String account, String key, - Iterable modules) { - checkNotNull(hint, "hint"); - checkNotNull(account, "account"); - String propertiesBuilderKey = String.format("%s.propertiesbuilder", hint); - String propertiesBuilderClassName = checkNotNull( - properties.getProperty(propertiesBuilderKey), hint + " service not supported"); - - String contextBuilderKey = String.format("%s.contextbuilder", hint); - String contextBuilderClassName = checkNotNull(properties.getProperty(contextBuilderKey), - contextBuilderKey); - - try { - Class propertiesBuilderClass = (Class) Class - .forName(propertiesBuilderClassName); - Class> contextBuilderClass = (Class>) Class - .forName(contextBuilderClassName); - HttpPropertiesBuilder builder = propertiesBuilderClass.getConstructor(String.class, - String.class).newInstance(account, key); - return contextBuilderClass.getConstructor(Properties.class).newInstance(builder.build()) - .withModules(Iterables.toArray(modules, Module.class)).buildContext(); - } catch (Exception e) { - throw new RuntimeException("error instantiating " + contextBuilderClassName, e); - } + super(properties); } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseTestInitializer.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseTestInitializer.java index 63bccb1e9a..37f7ae509d 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseTestInitializer.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseTestInitializer.java @@ -18,6 +18,8 @@ */ package org.jclouds.blobstore.integration.internal; +import java.io.IOException; + import org.jclouds.blobstore.BlobStoreContext; import org.testng.ITestContext; @@ -49,5 +51,5 @@ public abstract class BaseTestInitializer { protected abstract BlobStoreContext createStubContext(); protected abstract BlobStoreContext createLiveContext(Module configurationModule, - String url, String app, String account, String key); + String url, String app, String account, String key) throws IOException; } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java b/core/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java index cc0099025b..03a580d90f 100644 --- a/core/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java +++ b/core/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java @@ -18,93 +18,39 @@ */ package org.jclouds.compute; -import static com.google.common.base.Preconditions.checkNotNull; - import java.io.IOException; -import java.net.URI; import java.util.Properties; import javax.inject.Inject; -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpPropertiesBuilder; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.io.Resources; -import com.google.inject.Module; +import org.jclouds.rest.RestContextFactory; /** + * Helper class to instantiate {@code ComputeServiceContext} instances. * * @author Adrian Cole */ -public class ComputeServiceContextFactory { - private final Properties properties; +public class ComputeServiceContextFactory extends + RestContextFactory, ComputeServiceContextBuilder> { + /** + * Initializes with the default properties built-in to jclouds. This is typically stored in the + * classpath resource {@code compute.properties} + * + * @throws IOException + * if the default properties file cannot be loaded + * @see #init + */ public ComputeServiceContextFactory() throws IOException { - this(init()); - } - - static Properties init() throws IOException { - Properties properties = new Properties(); - properties.load(Resources.newInputStreamSupplier(Resources.getResource("compute.properties")) - .getInput()); - return properties; + super("compute.properties"); } + /** + * + * Initializes the {@code ComputeServiceContext) definitions from the specified properties. + */ @Inject public ComputeServiceContextFactory(Properties properties) { - this.properties = properties; + super(properties); } - - public ComputeServiceContext createContext(URI blobStore, - Iterable modules) { - return createContext(blobStore, Credentials.parse(blobStore), modules); - } - - public ComputeServiceContext createContext(URI blobStore) { - return createContext(blobStore, ImmutableSet. of()); - } - - public ComputeServiceContext createContext(URI blobStore, Credentials creds, - Iterable modules) { - return createContext(checkNotNull(blobStore.getHost(), "host"), checkNotNull(creds.account, - "account"), creds.key, modules); - } - - public ComputeServiceContext createContext(URI blobStore, Credentials creds) { - return createContext(blobStore, creds, ImmutableSet. of()); - } - - public ComputeServiceContext createContext(String hint, String account, String key) { - return createContext(hint, account, key, ImmutableSet. of()); - } - - @SuppressWarnings("unchecked") - public ComputeServiceContext createContext(String hint, String account, String key, - Iterable modules) { - checkNotNull(hint, "hint"); - checkNotNull(account, "account"); - String propertiesBuilderKey = String.format("%s.propertiesbuilder", hint); - String propertiesBuilderClassName = checkNotNull( - properties.getProperty(propertiesBuilderKey), hint + " service not supported"); - - String contextBuilderKey = String.format("%s.contextbuilder", hint); - String contextBuilderClassName = checkNotNull(properties.getProperty(contextBuilderKey), - contextBuilderKey); - - try { - Class propertiesBuilderClass = (Class) Class - .forName(propertiesBuilderClassName); - Class> contextBuilderClass = (Class>) Class - .forName(contextBuilderClassName); - - HttpPropertiesBuilder builder = propertiesBuilderClass.getConstructor(String.class, - String.class).newInstance(account, key); - return contextBuilderClass.getConstructor(Properties.class).newInstance(builder.build()) - .withModules(Iterables.toArray(modules, Module.class)).buildContext(); - } catch (Exception e) { - throw new RuntimeException("error instantiating " + contextBuilderClassName, e); - } - } -} +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/http/HttpPropertiesBuilder.java b/core/src/main/java/org/jclouds/http/HttpPropertiesBuilder.java index 44ac2db47e..67f43e639c 100755 --- a/core/src/main/java/org/jclouds/http/HttpPropertiesBuilder.java +++ b/core/src/main/java/org/jclouds/http/HttpPropertiesBuilder.java @@ -42,16 +42,16 @@ public class HttpPropertiesBuilder { /** * allow mismatches between the certificate and the hostname of ssl requests. */ - public HttpPropertiesBuilder relaxSSLHostname() { - properties.setProperty(PROPERTY_HTTP_RELAX_HOSTNAME, "true"); + public HttpPropertiesBuilder relaxSSLHostname(boolean relax) { + properties.setProperty(PROPERTY_HTTP_RELAX_HOSTNAME, relax+""); return this; } public HttpPropertiesBuilder useSystemProxies(boolean useSystemProxies) { - properties.setProperty(PROPERTY_HTTP_PROXY_SYSTEM, useSystemProxies+""); + properties.setProperty(PROPERTY_HTTP_PROXY_SYSTEM, useSystemProxies + ""); return this; } - + public HttpPropertiesBuilder withHttpMaxRetries(int httpMaxRetries) { properties.setProperty(PROPERTY_HTTP_MAX_RETRIES, Integer.toString(httpMaxRetries)); return this; @@ -109,6 +109,10 @@ public class HttpPropertiesBuilder { this.properties.putAll(properties); } + public HttpPropertiesBuilder withCredentials(String account, String key) { + return this; + } + @VisibleForTesting public Properties build() { return properties; diff --git a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java index b6d79c8db9..39bb6d6485 100644 --- a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java +++ b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java @@ -62,12 +62,13 @@ public class JavaUrlHttpCommandExecutorService extends @Named(HttpConstants.PROPERTY_HTTP_RELAX_HOSTNAME) private boolean relaxHostname = false; private final Map sslMap; - + @Inject(optional = true) @Named(HttpConstants.PROPERTY_HTTP_PROXY_SYSTEM) - private boolean systemProxies = System.getProperty("java.net.useSystemProxies") != null ? - Boolean.parseBoolean(System.getProperty("java.net.useSystemProxies")) : false; - + private boolean systemProxies = System.getProperty("java.net.useSystemProxies") != null ? Boolean + .parseBoolean(System.getProperty("java.net.useSystemProxies")) + : false; + @Inject public JavaUrlHttpCommandExecutorService(ExecutorService executorService, DelegatingRetryHandler retryHandler, DelegatingErrorHandler errorHandler, HttpWire wire) { @@ -120,7 +121,7 @@ public class JavaUrlHttpCommandExecutorService extends Proxy proxy = Iterables.getLast(proxies); connection = (HttpURLConnection) url.openConnection(proxy); } else { - connection = (HttpURLConnection) url.openConnection(); + connection = (HttpURLConnection) url.openConnection(); } if (relaxHostname && connection instanceof HttpsURLConnection) { HttpsURLConnection sslCon = (HttpsURLConnection) connection; diff --git a/core/src/main/java/org/jclouds/rest/RestContextFactory.java b/core/src/main/java/org/jclouds/rest/RestContextFactory.java new file mode 100644 index 0000000000..38d0437975 --- /dev/null +++ b/core/src/main/java/org/jclouds/rest/RestContextFactory.java @@ -0,0 +1,158 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed 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.rest; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.IOException; +import java.net.URI; +import java.util.Properties; + +import javax.inject.Inject; + +import org.jclouds.domain.Credentials; +import org.jclouds.http.HttpPropertiesBuilder; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.io.Resources; +import com.google.inject.Module; + +/** + * Helper class to instantiate {@code RestContext} instances. "blobstore.properties" + * + * @author Adrian Cole + */ +public class RestContextFactory, B extends RestContextBuilder> { + private final static Properties NO_PROPERTIES = new Properties(); + private final Properties properties; + + /** + * Initializes with the default properties built-in to jclouds. This is typically stored in the + * classpath resource {@code filename} + * + * @parma filename name of the properties file to initialize from + * @throws IOException + * if the default properties file cannot be loaded + * @see #init + */ + public RestContextFactory(String filename) throws IOException { + this(getPropertiesFromResource(filename)); + } + + /** + * Loads the default properties that define the {@code RestContext} objects.

properties file + * format

+ * + * Two properties are needed per context: + *
    + *
  • tag.contextbuilder=classname extends RestContextBuilder
  • + *
  • tag.propertiesbuilder=classname extends HttpPropertiesBuilder
  • + *
+ * Ex. + * + *
+    * azureblob.contextbuilder=org.jclouds.azure.storage.blob.blobstore.AzureRestContextBuilder
+    * azureblob.propertiesbuilder=org.jclouds.azure.storage.blob.AzureBlobPropertiesBuilder
+    * 
+ * + * @param filename + * name of file to load from in the resource path + * @return properties object with these items loaded for each tag + * @throws IOException + * if {@code filename} cannot load. + */ + static Properties getPropertiesFromResource(String filename) throws IOException { + Properties properties = new Properties(); + properties.load(Resources.newInputStreamSupplier(Resources.getResource(filename)).getInput()); + return properties; + } + + /** + * Initializes the {@code RestContext} definitions from the specified properties. + */ + @Inject + public RestContextFactory(Properties properties) { + this.properties = properties; + } + + public T createContext(URI blobStore, Iterable modules, Properties overrides) { + return createContext(blobStore, Credentials.parse(blobStore), modules, overrides); + } + + public T createContext(URI blobStore) { + return createContext(blobStore, ImmutableSet. of(), NO_PROPERTIES); + } + + public T createContext(URI blobStore, Credentials creds, Iterable modules, + Properties overrides) { + return createContext(checkNotNull(blobStore.getHost(), "host"), checkNotNull(creds.account, + "account"), checkNotNull(creds.key, "key"), checkNotNull(modules, "modules"), + checkNotNull(overrides, "overrides")); + } + + public T createContext(URI blobStore, Credentials creds) { + return createContext(blobStore, creds, ImmutableSet. of(), NO_PROPERTIES); + } + + public T createContext(String hint, String account, String key) { + return createContext(hint, account, key, ImmutableSet. of(), NO_PROPERTIES); + } + + /** + * + * FIXME Comment this // ImmutableSet.of(new ExecutorServiceModule(myexecutor)) + * + * @param hint + * @param account + * @param key + * @param modules + * @param overrides + * @return + */ + @SuppressWarnings("unchecked") + public T createContext(String hint, String account, String key, + Iterable modules, Properties overrides) { + checkNotNull(hint, "hint"); + checkNotNull(account, "account"); + checkNotNull(key, "key"); + checkNotNull(modules, "modules"); + checkNotNull(overrides, "overrides"); + String propertiesBuilderKey = String.format("%s.propertiesbuilder", hint); + String propertiesBuilderClassName = checkNotNull( + properties.getProperty(propertiesBuilderKey), hint + " service not supported"); + + String contextBuilderKey = String.format("%s.contextbuilder", hint); + String contextBuilderClassName = checkNotNull(properties.getProperty(contextBuilderKey), + contextBuilderKey); + + try { + Class propertiesBuilderClass = (Class) Class + .forName(propertiesBuilderClassName); + Class contextBuilderClass = (Class) Class.forName(contextBuilderClassName); + HttpPropertiesBuilder builder = propertiesBuilderClass.getConstructor(Properties.class) + .newInstance(overrides).withCredentials(account, key); + return (T) contextBuilderClass.getConstructor(Properties.class).newInstance( + builder.build()).withModules(Iterables.toArray(modules, Module.class)) + .buildContext(); + } catch (Exception e) { + throw new RuntimeException("error instantiating " + contextBuilderClassName, e); + } + } +} diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesTestInitializer.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesTestInitializer.java index 892f6a7718..6f9a6a8625 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesTestInitializer.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/integration/CloudFilesTestInitializer.java @@ -18,17 +18,20 @@ */ package org.jclouds.rackspace.cloudfiles.blobstore.integration; +import java.io.IOException; +import java.util.Properties; + import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; import org.jclouds.blobstore.integration.internal.BaseTestInitializer; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rackspace.StubRackspaceAuthenticationModule; import org.jclouds.rackspace.cloudfiles.CloudFilesAsyncClient; import org.jclouds.rackspace.cloudfiles.CloudFilesClient; -import org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder; -import org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextBuilder; import org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStoreContextFactory; import org.jclouds.rackspace.cloudfiles.config.CloudFilesStubClientModule; +import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** @@ -38,12 +41,14 @@ import com.google.inject.Module; public class CloudFilesTestInitializer extends BaseTestInitializer { + @SuppressWarnings("unchecked") @Override protected BlobStoreContext createLiveContext( - Module configurationModule, String url, String app, String account, String key) { - return new CloudFilesBlobStoreContextBuilder(new CloudFilesPropertiesBuilder(account, key) - .relaxSSLHostname().build()).withModules(configurationModule, - new Log4JLoggingModule()).buildContext(); + Module configurationModule, String url, String app, String account, String key) + throws IOException { + return (BlobStoreContext) new BlobStoreContextFactory() + .createContext("cloudfiles", account, key, ImmutableSet.of(configurationModule, + new Log4JLoggingModule()), new Properties()); } @Override diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClientLiveTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClientLiveTest.java index 510777031f..bf0677d6a5 100644 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClientLiveTest.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClientLiveTest.java @@ -41,7 +41,7 @@ import java.util.concurrent.TimeoutException; /** * Tests behavior of {@code TerremarkVCloudClient} - * + * * @author Adrian Cole */ @Test(groups = "live", sequential = true, testName = "rimuhosting.RimuHostingComputeClientLiveTest") @@ -51,7 +51,6 @@ public class RimuHostingComputeClientLiveTest { private Long id; - private InetAddress publicIp; private Predicate addressTester; @@ -78,7 +77,8 @@ public class RimuHostingComputeClientLiveTest { @BeforeGroups(groups = { "live" }) public void setupClient() { String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); - Injector injector = new RimuHostingContextBuilder(new RimuHostingPropertiesBuilder(key).relaxSSLHostname().build()).withModules(new Log4JLoggingModule(), + Injector injector = new RimuHostingContextBuilder(new RimuHostingPropertiesBuilder(key) + .relaxSSLHostname(true).build()).withModules(new Log4JLoggingModule(), new JschSshClientModule(), new AbstractModule() { @Override @@ -99,7 +99,6 @@ public class RimuHostingComputeClientLiveTest { return new RetryablePredicate(reachable, 60, 5, TimeUnit.SECONDS); } - }).buildInjector(); client = injector.getInstance(RimuHostingComputeClient.class); rhClient = injector.getInstance(RimuHostingClient.class); diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java index 5e8db6252e..8206bcbe8d 100755 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java @@ -28,6 +28,7 @@ import static org.testng.Assert.assertNotNull; import java.io.IOException; import java.net.InetSocketAddress; import java.net.UnknownHostException; +import java.util.Properties; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -79,7 +80,7 @@ public class RimuHostingComputeServiceLiveTest { public void setupClient() throws IOException { String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); context = new ComputeServiceContextFactory().createContext("rimuhosting", key, key, - ImmutableSet.of(new Log4JLoggingModule())); + ImmutableSet.of(new Log4JLoggingModule()), new Properties()); Injector injector = Guice.createInjector(new JschSshClientModule()); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); diff --git a/tools/antcontrib/samples/compute/build.xml b/tools/antcontrib/samples/compute/build.xml index 935e9b5574..b520fd5c06 100644 --- a/tools/antcontrib/samples/compute/build.xml +++ b/tools/antcontrib/samples/compute/build.xml @@ -32,6 +32,8 @@ + + @@ -41,8 +43,8 @@ @@ -56,6 +58,12 @@ addproperty="key" /> + + @@ -81,7 +89,7 @@ - + diff --git a/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java b/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java index 5dbcb13f10..511cf1f295 100644 --- a/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java +++ b/tools/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java @@ -48,7 +48,6 @@ import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; import com.google.common.collect.MapMaker; import com.google.common.io.Files; -import com.google.common.io.Resources; import com.google.inject.Module; import com.google.inject.Provider; @@ -74,28 +73,41 @@ public class ComputeTask extends Task { }; + /** + * we don't have a reference to the project during the constructor, so we need to defer expansion + * with a Provider. + */ + private static Provider defaultPropertiesProvider = new Provider() { + + @SuppressWarnings("unchecked") + @Override + public Properties get() { + Properties props = new Properties(); + props.putAll(project.getProperties()); + return props; + } + + }; + public ComputeTask(Map> computeMap) { this.computeMap = computeMap; } public ComputeTask() throws IOException { - this(buildComputeMap(loadDefaultProperties())); + this(buildComputeMap()); } - static Properties loadDefaultProperties() throws IOException { - Properties properties = new Properties(); - properties.load(Resources.newInputStreamSupplier(Resources.getResource("compute.properties")) - .getInput()); - return properties; - } - - static Map> buildComputeMap(final Properties props) { + static Map> buildComputeMap() { return new MapMaker().makeComputingMap(new Function>() { @Override public ComputeServiceContext apply(URI from) { - return new ComputeServiceContextFactory(props).createContext(from, - defaultModulesProvider.get()); + try { + return new ComputeServiceContextFactory().createContext(from, defaultModulesProvider + .get(), defaultPropertiesProvider.get()); + } catch (IOException e) { + throw new RuntimeException(e); + } } }); diff --git a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileProvider.java b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileProvider.java index 3a23744ae4..812cd0f303 100644 --- a/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileProvider.java +++ b/tools/vfs/src/main/java/org/jclouds/vfs/provider/blobstore/BlobStoreFileProvider.java @@ -23,6 +23,7 @@ import java.net.URI; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Properties; import org.apache.commons.vfs.Capability; import org.apache.commons.vfs.FileName; @@ -86,8 +87,8 @@ public class BlobStoreFileProvider extends AbstractOriginatingFileProvider { .toChar(rootName.getUserName()))), UserAuthenticatorUtils .toString(UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD, UserAuthenticatorUtils - .toChar(rootName.getPassword())))), modules) - .getBlobStore(); + .toChar(rootName.getPassword())))), modules, + new Properties()).getBlobStore(); } catch (IOException e) { throw new FileSystemException("vfs.provider.blobstore/properties.error", name, e); } finally { diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudComputeClientLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudComputeClientLiveTest.java index a314c4fdc6..3c4798310e 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudComputeClientLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudComputeClientLiveTest.java @@ -146,7 +146,7 @@ public class VCloudComputeClientLiveTest { String account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); Injector injector = new VCloudContextBuilder(new VCloudPropertiesBuilder( - URI.create(endpoint), account, key).relaxSSLHostname().build()).withModules( + URI.create(endpoint), account, key).build()).withModules( new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); client = injector.getInstance(VCloudComputeClient.class); tmClient = injector.getInstance(VCloudClient.class); diff --git a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudClient.java b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudClient.java index fbde8b3184..97266df997 100644 --- a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudClient.java +++ b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudClient.java @@ -36,7 +36,7 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; public interface HostingDotComVCloudClient extends VCloudClient { @Override - @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) + @Timeout(duration = 600, timeUnit = TimeUnit.SECONDS) HostingDotComVApp instantiateVAppTemplateInVDC(String vDCId, String appName, String templateId, InstantiateVAppTemplateOptions... options); diff --git a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeClient.java b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeClient.java index b27e20c613..97c97c8ccb 100644 --- a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeClient.java +++ b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeClient.java @@ -58,9 +58,21 @@ public class HostingDotComVCloudComputeClient { } private Map imageCatalogIdMap = ImmutableMap. builder().put( - Image.CENTOS_53, "3").put(Image.RHEL_53, "8").put(Image.UBUNTU_90, "10").put( - Image.UBUNTU_JEOS_90, "11").build(); + Image.CENTOS_53, "3").build(); +// +// +// +// + public Map start(String name, Image image, int minCores, int minMegs, long diskSize, Map properties) { checkArgument(imageCatalogIdMap.containsKey(image), "image not configured: " + image); diff --git a/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudClientLiveTest.java b/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudClientLiveTest.java index 68f711a430..2ed33a01a4 100644 --- a/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudClientLiveTest.java +++ b/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudClientLiveTest.java @@ -42,7 +42,7 @@ public class HostingDotComVCloudClientLiveTest extends VCloudClientLiveTest { account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); Injector injector = new HostingDotComVCloudContextBuilder( - new HostingDotComVCloudPropertiesBuilder(account, key).relaxSSLHostname().build()) + new HostingDotComVCloudPropertiesBuilder(account, key).build()) .withModules(new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); connection = injector.getInstance(HostingDotComVCloudClient.class); diff --git a/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeClientLiveTest.java b/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeClientLiveTest.java index b15d115f55..8065c85b27 100644 --- a/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeClientLiveTest.java +++ b/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeClientLiveTest.java @@ -148,7 +148,7 @@ public class HostingDotComVCloudComputeClientLiveTest { String account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); Injector injector = new HostingDotComVCloudContextBuilder( - new HostingDotComVCloudPropertiesBuilder(account, key).relaxSSLHostname().build()) + new HostingDotComVCloudPropertiesBuilder(account, key).build()) .withModules(new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); client = injector.getInstance(HostingDotComVCloudComputeClient.class); hostingClient = injector.getInstance(HostingDotComVCloudClient.class); diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/InternetServiceLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/InternetServiceLiveTest.java index 18c1b2b1fc..d6d9620694 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/InternetServiceLiveTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/InternetServiceLiveTest.java @@ -105,7 +105,7 @@ public class InternetServiceLiveTest { String account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); Injector injector = new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder( - account, key).relaxSSLHostname().build()).withModules(new Log4JLoggingModule(), + account, key).build()).withModules(new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); tmClient = injector.getInstance(TerremarkVCloudClient.class); diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudClientLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudClientLiveTest.java index ee57685346..b10f926c4e 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudClientLiveTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudClientLiveTest.java @@ -444,7 +444,7 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest { account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); Injector injector = new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder( - account, key).relaxSSLHostname().build()).withModules(new Log4JLoggingModule(), + account, key).build()).withModules(new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); connection = tmClient = injector.getInstance(TerremarkVCloudClient.class); diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClientLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClientLiveTest.java index 7dc0c271d2..e94a3e13b8 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClientLiveTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeClientLiveTest.java @@ -155,7 +155,7 @@ public class TerremarkVCloudComputeClientLiveTest { String account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); Injector injector = new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder( - account, key).relaxSSLHostname().build()).withModules(new Log4JLoggingModule(), + account, key).build()).withModules(new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); client = injector.getInstance(TerremarkVCloudComputeClient.class); tmClient = injector.getInstance(TerremarkVCloudClient.class);