From a1c7ccfd3f8bacc1c67f97556a618fd2b398404e Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 3 May 2010 01:04:48 -0700 Subject: [PATCH] Issue 241:Add provider to the Location hierarchy and make getParent a Location object; also fixed compute services where broken and added ssh logging for runscript --- .../saas/AtmosStorageContextBuilder.java | 8 +- .../saas/AtmosStorageContextFactory.java | 12 +-- .../config/AtmosBlobStoreContextModule.java | 7 +- .../saas/AtmosStorageClientLiveTest.java | 11 ++- .../config/AtmosBlobStoreModuleTest.java | 2 +- .../java/org/jclouds/aws/domain/Region.java | 3 - .../jclouds/aws/ec2/EC2ContextBuilder.java | 19 ++-- .../jclouds/aws/ec2/EC2ContextFactory.java | 10 +- .../aws/ec2/compute/EC2ComputeService.java | 1 - .../EC2ComputeServiceContextModule.java | 23 +++-- .../compute/functions/CreateNewKeyPair.java | 1 - .../CreateSecurityGroupIfNeeded.java | 1 - .../strategy/EC2DestroyNodeStrategy.java | 1 - .../EC2RunNodesAndAddToSetStrategy.java | 2 +- .../jclouds/aws/ec2/domain/Attachment.java | 2 - .../aws/ec2/domain/AvailabilityZoneInfo.java | 2 - .../org/jclouds/aws/ec2/domain/Image.java | 2 - .../aws/ec2/domain/InstanceStateChange.java | 2 - .../org/jclouds/aws/ec2/domain/KeyPair.java | 2 - .../ec2/domain/PublicIpInstanceIdPair.java | 2 - .../jclouds/aws/ec2/domain/Reservation.java | 2 - .../aws/ec2/domain/RunningInstance.java | 1 - .../jclouds/aws/ec2/domain/SecurityGroup.java | 2 - .../org/jclouds/aws/ec2/domain/Snapshot.java | 2 - .../org/jclouds/aws/ec2/domain/Volume.java | 2 - .../aws/ec2/functions/RegionToEndpoint.java | 1 - .../AvailabilityZoneAndRegionAsyncClient.java | 1 - .../AvailabilityZoneAndRegionClient.java | 1 - .../services/ElasticIPAddressAsyncClient.java | 1 - .../ec2/services/ElasticIPAddressClient.java | 1 - .../aws/ec2/services/KeyPairAsyncClient.java | 1 - .../aws/ec2/services/KeyPairClient.java | 1 - .../ec2/services/MonitoringAsyncClient.java | 1 - .../aws/ec2/services/MonitoringClient.java | 1 - .../services/SecurityGroupAsyncClient.java | 1 - .../aws/ec2/services/SecurityGroupClient.java | 1 - .../aws/ec2/xml/AttachmentHandler.java | 1 - .../xml/DescribeAddressesResponseHandler.java | 1 - .../xml/DescribeImagesResponseHandler.java | 1 - .../xml/DescribeInstancesResponseHandler.java | 1 - .../xml/DescribeKeyPairsResponseHandler.java | 1 - .../xml/DescribeRegionsResponseHandler.java | 1 - ...DescribeSecurityGroupsResponseHandler.java | 1 - .../ec2/xml/InstanceStateChangeHandler.java | 1 - .../aws/ec2/xml/InstanceTypeHandler.java | 1 - .../aws/ec2/xml/KeyPairResponseHandler.java | 1 - .../ec2/xml/RunInstancesResponseHandler.java | 1 - .../jclouds/aws/ec2/xml/SnapshotHandler.java | 1 - .../org/jclouds/aws/s3/S3ContextBuilder.java | 8 +- .../org/jclouds/aws/s3/S3ContextFactory.java | 30 +++--- .../config/S3BlobStoreContextModule.java | 9 +- .../functions/BucketToResourceMetadata.java | 1 - .../org/jclouds/aws/sqs/SQSAsyncClient.java | 1 - .../java/org/jclouds/aws/sqs/SQSClient.java | 1 - .../jclouds/aws/sqs/SQSContextBuilder.java | 8 +- .../jclouds/aws/sqs/SQSContextFactory.java | 23 ++--- .../aws/sqs/config/SQSContextModule.java | 3 + .../org/jclouds/aws/sqs/domain/Queue.java | 2 - .../aws/sqs/functions/RegionToEndpoint.java | 1 - .../org/jclouds/aws/sqs/xml/QueueHandler.java | 1 - .../xml/RegexListQueuesResponseHandler.java | 1 - .../aws/sqs/xml/RegexQueueHandler.java | 1 - .../xml/internal/BaseRegexQueueHandler.java | 1 - ...icationArchitecturesEC2ClientLiveTest.java | 73 +++++++-------- .../aws/ec2/EBSBootEC2ClientLiveTest.java | 91 ++++++++++--------- .../services/MonitoringAsyncClientTest.java | 1 - .../storage/blob/AzureBlobContextBuilder.java | 6 +- .../storage/blob/AzureBlobContextFactory.java | 13 +-- .../config/AzureBlobStoreContextModule.java | 2 +- .../queue/AzureQueueContextBuilder.java | 8 +- .../queue/AzureQueueContextFactory.java | 14 +-- .../queue/config/AzureQueueContextModule.java | 3 + .../queue/AzureQueueClientLiveTest.java | 8 +- .../main/clojure/org/jclouds/blobstore.clj | 2 +- .../org/jclouds/blobstore/AsyncBlobStore.java | 4 +- .../java/org/jclouds/blobstore/BlobStore.java | 2 +- .../blobstore/BlobStoreContextBuilder.java | 8 +- .../TransientBlobStoreContextBuilder.java | 6 +- .../TransientBlobStoreContextModule.java | 2 +- .../internal/BaseAsyncBlobStore.java | 2 +- .../blobstore/internal/BaseBlobStore.java | 2 +- .../internal/BaseServiceIntegrationTest.java | 50 +++++++++- .../src/main/clojure/org/jclouds/compute.clj | 2 +- .../org/jclouds/compute/ComputeService.java | 2 +- .../compute/ComputeServiceContextBuilder.java | 9 +- .../org/jclouds/compute/domain/OsFamily.java | 6 +- .../compute/internal/BaseComputeService.java | 2 +- .../strategy/impl/ReturnNullCredentials.java | 23 +++++ .../jclouds/compute/util/ComputeUtils.java | 9 ++ .../compute/BaseComputeServiceLiveTest.java | 58 ++++++++++-- .../java/org/jclouds/domain/Location.java | 4 +- .../org/jclouds/domain/LocationScope.java | 2 +- .../jclouds/domain/internal/LocationImpl.java | 8 +- .../org/jclouds/rest/RestContextBuilder.java | 10 +- .../org/jclouds/rest/RestContextFactory.java | 51 ++++++----- .../java/org/jclouds/http/BaseJettyTest.java | 71 ++++++++------- .../jclouds/rest/RestContextBuilderTest.java | 4 +- .../jclouds/gogrid/GoGridContextBuilder.java | 8 +- .../jclouds/gogrid/GoGridContextFactory.java | 15 +-- .../GoGridComputeServiceContextModule.java | 10 +- .../jclouds/mezeo/pcs2/PCSContextBuilder.java | 8 +- .../jclouds/mezeo/pcs2/PCSContextFactory.java | 4 +- .../mezeo/pcs2/config/PCSContextModule.java | 4 + .../pcs2/config/PCSContextModuleTest.java | 2 +- .../nirvanix/sdn/SDNContextBuilder.java | 8 +- .../nirvanix/sdn/config/SDNContextModule.java | 4 + .../nirvanix/sdn/SDNClientLiveTest.java | 4 +- .../cloudfiles/CloudFilesContextBuilder.java | 8 +- .../cloudfiles/CloudFilesContextFactory.java | 6 +- .../CloudFilesBlobStoreContextModule.java | 7 ++ .../config/CloudFilesContextModule.java | 2 - .../CloudServersContextBuilder.java | 8 +- .../CloudServersContextFactory.java | 20 ++-- ...oudServersComputeServiceContextModule.java | 22 +++-- .../functions/ServerToNodeMetadata.java | 5 +- .../config/RackspaceLocationsModule.java | 8 +- .../RackspaceAuthenticationLiveTest.java | 6 +- .../binders/BindCFObjectToPayloadTest.java | 4 +- .../config/CloudFilesBlobStoreModuleTest.java | 3 +- .../CloudServersClientLiveTest.java | 6 +- .../CloudServersComputeServiceLiveTest.java | 12 +++ .../miro/RimuHostingContextBuilder.java | 8 +- .../miro/RimuHostingContextFactory.java | 12 +-- ...imuHostingComputeServiceContextModule.java | 8 +- .../ant/taskdefs/compute/ComputeTask.java | 2 +- .../twitter/TwitterContextBuilder.java | 8 +- .../twitter/TwitterContextFactory.java | 6 +- .../twitter/config/TwitterContextModule.java | 3 + .../config/TwitterContextModuleTest.java | 29 +++--- .../BlueLockVCloudContextBuilder.java | 17 ++-- .../BlueLockVCloudContextFactory.java | 22 ++--- .../compute/BlueLockVCloudComputeClient.java | 22 +++-- ...LockVCloudComputeServiceContextModule.java | 8 ++ ...efaultLoginCredentialsFromBlueLockFAQ.java | 39 ++++++++ .../BlueLockVCloudClientLiveTest.java | 6 +- .../jclouds/vcloud/VCloudContextBuilder.java | 8 +- .../jclouds/vcloud/VCloudContextFactory.java | 20 ++-- .../VCloudComputeServiceContextModule.java | 38 ++++---- .../jclouds/vcloud/VCloudClientLiveTest.java | 5 +- .../jclouds/vcloud/VCloudLoginLiveTest.java | 4 +- .../vcloud/VCloudVersionsLiveTest.java | 4 +- .../compute/VCloudComputeClientLiveTest.java | 4 +- .../HostingDotComVCloudContextBuilder.java | 11 +-- .../HostingDotComVCloudContextFactory.java | 8 +- ...tComVCloudComputeServiceContextModule.java | 7 ++ .../HostingDotComVCloudClientLiveTest.java | 2 +- ...tingDotComVCloudComputeClientLiveTest.java | 5 +- .../TerremarkVCloudContextBuilder.java | 8 +- .../TerremarkVCloudContextFactory.java | 8 +- ...markVCloudComputeServiceContextModule.java | 4 + .../terremark/InternetServiceLiveTest.java | 2 +- .../TerremarkVCloudClientLiveTest.java | 4 +- 152 files changed, 770 insertions(+), 540 deletions(-) create mode 100644 compute/src/main/java/org/jclouds/compute/strategy/impl/ReturnNullCredentials.java create mode 100644 vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/strategy/DefaultLoginCredentialsFromBlueLockFAQ.java diff --git a/atmos/src/main/java/org/jclouds/atmosonline/saas/AtmosStorageContextBuilder.java b/atmos/src/main/java/org/jclouds/atmosonline/saas/AtmosStorageContextBuilder.java index 695e7a445e..a13210386e 100755 --- a/atmos/src/main/java/org/jclouds/atmosonline/saas/AtmosStorageContextBuilder.java +++ b/atmos/src/main/java/org/jclouds/atmosonline/saas/AtmosStorageContextBuilder.java @@ -47,15 +47,15 @@ import com.google.inject.TypeLiteral; public class AtmosStorageContextBuilder extends BlobStoreContextBuilder { - public AtmosStorageContextBuilder(Properties props) { - super(new TypeLiteral() { + public AtmosStorageContextBuilder(String providerName, Properties props) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, props); } @Override - protected void addContextModule(List modules) { - modules.add(new AtmosBlobStoreContextModule()); + protected void addContextModule(String providerName, List modules) { + modules.add(new AtmosBlobStoreContextModule(providerName)); } @Override diff --git a/atmos/src/main/java/org/jclouds/atmosonline/saas/AtmosStorageContextFactory.java b/atmos/src/main/java/org/jclouds/atmosonline/saas/AtmosStorageContextFactory.java index 36dc606aa8..0fac1970e6 100755 --- a/atmos/src/main/java/org/jclouds/atmosonline/saas/AtmosStorageContextFactory.java +++ b/atmos/src/main/java/org/jclouds/atmosonline/saas/AtmosStorageContextFactory.java @@ -41,18 +41,18 @@ import com.google.inject.Module; */ public class AtmosStorageContextFactory { public static BlobStoreContext createContext(Properties properties, Module... modules) { - return new AtmosStorageContextBuilder(new AtmosStoragePropertiesBuilder(properties).build()) - .withModules(modules).buildBlobStoreContext(); + return new AtmosStorageContextBuilder("atmosstorage", new AtmosStoragePropertiesBuilder( + properties).build()).withModules(modules).buildBlobStoreContext(); } public static BlobStoreContext createContext(String uid, String key, Module... modules) { - return new AtmosStorageContextBuilder(new AtmosStoragePropertiesBuilder(uid, key).build()) - .withModules(modules).buildBlobStoreContext(); + return new AtmosStorageContextBuilder("atmosstorage", new AtmosStoragePropertiesBuilder(uid, + key).build()).withModules(modules).buildBlobStoreContext(); } public static BlobStoreContext createContext(URI endpoint, String uid, String key, Module... modules) { - return new AtmosStorageContextBuilder(new AtmosStoragePropertiesBuilder(uid, key) - .withEndpoint(endpoint).build()).withModules(modules).buildBlobStoreContext(); + return new AtmosStorageContextBuilder("atmosstorage", new AtmosStoragePropertiesBuilder(uid, + key).withEndpoint(endpoint).build()).withModules(modules).buildBlobStoreContext(); } } diff --git a/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/config/AtmosBlobStoreContextModule.java b/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/config/AtmosBlobStoreContextModule.java index 85acabd597..e94bfab7cd 100755 --- a/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/config/AtmosBlobStoreContextModule.java +++ b/atmos/src/main/java/org/jclouds/atmosonline/saas/blobstore/config/AtmosBlobStoreContextModule.java @@ -50,6 +50,11 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ public class AtmosBlobStoreContextModule extends AtmosStorageContextModule { + private final String providerName; + + public AtmosBlobStoreContextModule(String providerName) { + this.providerName = providerName; + } @Override protected void configure() { @@ -68,7 +73,7 @@ public class AtmosBlobStoreContextModule extends AtmosStorageContextModule { @Provides @Singleton Location getLocation() { - return new LocationImpl(LocationScope.ZONE, "UNKNOWN", "TODO", null); + return new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null); } @Provides diff --git a/atmos/src/test/java/org/jclouds/atmosonline/saas/AtmosStorageClientLiveTest.java b/atmos/src/test/java/org/jclouds/atmosonline/saas/AtmosStorageClientLiveTest.java index efbff92f6a..fcf71ae9ec 100644 --- a/atmos/src/test/java/org/jclouds/atmosonline/saas/AtmosStorageClientLiveTest.java +++ b/atmos/src/test/java/org/jclouds/atmosonline/saas/AtmosStorageClientLiveTest.java @@ -35,6 +35,7 @@ import org.jclouds.atmosonline.saas.domain.FileType; import org.jclouds.atmosonline.saas.domain.SystemMetadata; import org.jclouds.atmosonline.saas.options.ListOptions; import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; import org.jclouds.blobstore.KeyAlreadyExistsException; import org.jclouds.blobstore.KeyNotFoundException; import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; @@ -49,6 +50,8 @@ import org.testng.annotations.Test; import com.google.common.base.Supplier; import com.google.common.base.Throwables; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Tests behavior of {@code AtmosStorageClient} @@ -109,12 +112,12 @@ public class AtmosStorageClientLiveTest { URI container2; @BeforeGroups(groups = { "live" }) - public void setupClient() throws InterruptedException, ExecutionException, TimeoutException { + public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, + IOException { String uid = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); - BlobStoreContext blobStoreContext = new AtmosStorageContextBuilder( - new AtmosStoragePropertiesBuilder(uid, key).build()).withModules( - new Log4JLoggingModule()).buildBlobStoreContext(); + BlobStoreContext blobStoreContext = new BlobStoreContextFactory().createContext( + "atmosstorage", uid, key, ImmutableSet. of(new Log4JLoggingModule())); RestContext context = blobStoreContext .getProviderSpecificContext(); connection = context.getApi(); diff --git a/atmos/src/test/java/org/jclouds/atmosonline/saas/blobstore/config/AtmosBlobStoreModuleTest.java b/atmos/src/test/java/org/jclouds/atmosonline/saas/blobstore/config/AtmosBlobStoreModuleTest.java index e1e31ba5f1..505882a9dc 100755 --- a/atmos/src/test/java/org/jclouds/atmosonline/saas/blobstore/config/AtmosBlobStoreModuleTest.java +++ b/atmos/src/test/java/org/jclouds/atmosonline/saas/blobstore/config/AtmosBlobStoreModuleTest.java @@ -45,7 +45,7 @@ public class AtmosBlobStoreModuleTest { Injector createInjector() { return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()), new JDKLoggingModule(), new AtmosStorageStubClientModule(), - new AtmosBlobStoreContextModule() { + new AtmosBlobStoreContextModule("atmos") { @Override protected void configure() { bindConstant().annotatedWith( diff --git a/aws/core/src/main/java/org/jclouds/aws/domain/Region.java b/aws/core/src/main/java/org/jclouds/aws/domain/Region.java index b6187090cd..d810458aaa 100644 --- a/aws/core/src/main/java/org/jclouds/aws/domain/Region.java +++ b/aws/core/src/main/java/org/jclouds/aws/domain/Region.java @@ -18,9 +18,6 @@ */ package org.jclouds.aws.domain; -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; /** * diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/EC2ContextBuilder.java b/aws/core/src/main/java/org/jclouds/aws/ec2/EC2ContextBuilder.java index a9ac4d36ed..bc0c98e3cc 100755 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/EC2ContextBuilder.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/EC2ContextBuilder.java @@ -45,11 +45,10 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole * @see EC2ComputeServiceContext */ -public class EC2ContextBuilder extends - ComputeServiceContextBuilder { +public class EC2ContextBuilder extends ComputeServiceContextBuilder { - public EC2ContextBuilder(Properties props) { - super(new TypeLiteral() { + public EC2ContextBuilder(String providerName, Properties props) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, props); } @@ -60,8 +59,8 @@ public class EC2ContextBuilder extends } @Override - protected void addContextModule(List modules) { - modules.add(new EC2ComputeServiceContextModule()); + protected void addContextModule(String providerName, List modules) { + modules.add(new EC2ComputeServiceContextModule(providerName)); } @Override @@ -69,8 +68,8 @@ public class EC2ContextBuilder extends modules.add(new EC2RestClientModule()); } - @Override - protected void addImageResolutionModule() { - modules.add(new EC2ResolveImagesModule()); - } + @Override + protected void addImageResolutionModule() { + modules.add(new EC2ResolveImagesModule()); + } } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/EC2ContextFactory.java b/aws/core/src/main/java/org/jclouds/aws/ec2/EC2ContextFactory.java index 820baedabe..bb0729b626 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/EC2ContextFactory.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/EC2ContextFactory.java @@ -42,26 +42,26 @@ import com.google.inject.Module; */ public class EC2ContextFactory { public static ComputeServiceContext createContext(Properties properties, Module... modules) { - return new EC2ContextBuilder(new EC2PropertiesBuilder(properties).build()) + return new EC2ContextBuilder("ec2", new EC2PropertiesBuilder(properties).build()) .withModules(modules).buildComputeServiceContext(); } public static ComputeServiceContext createContext(String awsAccessKeyId, String awsSecretAccessKey, Module... modules) { - return new EC2ContextBuilder(new EC2PropertiesBuilder(awsAccessKeyId, + return new EC2ContextBuilder("ec2", new EC2PropertiesBuilder(awsAccessKeyId, awsSecretAccessKey).build()).withModules(modules).buildComputeServiceContext(); } public static ComputeServiceContext createContext(Properties properties, String awsAccessKeyId, String awsSecretAccessKey, Module... modules) { - return new EC2ContextBuilder(new EC2PropertiesBuilder(properties) - .withCredentials(awsAccessKeyId, awsSecretAccessKey).build()).withModules(modules) + return new EC2ContextBuilder("ec2", new EC2PropertiesBuilder(properties).withCredentials( + awsAccessKeyId, awsSecretAccessKey).build()).withModules(modules) .buildComputeServiceContext(); } public static ComputeServiceContext createContext(URI endpoint, String awsAccessKeyId, String awsSecretAccessKey, Module... modules) { - return new EC2ContextBuilder(new EC2PropertiesBuilder(awsAccessKeyId, + return new EC2ContextBuilder("ec2", new EC2PropertiesBuilder(awsAccessKeyId, awsSecretAccessKey).withEndpoint(endpoint).build()).withModules(modules) .buildComputeServiceContext(); } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/EC2ComputeService.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/EC2ComputeService.java index ea2962d7c9..0d3e44b954 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/EC2ComputeService.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/EC2ComputeService.java @@ -27,7 +27,6 @@ import javax.inject.Provider; import javax.inject.Singleton; import org.jclouds.Constants; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.EC2Client; import org.jclouds.aws.ec2.compute.config.EC2ComputeServiceContextModule.GetRegionFromNodeOrDefault; import org.jclouds.aws.ec2.compute.domain.PortsRegionTag; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java index 471556fc88..78610c2b59 100755 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java @@ -99,6 +99,12 @@ import com.google.inject.TypeLiteral; */ public class EC2ComputeServiceContextModule extends EC2ContextModule { + private final String providerName; + + public EC2ComputeServiceContextModule(String providerName) { + this.providerName = providerName; + } + @Override protected void configure() { super.configure(); @@ -146,8 +152,8 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule { public static class GetRegionFromNodeOrDefault implements Function { public String apply(ComputeMetadata node) { Location location = node.getLocation(); - String region = location.getScope() == LocationScope.REGION ? location - .getId() : location.getParent(); + String region = location.getScope() == LocationScope.REGION ? location.getId() : location + .getParent().getId(); return region; } } @@ -257,14 +263,15 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule { @Provides @Singleton Map provideLocations(Map availabilityZoneToRegionMap) { + Location ec2 = new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null); Map locations = Maps.newLinkedHashMap(); - for (String zone : availabilityZoneToRegionMap.keySet()) { - locations.put(zone, new LocationImpl(LocationScope.ZONE, zone, zone, - availabilityZoneToRegionMap.get(zone))); - } for (String region : availabilityZoneToRegionMap.values()) { - locations.put(region, new LocationImpl(LocationScope.REGION, region, - region, null)); + locations.put(region, new LocationImpl(LocationScope.REGION, region, region, ec2)); + } + + for (String zone : availabilityZoneToRegionMap.keySet()) { + locations.put(zone, new LocationImpl(LocationScope.ZONE, zone, zone, locations + .get(availabilityZoneToRegionMap.get(zone)))); } return locations; } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/CreateNewKeyPair.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/CreateNewKeyPair.java index a5a6979e15..790344ece1 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/CreateNewKeyPair.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/CreateNewKeyPair.java @@ -29,7 +29,6 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.aws.AWSResponseException; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.EC2Client; import org.jclouds.aws.ec2.compute.domain.RegionTag; import org.jclouds.aws.ec2.domain.KeyPair; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/CreateSecurityGroupIfNeeded.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/CreateSecurityGroupIfNeeded.java index 2978d49577..34c6728fef 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/CreateSecurityGroupIfNeeded.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/CreateSecurityGroupIfNeeded.java @@ -8,7 +8,6 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.aws.AWSResponseException; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.EC2Client; import org.jclouds.aws.ec2.compute.domain.PortsRegionTag; import org.jclouds.aws.ec2.domain.IpProtocol; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2DestroyNodeStrategy.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2DestroyNodeStrategy.java index 02161ad709..a11d7f16fc 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2DestroyNodeStrategy.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2DestroyNodeStrategy.java @@ -24,7 +24,6 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.EC2Client; import org.jclouds.aws.ec2.compute.config.EC2ComputeServiceContextModule.GetRegionFromNodeOrDefault; import org.jclouds.aws.ec2.domain.RunningInstance; diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategy.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategy.java index c3b0f5cd9a..4a7a497ab3 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategy.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategy.java @@ -125,7 +125,7 @@ public class EC2RunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrate // if the location has a parent, it must be an availability zone. String region = zone == null ? template.getLocation().getId() : - template.getLocation().getParent(); + template.getLocation().getParent().getId(); // get or create incidental resources // TODO race condition. we were using MapMaker, but it doesn't seem to refresh properly when diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Attachment.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Attachment.java index eeb3e98a68..7d0e1bed43 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Attachment.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/Attachment.java @@ -22,8 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Date; -import org.jclouds.aws.domain.Region; - /** * * @see { - public S3ContextBuilder(Properties props) { - super(new TypeLiteral() { + public S3ContextBuilder(String providerName, Properties props) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, props); } @Override - protected void addContextModule(List modules) { - modules.add(new S3BlobStoreContextModule()); + protected void addContextModule(String providerName,List modules) { + modules.add(new S3BlobStoreContextModule(providerName)); } @Override diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/S3ContextFactory.java b/aws/core/src/main/java/org/jclouds/aws/s3/S3ContextFactory.java index e573d47137..ec023a3a62 100755 --- a/aws/core/src/main/java/org/jclouds/aws/s3/S3ContextFactory.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/S3ContextFactory.java @@ -41,27 +41,27 @@ import com.google.inject.Module; */ public class S3ContextFactory { - public static BlobStoreContext createContext(Properties properties, - Module... modules) { - return new S3ContextBuilder(new S3PropertiesBuilder(properties).build()).withModules(modules) + public static BlobStoreContext createContext(Properties properties, Module... modules) { + return new S3ContextBuilder("s3", new S3PropertiesBuilder(properties).build()).withModules( + modules).buildBlobStoreContext(); + } + + public static BlobStoreContext createContext(Properties properties, String awsAccessKeyId, + String awsSecretAccessKey, Module... modules) { + return new S3ContextBuilder("s3", new S3PropertiesBuilder(properties).withCredentials( + awsAccessKeyId, awsSecretAccessKey).build()).withModules(modules) .buildBlobStoreContext(); } - public static BlobStoreContext createContext(Properties properties, - String awsAccessKeyId, String awsSecretAccessKey, Module... modules) { - return new S3ContextBuilder(new S3PropertiesBuilder(properties).withCredentials( - awsAccessKeyId, awsSecretAccessKey).build()).withModules(modules).buildBlobStoreContext(); - } - - public static BlobStoreContext createContext(String awsAccessKeyId, - String awsSecretAccessKey, Module... modules) { - return new S3ContextBuilder(new S3PropertiesBuilder(awsAccessKeyId, awsSecretAccessKey) + public static BlobStoreContext createContext(String awsAccessKeyId, String awsSecretAccessKey, + Module... modules) { + return new S3ContextBuilder("s3", new S3PropertiesBuilder(awsAccessKeyId, awsSecretAccessKey) .build()).withModules(modules).buildBlobStoreContext(); } - public static BlobStoreContext createContext(URI endpoint, - String awsAccessKeyId, String awsSecretAccessKey, Module... modules) { - return new S3ContextBuilder(new S3PropertiesBuilder(awsAccessKeyId, awsSecretAccessKey) + public static BlobStoreContext createContext(URI endpoint, String awsAccessKeyId, + String awsSecretAccessKey, Module... modules) { + return new S3ContextBuilder("s3", new S3PropertiesBuilder(awsAccessKeyId, awsSecretAccessKey) .withEndpoint(endpoint).build()).withModules(modules).buildBlobStoreContext(); } } diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/config/S3BlobStoreContextModule.java b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/config/S3BlobStoreContextModule.java index af386549ca..36a074ccd8 100755 --- a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/config/S3BlobStoreContextModule.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/config/S3BlobStoreContextModule.java @@ -23,7 +23,6 @@ import java.util.Set; import javax.inject.Singleton; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.s3.S3; import org.jclouds.aws.s3.S3AsyncClient; import org.jclouds.aws.s3.S3Client; @@ -53,6 +52,11 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ public class S3BlobStoreContextModule extends S3ContextModule { + private final String providerName; + + public S3BlobStoreContextModule(String providerName) { + this.providerName = providerName; + } @Override protected void configure() { @@ -76,9 +80,10 @@ public class S3BlobStoreContextModule extends S3ContextModule { @Singleton Map provideLocations(@S3 Set regions) { Set locations = Sets.newHashSet(); + Location s3 = new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null); for (String zone : regions) { locations - .add(new LocationImpl(LocationScope.ZONE, zone.toString(), zone.toString(), null)); + .add(new LocationImpl(LocationScope.REGION, zone.toString(), zone.toString(), s3)); } return Maps.uniqueIndex(locations, new Function() { @Override diff --git a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/BucketToResourceMetadata.java b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/BucketToResourceMetadata.java index c1d49ba685..9f19f68fca 100644 --- a/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/BucketToResourceMetadata.java +++ b/aws/core/src/main/java/org/jclouds/aws/s3/blobstore/functions/BucketToResourceMetadata.java @@ -24,7 +24,6 @@ import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.s3.S3Client; import org.jclouds.aws.s3.domain.BucketMetadata; import org.jclouds.blobstore.ContainerNotFoundException; diff --git a/aws/core/src/main/java/org/jclouds/aws/sqs/SQSAsyncClient.java b/aws/core/src/main/java/org/jclouds/aws/sqs/SQSAsyncClient.java index bf1efa99ee..7d2afec7ef 100644 --- a/aws/core/src/main/java/org/jclouds/aws/sqs/SQSAsyncClient.java +++ b/aws/core/src/main/java/org/jclouds/aws/sqs/SQSAsyncClient.java @@ -28,7 +28,6 @@ import javax.ws.rs.FormParam; import javax.ws.rs.POST; import javax.ws.rs.Path; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.filters.FormSigner; import org.jclouds.aws.sqs.domain.Queue; import org.jclouds.aws.sqs.functions.QueueLocation; diff --git a/aws/core/src/main/java/org/jclouds/aws/sqs/SQSClient.java b/aws/core/src/main/java/org/jclouds/aws/sqs/SQSClient.java index 05d883aa4a..789436f642 100644 --- a/aws/core/src/main/java/org/jclouds/aws/sqs/SQSClient.java +++ b/aws/core/src/main/java/org/jclouds/aws/sqs/SQSClient.java @@ -23,7 +23,6 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.sqs.domain.Queue; import org.jclouds.aws.sqs.options.CreateQueueOptions; import org.jclouds.aws.sqs.options.ListQueuesOptions; diff --git a/aws/core/src/main/java/org/jclouds/aws/sqs/SQSContextBuilder.java b/aws/core/src/main/java/org/jclouds/aws/sqs/SQSContextBuilder.java index 0f2b617e5e..5b5b924348 100755 --- a/aws/core/src/main/java/org/jclouds/aws/sqs/SQSContextBuilder.java +++ b/aws/core/src/main/java/org/jclouds/aws/sqs/SQSContextBuilder.java @@ -46,15 +46,15 @@ import com.google.inject.TypeLiteral; */ public class SQSContextBuilder extends RestContextBuilder { - public SQSContextBuilder(Properties props) { - super(new TypeLiteral() { + public SQSContextBuilder(String providerName, Properties props) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, props); } @Override - protected void addContextModule(List modules) { - modules.add(new SQSContextModule()); + protected void addContextModule(String providerName, List modules) { + modules.add(new SQSContextModule(providerName)); } @Override diff --git a/aws/core/src/main/java/org/jclouds/aws/sqs/SQSContextFactory.java b/aws/core/src/main/java/org/jclouds/aws/sqs/SQSContextFactory.java index c9c3f4aec7..fc2c746296 100755 --- a/aws/core/src/main/java/org/jclouds/aws/sqs/SQSContextFactory.java +++ b/aws/core/src/main/java/org/jclouds/aws/sqs/SQSContextFactory.java @@ -43,25 +43,26 @@ public class SQSContextFactory { public static RestContext createContext(Properties properties, Module... modules) { - return new SQSContextBuilder(new SQSPropertiesBuilder(properties).build()).withModules( - modules).buildContext(); + return new SQSContextBuilder("sqs", new SQSPropertiesBuilder(properties).build()) + .withModules(modules).buildContext(); } - public static RestContext createContext(Properties properties, String awsAccessKeyId, - String awsSecretAccessKey, Module... modules) { - return new SQSContextBuilder(new SQSPropertiesBuilder(properties).withCredentials(awsAccessKeyId, awsSecretAccessKey) - .build()).withModules(modules).buildContext(); + public static RestContext createContext(Properties properties, + String awsAccessKeyId, String awsSecretAccessKey, Module... modules) { + return new SQSContextBuilder("sqs", new SQSPropertiesBuilder(properties).withCredentials( + awsAccessKeyId, awsSecretAccessKey).build()).withModules(modules).buildContext(); } - + public static RestContext createContext(String awsAccessKeyId, String awsSecretAccessKey, Module... modules) { - return new SQSContextBuilder(new SQSPropertiesBuilder(awsAccessKeyId, awsSecretAccessKey) - .build()).withModules(modules).buildContext(); + return new SQSContextBuilder("sqs", new SQSPropertiesBuilder(awsAccessKeyId, + awsSecretAccessKey).build()).withModules(modules).buildContext(); } public static RestContext createContext(URI endpoint, String awsAccessKeyId, String awsSecretAccessKey, Module... modules) { - return new SQSContextBuilder(new SQSPropertiesBuilder(awsAccessKeyId, awsSecretAccessKey) - .withEndpoint(endpoint).build()).withModules(modules).buildContext(); + return new SQSContextBuilder("sqs", new SQSPropertiesBuilder(awsAccessKeyId, + awsSecretAccessKey).withEndpoint(endpoint).build()).withModules(modules) + .buildContext(); } } diff --git a/aws/core/src/main/java/org/jclouds/aws/sqs/config/SQSContextModule.java b/aws/core/src/main/java/org/jclouds/aws/sqs/config/SQSContextModule.java index 0a5abc9f6b..a1a05869d2 100644 --- a/aws/core/src/main/java/org/jclouds/aws/sqs/config/SQSContextModule.java +++ b/aws/core/src/main/java/org/jclouds/aws/sqs/config/SQSContextModule.java @@ -42,6 +42,9 @@ import com.google.inject.Provides; * @author Adrian Cole */ public class SQSContextModule extends AbstractModule { + public SQSContextModule(String providerName) { + } + @Override protected void configure() { bind(DateAdapter.class).to(CDateAdapter.class); diff --git a/aws/core/src/main/java/org/jclouds/aws/sqs/domain/Queue.java b/aws/core/src/main/java/org/jclouds/aws/sqs/domain/Queue.java index b86573040d..7b98d69fed 100644 --- a/aws/core/src/main/java/org/jclouds/aws/sqs/domain/Queue.java +++ b/aws/core/src/main/java/org/jclouds/aws/sqs/domain/Queue.java @@ -22,8 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; -import org.jclouds.aws.domain.Region; - /** * * @see (new InstanceStateRunning(client @@ -111,13 +112,12 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest { securityGroupName = instancePrefix + "ingress"; try { - client.getSecurityGroupServices().deleteSecurityGroupInRegion(null, - securityGroupName); + client.getSecurityGroupServices().deleteSecurityGroupInRegion(null, securityGroupName); } catch (Exception e) { } - client.getSecurityGroupServices().createSecurityGroupInRegion(null, - securityGroupName, securityGroupName); + client.getSecurityGroupServices().createSecurityGroupInRegion(null, securityGroupName, + securityGroupName); for (int port : new int[] { 80, 443, 22 }) { client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(null, securityGroupName, IpProtocol.TCP, port, port, "0.0.0.0/0"); @@ -154,8 +154,13 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest { try { System.out.printf("%d: running instance%n", System.currentTimeMillis()); - Reservation reservation = client.getInstanceServices().runInstancesInRegion( - null, null, // allow ec2 to chose an availability zone + Reservation reservation = client.getInstanceServices().runInstancesInRegion(null, null, // allow + // ec2 + // to + // chose + // an + // availability + // zone "ami-ccf615a5", // alestic ami allows auto-invoke of user data scripts 1, // minimum instances 1, // maximum instances @@ -185,11 +190,11 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest { } private void verifyInstanceProperties(String script) { - assertEquals(script, client.getInstanceServices().getUserDataForInstanceInRegion( - null, instanceId)); + assertEquals(script, client.getInstanceServices().getUserDataForInstanceInRegion(null, + instanceId)); - assertEquals(null, client.getInstanceServices().getRootDeviceNameForInstanceInRegion( - null, instanceId)); + assertEquals(null, client.getInstanceServices().getRootDeviceNameForInstanceInRegion(null, + instanceId)); assert client.getInstanceServices().getRamdiskForInstanceInRegion(null, instanceId) .startsWith("ari-"); @@ -211,12 +216,12 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest { } private void setApiTerminationDisabledForInstanceInRegion() { - client.getInstanceServices().setApiTerminationDisabledForInstanceInRegion(null, - instanceId, true); + client.getInstanceServices().setApiTerminationDisabledForInstanceInRegion(null, instanceId, + true); assertEquals(true, client.getInstanceServices().isApiTerminationDisabledForInstanceInRegion( null, instanceId)); - client.getInstanceServices().setApiTerminationDisabledForInstanceInRegion(null, - instanceId, false); + client.getInstanceServices().setApiTerminationDisabledForInstanceInRegion(null, instanceId, + false); assertEquals(false, client.getInstanceServices().isApiTerminationDisabledForInstanceInRegion( null, instanceId)); } @@ -243,10 +248,9 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest { private void setRamdiskForInstanceInRegion() { try { - String ramdisk = client.getInstanceServices().getRamdiskForInstanceInRegion( - null, instanceId); - client.getInstanceServices().setRamdiskForInstanceInRegion(null, instanceId, - ramdisk); + String ramdisk = client.getInstanceServices().getRamdiskForInstanceInRegion(null, + instanceId); + client.getInstanceServices().setRamdiskForInstanceInRegion(null, instanceId, ramdisk); assert false : "shouldn't be allowed, as instance needs to be stopped"; } catch (AWSResponseException e) { assertEquals("IncorrectInstanceState", e.getError().getCode()); @@ -255,10 +259,9 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest { private void setKernelForInstanceInRegion() { try { - String oldKernel = client.getInstanceServices().getKernelForInstanceInRegion( - null, instanceId); - client.getInstanceServices().setKernelForInstanceInRegion(null, instanceId, - oldKernel); + String oldKernel = client.getInstanceServices().getKernelForInstanceInRegion(null, + instanceId); + client.getInstanceServices().setKernelForInstanceInRegion(null, instanceId, oldKernel); assert false : "shouldn't be allowed, as instance needs to be stopped"; } catch (AWSResponseException e) { assertEquals("IncorrectInstanceState", e.getError().getCode()); @@ -267,8 +270,8 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest { private void setInstanceTypeForInstanceInRegion() { try { - client.getInstanceServices().setInstanceTypeForInstanceInRegion(null, - instanceId, InstanceType.C1_MEDIUM); + client.getInstanceServices().setInstanceTypeForInstanceInRegion(null, instanceId, + InstanceType.C1_MEDIUM); assert false : "shouldn't be allowed, as instance needs to be stopped"; } catch (AWSResponseException e) { assertEquals("IncorrectInstanceState", e.getError().getCode()); @@ -278,8 +281,8 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest { private void setBlockDeviceMappingForInstanceInRegion() { BlockDeviceMapping blockDeviceMapping = new BlockDeviceMapping(); try { - client.getInstanceServices().setBlockDeviceMappingForInstanceInRegion(null, - instanceId, blockDeviceMapping); + client.getInstanceServices().setBlockDeviceMappingForInstanceInRegion(null, instanceId, + blockDeviceMapping); assert false : "shouldn't be allowed, as instance needs to be ebs based-ami"; } catch (AWSResponseException e) { assertEquals("InvalidParameterCombination", e.getError().getCode()); @@ -288,8 +291,8 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest { private void setInstanceInitiatedShutdownBehaviorForInstanceInRegion() { try { - client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion( - null, instanceId, InstanceInitiatedShutdownBehavior.STOP); + client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, + instanceId, InstanceInitiatedShutdownBehavior.STOP); assert false : "shouldn't be allowed, as instance needs to be ebs based-ami"; } catch (AWSResponseException e) { assertEquals("UnsupportedInstanceAttribute", e.getError().getCode()); @@ -328,8 +331,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest { assertEquals(compare.getPublicIp(), address); assert compare.getInstanceId() == null; - client.getElasticIPAddressServices().associateAddressInRegion(null, address, - instanceId); + client.getElasticIPAddressServices().associateAddressInRegion(null, address, instanceId); compare = Iterables.getLast(client.getElasticIPAddressServices().describeAddressesInRegion( null, address)); @@ -390,8 +392,8 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest { private RunningInstance getInstance(String instanceId) { // search my account for the instance I just created - Set reservations = client.getInstanceServices().describeInstancesInRegion( - null, instanceId); // last parameter (ids) narrows the search + Set reservations = client.getInstanceServices().describeInstancesInRegion(null, + instanceId); // last parameter (ids) narrows the search return Iterables.getOnlyElement(Iterables.getOnlyElement(reservations)); } @@ -439,8 +441,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest { if (keyPair != null) client.getKeyPairServices().deleteKeyPairInRegion(null, keyPair.getKeyName()); if (securityGroupName != null) - client.getSecurityGroupServices().deleteSecurityGroupInRegion(null, - securityGroupName); + client.getSecurityGroupServices().deleteSecurityGroupInRegion(null, securityGroupName); } } diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/EBSBootEC2ClientLiveTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/EBSBootEC2ClientLiveTest.java index df66858904..d9ec7922d9 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/EBSBootEC2ClientLiveTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/EBSBootEC2ClientLiveTest.java @@ -82,9 +82,9 @@ import com.google.inject.internal.ImmutableMap; * Adapted from the following sources: {@link http://gist.github.com/249915}, {@link http * ://www.capsunlock.net/2009/12/create-ebs-boot-ami.html} *

- * + * * Generally disabled, as it incurs higher fees. - * + * * @author Adrian Cole */ @Test(groups = "live", enabled = false, sequential = true, testName = "ec2.EBSBootEC2ClientLiveTest") @@ -120,8 +120,9 @@ public class EBSBootEC2ClientLiveTest { public void setupClient() { String user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); - Injector injector = new EC2ContextBuilder(new EC2PropertiesBuilder(user, password).build()) - .withModules(new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); + Injector injector = new EC2ContextBuilder("ec2", new EC2PropertiesBuilder(user, password) + .build()).withModules(new Log4JLoggingModule(), new JschSshClientModule()) + .buildInjector(); client = injector.getInstance(EC2Client.class); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); @@ -157,13 +158,12 @@ public class EBSBootEC2ClientLiveTest { securityGroupName = INSTANCE_PREFIX + "ingress"; try { - client.getSecurityGroupServices().deleteSecurityGroupInRegion(null, - securityGroupName); + client.getSecurityGroupServices().deleteSecurityGroupInRegion(null, securityGroupName); } catch (Exception e) { } - client.getSecurityGroupServices().createSecurityGroupInRegion(null, - securityGroupName, securityGroupName); + client.getSecurityGroupServices().createSecurityGroupInRegion(null, securityGroupName, + securityGroupName); client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(null, securityGroupName, IpProtocol.TCP, 80, 80, "0.0.0.0/0"); client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(null, @@ -199,8 +199,13 @@ public class EBSBootEC2ClientLiveTest { while (instance == null) { try { System.out.printf("%d: running instance%n", System.currentTimeMillis()); - Reservation reservation = client.getInstanceServices().runInstancesInRegion( - null, null, // allow ec2 to chose an availability zone + Reservation reservation = client.getInstanceServices().runInstancesInRegion(null, null, // allow + // ec2 + // to + // chose + // an + // availability + // zone imageId, 1, // minimum instances 1, // maximum instances withKeyName(keyPair.getKeyName())// key I created above @@ -422,37 +427,37 @@ public class EBSBootEC2ClientLiveTest { } private void setUserDataForInstanceInRegion() { - client.getInstanceServices().setUserDataForInstanceInRegion(null, - ebsInstance.getId(), "test".getBytes()); - assertEquals("test", client.getInstanceServices().getUserDataForInstanceInRegion( - null, ebsInstance.getId())); + client.getInstanceServices().setUserDataForInstanceInRegion(null, ebsInstance.getId(), + "test".getBytes()); + assertEquals("test", client.getInstanceServices().getUserDataForInstanceInRegion(null, + ebsInstance.getId())); } private void setRamdiskForInstanceInRegion() { String ramdisk = client.getInstanceServices().getRamdiskForInstanceInRegion(null, ebsInstance.getId()); - client.getInstanceServices().setRamdiskForInstanceInRegion(null, - ebsInstance.getId(), ramdisk); - assertEquals(ramdisk, client.getInstanceServices().getRamdiskForInstanceInRegion( - null, ebsInstance.getId())); + client.getInstanceServices() + .setRamdiskForInstanceInRegion(null, ebsInstance.getId(), ramdisk); + assertEquals(ramdisk, client.getInstanceServices().getRamdiskForInstanceInRegion(null, + ebsInstance.getId())); } private void setKernelForInstanceInRegion() { String oldKernel = client.getInstanceServices().getKernelForInstanceInRegion(null, ebsInstance.getId()); - client.getInstanceServices().setKernelForInstanceInRegion(null, - ebsInstance.getId(), oldKernel); - assertEquals(oldKernel, client.getInstanceServices().getKernelForInstanceInRegion( - null, ebsInstance.getId())); + client.getInstanceServices().setKernelForInstanceInRegion(null, ebsInstance.getId(), + oldKernel); + assertEquals(oldKernel, client.getInstanceServices().getKernelForInstanceInRegion(null, + ebsInstance.getId())); } private void setInstanceTypeForInstanceInRegion() { - client.getInstanceServices().setInstanceTypeForInstanceInRegion(null, - ebsInstance.getId(), InstanceType.C1_MEDIUM); + client.getInstanceServices().setInstanceTypeForInstanceInRegion(null, ebsInstance.getId(), + InstanceType.C1_MEDIUM); assertEquals(InstanceType.C1_MEDIUM, client.getInstanceServices() .getInstanceTypeForInstanceInRegion(null, ebsInstance.getId())); - client.getInstanceServices().setInstanceTypeForInstanceInRegion(null, - ebsInstance.getId(), InstanceType.M1_SMALL); + client.getInstanceServices().setInstanceTypeForInstanceInRegion(null, ebsInstance.getId(), + InstanceType.M1_SMALL); assertEquals(InstanceType.M1_SMALL, client.getInstanceServices() .getInstanceTypeForInstanceInRegion(null, ebsInstance.getId())); } @@ -461,22 +466,21 @@ public class EBSBootEC2ClientLiveTest { String volumeId = ebsInstance.getEbsBlockDevices().get("/dev/sda1").getVolumeId(); BlockDeviceMapping blockDeviceMapping = new BlockDeviceMapping(); - blockDeviceMapping.addEbsBlockDevice - ("/dev/sda1", new RunningInstance.EbsBlockDevice(volumeId, false)); + blockDeviceMapping.addEbsBlockDevice("/dev/sda1", new RunningInstance.EbsBlockDevice( + volumeId, false)); try { client.getInstanceServices().setBlockDeviceMappingForInstanceInRegion(null, ebsInstance.getId(), blockDeviceMapping); - Map devices = client - .getInstanceServices().getBlockDeviceMappingForInstanceInRegion(null, - ebsInstance.getId()); - assertEquals(devices.size(), 1); - String deviceName = Iterables.getOnlyElement(devices.keySet()); - RunningInstance.EbsBlockDevice device = Iterables.getOnlyElement(devices.values()); + Map devices = client.getInstanceServices() + .getBlockDeviceMappingForInstanceInRegion(null, ebsInstance.getId()); + assertEquals(devices.size(), 1); + String deviceName = Iterables.getOnlyElement(devices.keySet()); + RunningInstance.EbsBlockDevice device = Iterables.getOnlyElement(devices.values()); - assertEquals(device.getVolumeId(), volumeId); - assertEquals(deviceName, "/dev/sda1"); - assertEquals(device.isDeleteOnTermination(), false); + assertEquals(device.getVolumeId(), volumeId); + assertEquals(deviceName, "/dev/sda1"); + assertEquals(device.isDeleteOnTermination(), false); System.out.println("OK: setBlockDeviceMappingForInstanceInRegion"); } catch (Exception e) { @@ -489,14 +493,14 @@ public class EBSBootEC2ClientLiveTest { private void setInstanceInitiatedShutdownBehaviorForInstanceInRegion() { try { - client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion( - null, ebsInstance.getId(), InstanceInitiatedShutdownBehavior.STOP); + client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, + ebsInstance.getId(), InstanceInitiatedShutdownBehavior.STOP); assertEquals(InstanceInitiatedShutdownBehavior.STOP, client.getInstanceServices() .getInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, ebsInstance.getId())); - client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion( - null, ebsInstance.getId(), InstanceInitiatedShutdownBehavior.TERMINATE); + client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, + ebsInstance.getId(), InstanceInitiatedShutdownBehavior.TERMINATE); assertEquals(InstanceInitiatedShutdownBehavior.TERMINATE, client.getInstanceServices() .getInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, @@ -510,7 +514,7 @@ public class EBSBootEC2ClientLiveTest { /** * this tests "personality" as the file looked up was sent during instance creation - * + * * @throws UnknownHostException */ private void sshPing(RunningInstance newDetails) throws UnknownHostException { @@ -628,8 +632,7 @@ public class EBSBootEC2ClientLiveTest { } if (securityGroupName != null) { try { - client.getSecurityGroupServices().deleteSecurityGroupInRegion(null, - securityGroupName); + client.getSecurityGroupServices().deleteSecurityGroupInRegion(null, securityGroupName); } catch (Exception e) { e.printStackTrace(); } diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/services/MonitoringAsyncClientTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/services/MonitoringAsyncClientTest.java index 8330306d45..8ceafc5519 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/services/MonitoringAsyncClientTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/services/MonitoringAsyncClientTest.java @@ -22,7 +22,6 @@ import java.io.IOException; import java.lang.reflect.Array; import java.lang.reflect.Method; -import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.xml.MonitoringStateHandler; import org.jclouds.http.functions.ParseSax; import org.jclouds.rest.internal.GeneratedHttpRequest; diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextBuilder.java b/azure/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextBuilder.java index 29afd30272..b850631d9a 100755 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextBuilder.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextBuilder.java @@ -47,14 +47,14 @@ import com.google.inject.TypeLiteral; public class AzureBlobContextBuilder extends BlobStoreContextBuilder { - public AzureBlobContextBuilder(Properties props) { - super(new TypeLiteral() { + public AzureBlobContextBuilder(String providerName, Properties props) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, props); } @Override - protected void addContextModule(List modules) { + protected void addContextModule(String providerName, List modules) { modules.add(new AzureBlobStoreContextModule()); } diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextFactory.java b/azure/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextFactory.java index 6d5a00a9d6..e71fe5e2b9 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextFactory.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/AzureBlobContextFactory.java @@ -41,18 +41,19 @@ import com.google.inject.Module; */ public class AzureBlobContextFactory { public static BlobStoreContext createContext(Properties properties, Module... modules) { - return new AzureBlobContextBuilder(new AzureBlobPropertiesBuilder(properties).build()) - .withModules(modules).buildBlobStoreContext(); + return new AzureBlobContextBuilder("azureblob", new AzureBlobPropertiesBuilder(properties) + .build()).withModules(modules).buildBlobStoreContext(); } public static BlobStoreContext createContext(String user, String encodedKey, Module... modules) { - return new AzureBlobContextBuilder(new AzureBlobPropertiesBuilder(user, encodedKey) - .build()).withModules(modules).buildBlobStoreContext(); + return new AzureBlobContextBuilder("azureblob", new AzureBlobPropertiesBuilder(user, + encodedKey).build()).withModules(modules).buildBlobStoreContext(); } public static BlobStoreContext createContext(URI endpoint, String user, String encodedKey, Module... modules) { - return new AzureBlobContextBuilder(new AzureBlobPropertiesBuilder(user, encodedKey) - .withEndpoint(endpoint).build()).withModules(modules).buildBlobStoreContext(); + return new AzureBlobContextBuilder("azureblob", new AzureBlobPropertiesBuilder(user, + encodedKey).withEndpoint(endpoint).build()).withModules(modules) + .buildBlobStoreContext(); } } diff --git a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/config/AzureBlobStoreContextModule.java b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/config/AzureBlobStoreContextModule.java index def0ca8288..468d641c73 100755 --- a/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/config/AzureBlobStoreContextModule.java +++ b/azure/src/main/java/org/jclouds/azure/storage/blob/blobstore/config/AzureBlobStoreContextModule.java @@ -67,7 +67,7 @@ public class AzureBlobStoreContextModule extends AzureBlobContextModule { @Provides @Singleton Location getLocation() { - return new LocationImpl(LocationScope.ZONE, "UNKNOWN", "TODO", null); + return new LocationImpl(LocationScope.PROVIDER, "azureblob", "azureblob", null); } @Provides diff --git a/azure/src/main/java/org/jclouds/azure/storage/queue/AzureQueueContextBuilder.java b/azure/src/main/java/org/jclouds/azure/storage/queue/AzureQueueContextBuilder.java index 3688f42a78..9b762e9df3 100755 --- a/azure/src/main/java/org/jclouds/azure/storage/queue/AzureQueueContextBuilder.java +++ b/azure/src/main/java/org/jclouds/azure/storage/queue/AzureQueueContextBuilder.java @@ -47,15 +47,15 @@ import com.google.inject.TypeLiteral; public class AzureQueueContextBuilder extends RestContextBuilder { - public AzureQueueContextBuilder(Properties properties) { - super(new TypeLiteral() { + public AzureQueueContextBuilder(String providerName, Properties properties) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, properties); } @Override - protected void addContextModule(List modules) { - modules.add(new AzureQueueContextModule()); + protected void addContextModule(String providerName, List modules) { + modules.add(new AzureQueueContextModule(providerName)); } @Override diff --git a/azure/src/main/java/org/jclouds/azure/storage/queue/AzureQueueContextFactory.java b/azure/src/main/java/org/jclouds/azure/storage/queue/AzureQueueContextFactory.java index 9a09f52c1d..30d2846b24 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/queue/AzureQueueContextFactory.java +++ b/azure/src/main/java/org/jclouds/azure/storage/queue/AzureQueueContextFactory.java @@ -43,25 +43,25 @@ public class AzureQueueContextFactory { public static RestContext createContext( Properties properties, Module... modules) { - return new AzureQueueContextBuilder(new AzureQueuePropertiesBuilder(properties).build()) - .withModules(modules).buildContext(); + return new AzureQueueContextBuilder("azurequeue", new AzureQueuePropertiesBuilder(properties) + .build()).withModules(modules).buildContext(); } public static RestContext createContext( Properties properties, String account, String encodedKey, Module... modules) { - return new AzureQueueContextBuilder(new AzureQueuePropertiesBuilder(properties) + return new AzureQueueContextBuilder("azurequeue", new AzureQueuePropertiesBuilder(properties) .withCredentials(account, encodedKey).build()).withModules(modules).buildContext(); } public static RestContext createContext(String account, String encodedKey, Module... modules) { - return new AzureQueueContextBuilder(new AzureQueuePropertiesBuilder(account, encodedKey) - .build()).withModules(modules).buildContext(); + return new AzureQueueContextBuilder("azurequeue", new AzureQueuePropertiesBuilder(account, + encodedKey).build()).withModules(modules).buildContext(); } public static RestContext createContext(URI endpoint, String account, String encodedKey, Module... modules) { - return new AzureQueueContextBuilder(new AzureQueuePropertiesBuilder(account, encodedKey) - .withEndpoint(endpoint).build()).withModules(modules).buildContext(); + return new AzureQueueContextBuilder("azurequeue", new AzureQueuePropertiesBuilder(account, + encodedKey).withEndpoint(endpoint).build()).withModules(modules).buildContext(); } } diff --git a/azure/src/main/java/org/jclouds/azure/storage/queue/config/AzureQueueContextModule.java b/azure/src/main/java/org/jclouds/azure/storage/queue/config/AzureQueueContextModule.java index 566bad6f6a..0a70ce85f6 100644 --- a/azure/src/main/java/org/jclouds/azure/storage/queue/config/AzureQueueContextModule.java +++ b/azure/src/main/java/org/jclouds/azure/storage/queue/config/AzureQueueContextModule.java @@ -38,6 +38,9 @@ import com.google.inject.Provides; @RequiresHttp public class AzureQueueContextModule extends AbstractModule { + public AzureQueueContextModule(String providerName) { + } + @Override protected void configure() { } diff --git a/azure/src/test/java/org/jclouds/azure/storage/queue/AzureQueueClientLiveTest.java b/azure/src/test/java/org/jclouds/azure/storage/queue/AzureQueueClientLiveTest.java index 4d166c3966..df1b7678cd 100644 --- a/azure/src/test/java/org/jclouds/azure/storage/queue/AzureQueueClientLiveTest.java +++ b/azure/src/test/java/org/jclouds/azure/storage/queue/AzureQueueClientLiveTest.java @@ -53,7 +53,7 @@ public class AzureQueueClientLiveTest { public void setupClient() { account = System.getProperty("jclouds.test.user"); String key = System.getProperty("jclouds.test.key"); - Injector injector = new AzureQueueContextBuilder( + Injector injector = new AzureQueueContextBuilder("azurequeue", new AzureQueuePropertiesBuilder(account, key).build()).withModules( new Log4JLoggingModule()).buildInjector(); connection = injector.getInstance(AzureQueueClient.class); @@ -104,13 +104,13 @@ public class AzureQueueClientLiveTest { assertEquals(privateQueue, response.getPrefix()); assertEquals(1, response.getMaxResults()); } + @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = { "testCreateQueue" }) public void testPutMessage() throws Exception { - connection.putMessage(privateQueue,"holycow",PutMessageOptions.Builder.withTTL(4)); + connection.putMessage(privateQueue, "holycow", PutMessageOptions.Builder.withTTL(4)); // TODO loop for up to 30 seconds checking if they are really gone } - - + @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = { "testPutMessage" }) public void testDeleteQueue() throws Exception { connection.clearMessages(privateQueue); diff --git a/blobstore/src/main/clojure/org/jclouds/blobstore.clj b/blobstore/src/main/clojure/org/jclouds/blobstore.clj index 99c5c2c94a..15cdfef206 100644 --- a/blobstore/src/main/clojure/org/jclouds/blobstore.clj +++ b/blobstore/src/main/clojure/org/jclouds/blobstore.clj @@ -135,7 +135,7 @@ Options can also be specified for extension modules "Retrieve the available container locations for the blobstore context." ([] (locations *blobstore*)) ([#^BlobStore blobstore] - (seq-from-immutable-set (.getLocations blobstore)))) + (seq-from-immutable-set (.getAssignableLocations blobstore)))) (defn create-container "Create a container." diff --git a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java index 3790a6a199..606241831e 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java @@ -49,9 +49,9 @@ public interface AsyncBlobStore { Blob newBlob(String name); /** - * @see BlobStore#getLocations + * @see BlobStore#getAssignableLocations */ - ListenableFuture> getLocations(); + ListenableFuture> getAssignableLocations(); /** * @see BlobStore#list diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java index 53d55b46f5..37bdd40cd1 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java @@ -55,7 +55,7 @@ public interface BlobStore { * similar to a datacenter. If a location has a parent, that implies it is within that location. * For example a location can be a rack, whose parent is likely to be a zone. */ - Map getLocations(); + Map getAssignableLocations(); /** * Lists all root-level resources available to the account. diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java index 42f737cccf..e83e30f7ff 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java @@ -35,13 +35,13 @@ public abstract class BlobStoreContextBuilder extends RestContextBuilder) super.withModules(modules); } - public BlobStoreContextBuilder(TypeLiteral asyncClientType, TypeLiteral syncClientType) { - this(asyncClientType, syncClientType, new Properties()); + public BlobStoreContextBuilder(String providerName,TypeLiteral asyncClientType, TypeLiteral syncClientType) { + this(providerName, asyncClientType, syncClientType, new Properties()); } - public BlobStoreContextBuilder(TypeLiteral asyncClientType, TypeLiteral syncClientType, + public BlobStoreContextBuilder(String providerName,TypeLiteral asyncClientType, TypeLiteral syncClientType, Properties properties) { - super(asyncClientType, syncClientType, properties); + super(providerName, asyncClientType, syncClientType, properties); } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java index 9f3b0f3cde..4d2fab4d9e 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java @@ -37,18 +37,18 @@ public class TransientBlobStoreContextBuilder extends * This is only to have the same syntax. * */ - public TransientBlobStoreContextBuilder(Properties props) { + public TransientBlobStoreContextBuilder(String providerName, Properties props) { this(); } public TransientBlobStoreContextBuilder() { - super(new TypeLiteral() { + super("transient", new TypeLiteral() { }, new TypeLiteral() { }); } @Override - public void addContextModule(List modules) { + public void addContextModule(String providerName, List modules) { modules.add(new TransientBlobStoreContextModule()); } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java index dd45cb28f8..3b32c82b2f 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java @@ -54,7 +54,7 @@ public class TransientBlobStoreContextModule extends AbstractModule { @Provides @Singleton Location provideDefaultLocation() { - return new LocationImpl(LocationScope.ZONE, "default", "description", null); + return new LocationImpl(LocationScope.PROVIDER, "transient", "transient", null); } @Provides diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java index e522c7dea0..23d3d56677 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java @@ -271,7 +271,7 @@ public abstract class BaseAsyncBlobStore implements AsyncBlobStore { } @Override - public ListenableFuture> getLocations() { + public ListenableFuture> getAssignableLocations() { return immediateFuture(locations); } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java index dcbee8955f..46c967ba15 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java @@ -213,7 +213,7 @@ public abstract class BaseBlobStore implements BlobStore { } @Override - public Map getLocations() { + public Map getAssignableLocations() { return locations; } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java index 2da053041c..d5a779339a 100755 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java @@ -18,12 +18,16 @@ */ package org.jclouds.blobstore.integration.internal; +import static org.testng.Assert.assertEquals; + import java.util.Set; +import java.util.Map.Entry; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.internal.MutableStorageMetadataImpl; import org.jclouds.domain.Location; +import org.jclouds.domain.LocationScope; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -43,11 +47,13 @@ public class BaseServiceIntegrationTest extends BaseBlobStoreIntegrationTest { @Test(groups = { "integration", "live" }) public void testAllLocations() throws InterruptedException { - for (final Location location : context.getBlobStore().getLocations().values()) { + for (final Location location : context.getBlobStore().getAssignableLocations().values()) { final String containerName = getScratchContainerName(); try { - + System.err.printf(" >> creating container in location %s%n", location); context.getBlobStore().createContainerInLocation(location, containerName); + System.err.printf(" << call complete.. checking%n"); + assertConsistencyAware(new Runnable() { @Override @@ -68,4 +74,44 @@ public class BaseServiceIntegrationTest extends BaseBlobStoreIntegrationTest { } } } + + @Test(groups = { "integration", "live" }) + public void testGetAssignableLocations() throws Exception { + for (Entry location : context.getBlobStore() + .getAssignableLocations().entrySet()) { + System.err.printf("location %s%n", location.getValue()); + assertEquals(location.getKey(), location.getValue().getId()); + assert location.getValue().getId() != null : location; + assert location.getValue() != location.getValue().getParent() : location; + assert location.getValue().getScope() != null : location; + switch (location.getValue().getScope()) { + case PROVIDER: + assertProvider(location.getValue()); + break; + case REGION: + assertProvider(location.getValue().getParent()); + break; + case ZONE: + Location provider = location.getValue().getParent().getParent(); + // zone can be a direct descendant of provider + if (provider == null) + provider = location.getValue().getParent(); + assertProvider(provider); + break; + case HOST: + Location provider2 = location.getValue().getParent().getParent().getParent(); + // zone can be a direct descendant of provider + if (provider2 == null) + provider2 = location.getValue().getParent().getParent(); + assertProvider(provider2); + break; + } + } + } + + public void assertProvider(Location provider) { + assertEquals(provider.getScope(), LocationScope.PROVIDER); + assertEquals(provider.getParent(), null); + } + } \ No newline at end of file diff --git a/compute/src/main/clojure/org/jclouds/compute.clj b/compute/src/main/clojure/org/jclouds/compute.clj index b99dea8d15..17b34cac2b 100644 --- a/compute/src/main/clojure/org/jclouds/compute.clj +++ b/compute/src/main/clojure/org/jclouds/compute.clj @@ -117,7 +117,7 @@ See http://code.google.com/p/jclouds for details." "Retrieve the available compute locations for the compute context." ([] (locations *compute*)) ([#^ComputeService compute] - (seq-from-immutable-set (.getLocations compute)))) + (seq-from-immutable-set (.getAssignableLocations compute)))) (defn nodes-with-tag [#^String tag #^ComputeService compute] diff --git a/compute/src/main/java/org/jclouds/compute/ComputeService.java b/compute/src/main/java/org/jclouds/compute/ComputeService.java index 0a89b1848b..34c474b7eb 100755 --- a/compute/src/main/java/org/jclouds/compute/ComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeService.java @@ -90,7 +90,7 @@ public interface ComputeService { * similar to a datacenter. If a location has a parent, that implies it is within that location. * For example a location can be a rack, whose parent is likely to be a zone. */ - Map getLocations(); + Map getAssignableLocations(); /** * diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java index 44e074aa18..0e60e4f797 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java @@ -37,13 +37,14 @@ import com.google.inject.util.Types; */ public abstract class ComputeServiceContextBuilder extends RestContextBuilder { - public ComputeServiceContextBuilder(TypeLiteral asyncClientType, TypeLiteral syncClientType) { - this(asyncClientType, syncClientType, new Properties()); + public ComputeServiceContextBuilder(String providerName, TypeLiteral asyncClientType, + TypeLiteral syncClientType) { + this(providerName, asyncClientType, syncClientType, new Properties()); } - public ComputeServiceContextBuilder(TypeLiteral asyncClientType, + public ComputeServiceContextBuilder(String providerName, TypeLiteral asyncClientType, TypeLiteral syncClientType, Properties properties) { - super(asyncClientType, syncClientType, properties); + super(providerName, asyncClientType, syncClientType, properties); } diff --git a/compute/src/main/java/org/jclouds/compute/domain/OsFamily.java b/compute/src/main/java/org/jclouds/compute/domain/OsFamily.java index 430efa5573..a462eccd89 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/OsFamily.java +++ b/compute/src/main/java/org/jclouds/compute/domain/OsFamily.java @@ -33,7 +33,11 @@ import com.google.common.base.CaseFormat; * @author Adrian Cole */ public enum OsFamily { - CENTOS, RHEL, FEDORA, DEBIAN, UBUNTU, TTYLINUX, ARCH, GENTOO, WINDOWS; + CENTOS, + /** + * Oracle Enterprise Linux + */ + OEL, RHEL, FEDORA, DEBIAN, UBUNTU, TTYLINUX, ARCH, GENTOO, WINDOWS; public String value() { return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); } diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java index 1dc1b064de..440b49eeea 100755 --- a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java @@ -281,7 +281,7 @@ public class BaseComputeService implements ComputeService { } @Override - public Map getLocations() { + public Map getAssignableLocations() { return locations.get(); } diff --git a/compute/src/main/java/org/jclouds/compute/strategy/impl/ReturnNullCredentials.java b/compute/src/main/java/org/jclouds/compute/strategy/impl/ReturnNullCredentials.java new file mode 100644 index 0000000000..f983f3feb2 --- /dev/null +++ b/compute/src/main/java/org/jclouds/compute/strategy/impl/ReturnNullCredentials.java @@ -0,0 +1,23 @@ +package org.jclouds.compute.strategy.impl; + +import java.util.regex.Pattern; + +import javax.inject.Singleton; + +import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; +import org.jclouds.domain.Credentials; + +/** + * @author Adrian Cole + */ +@Singleton +public class ReturnNullCredentials implements PopulateDefaultLoginCredentialsForImageStrategy { + + public static final Pattern USER_PASSWORD_PATTERN = Pattern + .compile(".*[Uu]sername: ([a-z]+) ?.*\n[Pp]assword: ([^ ]+) ?\n.*"); + + @Override + public Credentials execute(Object resourceToAuthenticate) { + return null; + } +} diff --git a/compute/src/main/java/org/jclouds/compute/util/ComputeUtils.java b/compute/src/main/java/org/jclouds/compute/util/ComputeUtils.java index 19ef0fe2bf..bd040924b5 100644 --- a/compute/src/main/java/org/jclouds/compute/util/ComputeUtils.java +++ b/compute/src/main/java/org/jclouds/compute/util/ComputeUtils.java @@ -288,6 +288,15 @@ public class ComputeUtils { returnVal = runScriptAsDefaultUser(); runScriptNotRunning.apply(new CommandUsingClient("./" + scriptName + " status", ssh)); logger.debug("<< complete(%d)", returnVal.getExitCode()); + if (logger.isDebugEnabled() || returnVal.getExitCode() != 0) { + logger.debug("<< stdout from %s as %s@%s\n%s", scriptName, + node.getCredentials().account, Iterables.get(node.getPublicAddresses(), 0) + .getHostAddress(), ssh.exec("./" + scriptName + " tail").getOutput()); + logger.debug("<< stderr from %s as %s@%s\n%s", scriptName, + node.getCredentials().account, Iterables.get(node.getPublicAddresses(), 0) + .getHostAddress(), ssh.exec("./" + scriptName + " tailerr") + .getOutput()); + } return returnVal; } diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index 30098e5ef4..0cf671c86b 100755 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -50,6 +50,7 @@ import org.jclouds.compute.options.RunScriptOptions; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; +import org.jclouds.domain.LocationScope; import org.jclouds.http.HttpResponseException; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.predicates.RetryablePredicate; @@ -200,7 +201,7 @@ public abstract class BaseComputeServiceLiveTest { void assertLocationSameOrChild(Location test, Location expected) { if (!test.equals(expected)) { - assertEquals(test.getParent(), expected.getId()); + assertEquals(test.getParent().getId(), expected.getId()); } else { assertEquals(test, expected); } @@ -248,11 +249,19 @@ public abstract class BaseComputeServiceLiveTest { private Map runScriptWithCreds(String tag, OsFamily osFamily, Credentials creds) { - return client.runScriptOnNodesWithTag(tag, buildScript(osFamily).getBytes(), - RunScriptOptions.Builder.overrideCredentialsWith(creds)); + try { + return client.runScriptOnNodesWithTag(tag, buildScript(osFamily).getBytes(), + RunScriptOptions.Builder.overrideCredentialsWith(creds)); + } catch (SshException e) { + if (Throwables.getRootCause(e).getMessage().contains("Auth fail")) { + System.err.printf("bad credentials: %s:%s for %s", creds.account, creds.key, client + .getNodesWithTag(tag)); + } + throw e; + } } - private void checkNodes(Iterable nodes, String tag) throws IOException { + protected void checkNodes(Iterable nodes, String tag) throws IOException { for (NodeMetadata node : nodes) { assertNotNull(node.getId()); assertNotNull(node.getTag()); @@ -381,15 +390,44 @@ public abstract class BaseComputeServiceLiveTest { } } - public void testListLocations() throws Exception { - for (Entry image : client.getLocations().entrySet()) { - assertEquals(image.getKey(), image.getValue().getId()); - assert image.getValue().getId() != null : image; - assert image.getValue().getId() != image.getValue().getParent() : image; - assert image.getValue().getScope() != null : image; + @Test(groups = { "integration", "live" }) + public void testGetAssignableLocations() throws Exception { + for (Entry location : client.getAssignableLocations().entrySet()) { + System.err.printf("location %s%n", location.getValue()); + assertEquals(location.getKey(), location.getValue().getId()); + assert location.getValue().getId() != null : location; + assert location.getValue() != location.getValue().getParent() : location; + assert location.getValue().getScope() != null : location; + switch (location.getValue().getScope()) { + case PROVIDER: + assertProvider(location.getValue()); + break; + case REGION: + assertProvider(location.getValue().getParent()); + break; + case ZONE: + Location provider = location.getValue().getParent().getParent(); + // zone can be a direct descendant of provider + if (provider == null) + provider = location.getValue().getParent(); + assertProvider(provider); + break; + case HOST: + Location provider2 = location.getValue().getParent().getParent().getParent(); + // zone can be a direct descendant of provider + if (provider2 == null) + provider2 = location.getValue().getParent().getParent(); + assertProvider(provider2); + break; + } } } + private void assertProvider(Location provider) { + assertEquals(provider.getScope(), LocationScope.PROVIDER); + assertEquals(provider.getParent(), null); + } + public void testListSizes() throws Exception { for (Entry size : client.getSizes().entrySet()) { assertEquals(size.getKey(), size.getValue().getId()); diff --git a/core/src/main/java/org/jclouds/domain/Location.java b/core/src/main/java/org/jclouds/domain/Location.java index bf69c0c056..e8039c6d20 100644 --- a/core/src/main/java/org/jclouds/domain/Location.java +++ b/core/src/main/java/org/jclouds/domain/Location.java @@ -48,8 +48,8 @@ public interface Location { String getDescription(); /** - * The Id of the parent, or null, if top-level + * The parent, or null, if top-level */ - String getParent(); + Location getParent(); } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/domain/LocationScope.java b/core/src/main/java/org/jclouds/domain/LocationScope.java index eb4baac7a1..76bb327fe9 100644 --- a/core/src/main/java/org/jclouds/domain/LocationScope.java +++ b/core/src/main/java/org/jclouds/domain/LocationScope.java @@ -25,6 +25,6 @@ package org.jclouds.domain; */ public enum LocationScope { - REGION, ZONE, RACK, HOST; + PROVIDER, REGION, ZONE, RACK, HOST; } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/domain/internal/LocationImpl.java b/core/src/main/java/org/jclouds/domain/internal/LocationImpl.java index 6248ad5606..890e9274c8 100644 --- a/core/src/main/java/org/jclouds/domain/internal/LocationImpl.java +++ b/core/src/main/java/org/jclouds/domain/internal/LocationImpl.java @@ -40,9 +40,9 @@ public class LocationImpl implements Location, Serializable { private final LocationScope scope; private final String id; private final String description; - private final String parent; + private final Location parent; - public LocationImpl(LocationScope scope, String id, String description, @Nullable String parent) { + public LocationImpl(LocationScope scope, String id, String description, @Nullable Location parent) { this.scope = checkNotNull(scope, "scope"); this.id = checkNotNull(id, "id"); this.description = checkNotNull(description, "description"); @@ -61,7 +61,7 @@ public class LocationImpl implements Location, Serializable { return description; } - public String getParent() { + public Location getParent() { return parent; } @@ -111,7 +111,7 @@ public class LocationImpl implements Location, Serializable { @Override public String toString() { return "[id=" + id + ", scope=" + scope + ", description=" + description + ", parent=" - + parent + "]"; + + ((parent == null) ? null : parent.getId()) + "]"; } } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/RestContextBuilder.java b/core/src/main/java/org/jclouds/rest/RestContextBuilder.java index b926dfae3b..6c692b417d 100755 --- a/core/src/main/java/org/jclouds/rest/RestContextBuilder.java +++ b/core/src/main/java/org/jclouds/rest/RestContextBuilder.java @@ -64,13 +64,15 @@ import com.google.inject.util.Types; */ public abstract class RestContextBuilder { + protected final String providerName; protected final Properties properties; protected final List modules = new ArrayList(3); protected final TypeLiteral asyncClientType; protected final TypeLiteral syncClientType; - protected RestContextBuilder(TypeLiteral asyncClientType, TypeLiteral syncClientType, - Properties properties) { + protected RestContextBuilder(String providerName, TypeLiteral asyncClientType, + TypeLiteral syncClientType, Properties properties) { + this.providerName = providerName; this.asyncClientType = asyncClientType; this.syncClientType = syncClientType; this.properties = properties; @@ -83,7 +85,7 @@ public abstract class RestContextBuilder { public Injector buildInjector() { - addContextModule(modules); + addContextModule(providerName, modules); addClientModuleIfNotPresent(modules); addLoggingModuleIfNotPresent(modules); addHttpModuleIfNeededAndNotPresent(modules); @@ -124,7 +126,7 @@ public abstract class RestContextBuilder { } @VisibleForTesting - protected abstract void addContextModule(List modules); + protected abstract void addContextModule(String providerName, List modules); @VisibleForTesting protected void ifHttpConfigureRestOtherwiseGuiceClientFactory(final List modules) { diff --git a/core/src/main/java/org/jclouds/rest/RestContextFactory.java b/core/src/main/java/org/jclouds/rest/RestContextFactory.java index e081a8d1d5..d594e37102 100644 --- a/core/src/main/java/org/jclouds/rest/RestContextFactory.java +++ b/core/src/main/java/org/jclouds/rest/RestContextFactory.java @@ -98,46 +98,46 @@ public abstract class RestContextFactory> this.properties = properties; } - public T createContext(URI blobStore, Iterable modules, Properties overrides) { - return createContext(blobStore, Credentials.parse(blobStore), modules, overrides); + public T createContext(URI contextUri, Iterable modules, Properties overrides) { + return createContext(contextUri, Credentials.parse(contextUri), modules, overrides); } - public T createContext(URI blobStore) { - return createContext(blobStore, ImmutableSet. of(), NO_PROPERTIES); + public T createContext(URI contextUri) { + return createContext(contextUri, ImmutableSet. of(), NO_PROPERTIES); } - public T createContext(URI blobStore, Credentials creds, Iterable modules, + public T createContext(URI contextUri, Credentials creds, Iterable modules, Properties overrides) { - return createContext(checkNotNull(blobStore.getHost(), "host"), checkNotNull(creds.account, + return createContext(checkNotNull(contextUri.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(URI contextUri, Credentials creds) { + return createContext(contextUri, creds, ImmutableSet. of(), NO_PROPERTIES); } - public T createContext(String hint, String account, String key) { - return createContext(hint, account, key, ImmutableSet. of(), NO_PROPERTIES); + public T createContext(String provider, String account, String key) { + return createContext(provider, account, key, ImmutableSet. of(), NO_PROPERTIES); } - public T createContext(String hint, Properties overrides) { - return createContext(hint, null, null, ImmutableSet. of(), overrides); + public T createContext(String provider, Properties overrides) { + return createContext(provider, null, null, ImmutableSet. of(), overrides); } - public T createContext(String hint, Iterable modules, Properties overrides) { - return createContext(hint, null, null, modules, overrides); + public T createContext(String provider, Iterable modules, Properties overrides) { + return createContext(provider, null, null, modules, overrides); } - public T createContext(String hint, @Nullable String account, @Nullable String key, + public T createContext(String provider, @Nullable String account, @Nullable String key, Iterable modules) { - return createContext(hint, account, key, modules, new Properties()); + return createContext(provider, account, key, modules, new Properties()); } /** * Creates a new remote context. * - * @param hint + * @param provider * @param account * nullable, if credentials are present in the overrides * @param key @@ -150,20 +150,20 @@ public abstract class RestContextFactory> * @return initialized context ready for use */ @SuppressWarnings("unchecked") - public T createContext(String hint, @Nullable String account, @Nullable String key, + public T createContext(String provider, @Nullable String account, @Nullable String key, Iterable modules, Properties overrides) { - checkNotNull(hint, "hint"); + checkNotNull(provider, "provider"); checkNotNull(modules, "modules"); checkNotNull(overrides, "overrides"); - String propertiesBuilderKey = String.format("%s.propertiesbuilder", hint); + String propertiesBuilderKey = String.format("%s.propertiesbuilder", provider); String propertiesBuilderClassName = checkNotNull( - properties.getProperty(propertiesBuilderKey), hint + " service not supported"); + properties.getProperty(propertiesBuilderKey), provider + " service not supported"); - String contextBuilderKey = String.format("%s.contextbuilder", hint); + String contextBuilderKey = String.format("%s.contextbuilder", provider); String contextBuilderClassName = checkNotNull(properties.getProperty(contextBuilderKey), contextBuilderKey); - String endpointKey = String.format("%s.endpoint", hint); + String endpointKey = String.format("%s.endpoint", provider); String endpoint = properties.getProperty(endpointKey); try { Class propertiesBuilderClass = (Class) Class @@ -175,8 +175,9 @@ public abstract class RestContextFactory> builder.withCredentials(account, key); if (endpoint != null) builder.withEndpoint(URI.create(endpoint)); - B contextBuilder = (B) contextBuilderClass.getConstructor(Properties.class).newInstance( - builder.build()).withModules(Iterables.toArray(modules, Module.class)); + B contextBuilder = (B) contextBuilderClass.getConstructor(String.class, Properties.class) + .newInstance(provider, builder.build()).withModules( + Iterables.toArray(modules, Module.class)); return build(contextBuilder); } catch (ProvisionException e) { Throwable throwable = Utils.firstRootCauseOrOriginalException(e); diff --git a/core/src/test/java/org/jclouds/http/BaseJettyTest.java b/core/src/test/java/org/jclouds/http/BaseJettyTest.java index fec9a2d5d6..e4576c95e2 100644 --- a/core/src/test/java/org/jclouds/http/BaseJettyTest.java +++ b/core/src/test/java/org/jclouds/http/BaseJettyTest.java @@ -74,15 +74,15 @@ public abstract class BaseJettyTest { RestContextBuilder { private final int testPort; - public IntegrationContextBuilder(Properties properties, int testPort) { - super(new TypeLiteral() { + public IntegrationContextBuilder(String providerName, Properties properties, int testPort) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, properties); this.testPort = testPort; } @Override - protected void addContextModule(List modules) { + protected void addContextModule(String providerName, List modules) { modules.add(new JettyContextModule(testPort)); } @@ -190,19 +190,20 @@ public abstract class BaseJettyTest { if (failEveryTenRequests(request, response)) return; if (request.getContentLength() > 0) { - if(request.getHeader("Content-MD5") != null) { - String expectedMd5 = request.getHeader("Content-MD5"); - String realMd5FromRequest = Base64.encodeBytes(new JCEEncryptionService().md5(request.getInputStream())); - boolean matched = expectedMd5.equals(realMd5FromRequest); - if(matched) { - response.setContentType("text/xml"); - response.setStatus(HttpServletResponse.SC_OK); - response.getWriter().println("created"); - } + if (request.getHeader("Content-MD5") != null) { + String expectedMd5 = request.getHeader("Content-MD5"); + String realMd5FromRequest = Base64.encodeBytes(new JCEEncryptionService() + .md5(request.getInputStream())); + boolean matched = expectedMd5.equals(realMd5FromRequest); + if (matched) { + response.setContentType("text/xml"); + response.setStatus(HttpServletResponse.SC_OK); + response.getWriter().println("created"); + } } else { - response.setStatus(HttpServletResponse.SC_OK); - response.getWriter().println( - Utils.toStringAndClose(request.getInputStream()) + "POST"); + response.setStatus(HttpServletResponse.SC_OK); + response.getWriter().println( + Utils.toStringAndClose(request.getInputStream()) + "POST"); } } else { handleAction(request, response); @@ -214,8 +215,9 @@ public abstract class BaseJettyTest { response.setStatus(HttpServletResponse.SC_OK); response.getWriter().println("test"); } else if (request.getMethod().equals("HEAD")) { - /* NOTE: by HTML specification, HEAD response MUST NOT - include a body */ + /* + * NOTE: by HTML specification, HEAD response MUST NOT include a body + */ response.setContentType("text/xml"); response.setStatus(HttpServletResponse.SC_OK); } else { @@ -245,26 +247,28 @@ public abstract class BaseJettyTest { } } else if (request.getMethod().equals("POST")) { if (request.getContentLength() > 0) { - if(request.getHeader("Content-MD5") != null) { - String expectedMd5 = request.getHeader("Content-MD5"); - String realMd5FromRequest = Base64.encodeBytes(new JCEEncryptionService().md5(request.getInputStream())); - boolean matched = expectedMd5.equals(realMd5FromRequest); - if(matched) { - response.setContentType("text/xml"); - response.setStatus(HttpServletResponse.SC_OK); - response.getWriter().println("created"); - } - } else { + if (request.getHeader("Content-MD5") != null) { + String expectedMd5 = request.getHeader("Content-MD5"); + String realMd5FromRequest = Base64.encodeBytes(new JCEEncryptionService() + .md5(request.getInputStream())); + boolean matched = expectedMd5.equals(realMd5FromRequest); + if (matched) { + response.setContentType("text/xml"); response.setStatus(HttpServletResponse.SC_OK); - response.getWriter().println( - Utils.toStringAndClose(request.getInputStream()) + "POST"); + response.getWriter().println("created"); + } + } else { + response.setStatus(HttpServletResponse.SC_OK); + response.getWriter().println( + Utils.toStringAndClose(request.getInputStream()) + "POST"); } } else { handleAction(request, response); } } else if (request.getMethod().equals("HEAD")) { - /* NOTE: by HTML specification, HEAD response MUST NOT - include a body */ + /* + * NOTE: by HTML specification, HEAD response MUST NOT include a body + */ response.setContentType("text/xml"); response.setStatus(HttpServletResponse.SC_OK); } else { @@ -318,7 +322,8 @@ public abstract class BaseJettyTest { public static RestContextBuilder newBuilder( final int testPort, final Properties properties, Module connectionModule) { - return new IntegrationContextBuilder(properties, testPort).withModules(connectionModule); + return new IntegrationContextBuilder("integration-test", properties, testPort) + .withModules(connectionModule); } @AfterTest @@ -334,7 +339,7 @@ public abstract class BaseJettyTest { /** * Fails every 10 requests. - * + * * @param request * @param response * @return diff --git a/core/src/test/java/org/jclouds/rest/RestContextBuilderTest.java b/core/src/test/java/org/jclouds/rest/RestContextBuilderTest.java index 46c4393a5d..fbab5fbd63 100755 --- a/core/src/test/java/org/jclouds/rest/RestContextBuilderTest.java +++ b/core/src/test/java/org/jclouds/rest/RestContextBuilderTest.java @@ -87,7 +87,7 @@ public class RestContextBuilderTest { class TestRestContextBuilder extends RestContextBuilder { protected TestRestContextBuilder(Properties properties) { - super(new TypeLiteral() { + super("test", new TypeLiteral() { }, new TypeLiteral() { }, properties); } @@ -98,7 +98,7 @@ public class RestContextBuilderTest { } @Override - protected void addContextModule(List modules) { + protected void addContextModule(String providerName, List modules) { // ignored as we add it directly above without use of injection } diff --git a/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java b/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java index 3bb5659915..ba0a03b624 100644 --- a/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java +++ b/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java @@ -44,8 +44,8 @@ import com.google.inject.TypeLiteral; public class GoGridContextBuilder extends ComputeServiceContextBuilder { - public GoGridContextBuilder(Properties props) { - super(new TypeLiteral() { + public GoGridContextBuilder(String providerName, Properties props) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, props); } @@ -55,8 +55,8 @@ public class GoGridContextBuilder extends } @Override - protected void addContextModule(List modules) { - modules.add(new GoGridComputeServiceContextModule()); + protected void addContextModule(String providerName, List modules) { + modules.add(new GoGridComputeServiceContextModule(providerName)); } @Override diff --git a/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextFactory.java b/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextFactory.java index a7900a341a..924e092a9a 100644 --- a/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextFactory.java +++ b/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextFactory.java @@ -42,24 +42,25 @@ import com.google.inject.Module; *

* If no Modules are specified, the default {@link JDKLoggingModule logging} and * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. - * + * * @author Adrian Cole * @author Oleksiy Yarmula - * + * * @see RestContext * @see GridServerClient * @see GridServerAsyncClient */ public class GoGridContextFactory { - public static RestContext createContext(String user, String password, - Module... modules) { - return new GoGridContextBuilder(new GoGridPropertiesBuilder(user, password).build()) + public static RestContext createContext(String user, + String password, Module... modules) { + return new GoGridContextBuilder("gogrid", new GoGridPropertiesBuilder(user, password).build()) .withModules(modules).buildContext(); } - public static RestContext createContext(Properties properties, Module... modules) { - return new GoGridContextBuilder(new GoGridPropertiesBuilder(properties).build()) + public static RestContext createContext(Properties properties, + Module... modules) { + return new GoGridContextBuilder("gogrid", new GoGridPropertiesBuilder(properties).build()) .withModules(modules).buildContext(); } diff --git a/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java b/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java index 1f64f0cd0b..d41cf3fdf1 100755 --- a/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java +++ b/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java @@ -91,6 +91,11 @@ import com.google.inject.TypeLiteral; * @author Oleksiy Yarmula */ public class GoGridComputeServiceContextModule extends GoGridContextModule { + private final String providerName; + + public GoGridComputeServiceContextModule(String providerName) { + this.providerName = providerName; + } @Override protected void configure() { @@ -284,8 +289,9 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule { Function indexer) { final Set locations = Sets.newHashSet(); holder.logger.debug(">> providing locations"); - locations - .add(new LocationImpl(LocationScope.ZONE, "SANFRANCISCO", "San Francisco, CA", null)); + Location parent = new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null); + locations.add(new LocationImpl(LocationScope.ZONE, "SANFRANCISCO", "San Francisco, CA", + parent)); holder.logger.debug("<< locations(%d)", locations.size()); return Maps.uniqueIndex(locations, new Function() { diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/PCSContextBuilder.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/PCSContextBuilder.java index 5371d5ba3e..3f27cafb14 100755 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/PCSContextBuilder.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/PCSContextBuilder.java @@ -37,8 +37,8 @@ import com.google.inject.TypeLiteral; */ public class PCSContextBuilder extends RestContextBuilder { - public PCSContextBuilder(Properties props) { - super(new TypeLiteral() { + public PCSContextBuilder(String providerName, Properties props) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, props); checkNotNull(properties.getProperty(PCSConstants.PROPERTY_PCS2_USER)); @@ -51,8 +51,8 @@ public class PCSContextBuilder extends RestContextBuilder modules) { - modules.add(new PCSContextModule()); + protected void addContextModule(String providerName, List modules) { + modules.add(new PCSContextModule(providerName)); } } diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/PCSContextFactory.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/PCSContextFactory.java index 3c62a51b26..ebed3a0657 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/PCSContextFactory.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/PCSContextFactory.java @@ -43,12 +43,12 @@ public class PCSContextFactory { public static RestContext createContext(URI endpoint, String user, String key, Module... modules) { - return new PCSContextBuilder(new PCSPropertiesBuilder(endpoint, user, key).build()) + return new PCSContextBuilder("mezeo", new PCSPropertiesBuilder(endpoint, user, key).build()) .withModules(modules).buildContext(); } public static RestContext createContext(Properties properties, Module... modules) { - return new PCSContextBuilder(new PCSPropertiesBuilder(properties).build()).withModules( + return new PCSContextBuilder("mezeo", new PCSPropertiesBuilder(properties).build()).withModules( modules).buildContext(); } diff --git a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/config/PCSContextModule.java b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/config/PCSContextModule.java index 731808a289..5bc31975be 100644 --- a/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/config/PCSContextModule.java +++ b/mezeo/pcs2/core/src/main/java/org/jclouds/mezeo/pcs2/config/PCSContextModule.java @@ -42,6 +42,10 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ public class PCSContextModule extends AbstractModule { + public PCSContextModule(String providerName) { + + } + @Override protected void configure() { install(new BlobStoreObjectModule( diff --git a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/config/PCSContextModuleTest.java b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/config/PCSContextModuleTest.java index d62a9ae3b3..d9cac172e1 100644 --- a/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/config/PCSContextModuleTest.java +++ b/mezeo/pcs2/core/src/test/java/org/jclouds/mezeo/pcs2/config/PCSContextModuleTest.java @@ -50,7 +50,7 @@ import com.google.inject.Injector; public class PCSContextModuleTest { Injector createInjector() { - return Guice.createInjector(new PCSRestClientModule(), new PCSContextModule() { + return Guice.createInjector(new PCSRestClientModule(), new PCSContextModule("mezeo") { @Override protected void configure() { Jsr330.bindProperties(this.binder(), new PCSPropertiesBuilder(URI diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNContextBuilder.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNContextBuilder.java index 19d5f9ebf0..aee84abcdb 100755 --- a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNContextBuilder.java +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/SDNContextBuilder.java @@ -35,8 +35,8 @@ import com.google.inject.TypeLiteral; */ public class SDNContextBuilder extends RestContextBuilder { - public SDNContextBuilder(Properties props) { - super(new TypeLiteral() { + public SDNContextBuilder(String providerName, Properties props) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, props); } @@ -48,8 +48,8 @@ public class SDNContextBuilder extends RestContextBuilder modules) { - modules.add(new SDNContextModule()); + protected void addContextModule(String providerName, List modules) { + modules.add(new SDNContextModule(providerName)); } } diff --git a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/config/SDNContextModule.java b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/config/SDNContextModule.java index e58a2b652b..d9b10339e9 100644 --- a/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/config/SDNContextModule.java +++ b/nirvanix/sdn/core/src/main/java/org/jclouds/nirvanix/sdn/config/SDNContextModule.java @@ -39,6 +39,10 @@ import com.google.inject.TypeLiteral; @RequiresHttp public class SDNContextModule extends AbstractModule { + public SDNContextModule(String providerName) { + + } + @Override protected void configure() { // for converters to work. diff --git a/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/SDNClientLiveTest.java b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/SDNClientLiveTest.java index 9c47b5a651..7a755b9efe 100644 --- a/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/SDNClientLiveTest.java +++ b/nirvanix/sdn/core/src/test/java/org/jclouds/nirvanix/sdn/SDNClientLiveTest.java @@ -59,8 +59,8 @@ public class SDNClientLiveTest { String user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); - connection = new SDNContextBuilder(new SDNPropertiesBuilder(appid, appname, user, password) - .build()).withModules(new Log4JLoggingModule()).buildContext().getApi(); + connection = new SDNContextBuilder("nirvanix", new SDNPropertiesBuilder(appid, appname, user, + password).build()).withModules(new Log4JLoggingModule()).buildContext().getApi(); } public void testUploadToken() throws InterruptedException, ExecutionException, TimeoutException { diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesContextBuilder.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesContextBuilder.java index 4142d2c5c6..3c4bb70f9b 100755 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesContextBuilder.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesContextBuilder.java @@ -48,15 +48,15 @@ import com.google.inject.TypeLiteral; public class CloudFilesContextBuilder extends BlobStoreContextBuilder { - public CloudFilesContextBuilder(Properties props) { - super(new TypeLiteral() { + public CloudFilesContextBuilder(String providerName, Properties props) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, props); } @Override - protected void addContextModule(List modules) { - modules.add(new CloudFilesBlobStoreContextModule()); + protected void addContextModule(String providerName, List modules) { + modules.add(new CloudFilesBlobStoreContextModule(providerName)); } @Override diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesContextFactory.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesContextFactory.java index 2ac699fed4..5da2d93fa0 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesContextFactory.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesContextFactory.java @@ -42,18 +42,18 @@ import com.google.inject.Module; */ public class CloudFilesContextFactory { public static BlobStoreContext createContext(Properties properties, Module... modules) { - return new CloudFilesContextBuilder(new CloudFilesPropertiesBuilder(properties) + return new CloudFilesContextBuilder("cloudfiles", new CloudFilesPropertiesBuilder(properties) .build()).withModules(modules).buildBlobStoreContext(); } public static BlobStoreContext createContext(String user, String key, Module... modules) { - return new CloudFilesContextBuilder(new CloudFilesPropertiesBuilder(user, key) + return new CloudFilesContextBuilder("cloudfiles", new CloudFilesPropertiesBuilder(user, key) .build()).withModules(modules).buildBlobStoreContext(); } public static BlobStoreContext createContext(URI endpoint, String user, String key, Module... modules) { - return new CloudFilesContextBuilder(new CloudFilesPropertiesBuilder(user, key) + return new CloudFilesContextBuilder("cloudfiles", new CloudFilesPropertiesBuilder(user, key) .withEndpoint(endpoint).build()).withModules(modules).buildBlobStoreContext(); } } diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java index 9781593f30..ec59f2e836 100755 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java @@ -29,6 +29,7 @@ import org.jclouds.rackspace.cloudfiles.CloudFilesClient; import org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesAsyncBlobStore; import org.jclouds.rackspace.cloudfiles.blobstore.CloudFilesBlobStore; import org.jclouds.rackspace.cloudfiles.config.CloudFilesContextModule; +import org.jclouds.rackspace.config.RackspaceLocationsModule; import com.google.inject.Scopes; import com.google.inject.TypeLiteral; @@ -40,10 +41,16 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ public class CloudFilesBlobStoreContextModule extends CloudFilesContextModule { + private final String providerName; + + public CloudFilesBlobStoreContextModule(String providerName) { + this.providerName = providerName; + } @Override protected void configure() { super.configure(); + install(new RackspaceLocationsModule(providerName)); install(new BlobStoreMapModule()); bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); bind(AsyncBlobStore.class).to(CloudFilesAsyncBlobStore.class).in(Scopes.SINGLETON); diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/config/CloudFilesContextModule.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/config/CloudFilesContextModule.java index 679aec0121..54e9e74980 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/config/CloudFilesContextModule.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudfiles/config/CloudFilesContextModule.java @@ -28,7 +28,6 @@ import org.jclouds.lifecycle.Closer; import org.jclouds.rackspace.CloudFiles; import org.jclouds.rackspace.cloudfiles.CloudFilesAsyncClient; import org.jclouds.rackspace.cloudfiles.CloudFilesClient; -import org.jclouds.rackspace.config.RackspaceLocationsModule; import org.jclouds.rackspace.reference.RackspaceConstants; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.RestContextImpl; @@ -52,7 +51,6 @@ public class CloudFilesContextModule extends AbstractModule { }, new TypeLiteral() { })); install(new CFObjectModule()); - install(new RackspaceLocationsModule()); } @Provides diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersContextBuilder.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersContextBuilder.java index 0a733d5903..62e2e876fe 100755 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersContextBuilder.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersContextBuilder.java @@ -48,16 +48,16 @@ import com.google.inject.TypeLiteral; public class CloudServersContextBuilder extends ComputeServiceContextBuilder { - public CloudServersContextBuilder(Properties props) { - super(new TypeLiteral() { + public CloudServersContextBuilder(String providerName, Properties props) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, props); } @Override - protected void addContextModule(List modules) { + protected void addContextModule(String providerName, List modules) { modules.add(new RackspaceAuthenticationRestModule()); - modules.add(new CloudServersComputeServiceContextModule()); + modules.add(new CloudServersComputeServiceContextModule(providerName)); } @Override diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersContextFactory.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersContextFactory.java index 66f3afc68c..67b5166d08 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersContextFactory.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersContextFactory.java @@ -43,26 +43,26 @@ import com.google.inject.Module; */ public class CloudServersContextFactory { public static ComputeServiceContext createContext(Properties properties, Module... modules) { - return new CloudServersContextBuilder(new RackspacePropertiesBuilder(properties).build()) - .withModules(modules).buildComputeServiceContext(); + return new CloudServersContextBuilder("cloudservers", new RackspacePropertiesBuilder( + properties).build()).withModules(modules).buildComputeServiceContext(); } - public static ComputeServiceContext createContext(String user, - String password, Module... modules) { - return new CloudServersContextBuilder(new RackspacePropertiesBuilder(user, + public static ComputeServiceContext createContext(String user, String password, + Module... modules) { + return new CloudServersContextBuilder("cloudservers", new RackspacePropertiesBuilder(user, password).build()).withModules(modules).buildComputeServiceContext(); } public static ComputeServiceContext createContext(Properties properties, String user, String password, Module... modules) { - return new CloudServersContextBuilder(new RackspacePropertiesBuilder(properties) - .withCredentials(user, password).build()).withModules(modules) + return new CloudServersContextBuilder("cloudservers", new RackspacePropertiesBuilder( + properties).withCredentials(user, password).build()).withModules(modules) .buildComputeServiceContext(); } - public static ComputeServiceContext createContext(URI endpoint, String user, - String password, Module... modules) { - return new CloudServersContextBuilder(new RackspacePropertiesBuilder(user, + public static ComputeServiceContext createContext(URI endpoint, String user, String password, + Module... modules) { + return new CloudServersContextBuilder("cloudservers", new RackspacePropertiesBuilder(user, password).withEndpoint(endpoint).build()).withModules(modules) .buildComputeServiceContext(); } diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/config/CloudServersComputeServiceContextModule.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/config/CloudServersComputeServiceContextModule.java index 9b63a6a885..a991750315 100755 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/config/CloudServersComputeServiceContextModule.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/config/CloudServersComputeServiceContextModule.java @@ -64,6 +64,8 @@ import org.jclouds.compute.strategy.ListNodesStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; +import org.jclouds.domain.LocationScope; +import org.jclouds.domain.internal.LocationImpl; import org.jclouds.logging.Logger; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rackspace.cloudservers.CloudServersAsyncClient; @@ -97,11 +99,16 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ public class CloudServersComputeServiceContextModule extends CloudServersContextModule { + private final String providerName; + + public CloudServersComputeServiceContextModule(String providerName) { + this.providerName = providerName; + } @Override protected void configure() { super.configure(); - install(new RackspaceLocationsModule()); + install(new RackspaceLocationsModule(providerName)); bind(new TypeLiteral>() { }).to(ServerToNodeMetadata.class); bind(AddNodeWithTagStrategy.class).to(CloudServersAddNodeWithTagStrategy.class); @@ -187,11 +194,12 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext Server server = client.createServer(name, Integer.parseInt(template.getImage().getId()), Integer.parseInt(template.getSize().getId())); serverActive.apply(server); - return new NodeMetadataImpl(server.getId() + "", name, template.getLocation(), null, - server.getMetadata(), tag, template.getImage(), NodeState.RUNNING, server - .getAddresses().getPublicAddresses(), server.getAddresses() - .getPrivateAddresses(), ImmutableMap. of(), - new Credentials("root", server.getAdminPass())); + return new NodeMetadataImpl(server.getId() + "", name, new LocationImpl( + LocationScope.HOST, server.getHostId(), server.getHostId(), template + .getLocation()), null, server.getMetadata(), tag, template.getImage(), + NodeState.RUNNING, server.getAddresses().getPublicAddresses(), server + .getAddresses().getPrivateAddresses(), ImmutableMap + . of(), new Credentials("root", server.getAdminPass())); } } @@ -336,6 +344,8 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext osDescription = from.getName(); if (from.getName().indexOf("Red Hat EL") != -1) { os = OsFamily.RHEL; + } else if (from.getName().indexOf("Oracle EL") != -1) { + os = OsFamily.OEL; } else if (matcher.find()) { try { os = OsFamily.fromValue(matcher.group(2).toLowerCase()); diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/functions/ServerToNodeMetadata.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/functions/ServerToNodeMetadata.java index 837e04a91c..1e05350fb7 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/functions/ServerToNodeMetadata.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/functions/ServerToNodeMetadata.java @@ -31,6 +31,8 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.internal.NodeMetadataImpl; import org.jclouds.domain.Location; +import org.jclouds.domain.LocationScope; +import org.jclouds.domain.internal.LocationImpl; import org.jclouds.rackspace.cloudservers.domain.Server; import org.jclouds.rackspace.cloudservers.domain.ServerStatus; @@ -60,7 +62,8 @@ public class ServerToNodeMetadata implements Function { Matcher matcher = SECOND_FIELD_DELIMETED_BY_HYPHEN_ENDING_IN_HYPHEN_HEX.matcher(from .getName()); final String tag = matcher.find() ? matcher.group(1) : null; - return new NodeMetadataImpl(from.getId() + "", from.getName(), location, null, from + return new NodeMetadataImpl(from.getId() + "", from.getName(), new LocationImpl( + LocationScope.HOST, from.getHostId(), from.getHostId(), location), null, from .getMetadata(), tag, images.get(from.getImageId().toString()), serverToNodeState .get(from.getStatus()), from.getAddresses().getPublicAddresses(), from .getAddresses().getPrivateAddresses(), ImmutableMap. of(), null); diff --git a/rackspace/src/main/java/org/jclouds/rackspace/config/RackspaceLocationsModule.java b/rackspace/src/main/java/org/jclouds/rackspace/config/RackspaceLocationsModule.java index aeeff3ddab..69c26f424f 100644 --- a/rackspace/src/main/java/org/jclouds/rackspace/config/RackspaceLocationsModule.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/config/RackspaceLocationsModule.java @@ -38,6 +38,11 @@ import com.google.inject.Provides; */ @RequiresHttp public class RackspaceLocationsModule extends AbstractModule { + private final String providerName; + + public RackspaceLocationsModule(String providerName) { + this.providerName = providerName; + } @Override protected void configure() { @@ -46,7 +51,8 @@ public class RackspaceLocationsModule extends AbstractModule { @Provides @Singleton Location getLocation() { - return new LocationImpl(LocationScope.ZONE, "DFW1", "Dallas, TX", null); + Location provider = new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null); + return new LocationImpl(LocationScope.ZONE, "DFW1", "Dallas, TX", provider); } @Provides diff --git a/rackspace/src/test/java/org/jclouds/rackspace/RackspaceAuthenticationLiveTest.java b/rackspace/src/test/java/org/jclouds/rackspace/RackspaceAuthenticationLiveTest.java index 8ca9652816..e597fd7bbd 100755 --- a/rackspace/src/test/java/org/jclouds/rackspace/RackspaceAuthenticationLiveTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/RackspaceAuthenticationLiveTest.java @@ -119,7 +119,7 @@ public class RackspaceAuthenticationLiveTest { @BeforeClass void setupFactory() { context = new RestContextBuilder( - new TypeLiteral() { + "rackspace", new TypeLiteral() { }, new TypeLiteral() { }, new RackspacePropertiesBuilder(account, key).build()) { @Override @@ -128,8 +128,10 @@ public class RackspaceAuthenticationLiveTest { modules.add(new RackspaceAuthenticationRestModule()); } - public void addContextModule(List modules) { + @Override + protected void addContextModule(String providerName, List modules) { modules.add(new RackspaceAuthenticationContextModule()); + } }.withModules(new Log4JLoggingModule(), new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor())) diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/binders/BindCFObjectToPayloadTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/binders/BindCFObjectToPayloadTest.java index 059e2a743e..ce32dfea39 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/binders/BindCFObjectToPayloadTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/binders/BindCFObjectToPayloadTest.java @@ -53,8 +53,8 @@ public class BindCFObjectToPayloadTest { private BlobToObject blob2Object; public BindCFObjectToPayloadTest() { - Injector injector = new CloudFilesContextBuilder(new CloudFilesPropertiesBuilder("id", - "secret").build()).buildInjector(); + Injector injector = new CloudFilesContextBuilder("cloudfiles", + new CloudFilesPropertiesBuilder("id", "secret").build()).buildInjector(); blobProvider = injector.getInstance(Blob.Factory.class); binderProvider = injector.getInstance(Key diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/config/CloudFilesBlobStoreModuleTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/config/CloudFilesBlobStoreModuleTest.java index f11543b474..794bfb80e2 100755 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/config/CloudFilesBlobStoreModuleTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudfiles/blobstore/config/CloudFilesBlobStoreModuleTest.java @@ -43,7 +43,8 @@ public class CloudFilesBlobStoreModuleTest { Injector createInjector() { return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()), new JDKLoggingModule(), new CloudFilesStubClientModule(), - new StubRackspaceAuthenticationModule(), new CloudFilesBlobStoreContextModule() { + new StubRackspaceAuthenticationModule(), new CloudFilesBlobStoreContextModule( + "cloudfiles") { @Override protected void configure() { bindConstant().annotatedWith( diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersClientLiveTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersClientLiveTest.java index d2e886ce3e..319e105a75 100755 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersClientLiveTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersClientLiveTest.java @@ -82,9 +82,9 @@ public class CloudServersClientLiveTest { public void setupClient() { String user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); - Injector injector = new CloudServersContextBuilder(new RackspacePropertiesBuilder(user, - password).build()).withModules(new Log4JLoggingModule(), new JschSshClientModule()) - .buildInjector(); + Injector injector = new CloudServersContextBuilder("cloudservers", + new RackspacePropertiesBuilder(user, password).build()).withModules( + new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); client = injector.getInstance(CloudServersClient.class); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java index d2b8c17e1e..961fec83fd 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java @@ -21,11 +21,15 @@ package org.jclouds.rackspace.cloudservers.compute; import static org.testng.Assert.assertEquals; +import java.io.IOException; + import org.jclouds.compute.BaseComputeServiceLiveTest; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.Architecture; +import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; +import org.jclouds.domain.LocationScope; import org.jclouds.rackspace.cloudservers.CloudServersAsyncClient; import org.jclouds.rackspace.cloudservers.CloudServersClient; import org.jclouds.rest.RestContext; @@ -67,4 +71,12 @@ public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTe RestContext tmContext = new ComputeServiceContextFactory() .createContext(service, user, password).getProviderSpecificContext(); } + + @Override + protected void checkNodes(Iterable nodes, String tag) throws IOException { + super.checkNodes(nodes, tag); + for (NodeMetadata node : nodes) { + assertEquals(node.getLocation().getScope(), LocationScope.HOST); + } + } } \ No newline at end of file diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java index 889a5d301d..cae4c5f208 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java @@ -50,8 +50,8 @@ import com.google.inject.TypeLiteral; public class RimuHostingContextBuilder extends ComputeServiceContextBuilder { - public RimuHostingContextBuilder(Properties props) { - super(new TypeLiteral() { + public RimuHostingContextBuilder(String providerName, Properties props) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, props); } @@ -62,8 +62,8 @@ public class RimuHostingContextBuilder extends } @Override - protected void addContextModule(List modules) { - modules.add(new RimuHostingComputeServiceContextModule()); + protected void addContextModule(String providerName, List modules) { + modules.add(new RimuHostingComputeServiceContextModule(providerName)); } @Override diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextFactory.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextFactory.java index b9c1fa84ab..1c5917adaf 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextFactory.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextFactory.java @@ -41,8 +41,8 @@ import com.google.inject.Module; */ public class RimuHostingContextFactory { public static ComputeServiceContext createContext(Properties properties, Module... modules) { - return new RimuHostingContextBuilder(new RimuHostingPropertiesBuilder(properties).build()) - .withModules(modules).buildComputeServiceContext(); + return new RimuHostingContextBuilder("rimuhosting", new RimuHostingPropertiesBuilder( + properties).build()).withModules(modules).buildComputeServiceContext(); } /** @@ -50,12 +50,12 @@ public class RimuHostingContextFactory { */ public static ComputeServiceContext createContext(String apiKey, String apiKey1, Module... modules) { - return new RimuHostingContextBuilder(new RimuHostingPropertiesBuilder(apiKey).build()) - .withModules(modules).buildComputeServiceContext(); + return new RimuHostingContextBuilder("rimuhosting", new RimuHostingPropertiesBuilder(apiKey) + .build()).withModules(modules).buildComputeServiceContext(); } public static ComputeServiceContext createContext(String apiKey, Module... modules) { - return new RimuHostingContextBuilder(new RimuHostingPropertiesBuilder(apiKey).build()) - .withModules(modules).buildComputeServiceContext(); + return new RimuHostingContextBuilder("rimuhosting", new RimuHostingPropertiesBuilder(apiKey) + .build()).withModules(modules).buildComputeServiceContext(); } } diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java index c23b483385..6710d21f95 100755 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java @@ -97,6 +97,11 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ public class RimuHostingComputeServiceContextModule extends RimuHostingContextModule { + private final String providerName; + + public RimuHostingComputeServiceContextModule(String providerName) { + this.providerName = providerName; + } @Override protected void configure() { @@ -338,10 +343,11 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo Function indexer) { final Set locations = Sets.newHashSet(); holder.logger.debug(">> providing locations"); + Location provider = new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null); for (final PricingPlan from : sync.getPricingPlanList()) { try { locations.add(new LocationImpl(LocationScope.ZONE, from.getDataCenter().getId(), from - .getDataCenter().getName(), null)); + .getDataCenter().getName(), provider)); } catch (NullPointerException e) { holder.logger.warn("datacenter not present in " + from.getId()); } 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 7594ff5d60..3971315f53 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 @@ -168,7 +168,7 @@ public class ComputeTask extends Task { private void listLocations(ComputeService computeService) { log("list locations"); - for (Location location : computeService.getLocations().values()) {// TODO + for (Location location : computeService.getAssignableLocations().values()) {// TODO log(String.format(" location id=%s, scope=%s, description=%s, parent=%s", location .getId(), location.getScope(), location.getDescription(), location.getParent())); } diff --git a/twitter/src/main/java/org/jclouds/twitter/TwitterContextBuilder.java b/twitter/src/main/java/org/jclouds/twitter/TwitterContextBuilder.java index df1d8b3241..1fd87885b1 100755 --- a/twitter/src/main/java/org/jclouds/twitter/TwitterContextBuilder.java +++ b/twitter/src/main/java/org/jclouds/twitter/TwitterContextBuilder.java @@ -37,8 +37,8 @@ import com.google.inject.TypeLiteral; */ public class TwitterContextBuilder extends RestContextBuilder { - public TwitterContextBuilder(Properties props) { - super(new TypeLiteral() { + public TwitterContextBuilder(String providerName, Properties props) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, props); checkNotNull(properties.getProperty(TwitterConstants.PROPERTY_TWITTER_USER)); @@ -50,8 +50,8 @@ public class TwitterContextBuilder extends RestContextBuilder modules) { - modules.add(new TwitterContextModule()); + protected void addContextModule(String providerName, List modules) { + modules.add(new TwitterContextModule(providerName)); } } diff --git a/twitter/src/main/java/org/jclouds/twitter/TwitterContextFactory.java b/twitter/src/main/java/org/jclouds/twitter/TwitterContextFactory.java index 1c99dc874a..24c74a8f0d 100644 --- a/twitter/src/main/java/org/jclouds/twitter/TwitterContextFactory.java +++ b/twitter/src/main/java/org/jclouds/twitter/TwitterContextFactory.java @@ -44,13 +44,13 @@ public class TwitterContextFactory { public static RestContext createContext(String user, String password, Module... modules) { - return new TwitterContextBuilder(new TwitterPropertiesBuilder(user, password).build()) - .withModules(modules).buildContext(); + return new TwitterContextBuilder("twitter", new TwitterPropertiesBuilder(user, password) + .build()).withModules(modules).buildContext(); } public static RestContext createContext( Properties properties, Module... modules) { - return new TwitterContextBuilder(new TwitterPropertiesBuilder(properties).build()) + return new TwitterContextBuilder("twitter", new TwitterPropertiesBuilder(properties).build()) .withModules(modules).buildContext(); } diff --git a/twitter/src/main/java/org/jclouds/twitter/config/TwitterContextModule.java b/twitter/src/main/java/org/jclouds/twitter/config/TwitterContextModule.java index 578b1cbba5..fe54571962 100644 --- a/twitter/src/main/java/org/jclouds/twitter/config/TwitterContextModule.java +++ b/twitter/src/main/java/org/jclouds/twitter/config/TwitterContextModule.java @@ -42,6 +42,9 @@ import com.google.inject.Provides; * @author Adrian Cole */ public class TwitterContextModule extends AbstractModule { + public TwitterContextModule(String providerName) { + } + @Override protected void configure() { bind(DateAdapter.class).to(CDateAdapter.class); diff --git a/twitter/src/test/java/org/jclouds/twitter/config/TwitterContextModuleTest.java b/twitter/src/test/java/org/jclouds/twitter/config/TwitterContextModuleTest.java index b38f3f3872..ac5bf20a67 100644 --- a/twitter/src/test/java/org/jclouds/twitter/config/TwitterContextModuleTest.java +++ b/twitter/src/test/java/org/jclouds/twitter/config/TwitterContextModuleTest.java @@ -50,20 +50,21 @@ import com.google.inject.Injector; public class TwitterContextModuleTest { Injector createInjector() { - return Guice.createInjector(new TwitterRestClientModule(), new TwitterContextModule() { - @Override - protected void configure() { - Jsr330.bindProperties(this.binder(), new TwitterPropertiesBuilder("user", "pass") - .build()); - bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() { - public Logger getLogger(String category) { - return Logger.NULL; - } - }); - bind(UriBuilder.class).to(UriBuilderImpl.class); - super.configure(); - } - }, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(), + return Guice.createInjector(new TwitterRestClientModule(), + new TwitterContextModule("twitter") { + @Override + protected void configure() { + Jsr330.bindProperties(this.binder(), new TwitterPropertiesBuilder("user", + "pass").build()); + bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() { + public Logger getLogger(String category) { + return Logger.NULL; + } + }); + bind(UriBuilder.class).to(UriBuilderImpl.class); + super.configure(); + } + }, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(), new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor())); } diff --git a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextBuilder.java b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextBuilder.java index ab444e4134..863d7d8b01 100644 --- a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextBuilder.java +++ b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextBuilder.java @@ -24,14 +24,15 @@ import java.util.Properties; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.vcloud.VCloudContextBuilder; +import org.jclouds.vcloud.bluelock.compute.config.BlueLockVCloudComputeServiceContextModule; import org.jclouds.vcloud.bluelock.config.BlueLockVCloudRestClientModule; import com.google.inject.Injector; import com.google.inject.Module; /** - * Creates {@link BlueLockVCloudComputeServiceContext} or {@link Injector} instances based on - * the most commonly requested arguments. + * Creates {@link BlueLockVCloudComputeServiceContext} or {@link Injector} instances based on the + * most commonly requested arguments. *

* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. *

@@ -42,11 +43,15 @@ import com.google.inject.Module; * @author Adrian Cole * @see BlueLockVCloudComputeServiceContext */ -public class BlueLockVCloudContextBuilder extends - VCloudContextBuilder { +public class BlueLockVCloudContextBuilder extends VCloudContextBuilder { - public BlueLockVCloudContextBuilder(Properties props) { - super(props); + public BlueLockVCloudContextBuilder(String providerName, Properties props) { + super(providerName, props); + } + + @Override + protected void addContextModule(String providerName, List modules) { + modules.add(new BlueLockVCloudComputeServiceContextModule(providerName)); } @Override diff --git a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextFactory.java b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextFactory.java index f6942f7095..3ba1b101fa 100644 --- a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextFactory.java +++ b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudContextFactory.java @@ -42,28 +42,26 @@ import com.google.inject.Module; */ public class BlueLockVCloudContextFactory { public static ComputeServiceContext createContext(Properties properties, Module... modules) { - return new BlueLockVCloudContextBuilder( - new BlueLockVCloudPropertiesBuilder(properties).build()).withModules(modules) - .buildComputeServiceContext(); + return new BlueLockVCloudContextBuilder("bluelock", new BlueLockVCloudPropertiesBuilder( + properties).build()).withModules(modules).buildComputeServiceContext(); } public static ComputeServiceContext createContext(String user, String key, Module... modules) { - return new BlueLockVCloudContextBuilder( - new BlueLockVCloudPropertiesBuilder(user, key).build()).withModules(modules) - .buildComputeServiceContext(); + return new BlueLockVCloudContextBuilder("bluelock", new BlueLockVCloudPropertiesBuilder(user, + key).build()).withModules(modules).buildComputeServiceContext(); } public static ComputeServiceContext createContext(Properties properties, String user, String key, Module... modules) { - return new BlueLockVCloudContextBuilder( - new BlueLockVCloudPropertiesBuilder(properties).withCredentials(user, key) - .build()).withModules(modules).buildComputeServiceContext(); + return new BlueLockVCloudContextBuilder("bluelock", new BlueLockVCloudPropertiesBuilder( + properties).withCredentials(user, key).build()).withModules(modules) + .buildComputeServiceContext(); } public static ComputeServiceContext createContext(URI endpoint, String user, String key, Module... modules) { - return new BlueLockVCloudContextBuilder( - new BlueLockVCloudPropertiesBuilder(user, key).withEndpoint(endpoint).build()) - .withModules(modules).buildComputeServiceContext(); + return new BlueLockVCloudContextBuilder("bluelock", new BlueLockVCloudPropertiesBuilder(user, + key).withEndpoint(endpoint).build()).withModules(modules) + .buildComputeServiceContext(); } } diff --git a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeClient.java b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeClient.java index 0e43ba198d..bf46ffb4dd 100644 --- a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeClient.java +++ b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeClient.java @@ -7,31 +7,39 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.compute.domain.NodeState; +import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; +import org.jclouds.domain.Credentials; import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.compute.BaseVCloudComputeClient; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VAppStatus; import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableMap; /** * @author Adrian Cole */ @Singleton public class BlueLockVCloudComputeClient extends BaseVCloudComputeClient { + private final PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider; + @Inject - protected BlueLockVCloudComputeClient(VCloudClient client, Predicate successTester, + protected BlueLockVCloudComputeClient( + PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider, + VCloudClient client, Predicate successTester, @Named("NOT_FOUND") Predicate notFoundTester, Map vAppStatusToNodeState) { super(client, successTester, notFoundTester, vAppStatusToNodeState); + this.credentialsProvider = credentialsProvider; } @Override - protected Map parseResponse(String templateId, VApp vAppResponse) { - // https://forums.bluelock.com/faq.php?faq=vcloudexpressfaq - return ImmutableMap. of("id", vAppResponse.getId(), "username", (vAppResponse - .getOperatingSystemDescription().indexOf("buntu") != -1) ? "express" : "root", - "password", "ExpressPassword#1"); + protected Map parseAndValidateResponse(String templateId, VApp vAppResponse) { + Credentials credentials = credentialsProvider.execute(client.getVAppTemplate(templateId)); + Map toReturn = super.parseResponse(templateId, vAppResponse); + toReturn.put("username", credentials.account); + toReturn.put("password", credentials.key); + return toReturn; } + } \ No newline at end of file diff --git a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/config/BlueLockVCloudComputeServiceContextModule.java b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/config/BlueLockVCloudComputeServiceContextModule.java index 3574be1cc6..bf63af4c77 100644 --- a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/config/BlueLockVCloudComputeServiceContextModule.java +++ b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/config/BlueLockVCloudComputeServiceContextModule.java @@ -18,7 +18,9 @@ */ package org.jclouds.vcloud.bluelock.compute.config; +import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; import org.jclouds.vcloud.bluelock.compute.BlueLockVCloudComputeClient; +import org.jclouds.vcloud.bluelock.compute.strategy.DefaultLoginCredentialsFromBlueLockFAQ; import org.jclouds.vcloud.compute.VCloudComputeClient; import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; @@ -30,10 +32,16 @@ import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; */ public class BlueLockVCloudComputeServiceContextModule extends VCloudComputeServiceContextModule { + public BlueLockVCloudComputeServiceContextModule(String providerName) { + super(providerName); + } + @Override protected void configure() { super.configure(); bind(VCloudComputeClient.class).to(BlueLockVCloudComputeClient.class); + bind(PopulateDefaultLoginCredentialsForImageStrategy.class).to( + DefaultLoginCredentialsFromBlueLockFAQ.class); } } diff --git a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/strategy/DefaultLoginCredentialsFromBlueLockFAQ.java b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/strategy/DefaultLoginCredentialsFromBlueLockFAQ.java new file mode 100644 index 0000000000..dd0e95e9a5 --- /dev/null +++ b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/strategy/DefaultLoginCredentialsFromBlueLockFAQ.java @@ -0,0 +1,39 @@ +package org.jclouds.vcloud.bluelock.compute.strategy; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Singleton; + +import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; +import org.jclouds.domain.Credentials; +import org.jclouds.vcloud.domain.VAppTemplate; + +/** + * + * from https://forums.bluelock.com/faq.php?faq=vcloudexpressfaq + * + * @author Adrian Cole + * + */ +@Singleton +public class DefaultLoginCredentialsFromBlueLockFAQ implements + PopulateDefaultLoginCredentialsForImageStrategy { + + @Override + public Credentials execute(Object resourceToAuthenticate) { + checkNotNull(resourceToAuthenticate); + checkArgument(resourceToAuthenticate instanceof VAppTemplate, + "Resource must be an VAppTemplate (for Terremark)"); + VAppTemplate template = (VAppTemplate) resourceToAuthenticate; + if (template.getDescription().indexOf("Windows") >= 0) { + return new Credentials("expressuser", "ExpressPassword#1"); + } else { + if (template.getDescription().indexOf("buntu") != -1) { + return new Credentials("express", "ExpressPassword#1"); + } else { + return new Credentials("root", "ExpressPassword#1"); + } + } + } +} diff --git a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/BlueLockVCloudClientLiveTest.java b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/BlueLockVCloudClientLiveTest.java index e033575ebe..2ac5804103 100644 --- a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/BlueLockVCloudClientLiveTest.java +++ b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/BlueLockVCloudClientLiveTest.java @@ -43,9 +43,9 @@ public class BlueLockVCloudClientLiveTest extends VCloudClientLiveTest { public void setupClient() { account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); - Injector injector = new BlueLockVCloudContextBuilder(new BlueLockVCloudPropertiesBuilder( - account, key).build()).withModules(new Log4JLoggingModule(), - new JschSshClientModule()).buildInjector(); + Injector injector = new BlueLockVCloudContextBuilder("bluelock", + new BlueLockVCloudPropertiesBuilder(account, key).build()).withModules( + new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); connection = injector.getInstance(VCloudClient.class); } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java index b2bc81de0d..3ea0a924b4 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java @@ -50,15 +50,15 @@ import com.google.inject.TypeLiteral; public class VCloudContextBuilder extends ComputeServiceContextBuilder { - public VCloudContextBuilder(Properties props) { - super(new TypeLiteral() { + public VCloudContextBuilder(String providerName, Properties props) { + super(providerName, new TypeLiteral() { }, new TypeLiteral() { }, props); } @Override - protected void addContextModule(List modules) { - modules.add(new VCloudComputeServiceContextModule()); + protected void addContextModule(String providerName, List modules) { + modules.add(new VCloudComputeServiceContextModule(providerName)); } @Override diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudContextFactory.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudContextFactory.java index 1d2ffa54c3..335eada2b7 100755 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudContextFactory.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudContextFactory.java @@ -28,8 +28,8 @@ import org.jclouds.logging.jdk.config.JDKLoggingModule; import com.google.inject.Module; /** - * Creates {@link VCloudComputeServiceContext} instances based on the most commonly - * requested arguments. + * Creates {@link VCloudComputeServiceContext} instances based on the most commonly requested + * arguments. *

* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. *

@@ -42,22 +42,20 @@ import com.google.inject.Module; */ public class VCloudContextFactory { public static ComputeServiceContext createContext(Properties properties, Module... modules) { - return new VCloudContextBuilder( - new VCloudPropertiesBuilder(properties).build()).withModules(modules) - .buildComputeServiceContext(); + return new VCloudContextBuilder("vcloud", new VCloudPropertiesBuilder(properties).build()) + .withModules(modules).buildComputeServiceContext(); } public static ComputeServiceContext createContext(Properties properties, String user, String key, Module... modules) { - return new VCloudContextBuilder( - new VCloudPropertiesBuilder(properties).withCredentials(user, key) - .build()).withModules(modules).buildComputeServiceContext(); + return new VCloudContextBuilder("vcloud", new VCloudPropertiesBuilder(properties) + .withCredentials(user, key).build()).withModules(modules) + .buildComputeServiceContext(); } public static ComputeServiceContext createContext(URI endpoint, String user, String key, Module... modules) { - return new VCloudContextBuilder( - new VCloudPropertiesBuilder(endpoint, user, key).withEndpoint(endpoint).build()) - .withModules(modules).buildComputeServiceContext(); + return new VCloudContextBuilder("vcloud", new VCloudPropertiesBuilder(endpoint, user, key) + .withEndpoint(endpoint).build()).withModules(modules).buildComputeServiceContext(); } } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java index bc75f43a10..b342792c2b 100755 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java @@ -87,16 +87,16 @@ import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VAppStatus; import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.VDC; +import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.common.util.concurrent.ListenableFuture; @@ -110,6 +110,12 @@ import com.google.inject.Provides; */ public class VCloudComputeServiceContextModule extends VCloudContextModule { + private final String providerName; + + public VCloudComputeServiceContextModule(String providerName) { + this.providerName = providerName; + } + @Singleton @Provides Map provideVAppStatusToNodeState() { @@ -364,24 +370,20 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule { @Provides @Singleton - Map provideLocations(final VCloudClient client) { - return Maps.uniqueIndex(Iterables.transform(client.getDefaultOrganization().getVDCs() - .values(), new Function() { + Map provideLocations(Supplier cache, + VCloudClient client) { + Location provider = new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null); + Map locations = Maps.newLinkedHashMap(); - @Override - public Location apply(NamedResource from) { - VDC vdc = client.getVDC(from.getId()); - return new LocationImpl(LocationScope.ZONE, vdc.getId(), vdc.getName(), null); + for (NamedResource org : cache.get().getOrgs().values()) { + Location orgL = new LocationImpl(LocationScope.REGION, org.getId(), org.getName(), + provider); + for (NamedResource vdc : client.getOrganization(org.getId()).getVDCs().values()) { + locations.put(vdc.getId(), new LocationImpl(LocationScope.ZONE, vdc.getId(), vdc + .getName(), orgL)); } - - }), new Function() { - - @Override - public String apply(Location from) { - return from.getId(); - } - - }); + } + return locations; } @Provides diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java index 181d6e5236..8f7a1095fe 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java @@ -160,8 +160,9 @@ public class VCloudClientLiveTest { "jclouds.test.endpoint"); account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); - connection = new VCloudContextBuilder(new VCloudPropertiesBuilder(URI.create(endpoint), - account, key).build()).withModules(new Log4JLoggingModule()).buildContext().getApi(); + connection = new VCloudContextBuilder("vcloud", new VCloudPropertiesBuilder(URI + .create(endpoint), account, key).build()).withModules(new Log4JLoggingModule()) + .buildContext().getApi(); } } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudLoginLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudLoginLiveTest.java index db0dcbf285..cc694c459e 100755 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudLoginLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudLoginLiveTest.java @@ -135,12 +135,12 @@ public class VCloudLoginLiveTest { + "/v0.8/login"; String account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); - context = new RestContextBuilder( + context = new RestContextBuilder("vcloud", new TypeLiteral() { }, new TypeLiteral() { }, new VCloudPropertiesBuilder(URI.create(endpoint), account, key).build()) { - public void addContextModule(List modules) { + public void addContextModule(String providerName, List modules) { modules.add(new VCloudLoginContextModule()); } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudVersionsLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudVersionsLiveTest.java index 05100afa77..00db782e7f 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudVersionsLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudVersionsLiveTest.java @@ -118,11 +118,11 @@ public class VCloudVersionsLiveTest { String account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); context = new RestContextBuilder( - new TypeLiteral() { + "vcloud", new TypeLiteral() { }, new TypeLiteral() { }, new VCloudPropertiesBuilder(URI.create(endpoint), account, key).build()) { - public void addContextModule(List modules) { + public void addContextModule(String providerName, List modules) { modules.add(new VCloudVersionsContextModule()); } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeClientLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeClientLiveTest.java index b35673c1cf..1b785dab4d 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeClientLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeClientLiveTest.java @@ -146,8 +146,8 @@ public class VCloudComputeClientLiveTest { String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"), "jclouds.test.endpoint"); - Injector injector = new VCloudContextBuilder(new VCloudPropertiesBuilder( - URI.create(endpoint), account, key).build()).withModules(new Log4JLoggingModule(), + Injector injector = new VCloudContextBuilder("vcloud", new VCloudPropertiesBuilder(URI + .create(endpoint), account, key).build()).withModules(new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); computeClient = injector.getInstance(VCloudComputeClient.class); client = injector.getInstance(VCloudClient.class); diff --git a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudContextBuilder.java b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudContextBuilder.java index bb98d1abdd..8592196b55 100644 --- a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudContextBuilder.java +++ b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudContextBuilder.java @@ -43,16 +43,15 @@ import com.google.inject.Module; * @author Adrian Cole * @see HostingDotComVCloudComputeServiceContext */ -public class HostingDotComVCloudContextBuilder extends - VCloudContextBuilder { +public class HostingDotComVCloudContextBuilder extends VCloudContextBuilder { - public HostingDotComVCloudContextBuilder(Properties props) { - super(props); + public HostingDotComVCloudContextBuilder(String providerName, Properties props) { + super(providerName, props); } @Override - protected void addContextModule(List modules) { - modules.add(new HostingDotComVCloudComputeServiceContextModule()); + protected void addContextModule(String providerName, List modules) { + modules.add(new HostingDotComVCloudComputeServiceContextModule(providerName)); } @Override diff --git a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudContextFactory.java b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudContextFactory.java index 8396371c09..ec982c09c5 100644 --- a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudContextFactory.java +++ b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/HostingDotComVCloudContextFactory.java @@ -42,27 +42,27 @@ import com.google.inject.Module; */ public class HostingDotComVCloudContextFactory { public static ComputeServiceContext createContext(Properties properties, Module... modules) { - return new HostingDotComVCloudContextBuilder( + return new HostingDotComVCloudContextBuilder("hostingdotcom", new HostingDotComVCloudPropertiesBuilder(properties).build()).withModules(modules) .buildComputeServiceContext(); } public static ComputeServiceContext createContext(String user, String key, Module... modules) { - return new HostingDotComVCloudContextBuilder( + return new HostingDotComVCloudContextBuilder("hostingdotcom", new HostingDotComVCloudPropertiesBuilder(user, key).build()).withModules(modules) .buildComputeServiceContext(); } public static ComputeServiceContext createContext(Properties properties, String user, String key, Module... modules) { - return new HostingDotComVCloudContextBuilder( + return new HostingDotComVCloudContextBuilder("hostingdotcom", new HostingDotComVCloudPropertiesBuilder(properties).withCredentials(user, key) .build()).withModules(modules).buildComputeServiceContext(); } public static ComputeServiceContext createContext(URI endpoint, String user, String key, Module... modules) { - return new HostingDotComVCloudContextBuilder( + return new HostingDotComVCloudContextBuilder("hostingdotcom", new HostingDotComVCloudPropertiesBuilder(user, key).withEndpoint(endpoint).build()) .withModules(modules).buildComputeServiceContext(); } diff --git a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/compute/config/HostingDotComVCloudComputeServiceContextModule.java b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/compute/config/HostingDotComVCloudComputeServiceContextModule.java index 061b4e5980..0a7513037e 100755 --- a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/compute/config/HostingDotComVCloudComputeServiceContextModule.java +++ b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/compute/config/HostingDotComVCloudComputeServiceContextModule.java @@ -22,6 +22,8 @@ import static org.jclouds.compute.domain.OsFamily.CENTOS; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.internal.TemplateBuilderImpl; +import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; +import org.jclouds.compute.strategy.impl.ReturnNullCredentials; import org.jclouds.vcloud.compute.VCloudComputeClient; import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; import org.jclouds.vcloud.hostingdotcom.compute.HostingDotComVCloudComputeClient; @@ -35,10 +37,15 @@ import org.jclouds.vcloud.hostingdotcom.compute.HostingDotComVCloudComputeClient public class HostingDotComVCloudComputeServiceContextModule extends VCloudComputeServiceContextModule { + public HostingDotComVCloudComputeServiceContextModule(String providerName) { + super(providerName); + } + @Override protected void configure() { super.configure(); bind(VCloudComputeClient.class).to(HostingDotComVCloudComputeClient.class); + bind(PopulateDefaultLoginCredentialsForImageStrategy.class).to(ReturnNullCredentials.class); } @Override 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 2ed33a01a4..4d83e30e1c 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 @@ -41,7 +41,7 @@ public class HostingDotComVCloudClientLiveTest extends VCloudClientLiveTest { public void setupClient() { 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( + Injector injector = new HostingDotComVCloudContextBuilder("hostingdotcom", new HostingDotComVCloudPropertiesBuilder(account, key).build()) .withModules(new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); 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 24c9a02465..f955c969d6 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 @@ -51,15 +51,14 @@ public class HostingDotComVCloudComputeClientLiveTest extends VCloudComputeClien public void setupClient() { 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( + Injector injector = new HostingDotComVCloudContextBuilder("hostingdotcom", new HostingDotComVCloudPropertiesBuilder(account, key).build()).withModules( new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); computeClient = injector.getInstance(HostingDotComVCloudComputeClient.class); client = injector.getInstance(HostingDotComVCloudClient.class); addressTester = injector.getInstance(Key.get(new TypeLiteral>() { })); - expectationMap = ImmutableMap. builder().put( - OsFamily.CENTOS, + expectationMap = ImmutableMap. builder().put(OsFamily.CENTOS, new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).build(); service = "vcloudtest"; templateId = "3"; diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudContextBuilder.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudContextBuilder.java index 7203dc1325..5d70309c96 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudContextBuilder.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudContextBuilder.java @@ -45,13 +45,13 @@ import com.google.inject.Module; */ public class TerremarkVCloudContextBuilder extends VCloudContextBuilder { - public TerremarkVCloudContextBuilder(Properties props) { - super(props); + public TerremarkVCloudContextBuilder(String providerName, Properties props) { + super(providerName, props); } @Override - protected void addContextModule(List modules) { - modules.add(new TerremarkVCloudComputeServiceContextModule()); + protected void addContextModule(String providerName, List modules) { + modules.add(new TerremarkVCloudComputeServiceContextModule(providerName)); } @Override diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudContextFactory.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudContextFactory.java index 310581c1c7..8240cbb44c 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudContextFactory.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudContextFactory.java @@ -42,25 +42,25 @@ import com.google.inject.Module; */ public class TerremarkVCloudContextFactory { public static ComputeServiceContext createContext(Properties properties, Module... modules) { - return new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder( + return new TerremarkVCloudContextBuilder("terremark", new TerremarkVCloudPropertiesBuilder( properties).build()).withModules(modules).buildComputeServiceContext(); } public static ComputeServiceContext createContext(String user, String key, Module... modules) { - return new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder( + return new TerremarkVCloudContextBuilder("terremark", new TerremarkVCloudPropertiesBuilder( user, key).build()).withModules(modules).buildComputeServiceContext(); } public static ComputeServiceContext createContext(Properties properties, String user, String key, Module... modules) { - return new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder( + return new TerremarkVCloudContextBuilder("terremark", new TerremarkVCloudPropertiesBuilder( properties).withCredentials(user, key).build()).withModules(modules) .buildComputeServiceContext(); } public static ComputeServiceContext createContext(URI endpoint, String user, String key, Module... modules) { - return new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder( + return new TerremarkVCloudContextBuilder("terremark", new TerremarkVCloudPropertiesBuilder( user, key).withEndpoint(endpoint).build()).withModules(modules) .buildComputeServiceContext(); } diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java index 643f9a8e75..ee28d1131e 100755 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java @@ -73,6 +73,10 @@ import com.google.inject.Provides; */ public class TerremarkVCloudComputeServiceContextModule extends VCloudComputeServiceContextModule { + public TerremarkVCloudComputeServiceContextModule(String providerName) { + super(providerName); + } + @Override protected void configure() { super.configure(); 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 d6d9620694..2228932808 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 @@ -104,7 +104,7 @@ public class InternetServiceLiveTest { public void setupClient() { 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( + Injector injector = new TerremarkVCloudContextBuilder("terremark", new TerremarkVCloudPropertiesBuilder( account, key).build()).withModules(new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); 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 ac833b316a..81a832749a 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 @@ -472,8 +472,8 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest { public void setupClient() { 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).build()).withModules(new Log4JLoggingModule(), + Injector injector = new TerremarkVCloudContextBuilder("terremark", + new TerremarkVCloudPropertiesBuilder( account, key).build()).withModules(new Log4JLoggingModule(), new JschSshClientModule()).buildInjector(); connection = tmClient = injector.getInstance(TerremarkVCloudClient.class);