mirror of https://github.com/apache/jclouds.git
Issues 203 234 235, add visibility to image from nodemetadata, update to stable version of guava, harden tests, normalize location
This commit is contained in:
parent
82bb9e98f7
commit
10af8cdae8
|
@ -21,7 +21,7 @@
|
||||||
package ${package}.config;
|
package ${package}.config;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
|
|
||||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||||
import org.jclouds.http.HttpRetryHandler;
|
import org.jclouds.http.HttpRetryHandler;
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
package ${package}.config;
|
package ${package}.config;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
|
|
||||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||||
import org.jclouds.http.HttpRetryHandler;
|
import org.jclouds.http.HttpRetryHandler;
|
||||||
|
|
|
@ -18,12 +18,14 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.atmosonline.saas;
|
package org.jclouds.atmosonline.saas;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
|
||||||
|
@ -67,7 +69,7 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "emcsaas.AtmosStorageClientTest")
|
@Test(groups = "unit", testName = "emcsaas.AtmosStorageClientTest")
|
||||||
public class AtmosStorageClientTest extends RestClientTest<AtmosStorageAsyncClient> {
|
public class AtmosStorageAsyncClientTest extends RestClientTest<AtmosStorageAsyncClient> {
|
||||||
|
|
||||||
private BlobToObject blobToObject;
|
private BlobToObject blobToObject;
|
||||||
|
|
||||||
|
@ -294,12 +296,11 @@ public class AtmosStorageClientTest extends RestClientTest<AtmosStorageAsyncClie
|
||||||
}, new TypeLiteral<AtmosStorageClient>() {
|
}, new TypeLiteral<AtmosStorageClient>() {
|
||||||
}));
|
}));
|
||||||
install(new AtmosObjectModule());
|
install(new AtmosObjectModule());
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new AtmosStoragePropertiesBuilder(
|
||||||
|
new Properties()).build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(AtmosStorage.class).toInstance(
|
bind(URI.class).annotatedWith(AtmosStorage.class).toInstance(
|
||||||
URI.create("http://accesspoint.emccis.com"));
|
URI.create("http://accesspoint.emccis.com"));
|
||||||
bind(String.class).annotatedWith(TimeStamp.class).toInstance("timestamp");
|
bind(String.class).annotatedWith(TimeStamp.class).toInstance("timestamp");
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(AtmosStorageConstants.PROPERTY_EMCSAAS_ENDPOINT)).to(
|
|
||||||
"http://accesspoint.emccis.com");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(AtmosStorageConstants.PROPERTY_EMCSAAS_UID))
|
bindConstant().annotatedWith(Jsr330.named(AtmosStorageConstants.PROPERTY_EMCSAAS_UID))
|
||||||
.to("uid");
|
.to("uid");
|
||||||
bindConstant().annotatedWith(Jsr330.named(AtmosStorageConstants.PROPERTY_EMCSAAS_KEY))
|
bindConstant().annotatedWith(Jsr330.named(AtmosStorageConstants.PROPERTY_EMCSAAS_KEY))
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.atmosonline.saas.blobstore.config;
|
package org.jclouds.atmosonline.saas.blobstore.config;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.atmosonline.saas.config;
|
package org.jclouds.atmosonline.saas.config;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.atmosonline.saas.filters;
|
package org.jclouds.atmosonline.saas.filters;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -138,15 +138,8 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class GetRegionFromNodeOrDefault implements Function<ComputeMetadata, Region> {
|
public static class GetRegionFromNodeOrDefault implements Function<ComputeMetadata, Region> {
|
||||||
private final Map<String, ? extends Location> locations;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
protected GetRegionFromNodeOrDefault(Map<String, ? extends Location> locations) {
|
|
||||||
this.locations = locations;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Region apply(ComputeMetadata node) {
|
public Region apply(ComputeMetadata node) {
|
||||||
Location location = locations.get(node.getLocationId());
|
Location location = node.getLocation();
|
||||||
Region region = location.getScope() == LocationScope.REGION ? Region.fromValue(location
|
Region region = location.getScope() == LocationScope.REGION ? Region.fromValue(location
|
||||||
.getId()) : Region.fromValue(location.getParent());
|
.getId()) : Region.fromValue(location.getParent());
|
||||||
return region;
|
return region;
|
||||||
|
@ -261,11 +254,11 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
||||||
Set<Location> locations = Sets.newHashSet();
|
Set<Location> locations = Sets.newHashSet();
|
||||||
for (AvailabilityZone zone : map.keySet()) {
|
for (AvailabilityZone zone : map.keySet()) {
|
||||||
locations.add(new LocationImpl(LocationScope.ZONE, zone.toString(), zone.toString(), map
|
locations.add(new LocationImpl(LocationScope.ZONE, zone.toString(), zone.toString(), map
|
||||||
.get(zone).toString(), true));
|
.get(zone).toString()));
|
||||||
}
|
}
|
||||||
for (Region region : map.values()) {
|
for (Region region : map.values()) {
|
||||||
locations.add(new LocationImpl(LocationScope.REGION, region.toString(), region.toString(),
|
locations.add(new LocationImpl(LocationScope.REGION, region.toString(), region.toString(),
|
||||||
null, true));
|
null));
|
||||||
}
|
}
|
||||||
return Maps.uniqueIndex(locations, new Function<Location, String>() {
|
return Maps.uniqueIndex(locations, new Function<Location, String>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.compute.functions;
|
package org.jclouds.aws.ec2.compute.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -35,6 +37,7 @@ import org.jclouds.compute.domain.internal.ImageImpl;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -58,10 +61,14 @@ public class ImageParser implements Function<org.jclouds.aws.ec2.domain.Image, I
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private final PopulateDefaultLoginCredentialsForImageStrategy credentialProvider;
|
private final PopulateDefaultLoginCredentialsForImageStrategy credentialProvider;
|
||||||
|
private final Map<String, ? extends Location> locations;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ImageParser(PopulateDefaultLoginCredentialsForImageStrategy credentialProvider) {
|
ImageParser(PopulateDefaultLoginCredentialsForImageStrategy credentialProvider,
|
||||||
this.credentialProvider = credentialProvider;
|
Map<String, ? extends Location> locations) {
|
||||||
|
this.credentialProvider = checkNotNull(credentialProvider, "credentialProvider");
|
||||||
|
this.locations = checkNotNull(locations, "locations");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -98,7 +105,7 @@ public class ImageParser implements Function<org.jclouds.aws.ec2.domain.Image, I
|
||||||
return new ImageImpl(
|
return new ImageImpl(
|
||||||
from.getId(),
|
from.getId(),
|
||||||
name,
|
name,
|
||||||
from.getRegion().toString(),
|
locations.get(from.getRegion().toString()),
|
||||||
null,
|
null,
|
||||||
ImmutableMap.<String, String> of("owner", from.getImageOwnerId()),
|
ImmutableMap.<String, String> of("owner", from.getImageOwnerId()),
|
||||||
description,
|
description,
|
||||||
|
|
|
@ -30,18 +30,19 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.compute.domain.RegionTag;
|
import org.jclouds.aws.ec2.compute.domain.RegionTag;
|
||||||
import org.jclouds.aws.ec2.domain.Image;
|
|
||||||
import org.jclouds.aws.ec2.domain.InstanceState;
|
import org.jclouds.aws.ec2.domain.InstanceState;
|
||||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||||
import org.jclouds.aws.ec2.domain.RunningInstance;
|
import org.jclouds.aws.ec2.domain.RunningInstance;
|
||||||
import org.jclouds.aws.ec2.functions.InstanceTypeToStorageMappingUnix;
|
import org.jclouds.aws.ec2.functions.InstanceTypeToStorageMappingUnix;
|
||||||
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
||||||
import org.jclouds.aws.ec2.services.AMIClient;
|
import org.jclouds.aws.ec2.services.AMIClient;
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeState;
|
||||||
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
||||||
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -62,13 +63,18 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
|
||||||
private final AMIClient amiClient;
|
private final AMIClient amiClient;
|
||||||
private final Map<RegionTag, KeyPair> credentialsMap;
|
private final Map<RegionTag, KeyPair> credentialsMap;
|
||||||
private final PopulateDefaultLoginCredentialsForImageStrategy credentialProvider;
|
private final PopulateDefaultLoginCredentialsForImageStrategy credentialProvider;
|
||||||
|
private final Map<String, ? extends Image> images;
|
||||||
|
private final Map<String, ? extends Location> locations;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RunningInstanceToNodeMetadata(AMIClient amiClient, Map<RegionTag, KeyPair> credentialsMap,
|
RunningInstanceToNodeMetadata(AMIClient amiClient, Map<RegionTag, KeyPair> credentialsMap,
|
||||||
PopulateDefaultLoginCredentialsForImageStrategy credentialProvider) {
|
PopulateDefaultLoginCredentialsForImageStrategy credentialProvider,
|
||||||
|
Map<String, ? extends Image> images, Map<String, ? extends Location> locations) {
|
||||||
this.amiClient = checkNotNull(amiClient, "amiClient");
|
this.amiClient = checkNotNull(amiClient, "amiClient");
|
||||||
this.credentialsMap = checkNotNull(credentialsMap, "credentialsMap");
|
this.credentialsMap = checkNotNull(credentialsMap, "credentialsMap");
|
||||||
this.credentialProvider = checkNotNull(credentialProvider, "credentialProvider");
|
this.credentialProvider = checkNotNull(credentialProvider, "credentialProvider");
|
||||||
|
this.images = checkNotNull(images, "images");
|
||||||
|
this.locations = checkNotNull(locations, "locations");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -97,8 +103,9 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
|
||||||
|
|
||||||
Map<String, String> extra = getExtra(instance);
|
Map<String, String> extra = getExtra(instance);
|
||||||
|
|
||||||
return new NodeMetadataImpl(id, name, locationId, uri, userMetadata, tag, state,
|
return new NodeMetadataImpl(id, name, locations.get(locationId), uri, userMetadata, tag,
|
||||||
publicAddresses, privateAddresses, extra, credentials);
|
images.get(instance.getImageId()), state, publicAddresses, privateAddresses, extra,
|
||||||
|
credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,14 +133,14 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
|
||||||
String getPrivateKeyOrNull(RunningInstance instance, String tag) {
|
String getPrivateKeyOrNull(RunningInstance instance, String tag) {
|
||||||
KeyPair keyPair = credentialsMap.get(new RegionTag(instance.getRegion(), instance
|
KeyPair keyPair = credentialsMap.get(new RegionTag(instance.getRegion(), instance
|
||||||
.getKeyName()));
|
.getKeyName()));
|
||||||
String privateKey = keyPair != null ? keyPair.getKeyMaterial() : null;
|
return keyPair != null ? keyPair.getKeyMaterial() : null;
|
||||||
return privateKey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
String getLoginAccountFor(RunningInstance from) {
|
String getLoginAccountFor(RunningInstance from) {
|
||||||
Image image = Iterables.getOnlyElement(amiClient.describeImagesInRegion(from.getRegion(),
|
org.jclouds.aws.ec2.domain.Image image = Iterables.getOnlyElement(amiClient
|
||||||
DescribeImagesOptions.Builder.imageIds(from.getImageId())));
|
.describeImagesInRegion(from.getRegion(), DescribeImagesOptions.Builder
|
||||||
|
.imageIds(from.getImageId())));
|
||||||
return checkNotNull(credentialProvider.execute(image), "login from image: "
|
return checkNotNull(credentialProvider.execute(image), "login from image: "
|
||||||
+ from.getImageId()).account;
|
+ from.getImageId()).account;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,8 +111,8 @@ public class EC2ComputeServiceTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private TemplateBuilder newTemplateBuilder() {
|
private TemplateBuilder newTemplateBuilder() {
|
||||||
Location location = new LocationImpl(LocationScope.REGION, "us-east-1", "us east", null, true);
|
Location location = new LocationImpl(LocationScope.REGION, "us-east-1", "us east", null);
|
||||||
Image image = new ImageImpl("ami-image", "image", "us-east-1", null, Maps
|
Image image = new ImageImpl("ami-image", "image", location, null, Maps
|
||||||
.<String, String> newHashMap(), "description", "1.0", null, "ubuntu",
|
.<String, String> newHashMap(), "description", "1.0", null, "ubuntu",
|
||||||
Architecture.X86_64, new Credentials("root", null));
|
Architecture.X86_64, new Credentials("root", null));
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.jclouds.aws.ec2.compute.strategy.EC2PopulateDefaultLoginCredentialsFo
|
||||||
import org.jclouds.aws.ec2.domain.Image;
|
import org.jclouds.aws.ec2.domain.Image;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeImagesResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeImagesResponseHandler;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
|
@ -51,14 +52,16 @@ public class ImageParserTest extends BaseHandlerTest {
|
||||||
Set<Image> result = parseImages(is);
|
Set<Image> result = parseImages(is);
|
||||||
assertEquals(result.size(), 6);
|
assertEquals(result.size(), 6);
|
||||||
|
|
||||||
ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy());
|
ImageParser parser = new ImageParser(
|
||||||
|
new EC2PopulateDefaultLoginCredentialsForImageStrategy(), ImmutableMap
|
||||||
|
.<String, Location> of());
|
||||||
org.jclouds.compute.domain.Image ubuntuHardy = parser.apply(Iterables.get(result, 0));
|
org.jclouds.compute.domain.Image ubuntuHardy = parser.apply(Iterables.get(result, 0));
|
||||||
|
|
||||||
assertEquals(ubuntuHardy.getArchitecture(), org.jclouds.compute.domain.Architecture.X86_32);
|
assertEquals(ubuntuHardy.getArchitecture(), org.jclouds.compute.domain.Architecture.X86_32);
|
||||||
assertEquals(ubuntuHardy.getDescription(),
|
assertEquals(ubuntuHardy.getDescription(),
|
||||||
"ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml");
|
"ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml");
|
||||||
assertEquals(ubuntuHardy.getId(), "ami-7e28ca17");
|
assertEquals(ubuntuHardy.getId(), "ami-7e28ca17");
|
||||||
assertEquals(ubuntuHardy.getLocationId(), "default");
|
assertEquals(ubuntuHardy.getLocation(), null);
|
||||||
assertEquals(ubuntuHardy.getName(), "8.04");
|
assertEquals(ubuntuHardy.getName(), "8.04");
|
||||||
assertEquals(ubuntuHardy.getOsDescription(),
|
assertEquals(ubuntuHardy.getOsDescription(),
|
||||||
"ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml");
|
"ubuntu-images-us/ubuntu-hardy-8.04-i386-server-20091130.manifest.xml");
|
||||||
|
@ -73,7 +76,7 @@ public class ImageParserTest extends BaseHandlerTest {
|
||||||
assertEquals(alesticKarmic.getDescription(),
|
assertEquals(alesticKarmic.getDescription(),
|
||||||
"alestic/ubuntu-9.10-karmic-base-20090623.manifest.xml");
|
"alestic/ubuntu-9.10-karmic-base-20090623.manifest.xml");
|
||||||
assertEquals(alesticKarmic.getId(), "ami-19a34270");
|
assertEquals(alesticKarmic.getId(), "ami-19a34270");
|
||||||
assertEquals(alesticKarmic.getLocationId(), "default");
|
assertEquals(alesticKarmic.getLocation(), null);
|
||||||
assertEquals(alesticKarmic.getName(), "9.10");
|
assertEquals(alesticKarmic.getName(), "9.10");
|
||||||
assertEquals(alesticKarmic.getOsDescription(),
|
assertEquals(alesticKarmic.getOsDescription(),
|
||||||
"alestic/ubuntu-9.10-karmic-base-20090623.manifest.xml");
|
"alestic/ubuntu-9.10-karmic-base-20090623.manifest.xml");
|
||||||
|
@ -88,7 +91,7 @@ public class ImageParserTest extends BaseHandlerTest {
|
||||||
assertEquals(ubuntuKarmic.getDescription(),
|
assertEquals(ubuntuKarmic.getDescription(),
|
||||||
"ubuntu-images-us/ubuntu-karmic-9.10-i386-server-20100121.manifest.xml");
|
"ubuntu-images-us/ubuntu-karmic-9.10-i386-server-20100121.manifest.xml");
|
||||||
assertEquals(ubuntuKarmic.getId(), "ami-bb709dd2");
|
assertEquals(ubuntuKarmic.getId(), "ami-bb709dd2");
|
||||||
assertEquals(ubuntuKarmic.getLocationId(), "default");
|
assertEquals(ubuntuKarmic.getLocation(), null);
|
||||||
assertEquals(ubuntuKarmic.getName(), "9.10");
|
assertEquals(ubuntuKarmic.getName(), "9.10");
|
||||||
assertEquals(ubuntuKarmic.getOsDescription(),
|
assertEquals(ubuntuKarmic.getOsDescription(),
|
||||||
"ubuntu-images-us/ubuntu-karmic-9.10-i386-server-20100121.manifest.xml");
|
"ubuntu-images-us/ubuntu-karmic-9.10-i386-server-20100121.manifest.xml");
|
||||||
|
@ -106,7 +109,7 @@ public class ImageParserTest extends BaseHandlerTest {
|
||||||
assertEquals(alesticHardy.getDescription(),
|
assertEquals(alesticHardy.getDescription(),
|
||||||
"alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml");
|
"alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml");
|
||||||
assertEquals(alesticHardy.getId(), "ami-c0fa1ea9");
|
assertEquals(alesticHardy.getId(), "ami-c0fa1ea9");
|
||||||
assertEquals(alesticHardy.getLocationId(), "default");
|
assertEquals(alesticHardy.getLocation(), null);
|
||||||
assertEquals(alesticHardy.getName(), "8.04");
|
assertEquals(alesticHardy.getName(), "8.04");
|
||||||
assertEquals(alesticHardy.getOsDescription(),
|
assertEquals(alesticHardy.getOsDescription(),
|
||||||
"alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml");
|
"alestic/ubuntu-8.04-hardy-base-20080905.manifest.xml");
|
||||||
|
@ -124,7 +127,9 @@ public class ImageParserTest extends BaseHandlerTest {
|
||||||
|
|
||||||
Set<Image> result = parseImages(is);
|
Set<Image> result = parseImages(is);
|
||||||
|
|
||||||
ImageParser parser = new ImageParser(new EC2PopulateDefaultLoginCredentialsForImageStrategy());
|
ImageParser parser = new ImageParser(
|
||||||
|
new EC2PopulateDefaultLoginCredentialsForImageStrategy(), ImmutableMap
|
||||||
|
.<String, Location> of());
|
||||||
|
|
||||||
org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0));
|
org.jclouds.compute.domain.Image image = parser.apply(Iterables.get(result, 0));
|
||||||
|
|
||||||
|
@ -132,7 +137,7 @@ public class ImageParserTest extends BaseHandlerTest {
|
||||||
assertEquals(image.getDescription(),
|
assertEquals(image.getDescription(),
|
||||||
"vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml");
|
"vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml");
|
||||||
assertEquals(image.getId(), "ami-870de2ee");
|
assertEquals(image.getId(), "ami-870de2ee");
|
||||||
assertEquals(image.getLocationId(), "default");
|
assertEquals(image.getLocation(), null);
|
||||||
assertEquals(image.getName(), "");
|
assertEquals(image.getName(), "");
|
||||||
assertEquals(image.getOsDescription(),
|
assertEquals(image.getOsDescription(),
|
||||||
"vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml");
|
"vostok-builds/vostok-0.95-5622/vostok-0.95-5622.manifest.xml");
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.aws.ec2.compute.functions;
|
||||||
|
|
||||||
import static org.easymock.EasyMock.expect;
|
import static org.easymock.EasyMock.expect;
|
||||||
import static org.easymock.classextension.EasyMock.createMock;
|
import static org.easymock.classextension.EasyMock.createMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.createNiceMock;
|
||||||
import static org.easymock.classextension.EasyMock.replay;
|
import static org.easymock.classextension.EasyMock.replay;
|
||||||
import static org.easymock.classextension.EasyMock.verify;
|
import static org.easymock.classextension.EasyMock.verify;
|
||||||
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.imageIds;
|
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.imageIds;
|
||||||
|
@ -41,6 +42,9 @@ import org.jclouds.aws.ec2.services.AMIClient;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.domain.LocationScope;
|
||||||
|
import org.jclouds.domain.internal.LocationImpl;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -57,12 +61,19 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
throws UnknownHostException {
|
throws UnknownHostException {
|
||||||
AMIClient amiClient = createMock(AMIClient.class);
|
AMIClient amiClient = createMock(AMIClient.class);
|
||||||
Map<RegionTag, KeyPair> credentialsMap = createMock(Map.class);
|
Map<RegionTag, KeyPair> credentialsMap = createMock(Map.class);
|
||||||
|
Map<String, org.jclouds.compute.domain.Image> images = createMock(Map.class);
|
||||||
|
Map<String, Location> locations = createMock(Map.class);
|
||||||
PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class);
|
PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class);
|
||||||
RunningInstance instance = createMock(RunningInstance.class);
|
RunningInstance instance = createMock(RunningInstance.class);
|
||||||
|
|
||||||
expect(instance.getId()).andReturn("id").atLeastOnce();
|
expect(instance.getId()).andReturn("id").atLeastOnce();
|
||||||
expect(instance.getKeyName()).andReturn(null).atLeastOnce();
|
expect(instance.getKeyName()).andReturn(null).atLeastOnce();
|
||||||
expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING);
|
expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING);
|
||||||
|
Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null);
|
||||||
|
expect(locations.get("us-east-1a")).andReturn(location);
|
||||||
|
|
||||||
|
org.jclouds.compute.domain.Image jcImage = createNiceMock(org.jclouds.compute.domain.Image.class);
|
||||||
|
expect(images.get("imageId")).andReturn(jcImage);
|
||||||
|
|
||||||
expect(instance.getIpAddress()).andReturn(
|
expect(instance.getIpAddress()).andReturn(
|
||||||
InetAddress.getByAddress(new byte[] { 12, 10, 10, 1 }));
|
InetAddress.getByAddress(new byte[] { 12, 10, 10, 1 }));
|
||||||
|
@ -71,18 +82,23 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
|
|
||||||
expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce();
|
expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce();
|
||||||
|
|
||||||
|
expect(instance.getImageId()).andReturn("imageId").atLeastOnce();
|
||||||
|
|
||||||
expect(instance.getInstanceType()).andReturn(InstanceType.C1_XLARGE).atLeastOnce();
|
expect(instance.getInstanceType()).andReturn(InstanceType.C1_XLARGE).atLeastOnce();
|
||||||
|
|
||||||
replay(amiClient);
|
replay(amiClient);
|
||||||
replay(credentialsMap);
|
replay(credentialsMap);
|
||||||
replay(credentialProvider);
|
replay(credentialProvider);
|
||||||
replay(instance);
|
replay(instance);
|
||||||
|
replay(images);
|
||||||
|
replay(locations);
|
||||||
|
|
||||||
RunningInstanceToNodeMetadata parser = new RunningInstanceToNodeMetadata(amiClient,
|
RunningInstanceToNodeMetadata parser = new RunningInstanceToNodeMetadata(amiClient,
|
||||||
credentialsMap, credentialProvider);
|
credentialsMap, credentialProvider, images, locations);
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(instance);
|
NodeMetadata metadata = parser.apply(instance);
|
||||||
|
assertEquals(metadata.getLocation(), location);
|
||||||
|
assertEquals(metadata.getImage(), jcImage);
|
||||||
assertEquals(metadata.getTag(), "NOTAG-id");
|
assertEquals(metadata.getTag(), "NOTAG-id");
|
||||||
assertEquals(metadata.getCredentials(), null);
|
assertEquals(metadata.getCredentials(), null);
|
||||||
|
|
||||||
|
@ -90,6 +106,8 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
verify(credentialsMap);
|
verify(credentialsMap);
|
||||||
verify(credentialProvider);
|
verify(credentialProvider);
|
||||||
verify(instance);
|
verify(instance);
|
||||||
|
verify(images);
|
||||||
|
verify(locations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -98,6 +116,9 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
throws UnknownHostException {
|
throws UnknownHostException {
|
||||||
AMIClient amiClient = createMock(AMIClient.class);
|
AMIClient amiClient = createMock(AMIClient.class);
|
||||||
Map<RegionTag, KeyPair> credentialsMap = createMock(Map.class);
|
Map<RegionTag, KeyPair> credentialsMap = createMock(Map.class);
|
||||||
|
Map<String, org.jclouds.compute.domain.Image> images = createMock(Map.class);
|
||||||
|
Map<String, Location> locations = createMock(Map.class);
|
||||||
|
|
||||||
PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class);
|
PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class);
|
||||||
RunningInstance instance = createMock(RunningInstance.class);
|
RunningInstance instance = createMock(RunningInstance.class);
|
||||||
Image image = createMock(Image.class);
|
Image image = createMock(Image.class);
|
||||||
|
@ -106,6 +127,12 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
expect(instance.getKeyName()).andReturn("keyName-100").atLeastOnce();
|
expect(instance.getKeyName()).andReturn("keyName-100").atLeastOnce();
|
||||||
expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING);
|
expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING);
|
||||||
|
|
||||||
|
Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null);
|
||||||
|
expect(locations.get("us-east-1a")).andReturn(location);
|
||||||
|
|
||||||
|
org.jclouds.compute.domain.Image jcImage = createNiceMock(org.jclouds.compute.domain.Image.class);
|
||||||
|
expect(images.get("imageId")).andReturn(jcImage);
|
||||||
|
|
||||||
expect(instance.getIpAddress()).andReturn(
|
expect(instance.getIpAddress()).andReturn(
|
||||||
InetAddress.getByAddress(new byte[] { 12, 10, 10, 1 }));
|
InetAddress.getByAddress(new byte[] { 12, 10, 10, 1 }));
|
||||||
expect(instance.getPrivateIpAddress()).andReturn(
|
expect(instance.getPrivateIpAddress()).andReturn(
|
||||||
|
@ -131,13 +158,17 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
replay(credentialsMap);
|
replay(credentialsMap);
|
||||||
replay(credentialProvider);
|
replay(credentialProvider);
|
||||||
replay(instance);
|
replay(instance);
|
||||||
|
replay(images);
|
||||||
|
replay(locations);
|
||||||
|
|
||||||
RunningInstanceToNodeMetadata parser = new RunningInstanceToNodeMetadata(amiClient,
|
RunningInstanceToNodeMetadata parser = new RunningInstanceToNodeMetadata(amiClient,
|
||||||
credentialsMap, credentialProvider);
|
credentialsMap, credentialProvider, images, locations);
|
||||||
|
|
||||||
NodeMetadata metadata = parser.apply(instance);
|
NodeMetadata metadata = parser.apply(instance);
|
||||||
|
|
||||||
assertEquals(metadata.getTag(), "keyName");
|
assertEquals(metadata.getTag(), "keyName");
|
||||||
|
assertEquals(metadata.getLocation(), location);
|
||||||
|
assertEquals(metadata.getImage(), jcImage);
|
||||||
|
|
||||||
assertEquals(metadata.getCredentials(), new Credentials("user", "pass"));
|
assertEquals(metadata.getCredentials(), new Credentials("user", "pass"));
|
||||||
|
|
||||||
|
@ -145,6 +176,8 @@ public class RunningInstanceToNodeMetadataTest {
|
||||||
verify(credentialsMap);
|
verify(credentialsMap);
|
||||||
verify(credentialProvider);
|
verify(credentialProvider);
|
||||||
verify(instance);
|
verify(instance);
|
||||||
|
verify(images);
|
||||||
|
verify(locations);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.config;
|
package org.jclouds.aws.ec2.config;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.config;
|
package org.jclouds.aws.ec2.config;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.executableBy;
|
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.executableBy;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -26,11 +27,13 @@ import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
||||||
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
||||||
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
||||||
import org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions;
|
import org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions;
|
||||||
|
@ -43,8 +46,8 @@ import org.jclouds.aws.ec2.xml.ProductCodesHandler;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
import org.jclouds.aws.reference.AWSConstants;
|
||||||
import org.jclouds.date.TimeStamp;
|
import org.jclouds.date.TimeStamp;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
|
||||||
import org.jclouds.http.functions.CloseContentAndReturn;
|
import org.jclouds.http.functions.CloseContentAndReturn;
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.logging.Logger.LoggerFactory;
|
import org.jclouds.logging.Logger.LoggerFactory;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.RestClientTest;
|
||||||
|
@ -453,6 +456,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
||||||
|
.build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
URI.create("https://ec2.amazonaws.com"));
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions.Builder.availabilityZones;
|
import static org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions.Builder.availabilityZones;
|
||||||
import static org.jclouds.aws.ec2.options.DescribeRegionsOptions.Builder.regions;
|
import static org.jclouds.aws.ec2.options.DescribeRegionsOptions.Builder.regions;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
@ -27,11 +28,13 @@ import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
||||||
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
import org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions;
|
import org.jclouds.aws.ec2.options.DescribeAvailabilityZonesOptions;
|
||||||
import org.jclouds.aws.ec2.options.DescribeRegionsOptions;
|
import org.jclouds.aws.ec2.options.DescribeRegionsOptions;
|
||||||
|
@ -163,6 +166,8 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
||||||
|
.build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
URI.create("https://ec2.amazonaws.com"));
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.aws.ec2.options.DescribeSnapshotsOptions.Builder.ownedBy;
|
import static org.jclouds.aws.ec2.options.DescribeSnapshotsOptions.Builder.ownedBy;
|
||||||
import static org.jclouds.aws.ec2.options.DetachVolumeOptions.Builder.fromInstance;
|
import static org.jclouds.aws.ec2.options.DetachVolumeOptions.Builder.fromInstance;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
@ -27,11 +28,13 @@ import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
||||||
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
import org.jclouds.aws.ec2.functions.ReturnVoidOnVolumeAvailable;
|
import org.jclouds.aws.ec2.functions.ReturnVoidOnVolumeAvailable;
|
||||||
import org.jclouds.aws.ec2.options.CreateSnapshotOptions;
|
import org.jclouds.aws.ec2.options.CreateSnapshotOptions;
|
||||||
|
@ -110,11 +113,11 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateVolumeFromSnapShotWithSize() throws SecurityException, NoSuchMethodException,
|
public void testCreateVolumeFromSnapShotWithSize() throws SecurityException,
|
||||||
IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = ElasticBlockStoreAsyncClient.class.getMethod(
|
Method method = ElasticBlockStoreAsyncClient.class.getMethod(
|
||||||
"createVolumeFromSnapshotInAvailabilityZone", AvailabilityZone.class,
|
"createVolumeFromSnapshotInAvailabilityZone", AvailabilityZone.class, int.class,
|
||||||
int.class, String.class);
|
String.class);
|
||||||
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
GeneratedHttpRequest<ElasticBlockStoreAsyncClient> httpMethod = processor.createRequest(
|
||||||
method, AvailabilityZone.US_EAST_1A, 15, "snapshotId");
|
method, AvailabilityZone.US_EAST_1A, 15, "snapshotId");
|
||||||
|
|
||||||
|
@ -433,6 +436,8 @@ public class ElasticBlockStoreAsyncClientTest extends RestClientTest<ElasticBloc
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
||||||
|
.build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
URI.create("https://ec2.amazonaws.com"));
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -26,11 +27,13 @@ import java.lang.reflect.Method;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
||||||
import org.jclouds.aws.ec2.xml.AllocateAddressResponseHandler;
|
import org.jclouds.aws.ec2.xml.AllocateAddressResponseHandler;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeAddressesResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeAddressesResponseHandler;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
|
@ -171,6 +174,8 @@ public class ElasticIPAddressAsyncClientTest extends RestClientTest<ElasticIPAdd
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
||||||
|
.build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
URI.create("https://ec2.amazonaws.com"));
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -25,11 +26,13 @@ import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
||||||
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
import org.jclouds.aws.ec2.domain.AvailabilityZone;
|
||||||
import org.jclouds.aws.ec2.domain.BlockDeviceMapping;
|
import org.jclouds.aws.ec2.domain.BlockDeviceMapping;
|
||||||
import org.jclouds.aws.ec2.domain.InstanceType;
|
import org.jclouds.aws.ec2.domain.InstanceType;
|
||||||
|
@ -578,6 +581,8 @@ public class InstanceAsyncClientTest extends RestClientTest<InstanceAsyncClient>
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
||||||
|
.build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
URI.create("https://ec2.amazonaws.com"));
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -25,11 +26,13 @@ import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
||||||
import org.jclouds.aws.ec2.xml.DescribeKeyPairsResponseHandler;
|
import org.jclouds.aws.ec2.xml.DescribeKeyPairsResponseHandler;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
import org.jclouds.aws.reference.AWSConstants;
|
||||||
|
@ -131,6 +134,8 @@ public class KeyPairAsyncClientTest extends RestClientTest<KeyPairAsyncClient> {
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
||||||
|
.build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
URI.create("https://ec2.amazonaws.com"));
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -25,11 +26,13 @@ import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
||||||
import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
|
import org.jclouds.aws.ec2.xml.MonitoringStateHandler;
|
||||||
import org.jclouds.aws.filters.FormSigner;
|
import org.jclouds.aws.filters.FormSigner;
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
import org.jclouds.aws.reference.AWSConstants;
|
||||||
|
@ -113,6 +116,8 @@ public class MonitoringAsyncClientTest extends RestClientTest<MonitoringAsyncCli
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
||||||
|
.build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
URI.create("https://ec2.amazonaws.com"));
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.services;
|
package org.jclouds.aws.ec2.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -25,11 +26,13 @@ import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.ec2.EC2;
|
import org.jclouds.aws.ec2.EC2;
|
||||||
|
import org.jclouds.aws.ec2.EC2PropertiesBuilder;
|
||||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||||
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
import org.jclouds.aws.ec2.domain.UserIdGroupPair;
|
||||||
import org.jclouds.aws.ec2.functions.ReturnVoidOnGroupNotFound;
|
import org.jclouds.aws.ec2.functions.ReturnVoidOnGroupNotFound;
|
||||||
|
@ -245,6 +248,8 @@ public class SecurityGroupAsyncClientTest extends RestClientTest<SecurityGroupAs
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new EC2PropertiesBuilder(new Properties())
|
||||||
|
.build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
bind(URI.class).annotatedWith(EC2.class).toInstance(
|
||||||
URI.create("https://ec2.amazonaws.com"));
|
URI.create("https://ec2.amazonaws.com"));
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.filters;
|
package org.jclouds.aws.filters;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -36,7 +36,6 @@ import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.util.concurrent.Executors;
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
@ -65,8 +64,8 @@ public class FormSignerTest {
|
||||||
*/
|
*/
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
protected void createFilter() {
|
protected void createFilter() {
|
||||||
injector = Guice.createInjector(new ParserModule(), new ExecutorServiceModule(Executors
|
injector = Guice.createInjector(new ParserModule(), new ExecutorServiceModule(
|
||||||
.sameThreadExecutor(), sameThreadExecutor()), new AbstractModule() {
|
sameThreadExecutor(), sameThreadExecutor()), new AbstractModule() {
|
||||||
|
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||||
|
|
|
@ -18,12 +18,14 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.s3;
|
package org.jclouds.aws.s3;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.aws.domain.Region;
|
import org.jclouds.aws.domain.Region;
|
||||||
import org.jclouds.aws.s3.blobstore.functions.BlobToObject;
|
import org.jclouds.aws.s3.blobstore.functions.BlobToObject;
|
||||||
|
@ -60,7 +62,6 @@ import org.jclouds.blobstore.functions.ReturnFalseOnKeyNotFound;
|
||||||
import org.jclouds.blobstore.functions.ReturnNullOnKeyNotFound;
|
import org.jclouds.blobstore.functions.ReturnNullOnKeyNotFound;
|
||||||
import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404;
|
import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404;
|
||||||
import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
|
import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
|
||||||
import org.jclouds.blobstore.reference.BlobStoreConstants;
|
|
||||||
import org.jclouds.date.TimeStamp;
|
import org.jclouds.date.TimeStamp;
|
||||||
import org.jclouds.http.functions.CloseContentAndReturn;
|
import org.jclouds.http.functions.CloseContentAndReturn;
|
||||||
import org.jclouds.http.functions.ParseETagHeader;
|
import org.jclouds.http.functions.ParseETagHeader;
|
||||||
|
@ -545,13 +546,13 @@ public class S3AsyncClientTest extends RestClientTest<S3AsyncClient> {
|
||||||
}, new TypeLiteral<S3Client>() {
|
}, new TypeLiteral<S3Client>() {
|
||||||
}));
|
}));
|
||||||
install(new S3ObjectModule());
|
install(new S3ObjectModule());
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new S3PropertiesBuilder(new Properties())
|
||||||
|
.build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(S3.class).toInstance(URI.create("http://stub:8080"));
|
bind(URI.class).annotatedWith(S3.class).toInstance(URI.create("http://stub:8080"));
|
||||||
bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to(
|
bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||||
"user");
|
"user");
|
||||||
bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY))
|
bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY))
|
||||||
.to("key");
|
.to("key");
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX)).to("prefix");
|
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||||
public Logger getLogger(String category) {
|
public Logger getLogger(String category) {
|
||||||
return Logger.NULL;
|
return Logger.NULL;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.s3.blobstore.config;
|
package org.jclouds.aws.s3.blobstore.config;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.s3.config;
|
package org.jclouds.aws.s3.config;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.s3.filters;
|
package org.jclouds.aws.s3.filters;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.sqs;
|
package org.jclouds.aws.sqs;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -25,6 +26,7 @@ import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
@ -152,6 +154,8 @@ public class SQSAsyncClientTest extends RestClientTest<SQSAsyncClient> {
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new SQSPropertiesBuilder(new Properties())
|
||||||
|
.build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(SQS.class).toInstance(URI.create("https://default"));
|
bind(URI.class).annotatedWith(SQS.class).toInstance(URI.create("https://default"));
|
||||||
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
bindConstant().annotatedWith(Jsr330.named(AWSConstants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||||
"user");
|
"user");
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.aws.sqs.config;
|
package org.jclouds.aws.sqs.config;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
|
@ -19,46 +19,47 @@
|
||||||
|
|
||||||
package org.jclouds.azure.storage.blob.predicates.validators;
|
package org.jclouds.azure.storage.blob.predicates.validators;
|
||||||
|
|
||||||
import com.google.common.base.CharMatcher;
|
import javax.inject.Inject;
|
||||||
import org.jclouds.predicates.Validator;
|
|
||||||
import javax.annotation.Nullable;
|
import org.jclouds.predicates.validators.DnsNameValidator;
|
||||||
import static com.google.common.base.CharMatcher.*;
|
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates name for Azure container.
|
* Validates name for Azure container. The complete requirements are listed at:
|
||||||
* The complete requirements are listed at:
|
* http://weblogs.asp.net
|
||||||
* http://weblogs.asp.net/vblasberg/archive/2009/02/17/azure-details-and-limitations-blobs-tables-and-queues.aspx
|
* /vblasberg/archive/2009/02/17/azure-details-and-limitations-blobs-tables-and-queues.aspx
|
||||||
*
|
*
|
||||||
* @see org.jclouds.rest.InputParamValidator
|
* @see org.jclouds.rest.InputParamValidator
|
||||||
* @see org.jclouds.predicates.Validator
|
* @see org.jclouds.predicates.Validator
|
||||||
*
|
*
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
public class ContainerNameValidator extends Validator<String> {
|
@Singleton
|
||||||
|
public class ContainerNameValidator extends DnsNameValidator {
|
||||||
|
|
||||||
public void validate(@Nullable String containerName) {
|
@Inject
|
||||||
|
ContainerNameValidator() {
|
||||||
if(containerName == null || containerName.length() < 3 || containerName.length() > 63) throw exception(containerName, "Can't be null or empty. Length must be 3 to 63 symbols.");
|
super(3,63);
|
||||||
if(CharMatcher.JAVA_LETTER_OR_DIGIT.indexIn(containerName) != 0) throw exception(containerName, "Should start with letter/number");
|
|
||||||
if(!containerName.toLowerCase().equals(containerName)) throw exception(containerName, "Should be only lowercase");
|
|
||||||
|
|
||||||
/* The name must be a valid DNS name. From wikipedia:
|
|
||||||
"The characters allowed in a label are a subset of the ASCII character set, a
|
|
||||||
and includes the characters a through z, A through Z, digits 0 through 9".
|
|
||||||
From Azure:
|
|
||||||
Every Dash (-) Must Be Immediately Preceded and Followed by a Letter or Number.
|
|
||||||
*/
|
|
||||||
CharMatcher lettersNumbersOrDashes = inRange('a', 'z').or(inRange('0', '9').or(is('-')));
|
|
||||||
if(! lettersNumbersOrDashes.matchesAllOf(containerName)) throw exception(containerName, "Should have lowercase ASCII letters, " +
|
|
||||||
"numbers, or dashes");
|
|
||||||
if(containerName.contains("--")) throw exception(containerName, "Every dash must be followed by letter or number");
|
|
||||||
if(containerName.endsWith("-")) throw exception(containerName, "Shouldn't end with a dash");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IllegalArgumentException exception(String containerName, String reason) {
|
public void validate(String containerName) {
|
||||||
return new IllegalArgumentException(String.format("Object '%s' doesn't match Azure container naming convention. " +
|
super.validate(containerName);
|
||||||
"Reason: %s. For more info, please refer to http://weblogs.asp.net/vblasberg/archive/2009/02/17/" +
|
if (containerName.contains("--"))
|
||||||
"azure-details-and-limitations-blobs-tables-and-queues.aspx.", containerName, reason));
|
throw exception(containerName, "Every dash must be followed by letter or number");
|
||||||
|
if (containerName.endsWith("-"))
|
||||||
|
throw exception(containerName, "Shouldn't end with a dash");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IllegalArgumentException exception(String containerName, String reason) {
|
||||||
|
return new IllegalArgumentException(
|
||||||
|
String
|
||||||
|
.format(
|
||||||
|
"Object '%s' doesn't match Azure container naming convention. "
|
||||||
|
+ "Reason: %s. For more info, please refer to http://weblogs.asp.net/vblasberg/archive/2009/02/17/"
|
||||||
|
+ "azure-details-and-limitations-blobs-tables-and-queues.aspx.",
|
||||||
|
containerName, reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.azure.storage.blob;
|
package org.jclouds.azure.storage.blob;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.jclouds.azure.storage.blob.options.CreateContainerOptions.Builder.withPublicAcl;
|
import static org.jclouds.azure.storage.blob.options.CreateContainerOptions.Builder.withPublicAcl;
|
||||||
import static org.jclouds.azure.storage.options.ListOptions.Builder.maxResults;
|
import static org.jclouds.azure.storage.options.ListOptions.Builder.maxResults;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.azure.storage.blob.blobstore.config;
|
package org.jclouds.azure.storage.blob.blobstore.config;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.jclouds.azure.storage.blob.blobstore.strategy.FindMD5InBlobProperties;
|
import org.jclouds.azure.storage.blob.blobstore.strategy.FindMD5InBlobProperties;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.azure.storage.blob.config;
|
package org.jclouds.azure.storage.blob.config;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.azure.storage.predicates.validators;
|
package org.jclouds.azure.storage.blob.predicates.validators;
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.jclouds.azure.storage.blob.predicates.validators.ContainerNameValidator;
|
import org.jclouds.azure.storage.blob.predicates.validators.ContainerNameValidator;
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.azure.storage.config;
|
package org.jclouds.azure.storage.config;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT;
|
import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT;
|
||||||
import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY;
|
import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY;
|
||||||
import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL;
|
import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.azure.storage.filters;
|
package org.jclouds.azure.storage.filters;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL;
|
import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.jclouds.azure.storage.options.ListOptions;
|
||||||
import org.jclouds.azure.storage.queue.options.PutMessageOptions;
|
import org.jclouds.azure.storage.queue.options.PutMessageOptions;
|
||||||
import org.jclouds.azure.storage.reference.AzureStorageConstants;
|
import org.jclouds.azure.storage.reference.AzureStorageConstants;
|
||||||
import org.jclouds.date.TimeStamp;
|
import org.jclouds.date.TimeStamp;
|
||||||
import org.jclouds.encryption.internal.Base64;
|
|
||||||
import org.jclouds.http.functions.CloseContentAndReturn;
|
import org.jclouds.http.functions.CloseContentAndReturn;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ReturnTrueIf2xx;
|
import org.jclouds.http.functions.ReturnTrueIf2xx;
|
||||||
|
@ -249,11 +248,8 @@ public class AzureQueueAsyncClientTest extends RestClientTest<AzureQueueAsyncCli
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(URI.class).annotatedWith(AzureQueue.class).toInstance(
|
bind(URI.class).annotatedWith(AzureQueue.class).toInstance(
|
||||||
URI.create("http://localhost:8080"));
|
URI.create("http://localhost:8080"));
|
||||||
bindConstant().annotatedWith(
|
Jsr330.bindProperties(this.binder(), new AzureQueuePropertiesBuilder("user", "key")
|
||||||
Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT)).to("user");
|
.build());
|
||||||
bindConstant().annotatedWith(
|
|
||||||
Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY)).to(
|
|
||||||
Base64.encodeBytes("key".getBytes()));
|
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||||
public Logger getLogger(String category) {
|
public Logger getLogger(String category) {
|
||||||
return Logger.NULL;
|
return Logger.NULL;
|
||||||
|
|
|
@ -59,15 +59,6 @@ public interface StorageMetadata extends ResourceMetadata<StorageType> {
|
||||||
@Override
|
@Override
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
/**
|
|
||||||
* Physical location of the resource.
|
|
||||||
*
|
|
||||||
* ex. us-west-1
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
String getLocationId();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URI used to access this resource
|
* URI used to access this resource
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Map;
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||||
import org.jclouds.blobstore.domain.StorageType;
|
import org.jclouds.blobstore.domain.StorageType;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
|
||||||
import com.google.inject.internal.Nullable;
|
import com.google.inject.internal.Nullable;
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ public class BlobMetadataImpl extends StorageMetadataImpl implements Serializabl
|
||||||
private final String contentType;
|
private final String contentType;
|
||||||
private final byte[] contentMD5;
|
private final byte[] contentMD5;
|
||||||
|
|
||||||
public BlobMetadataImpl(String id, String name, @Nullable String location, URI uri,
|
public BlobMetadataImpl(String id, String name, @Nullable Location location, URI uri,
|
||||||
String eTag, Long size, Date lastModified, Map<String, String> userMetadata,
|
String eTag, Long size, Date lastModified, Map<String, String> userMetadata,
|
||||||
String contentType, byte[] contentMD5) {
|
String contentType, byte[] contentMD5) {
|
||||||
super(StorageType.BLOB, id, name, location, uri, eTag, size, lastModified, userMetadata);
|
super(StorageType.BLOB, id, name, location, uri, eTag, size, lastModified, userMetadata);
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||||
import org.jclouds.blobstore.domain.StorageType;
|
import org.jclouds.blobstore.domain.StorageType;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.internal.ResourceMetadataImpl;
|
import org.jclouds.domain.internal.ResourceMetadataImpl;
|
||||||
|
|
||||||
import com.google.inject.internal.Nullable;
|
import com.google.inject.internal.Nullable;
|
||||||
|
@ -48,7 +49,7 @@ public class StorageMetadataImpl extends ResourceMetadataImpl<StorageType> imple
|
||||||
private final Date lastModified;
|
private final Date lastModified;
|
||||||
|
|
||||||
public StorageMetadataImpl(StorageType type, @Nullable String id, @Nullable String name,
|
public StorageMetadataImpl(StorageType type, @Nullable String id, @Nullable String name,
|
||||||
@Nullable String location, @Nullable URI uri, @Nullable String eTag,
|
@Nullable Location location, @Nullable URI uri, @Nullable String eTag,
|
||||||
@Nullable Long size, @Nullable Date lastModified, Map<String, String> userMetadata) {
|
@Nullable Long size, @Nullable Date lastModified, Map<String, String> userMetadata) {
|
||||||
super(type, id, name, location, uri, userMetadata);
|
super(type, id, name, location, uri, userMetadata);
|
||||||
this.eTag = eTag;
|
this.eTag = eTag;
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class ResourceMetadataToRelativePathResourceMetadata implements
|
||||||
name = name.substring(0, name.length() - suffix.length());
|
name = name.substring(0, name.length() - suffix.length());
|
||||||
}
|
}
|
||||||
return new StorageMetadataImpl(StorageType.RELATIVE_PATH, md.getId(), name, md
|
return new StorageMetadataImpl(StorageType.RELATIVE_PATH, md.getId(), name, md
|
||||||
.getLocationId(), md.getUri(), md.getETag(), md.getSize(), md.getLastModified(), md
|
.getLocation(), md.getUri(), md.getETag(), md.getSize(), md.getLastModified(), md
|
||||||
.getUserMetadata());
|
.getUserMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.blobstore.strategy.internal;
|
package org.jclouds.blobstore.strategy.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.jclouds.concurrent.ConcurrentUtils.awaitCompletion;
|
import static org.jclouds.concurrent.ConcurrentUtils.awaitCompletion;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -45,7 +46,6 @@ import com.google.common.base.Function;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.util.concurrent.Executors;
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ public class FetchBlobMetadata implements
|
||||||
Throwables.propagate(e);
|
Throwables.propagate(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, Executors.sameThreadExecutor());
|
}, sameThreadExecutor());
|
||||||
responses.put(md, future);
|
responses.put(md, future);
|
||||||
} else {
|
} else {
|
||||||
metadata.add(md);
|
metadata.add(md);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.blobstore.strategy.internal;
|
package org.jclouds.blobstore.strategy.internal;
|
||||||
|
|
||||||
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.jclouds.concurrent.ConcurrentUtils.awaitCompletion;
|
import static org.jclouds.concurrent.ConcurrentUtils.awaitCompletion;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -44,7 +45,6 @@ import org.jclouds.logging.Logger;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.util.concurrent.Executors;
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ public class GetAllBlobsInListAndRetryOnFailure implements GetBlobsInListStrateg
|
||||||
Throwables.propagate(e);
|
Throwables.propagate(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, Executors.sameThreadExecutor());
|
}, sameThreadExecutor());
|
||||||
responses.put(md, future);
|
responses.put(md, future);
|
||||||
}
|
}
|
||||||
exceptions = awaitCompletion(responses, userExecutor, maxTime, logger, String.format(
|
exceptions = awaitCompletion(responses, userExecutor, maxTime, logger, String.format(
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class BlobStoreUtilsImpl implements BlobStoreUtils {
|
||||||
blob.getMetadata().setETag(blobMeta.getETag());
|
blob.getMetadata().setETag(blobMeta.getETag());
|
||||||
blob.getMetadata().setId(blobMeta.getId());
|
blob.getMetadata().setId(blobMeta.getId());
|
||||||
blob.getMetadata().setLastModified(blobMeta.getLastModified());
|
blob.getMetadata().setLastModified(blobMeta.getLastModified());
|
||||||
blob.getMetadata().setLocationId(blobMeta.getLocationId());
|
blob.getMetadata().setLocation(blobMeta.getLocation());
|
||||||
blob.getMetadata().setUri(blobMeta.getUri());
|
blob.getMetadata().setUri(blobMeta.getUri());
|
||||||
blob.getMetadata().setUserMetadata(blobMeta.getUserMetadata());
|
blob.getMetadata().setUserMetadata(blobMeta.getUserMetadata());
|
||||||
return blob;
|
return blob;
|
||||||
|
|
|
@ -65,10 +65,16 @@
|
||||||
<version>2.3.14</version>
|
<version>2.3.14</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.common</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>google-guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>1.0-r11</version>
|
<version>r03</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
|
<artifactId>jsr305</artifactId>
|
||||||
|
<version>1.3.9</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -22,6 +22,8 @@ import java.net.InetAddress;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,6 +41,12 @@ public interface NodeMetadata extends ComputeMetadata {
|
||||||
*/
|
*/
|
||||||
String getTag();
|
String getTag();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The image this node was created from, if possible to correlate.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
Image getImage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current State of the node
|
* Current State of the node
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
import org.jclouds.compute.domain.ComputeType;
|
import org.jclouds.compute.domain.ComputeType;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.internal.ResourceMetadataImpl;
|
import org.jclouds.domain.internal.ResourceMetadataImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,9 +36,9 @@ public class ComputeMetadataImpl extends ResourceMetadataImpl<ComputeType> imple
|
||||||
/** The serialVersionUID */
|
/** The serialVersionUID */
|
||||||
private static final long serialVersionUID = 7374704415964898694L;
|
private static final long serialVersionUID = 7374704415964898694L;
|
||||||
|
|
||||||
public ComputeMetadataImpl(ComputeType type, String id, String name, String locationId, URI uri,
|
public ComputeMetadataImpl(ComputeType type, String id, String name, Location location, URI uri,
|
||||||
Map<String, String> userMetadata) {
|
Map<String, String> userMetadata) {
|
||||||
super(type, id, name, locationId, uri, userMetadata);
|
super(type, id, name, location, uri, userMetadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.jclouds.compute.domain.ComputeType;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -52,11 +53,11 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
private final Credentials defaultCredentials;
|
private final Credentials defaultCredentials;
|
||||||
|
|
||||||
|
|
||||||
public ImageImpl(String id, String name, String locationId, URI uri,
|
public ImageImpl(String id, String name, Location location, URI uri,
|
||||||
Map<String, String> userMetadata, String description, String version,
|
Map<String, String> userMetadata, String description, String version,
|
||||||
@Nullable OsFamily osFamily, String osDescription, Architecture architecture,
|
@Nullable OsFamily osFamily, String osDescription, Architecture architecture,
|
||||||
Credentials defaultCredentials) {
|
Credentials defaultCredentials) {
|
||||||
super(ComputeType.IMAGE, id, name, locationId, uri, userMetadata);
|
super(ComputeType.IMAGE, id, name, location, uri, userMetadata);
|
||||||
this.version = checkNotNull(version, "version");
|
this.version = checkNotNull(version, "version");
|
||||||
this.osFamily = osFamily;
|
this.osFamily = osFamily;
|
||||||
this.description = checkNotNull(description, "description");
|
this.description = checkNotNull(description, "description");
|
||||||
|
@ -115,7 +116,7 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + getId() + ", name=" + getName() + ", locationId=" + getLocationId()
|
return "[id=" + getId() + ", name=" + getName() + ", locationId=" + getLocation()
|
||||||
+ ", architecture=" + architecture + ", osDescription=" + osDescription
|
+ ", architecture=" + architecture + ", osDescription=" + osDescription
|
||||||
+ ", osFamily=" + osFamily + ", version=" + version + "]";
|
+ ", osFamily=" + osFamily + ", version=" + version + "]";
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,11 @@ import java.util.Set;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.ComputeType;
|
import org.jclouds.compute.domain.ComputeType;
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeState;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
@ -50,13 +52,16 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
||||||
private final Map<String, String> extra = Maps.newLinkedHashMap();
|
private final Map<String, String> extra = Maps.newLinkedHashMap();
|
||||||
private final Credentials credentials;
|
private final Credentials credentials;
|
||||||
private final String tag;
|
private final String tag;
|
||||||
|
private final Image image;
|
||||||
|
|
||||||
public NodeMetadataImpl(String id, String name, String locationId, URI uri,
|
public NodeMetadataImpl(String id, String name, Location location, URI uri,
|
||||||
Map<String, String> userMetadata, @Nullable String tag, NodeState state,
|
Map<String, String> userMetadata, @Nullable String tag, @Nullable Image image,
|
||||||
Iterable<InetAddress> publicAddresses, Iterable<InetAddress> privateAddresses,
|
NodeState state, Iterable<InetAddress> publicAddresses,
|
||||||
Map<String, String> extra, @Nullable Credentials credentials) {
|
Iterable<InetAddress> privateAddresses, Map<String, String> extra,
|
||||||
super(ComputeType.NODE, id, name, locationId, uri, userMetadata);
|
@Nullable Credentials credentials) {
|
||||||
|
super(ComputeType.NODE, id, name, location, uri, userMetadata);
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
|
this.image = image;
|
||||||
this.state = checkNotNull(state, "state");
|
this.state = checkNotNull(state, "state");
|
||||||
Iterables.addAll(this.publicAddresses, checkNotNull(publicAddresses, "publicAddresses"));
|
Iterables.addAll(this.publicAddresses, checkNotNull(publicAddresses, "publicAddresses"));
|
||||||
Iterables.addAll(this.privateAddresses, checkNotNull(privateAddresses, "privateAddresses"));
|
Iterables.addAll(this.privateAddresses, checkNotNull(privateAddresses, "privateAddresses"));
|
||||||
|
@ -80,6 +85,15 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
||||||
return credentials;
|
return credentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public Image getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -115,7 +129,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + getId() + ", tag=" + getTag() + ", name=" + getName() + ", location="
|
return "[id=" + getId() + ", tag=" + getTag() + ", name=" + getName() + ", location="
|
||||||
+ getLocationId() + ", uri=" + getUri() + ", userMetadata=" + getUserMetadata()
|
+ getLocation() + ", uri=" + getUri() + ", userMetadata=" + getUserMetadata()
|
||||||
+ ", state=" + getState() + ", privateAddresses=" + privateAddresses
|
+ ", state=" + getState() + ", privateAddresses=" + privateAddresses
|
||||||
+ ", publicAddresses=" + publicAddresses + "]";
|
+ ", publicAddresses=" + publicAddresses + "]";
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import javax.annotation.Nullable;
|
||||||
import org.jclouds.compute.domain.Architecture;
|
import org.jclouds.compute.domain.Architecture;
|
||||||
import org.jclouds.compute.domain.ComputeType;
|
import org.jclouds.compute.domain.ComputeType;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.ResourceMetadata;
|
import org.jclouds.domain.ResourceMetadata;
|
||||||
|
|
||||||
import com.google.common.collect.ComparisonChain;
|
import com.google.common.collect.ComparisonChain;
|
||||||
|
@ -47,7 +48,7 @@ public class SizeImpl extends ComputeMetadataImpl implements Size {
|
||||||
|
|
||||||
private final Set<Architecture> supportedArchitectures = Sets.newHashSet();
|
private final Set<Architecture> supportedArchitectures = Sets.newHashSet();
|
||||||
|
|
||||||
public SizeImpl(String id, String name, @Nullable String location, URI uri,
|
public SizeImpl(String id, String name, @Nullable Location location, URI uri,
|
||||||
Map<String, String> userMetadata, double cores, int ram, int disk,
|
Map<String, String> userMetadata, double cores, int ram, int disk,
|
||||||
Iterable<Architecture> supportedArchitectures) {
|
Iterable<Architecture> supportedArchitectures) {
|
||||||
super(ComputeType.SIZE, id, name, location, uri, userMetadata);
|
super(ComputeType.SIZE, id, name, location, uri, userMetadata);
|
||||||
|
|
|
@ -110,8 +110,8 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(ComputeMetadata input) {
|
public boolean apply(ComputeMetadata input) {
|
||||||
boolean returnVal = true;
|
boolean returnVal = true;
|
||||||
if (locationId != null && input.getLocationId() != null)
|
if (locationId != null && input.getLocation() != null)
|
||||||
returnVal = locationId.equals(input.getLocationId());
|
returnVal = locationId.equals(input.getLocation().getId());
|
||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -302,8 +302,8 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TemplateBuilder fromSize(Size size) {
|
public TemplateBuilder fromSize(Size size) {
|
||||||
if (size.getLocationId() != null)
|
if (size.getLocation() != null)
|
||||||
this.locationId = size.getLocationId();
|
this.locationId = size.getLocation().getId();
|
||||||
this.minCores = size.getCores();
|
this.minCores = size.getCores();
|
||||||
this.minRam = size.getRam();
|
this.minRam = size.getRam();
|
||||||
return this;
|
return this;
|
||||||
|
@ -314,8 +314,8 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TemplateBuilder fromImage(Image image) {
|
public TemplateBuilder fromImage(Image image) {
|
||||||
if (image.getLocationId() != null)
|
if (image.getLocation() != null)
|
||||||
this.locationId = image.getLocationId();
|
this.locationId = image.getLocation().getId();
|
||||||
if (image.getOsFamily() != null)
|
if (image.getOsFamily() != null)
|
||||||
this.os = image.getOsFamily();
|
this.os = image.getOsFamily();
|
||||||
if (image.getName() != null)
|
if (image.getName() != null)
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.strategy.impl.OneByOneRunNodesAndAddToSetStrategy;
|
import org.jclouds.compute.strategy.impl.EncodeTagIntoNameRunNodesAndAddToSetStrategy;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.inject.ImplementedBy;
|
import com.google.inject.ImplementedBy;
|
||||||
|
@ -34,7 +34,7 @@ import com.google.inject.ImplementedBy;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@ImplementedBy(OneByOneRunNodesAndAddToSetStrategy.class)
|
@ImplementedBy(EncodeTagIntoNameRunNodesAndAddToSetStrategy.class)
|
||||||
public interface RunNodesAndAddToSetStrategy {
|
public interface RunNodesAndAddToSetStrategy {
|
||||||
|
|
||||||
Map<?, ListenableFuture<Void>> execute(String tag, int count, Template template,
|
Map<?, ListenableFuture<Void>> execute(String tag, int count, Template template,
|
||||||
|
|
|
@ -55,7 +55,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OneByOneRunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrategy {
|
public class EncodeTagIntoNameRunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrategy {
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
@ -66,7 +66,7 @@ public class OneByOneRunNodesAndAddToSetStrategy implements RunNodesAndAddToSetS
|
||||||
protected final ExecutorService executor;
|
protected final ExecutorService executor;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected OneByOneRunNodesAndAddToSetStrategy(AddNodeWithTagStrategy addNodeWithTagStrategy,
|
protected EncodeTagIntoNameRunNodesAndAddToSetStrategy(AddNodeWithTagStrategy addNodeWithTagStrategy,
|
||||||
ListNodesStrategy listNodesStrategy,
|
ListNodesStrategy listNodesStrategy,
|
||||||
@Named("NAMING_CONVENTION") String nodeNamingConvention, ComputeUtils utils,
|
@Named("NAMING_CONVENTION") String nodeNamingConvention, ComputeUtils utils,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||||
|
@ -77,11 +77,15 @@ public class OneByOneRunNodesAndAddToSetStrategy implements RunNodesAndAddToSetS
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This implementation gets a list of acceptable node names to encode the tag into, then it
|
||||||
|
* simultaneously runs the nodes and applies options to them.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<?, ListenableFuture<Void>> execute(final String tag, final int count,
|
public Map<?, ListenableFuture<Void>> execute(final String tag, final int count,
|
||||||
final Template template, final Set<NodeMetadata> nodes) {
|
final Template template, final Set<NodeMetadata> nodes) {
|
||||||
Map<String, ListenableFuture<Void>> responses = Maps.newHashMap();
|
Map<String, ListenableFuture<Void>> responses = Maps.newHashMap();
|
||||||
for (final String name : getNextNames(tag, count)) {
|
for (final String name : getNextNames(tag, template, count)) {
|
||||||
responses.put(name, makeListenable(executor.submit(new Callable<Void>() {
|
responses.put(name, makeListenable(executor.submit(new Callable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
|
@ -104,13 +108,22 @@ public class OneByOneRunNodesAndAddToSetStrategy implements RunNodesAndAddToSetS
|
||||||
return responses;
|
return responses;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Set<String> getNextNames(final String tag, int count) {
|
/**
|
||||||
|
* Find the next node names that can be used. These will be derived from the tag and the
|
||||||
|
* template. We will pre-allocate a specified quantity, and attempt to verify that there is no
|
||||||
|
* name conflict with the current service.
|
||||||
|
*
|
||||||
|
* @param tag
|
||||||
|
* @param count
|
||||||
|
* @param template
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected Set<String> getNextNames(final String tag, final Template template, int count) {
|
||||||
Set<String> names = Sets.newHashSet();
|
Set<String> names = Sets.newHashSet();
|
||||||
int nodeIndex = new SecureRandom().nextInt(8096);
|
|
||||||
Map<String, ? extends ComputeMetadata> currentNodes = Maps.uniqueIndex(listNodesStrategy
|
Map<String, ? extends ComputeMetadata> currentNodes = Maps.uniqueIndex(listNodesStrategy
|
||||||
.execute(GetNodesOptions.NONE), BaseComputeService.METADATA_TO_NAME);
|
.execute(GetNodesOptions.NONE), BaseComputeService.METADATA_TO_NAME);
|
||||||
while (names.size() < count) {
|
while (names.size() < count) {
|
||||||
String name = String.format(nodeNamingConvention, tag, nodeIndex++);
|
String name = getNextName(tag, template);
|
||||||
if (!currentNodes.containsKey(name)) {
|
if (!currentNodes.containsKey(name)) {
|
||||||
names.add(name);
|
names.add(name);
|
||||||
}
|
}
|
||||||
|
@ -118,4 +131,16 @@ public class OneByOneRunNodesAndAddToSetStrategy implements RunNodesAndAddToSetS
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a name using a random mechanism that still ties all nodes in a tag together.
|
||||||
|
*
|
||||||
|
* This implementation will pass the tag and a hex formatted random number to the configured
|
||||||
|
* naming convention.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected String getNextName(final String tag, final Template template) {
|
||||||
|
return String.format(nodeNamingConvention, tag, Integer.toHexString(new SecureRandom()
|
||||||
|
.nextInt(4095)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -387,8 +387,8 @@ public class ComputeUtils {
|
||||||
* returns a new instance of {@link NodeMetadata} that has new credentials
|
* returns a new instance of {@link NodeMetadata} that has new credentials
|
||||||
*/
|
*/
|
||||||
public static NodeMetadata installNewCredentials(NodeMetadata node, Credentials newCredentials) {
|
public static NodeMetadata installNewCredentials(NodeMetadata node, Credentials newCredentials) {
|
||||||
return new NodeMetadataImpl(node.getId(), node.getName(), node.getLocationId(),
|
return new NodeMetadataImpl(node.getId(), node.getName(), node.getLocation(), node.getUri(),
|
||||||
node.getUri(), node.getUserMetadata(), node.getTag(), node.getState(), node
|
node.getUserMetadata(), node.getTag(), node.getImage(), node.getState(), node
|
||||||
.getPublicAddresses(), node.getPrivateAddresses(), node.getExtra(),
|
.getPublicAddresses(), node.getPrivateAddresses(), node.getExtra(),
|
||||||
newCredentials);
|
newCredentials);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -77,7 +78,7 @@ import com.google.inject.Module;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", enabled = true, sequential = true, testName = "compute.ComputeServiceLiveTest")
|
@Test(groups = "live", sequential = true, testName = "compute.ComputeServiceLiveTest")
|
||||||
public abstract class BaseComputeServiceLiveTest {
|
public abstract class BaseComputeServiceLiveTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
abstract public void setServiceDefaults();
|
abstract public void setServiceDefaults();
|
||||||
|
@ -149,7 +150,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
assertEquals(toMatch, template);
|
assertEquals(toMatch, template);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testTemplateMatch")
|
@Test(enabled = true, dependsOnMethods = "testTemplateMatch")
|
||||||
public void testCreateTwoNodesWithRunScript() throws Exception {
|
public void testCreateTwoNodesWithRunScript() throws Exception {
|
||||||
try {
|
try {
|
||||||
client.destroyNodesWithTag(tag);
|
client.destroyNodesWithTag(tag);
|
||||||
|
@ -170,20 +171,39 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
NodeMetadata node2 = nodes.last();
|
NodeMetadata node2 = nodes.last();
|
||||||
// credentials aren't always the same
|
// credentials aren't always the same
|
||||||
// assertEquals(node1.getCredentials(), node2.getCredentials());
|
// assertEquals(node1.getCredentials(), node2.getCredentials());
|
||||||
assert !node1.getId().equals(node2.getId());
|
|
||||||
|
assertLocationSameOrChild(node1.getLocation(), template.getLocation());
|
||||||
|
assertLocationSameOrChild(node2.getLocation(), template.getLocation());
|
||||||
|
|
||||||
|
assertEquals(node1.getImage(), template.getImage());
|
||||||
|
assertEquals(node2.getImage(), template.getImage());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateTwoNodesWithRunScript")
|
void assertLocationSameOrChild(Location test, Location expected) {
|
||||||
|
if (!test.equals(expected)) {
|
||||||
|
assertEquals(test.getParent(), expected.getId());
|
||||||
|
} else {
|
||||||
|
assertEquals(test, expected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(enabled = true, dependsOnMethods = "testCreateTwoNodesWithRunScript")
|
||||||
public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() throws Exception {
|
public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() throws Exception {
|
||||||
initializeContextAndClient();
|
initializeContextAndClient();
|
||||||
|
TreeSet<NodeMetadata> nodes = Sets.newTreeSet(client.runNodesWithTag(tag, 1, template)
|
||||||
|
.values());
|
||||||
|
checkNodes(nodes, tag);
|
||||||
|
NodeMetadata node = nodes.first();
|
||||||
|
|
||||||
checkNodes(client.runNodesWithTag(tag, 1, template).values(), tag);
|
assertEquals(nodes.size(), 1);
|
||||||
|
assertLocationSameOrChild(node.getLocation(), template.getLocation());
|
||||||
|
assertEquals(node.getImage(), template.getImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testScriptExecutionAfterBootWithBasicTemplate() throws Exception {
|
public void testScriptExecutionAfterBootWithBasicTemplate() throws Exception {
|
||||||
String tag = this.tag + "script";
|
String tag = this.tag + "run";
|
||||||
Template simpleTemplate = buildTemplate(client.templateBuilder());
|
Template simpleTemplate = buildTemplate(client.templateBuilder());
|
||||||
simpleTemplate.getOptions().blockOnPort(22, 60);
|
simpleTemplate.getOptions().blockOnPort(22, 60);
|
||||||
try {
|
try {
|
||||||
|
@ -192,9 +212,9 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
assert good.account != null;
|
assert good.account != null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
runScriptWithCreds(tag, simpleTemplate.getImage().getOsFamily(), new Credentials(
|
Map<String, ExecResponse> responses = runScriptWithCreds(tag, simpleTemplate.getImage()
|
||||||
good.account, "romeo"));
|
.getOsFamily(), new Credentials(good.account, "romeo"));
|
||||||
assert false : "shouldn't pass with a bad password";
|
assert false : "shouldn't pass with a bad password\n" + responses;
|
||||||
} catch (SshException e) {
|
} catch (SshException e) {
|
||||||
assert Throwables.getRootCause(e).getMessage().contains("Auth fail") : e;
|
assert Throwables.getRootCause(e).getMessage().contains("Auth fail") : e;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +294,9 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
metadataSet.remove(node);
|
metadataSet.remove(node);
|
||||||
NodeMetadata metadata = client.getNodeMetadata(node);
|
NodeMetadata metadata = client.getNodeMetadata(node);
|
||||||
assertEquals(metadata.getId(), node.getId());
|
assertEquals(metadata.getId(), node.getId());
|
||||||
assertEquals(metadata.getName(), node.getName());
|
assertEquals(metadata.getTag(), node.getTag());
|
||||||
|
assertEquals(metadata.getLocation(), template.getLocation());
|
||||||
|
assertEquals(metadata.getImage(), template.getImage());
|
||||||
assertEquals(metadata.getState(), NodeState.RUNNING);
|
assertEquals(metadata.getState(), NodeState.RUNNING);
|
||||||
assertEquals(metadata.getPrivateAddresses(), node.getPrivateAddresses());
|
assertEquals(metadata.getPrivateAddresses(), node.getPrivateAddresses());
|
||||||
assertEquals(metadata.getPublicAddresses(), node.getPublicAddresses());
|
assertEquals(metadata.getPublicAddresses(), node.getPublicAddresses());
|
||||||
|
@ -298,7 +320,7 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
for (Entry<String, ? extends ComputeMetadata> node : client.getNodes().entrySet()) {
|
for (Entry<String, ? extends ComputeMetadata> node : client.getNodes().entrySet()) {
|
||||||
assertEquals(node.getKey(), node.getValue().getId());
|
assertEquals(node.getKey(), node.getValue().getId());
|
||||||
assert node.getValue().getId() != null;
|
assert node.getValue().getId() != null;
|
||||||
assert node.getValue().getLocationId() != null;
|
assert node.getValue().getLocation() != null;
|
||||||
assertEquals(node.getValue().getType(), ComputeType.NODE);
|
assertEquals(node.getValue().getType(), ComputeType.NODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,19 +330,21 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
new GetNodesOptions().withDetails()).entrySet()) {
|
new GetNodesOptions().withDetails()).entrySet()) {
|
||||||
assertEquals(node.getKey(), node.getValue().getId());
|
assertEquals(node.getKey(), node.getValue().getId());
|
||||||
assert node.getValue().getId() != null : node;
|
assert node.getValue().getId() != null : node;
|
||||||
assert node.getValue().getLocationId() != null : node;
|
assert node.getValue().getLocation() != null : node;
|
||||||
assertEquals(node.getValue().getType(), ComputeType.NODE);
|
assertEquals(node.getValue().getType(), ComputeType.NODE);
|
||||||
assert node.getValue() instanceof NodeMetadata;
|
assert node.getValue() instanceof NodeMetadata;
|
||||||
NodeMetadata nodeMetadata = (NodeMetadata) node.getValue();
|
NodeMetadata nodeMetadata = (NodeMetadata) node.getValue();
|
||||||
assert nodeMetadata.getId() != null : nodeMetadata;
|
assert nodeMetadata.getId() != null : nodeMetadata;
|
||||||
|
assert nodeMetadata.getImage() != null : node;
|
||||||
// user specified name is not always supported
|
// user specified name is not always supported
|
||||||
// assert nodeMetadata.getName() != null : nodeMetadata;
|
// assert nodeMetadata.getName() != null : nodeMetadata;
|
||||||
|
if (nodeMetadata.getState() != NodeState.TERMINATED) {
|
||||||
assert nodeMetadata.getPublicAddresses() != null : nodeMetadata;
|
assert nodeMetadata.getPublicAddresses() != null : nodeMetadata;
|
||||||
|
assert nodeMetadata.getPublicAddresses().size() > 0 : nodeMetadata;
|
||||||
assert nodeMetadata.getPublicAddresses().size() > 1 : nodeMetadata;
|
|
||||||
assertNotNull(nodeMetadata.getPrivateAddresses());
|
assertNotNull(nodeMetadata.getPrivateAddresses());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testListImages() throws Exception {
|
public void testListImages() throws Exception {
|
||||||
for (Entry<String, ? extends Image> image : client.getImages().entrySet()) {
|
for (Entry<String, ? extends Image> image : client.getImages().entrySet()) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class TemplateBuilderImplTest {
|
||||||
public void testImageIdNullsEverythingElse() {
|
public void testImageIdNullsEverythingElse() {
|
||||||
TemplateBuilderImpl template = new TemplateBuilderImpl(ImmutableMap.<String, Location> of(),
|
TemplateBuilderImpl template = new TemplateBuilderImpl(ImmutableMap.<String, Location> of(),
|
||||||
ImmutableMap.<String, Image> of(), ImmutableMap.<String, Size> of(),
|
ImmutableMap.<String, Image> of(), ImmutableMap.<String, Size> of(),
|
||||||
new LocationImpl(LocationScope.REGION, " id", "description", null, true));
|
new LocationImpl(LocationScope.REGION, " id", "description", null));
|
||||||
template.architecture(Architecture.X86_32);
|
template.architecture(Architecture.X86_32);
|
||||||
template.imageDescriptionMatches("imageDescriptionMatches");
|
template.imageDescriptionMatches("imageDescriptionMatches");
|
||||||
template.imageNameMatches("imageNameMatches");
|
template.imageNameMatches("imageNameMatches");
|
||||||
|
|
11
core/pom.xml
11
core/pom.xml
|
@ -84,9 +84,14 @@
|
||||||
<version>1.4</version>
|
<version>1.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.common</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>google-guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>1.0-r11</version>
|
<version>r03</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
|
<artifactId>jsr305</artifactId>
|
||||||
|
<version>1.3.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -18,17 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.concurrent.internal;
|
package org.jclouds.concurrent.internal;
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates RESTful clients from appropriately annotated interfaces.
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
import java.lang.reflect.InvocationHandler;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -39,10 +34,15 @@ import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates RESTful clients from appropriately annotated interfaces.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SyncProxy implements InvocationHandler {
|
public class SyncProxy implements InvocationHandler {
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class SyncProxy implements InvocationHandler {
|
||||||
private final Map<Method, Method> methodMap;
|
private final Map<Method, Method> methodMap;
|
||||||
private final Map<Method, Method> syncMethodMap;
|
private final Map<Method, Method> syncMethodMap;
|
||||||
private final Map<Method, Long> timeoutMap;
|
private final Map<Method, Long> timeoutMap;
|
||||||
private static final List<Method> objectMethods = ImmutableList.of(Object.class.getMethods());
|
private static final Set<Method> objectMethods = ImmutableSet.copyOf(Object.class.getMethods());
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SyncProxy(Class<?> declaring, Object delegate) throws SecurityException,
|
public SyncProxy(Class<?> declaring, Object delegate) throws SecurityException,
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.domain;
|
package org.jclouds.domain;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Running Operating system
|
* Running Operating system
|
||||||
*
|
*
|
||||||
|
@ -53,10 +52,4 @@ public interface Location {
|
||||||
*/
|
*/
|
||||||
String getParent();
|
String getParent();
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether nodes can be assigned to this location. It is possible that a location is a container
|
|
||||||
* type that cannot be assigned to, or that a location is full.
|
|
||||||
*/
|
|
||||||
boolean isAssignable();
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -49,9 +49,9 @@ public interface MutableResourceMetadata<T extends Enum<T>> extends ResourceMeta
|
||||||
void setName(String name);
|
void setName(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #getLocationId
|
* @see #getLocation
|
||||||
*/
|
*/
|
||||||
void setLocationId(String location);
|
void setLocation(Location location);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #getUri
|
* @see #getUri
|
||||||
|
@ -63,5 +63,4 @@ public interface MutableResourceMetadata<T extends Enum<T>> extends ResourceMeta
|
||||||
*/
|
*/
|
||||||
void setUserMetadata(Map<String, String> userMetadata);
|
void setUserMetadata(Map<String, String> userMetadata);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,6 +21,8 @@ package org.jclouds.domain;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.domain.internal.ResourceMetadataImpl;
|
||||||
|
|
||||||
import com.google.inject.ImplementedBy;
|
import com.google.inject.ImplementedBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +30,7 @@ import com.google.inject.ImplementedBy;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@ImplementedBy(ResourceMetadata.class)
|
@ImplementedBy(ResourceMetadataImpl.class)
|
||||||
public interface ResourceMetadata<T extends Enum<T>> extends Comparable<ResourceMetadata<T>> {
|
public interface ResourceMetadata<T extends Enum<T>> extends Comparable<ResourceMetadata<T>> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +59,7 @@ public interface ResourceMetadata<T extends Enum<T>> extends Comparable<Resource
|
||||||
* ex. us-west-1
|
* ex. us-west-1
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
String getLocationId();
|
Location getLocation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URI used to access this resource
|
* URI used to access this resource
|
||||||
|
|
|
@ -41,15 +41,12 @@ public class LocationImpl implements Location, Serializable {
|
||||||
private final String id;
|
private final String id;
|
||||||
private final String description;
|
private final String description;
|
||||||
private final String parent;
|
private final String parent;
|
||||||
private final boolean assignable;
|
|
||||||
|
|
||||||
public LocationImpl(LocationScope scope, String id, String description, @Nullable String parent,
|
public LocationImpl(LocationScope scope, String id, String description, @Nullable String parent) {
|
||||||
boolean assignable) {
|
|
||||||
this.scope = checkNotNull(scope, "scope");
|
this.scope = checkNotNull(scope, "scope");
|
||||||
this.id = checkNotNull(id, "id");
|
this.id = checkNotNull(id, "id");
|
||||||
this.description = checkNotNull(description, "description");
|
this.description = checkNotNull(description, "description");
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.assignable = checkNotNull(assignable, "assignable");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocationScope getScope() {
|
public LocationScope getScope() {
|
||||||
|
@ -68,15 +65,10 @@ public class LocationImpl implements Location, Serializable {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAssignable() {
|
|
||||||
return assignable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + (assignable ? 1231 : 1237);
|
|
||||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||||
result = prime * result + ((parent == null) ? 0 : parent.hashCode());
|
result = prime * result + ((parent == null) ? 0 : parent.hashCode());
|
||||||
|
@ -93,8 +85,6 @@ public class LocationImpl implements Location, Serializable {
|
||||||
if (getClass() != obj.getClass())
|
if (getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
LocationImpl other = (LocationImpl) obj;
|
LocationImpl other = (LocationImpl) obj;
|
||||||
if (assignable != other.assignable)
|
|
||||||
return false;
|
|
||||||
if (description == null) {
|
if (description == null) {
|
||||||
if (other.description != null)
|
if (other.description != null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -121,7 +111,7 @@ public class LocationImpl implements Location, Serializable {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + id + ", scope=" + scope + ", description=" + description + ", parent="
|
return "[id=" + id + ", scope=" + scope + ", description=" + description + ", parent="
|
||||||
+ parent + ", assignable=" + assignable + "]";
|
+ parent + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -22,6 +22,7 @@ import java.io.Serializable;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.MutableResourceMetadata;
|
import org.jclouds.domain.MutableResourceMetadata;
|
||||||
import org.jclouds.domain.ResourceMetadata;
|
import org.jclouds.domain.ResourceMetadata;
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ public class MutableResourceMetadataImpl<T extends Enum<T>> implements MutableRe
|
||||||
private T type;
|
private T type;
|
||||||
private String id;
|
private String id;
|
||||||
private String name;
|
private String name;
|
||||||
private String location;
|
private Location location;
|
||||||
private URI uri;
|
private URI uri;
|
||||||
private Map<String, String> userMetadata;
|
private Map<String, String> userMetadata;
|
||||||
|
|
||||||
|
@ -53,7 +54,7 @@ public class MutableResourceMetadataImpl<T extends Enum<T>> implements MutableRe
|
||||||
this.type = from.getType();
|
this.type = from.getType();
|
||||||
this.id = from.getId();
|
this.id = from.getId();
|
||||||
this.name = from.getName();
|
this.name = from.getName();
|
||||||
this.location = from.getLocationId();
|
this.location = from.getLocation();
|
||||||
this.uri = from.getUri();
|
this.uri = from.getUri();
|
||||||
this.userMetadata = from.getUserMetadata();
|
this.userMetadata = from.getUserMetadata();
|
||||||
}
|
}
|
||||||
|
@ -152,7 +153,7 @@ public class MutableResourceMetadataImpl<T extends Enum<T>> implements MutableRe
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setLocationId(String location) {
|
public void setLocation(Location location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +161,7 @@ public class MutableResourceMetadataImpl<T extends Enum<T>> implements MutableRe
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getLocationId() {
|
public Location getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.io.Serializable;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.ResourceMetadata;
|
import org.jclouds.domain.ResourceMetadata;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
@ -45,17 +46,17 @@ public class ResourceMetadataImpl<T extends Enum<T>> implements ResourceMetadata
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String name;
|
private final String name;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String locationId;
|
private final Location location;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final URI uri;
|
private final URI uri;
|
||||||
private final Map<String, String> userMetadata = Maps.newLinkedHashMap();
|
private final Map<String, String> userMetadata = Maps.newLinkedHashMap();
|
||||||
|
|
||||||
public ResourceMetadataImpl(T type, @Nullable String id, @Nullable String name,
|
public ResourceMetadataImpl(T type, @Nullable String id, @Nullable String name,
|
||||||
@Nullable String locationId, @Nullable URI uri, Map<String, String> userMetadata) {
|
@Nullable Location location, @Nullable URI uri, Map<String, String> userMetadata) {
|
||||||
this.type = checkNotNull(type, "type");
|
this.type = checkNotNull(type, "type");
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.locationId = locationId;
|
this.location = location;
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
this.userMetadata.putAll(checkNotNull(userMetadata, "userMetadata"));
|
this.userMetadata.putAll(checkNotNull(userMetadata, "userMetadata"));
|
||||||
}
|
}
|
||||||
|
@ -98,8 +99,8 @@ public class ResourceMetadataImpl<T extends Enum<T>> implements ResourceMetadata
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getLocationId() {
|
public Location getLocation() {
|
||||||
return locationId;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,7 +121,7 @@ public class ResourceMetadataImpl<T extends Enum<T>> implements ResourceMetadata
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[type=" + type + ", id=" + id + ", name=" + name + ", location=" + locationId
|
return "[type=" + type + ", id=" + id + ", name=" + name + ", location=" + location
|
||||||
+ ", uri=" + uri + ", userMetadata=" + userMetadata + "]";
|
+ ", uri=" + uri + ", userMetadata=" + userMetadata + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +130,7 @@ public class ResourceMetadataImpl<T extends Enum<T>> implements ResourceMetadata
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||||
result = prime * result + ((locationId == null) ? 0 : locationId.hashCode());
|
result = prime * result + ((location == null) ? 0 : location.hashCode());
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||||
result = prime * result + ((uri == null) ? 0 : uri.hashCode());
|
result = prime * result + ((uri == null) ? 0 : uri.hashCode());
|
||||||
|
@ -150,10 +151,10 @@ public class ResourceMetadataImpl<T extends Enum<T>> implements ResourceMetadata
|
||||||
return false;
|
return false;
|
||||||
} else if (!id.equals(other.id))
|
} else if (!id.equals(other.id))
|
||||||
return false;
|
return false;
|
||||||
if (locationId == null) {
|
if (location == null) {
|
||||||
if (other.locationId != null)
|
if (other.location != null)
|
||||||
return false;
|
return false;
|
||||||
} else if (!locationId.equals(other.locationId))
|
} else if (!location.equals(other.location))
|
||||||
return false;
|
return false;
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
if (other.name != null)
|
if (other.name != null)
|
||||||
|
@ -173,5 +174,4 @@ public class ResourceMetadataImpl<T extends Enum<T>> implements ResourceMetadata
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,11 +19,11 @@
|
||||||
package org.jclouds.http;
|
package org.jclouds.http;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Futures.compose;
|
import static com.google.common.util.concurrent.Futures.compose;
|
||||||
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.util.concurrent.Executors;
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +46,7 @@ public class TransformingHttpCommandExecutorServiceImpl implements
|
||||||
*/
|
*/
|
||||||
public <T> ListenableFuture<T> submit(HttpCommand command,
|
public <T> ListenableFuture<T> submit(HttpCommand command,
|
||||||
Function<HttpResponse, T> responseTransformer) {
|
Function<HttpResponse, T> responseTransformer) {
|
||||||
return compose(client.submit(command), responseTransformer, Executors.sameThreadExecutor());
|
return compose(client.submit(command), responseTransformer, sameThreadExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.predicates.validators;
|
||||||
|
|
||||||
|
import static com.google.common.base.CharMatcher.inRange;
|
||||||
|
import static com.google.common.base.CharMatcher.is;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.jclouds.predicates.Validator;
|
||||||
|
|
||||||
|
import com.google.common.base.CharMatcher;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates name for dns-style names
|
||||||
|
*
|
||||||
|
* @see org.jclouds.rest.InputParamValidator
|
||||||
|
* @see org.jclouds.predicates.Validator
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class DnsNameValidator extends Validator<String> {
|
||||||
|
private int min;
|
||||||
|
private int max;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
protected DnsNameValidator(@Named("jclouds.dns_name_length_min") int min,
|
||||||
|
@Named("jclouds.dns_name_length_max") int max) {
|
||||||
|
this.min = min;
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate(String name) {
|
||||||
|
|
||||||
|
if (name == null || name.length() < min || name.length() > max)
|
||||||
|
throw exception(name, "Can't be null or empty. Length must be " + min + " to " + max
|
||||||
|
+ " symbols.");
|
||||||
|
if (CharMatcher.JAVA_LETTER_OR_DIGIT.indexIn(name) != 0)
|
||||||
|
throw exception(name, "Should start with letter/number");
|
||||||
|
if (!name.toLowerCase().equals(name))
|
||||||
|
throw exception(name, "Should be only lowercase");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The name must be a valid DNS name. From wikipedia: "The characters allowed in a label are a
|
||||||
|
* subset of the ASCII character set, a and includes the characters a through z, A through Z,
|
||||||
|
* digits 0 through 9". From Azure: Every Dash (-) Must Be Immediately Preceded and Followed
|
||||||
|
* by a Letter or Number.
|
||||||
|
*/
|
||||||
|
CharMatcher lettersNumbersOrDashes = inRange('a', 'z').or(inRange('0', '9').or(is('-')));
|
||||||
|
if (!lettersNumbersOrDashes.matchesAllOf(name))
|
||||||
|
throw exception(name, "Should have lowercase ASCII letters, " + "numbers, or dashes");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IllegalArgumentException exception(String vAppName, String reason) {
|
||||||
|
return new IllegalArgumentException(String.format(
|
||||||
|
"Object '%s' doesn't match dns naming constraints. " + "Reason: %s.", vAppName,
|
||||||
|
reason));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.rest;
|
package org.jclouds.rest;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.concurrent;
|
package org.jclouds.concurrent;
|
||||||
|
|
||||||
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.jclouds.concurrent.ConcurrentUtils.makeListenable;
|
import static org.jclouds.concurrent.ConcurrentUtils.makeListenable;
|
||||||
import static org.jclouds.util.Utils.propagateOrNull;
|
import static org.jclouds.util.Utils.propagateOrNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
@ -33,7 +34,6 @@ import org.testng.annotations.Test;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.util.concurrent.Executors;
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,7 +43,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "concurrent.ListenableFutureExceptionParserTest")
|
@Test(groups = "unit", testName = "concurrent.ListenableFutureExceptionParserTest")
|
||||||
public class FutureExceptionParserTest {
|
public class FutureExceptionParserTest {
|
||||||
ExecutorService executorService = Executors.sameThreadExecutor();
|
ExecutorService executorService = sameThreadExecutor();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGet() throws InterruptedException, ExecutionException {
|
public void testGet() throws InterruptedException, ExecutionException {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rest;
|
package org.jclouds.rest;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
|
@ -18,15 +18,13 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rest;
|
package org.jclouds.rest;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNull;
|
import static org.testng.Assert.assertNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
|
||||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||||
import org.jclouds.http.HttpUtils;
|
import org.jclouds.http.HttpUtils;
|
||||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||||
|
@ -34,11 +32,9 @@ import org.jclouds.rest.config.RestModule;
|
||||||
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
|
||||||
import org.jclouds.util.Utils;
|
import org.jclouds.util.Utils;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Key;
|
import com.google.inject.Key;
|
||||||
|
@ -47,7 +43,25 @@ import com.google.inject.TypeLiteral;
|
||||||
import com.google.inject.internal.Nullable;
|
import com.google.inject.internal.Nullable;
|
||||||
|
|
||||||
public abstract class RestClientTest<T> {
|
public abstract class RestClientTest<T> {
|
||||||
|
// , new AbstractModule() {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected void configure() {
|
||||||
|
// Jsr330.bindProperties(binder(), new PropertiesBuilder() {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public PropertiesBuilder withCredentials(String account, String key) {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public PropertiesBuilder withEndpoint(URI endpoint) {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// }.build());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
protected RestAnnotationProcessor<T> processor;
|
protected RestAnnotationProcessor<T> processor;
|
||||||
protected Injector injector;
|
protected Injector injector;
|
||||||
|
|
||||||
|
@ -60,25 +74,8 @@ public abstract class RestClientTest<T> {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
protected void setupFactory() {
|
protected void setupFactory() {
|
||||||
|
|
||||||
injector = Guice.createInjector(createModule(), new AbstractModule() {
|
injector = Guice.createInjector(createModule(), new RestModule(), new ExecutorServiceModule(
|
||||||
|
sameThreadExecutor(), sameThreadExecutor()),
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Jsr330.bindProperties(binder(), new PropertiesBuilder() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PropertiesBuilder withCredentials(String account, String key) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PropertiesBuilder withEndpoint(URI endpoint) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
}, new RestModule(), new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()),
|
|
||||||
new JavaUrlHttpCommandExecutorServiceModule());
|
new JavaUrlHttpCommandExecutorServiceModule());
|
||||||
|
|
||||||
processor = injector.getInstance(Key.get(createTypeLiteral()));
|
processor = injector.getInstance(Key.get(createTypeLiteral()));
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.rest.internal;
|
package org.jclouds.rest.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNull;
|
import static org.testng.Assert.assertNull;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.gae;
|
package org.jclouds.gae;
|
||||||
|
|
||||||
import static com.google.appengine.api.urlfetch.FetchOptions.Builder.disallowTruncate;
|
import static com.google.appengine.api.urlfetch.FetchOptions.Builder.disallowTruncate;
|
||||||
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -53,7 +54,6 @@ import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.google.common.io.Closeables;
|
import com.google.common.io.Closeables;
|
||||||
import com.google.common.util.concurrent.Executors;
|
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
@ -84,8 +84,8 @@ public class AsyncGaeHttpCommandExecutorService implements HttpCommandExecutorSe
|
||||||
public ListenableFuture<HttpResponse> submit(HttpCommand command) {
|
public ListenableFuture<HttpResponse> submit(HttpCommand command) {
|
||||||
// TODO: this needs to handle retrying and filtering
|
// TODO: this needs to handle retrying and filtering
|
||||||
return Futures.compose(ConcurrentUtils.makeListenable(urlFetchService
|
return Futures.compose(ConcurrentUtils.makeListenable(urlFetchService
|
||||||
.fetchAsync(convertToGaeRequest.apply(command.getRequest())), Executors
|
.fetchAsync(convertToGaeRequest.apply(command.getRequest())), sameThreadExecutor()),
|
||||||
.sameThreadExecutor()), convertToJcloudsResponse);
|
convertToJcloudsResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gae.config;
|
package org.jclouds.gae.config;
|
||||||
|
|
||||||
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
|
|
||||||
import org.jclouds.concurrent.SingleThreaded;
|
import org.jclouds.concurrent.SingleThreaded;
|
||||||
import org.jclouds.concurrent.config.ConfiguresExecutorService;
|
import org.jclouds.concurrent.config.ConfiguresExecutorService;
|
||||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||||
|
@ -30,7 +32,6 @@ import org.jclouds.http.config.ConfiguresHttpCommandExecutorService;
|
||||||
|
|
||||||
import com.google.appengine.api.urlfetch.URLFetchService;
|
import com.google.appengine.api.urlfetch.URLFetchService;
|
||||||
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
|
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
|
||||||
import com.google.common.util.concurrent.Executors;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +45,7 @@ import com.google.inject.Provides;
|
||||||
public class GoogleAppEngineConfigurationModule extends ExecutorServiceModule {
|
public class GoogleAppEngineConfigurationModule extends ExecutorServiceModule {
|
||||||
|
|
||||||
public GoogleAppEngineConfigurationModule() {
|
public GoogleAppEngineConfigurationModule() {
|
||||||
super(Executors.sameThreadExecutor(), Executors.sameThreadExecutor());
|
super(sameThreadExecutor(), sameThreadExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Properties;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||||
import org.jclouds.gogrid.config.GoGridComputeServiceContextModule;
|
import org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule;
|
||||||
import org.jclouds.gogrid.config.GoGridRestClientModule;
|
import org.jclouds.gogrid.config.GoGridRestClientModule;
|
||||||
import org.jclouds.gogrid.config.internal.GoGridResolveImagesModule;
|
import org.jclouds.gogrid.config.internal.GoGridResolveImagesModule;
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,7 @@ import static org.jclouds.gogrid.reference.GoGridQueryParams.REAL_IP_LIST_KEY;
|
||||||
/**
|
/**
|
||||||
* Binds a list of real IPs to the request.
|
* Binds a list of real IPs to the request.
|
||||||
*
|
*
|
||||||
* The {@link IpPortPair pairs} must have a {@link IpPortPair#ip} set with a valid
|
* The {@link IpPortPair pairs} must have a {@link IpPortPair#ip} set with a valid IP address.
|
||||||
* IP address.
|
|
||||||
*
|
*
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
|
@ -54,13 +53,14 @@ public class BindRealIpPortPairsToQueryParams implements Binder {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (IpPortPair ipPortPair : ipPortPairs) {
|
for (IpPortPair ipPortPair : ipPortPairs) {
|
||||||
checkNotNull(ipPortPair.getIp(), "There must be an IP address defined");
|
checkNotNull(ipPortPair.getIp(), "There must be an IP address defined");
|
||||||
checkNotNull(ipPortPair.getIp().getIp(), "There must be an IP address defined in Ip object");
|
checkNotNull(ipPortPair.getIp().getIp(),
|
||||||
|
"There must be an IP address defined in Ip object");
|
||||||
checkState(ipPortPair.getPort() > 0, "The port number must be a positive integer");
|
checkState(ipPortPair.getPort() > 0, "The port number must be a positive integer");
|
||||||
|
|
||||||
generatedRequest.addQueryParam(REAL_IP_LIST_KEY + i + ".ip",
|
generatedRequest.addQueryParam(REAL_IP_LIST_KEY + i + ".ip", ipPortPair.getIp().getIp()
|
||||||
ipPortPair.getIp().getIp());
|
.getHostAddress());
|
||||||
generatedRequest.addQueryParam(REAL_IP_LIST_KEY + i + ".port",
|
generatedRequest.addQueryParam(REAL_IP_LIST_KEY + i + ".port", String.valueOf(ipPortPair
|
||||||
String.valueOf(ipPortPair.getPort()));
|
.getPort()));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,8 @@ public class BindVirtualIpPortPairToQueryParams implements Binder {
|
||||||
checkNotNull(ipPortPair.getIp().getIp(), "There must be an IP address defined in Ip object");
|
checkNotNull(ipPortPair.getIp().getIp(), "There must be an IP address defined in Ip object");
|
||||||
checkState(ipPortPair.getPort() > 0, "The port number must be a positive integer");
|
checkState(ipPortPair.getPort() > 0, "The port number must be a positive integer");
|
||||||
|
|
||||||
generatedRequest.addQueryParam(VIRTUAL_IP_KEY + "ip", ipPortPair.getIp().getIp());
|
generatedRequest.addQueryParam(VIRTUAL_IP_KEY + "ip", ipPortPair.getIp().getIp()
|
||||||
|
.getHostAddress());
|
||||||
generatedRequest.addQueryParam(VIRTUAL_IP_KEY + "port", String.valueOf(ipPortPair.getPort()));
|
generatedRequest.addQueryParam(VIRTUAL_IP_KEY + "port", String.valueOf(ipPortPair.getPort()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.config;
|
package org.jclouds.gogrid.compute.config;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.*;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.compute.domain.OsFamily.CENTOS;
|
import static org.jclouds.compute.domain.OsFamily.CENTOS;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
@ -48,20 +48,26 @@ import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.domain.internal.ImageImpl;
|
import org.jclouds.compute.domain.internal.ImageImpl;
|
||||||
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
|
||||||
import org.jclouds.compute.domain.internal.SizeImpl;
|
import org.jclouds.compute.domain.internal.SizeImpl;
|
||||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||||
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
||||||
import org.jclouds.compute.options.GetNodesOptions;
|
import org.jclouds.compute.options.GetNodesOptions;
|
||||||
import org.jclouds.compute.predicates.RunScriptRunning;
|
import org.jclouds.compute.predicates.RunScriptRunning;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.*;
|
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||||
|
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||||
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
|
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||||
|
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
||||||
|
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.domain.LocationScope;
|
import org.jclouds.domain.LocationScope;
|
||||||
import org.jclouds.domain.internal.LocationImpl;
|
import org.jclouds.domain.internal.LocationImpl;
|
||||||
import org.jclouds.gogrid.GoGridAsyncClient;
|
import org.jclouds.gogrid.GoGridAsyncClient;
|
||||||
import org.jclouds.gogrid.GoGridClient;
|
import org.jclouds.gogrid.GoGridClient;
|
||||||
|
import org.jclouds.gogrid.compute.functions.ServerToNodeMetadata;
|
||||||
|
import org.jclouds.gogrid.config.GoGridContextModule;
|
||||||
import org.jclouds.gogrid.domain.Ip;
|
import org.jclouds.gogrid.domain.Ip;
|
||||||
import org.jclouds.gogrid.domain.IpType;
|
import org.jclouds.gogrid.domain.IpType;
|
||||||
import org.jclouds.gogrid.domain.PowerCommand;
|
import org.jclouds.gogrid.domain.PowerCommand;
|
||||||
|
@ -75,12 +81,10 @@ import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
|
|
||||||
import com.google.common.base.CharMatcher;
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -115,7 +119,7 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
@Named("NAMING_CONVENTION")
|
@Named("NAMING_CONVENTION")
|
||||||
@Singleton
|
@Singleton
|
||||||
String provideNamingConvention() {
|
String provideNamingConvention() {
|
||||||
return "%s-%d";
|
return "%s-%s";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -315,36 +319,6 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
|
||||||
private static class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
|
||||||
private final Map<String, NodeState> serverStateToNodeState;
|
|
||||||
private final Function<String, InetAddress> stringIpToInetAddress;
|
|
||||||
private final GoGridClient client;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Inject
|
|
||||||
ServerToNodeMetadata(Map<String, NodeState> serverStateToNodeState,
|
|
||||||
Function<String, InetAddress> stringIpToInetAddress, GoGridClient client) {
|
|
||||||
this.serverStateToNodeState = serverStateToNodeState;
|
|
||||||
this.stringIpToInetAddress = stringIpToInetAddress;
|
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NodeMetadata apply(Server from) {
|
|
||||||
String locationId = "Unavailable";
|
|
||||||
String tag = CharMatcher.JAVA_LETTER.retainFrom(from.getName());
|
|
||||||
Set<InetAddress> ipSet = ImmutableSet
|
|
||||||
.of(stringIpToInetAddress.apply(from.getIp().getIp()));
|
|
||||||
NodeState state = serverStateToNodeState.get(from.getState().getName());
|
|
||||||
Credentials creds = client.getServerServices().getServerCredentialsList().get(
|
|
||||||
from.getName());
|
|
||||||
return new NodeMetadataImpl(from.getId() + "", from.getName(), locationId, null,
|
|
||||||
ImmutableMap.<String, String> of(), tag, state, ipSet, ImmutableList
|
|
||||||
.<InetAddress> of(), ImmutableMap.<String, String> of(), creds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
ComputeServiceContext provideContext(ComputeService computeService,
|
ComputeServiceContext provideContext(ComputeService computeService,
|
||||||
|
@ -372,8 +346,8 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
Function<ComputeMetadata, String> indexer) {
|
Function<ComputeMetadata, String> indexer) {
|
||||||
final Set<Location> locations = Sets.newHashSet();
|
final Set<Location> locations = Sets.newHashSet();
|
||||||
holder.logger.debug(">> providing locations");
|
holder.logger.debug(">> providing locations");
|
||||||
locations.add(new LocationImpl(LocationScope.ZONE, "SANFRANCISCO", "San Francisco, CA", null,
|
locations
|
||||||
true));
|
.add(new LocationImpl(LocationScope.ZONE, "SANFRANCISCO", "San Francisco, CA", null));
|
||||||
holder.logger.debug("<< locations(%d)", locations.size());
|
holder.logger.debug("<< locations(%d)", locations.size());
|
||||||
return Maps.uniqueIndex(locations, new Function<Location, String>() {
|
return Maps.uniqueIndex(locations, new Function<Location, String>() {
|
||||||
|
|
||||||
|
@ -452,8 +426,8 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
holder.logger.debug("<< didn't match os(%s)", matchedOs);
|
holder.logger.debug("<< didn't match os(%s)", matchedOs);
|
||||||
}
|
}
|
||||||
Credentials defaultCredentials = authenticator.execute(from);
|
Credentials defaultCredentials = authenticator.execute(from);
|
||||||
images.add(new ImageImpl(from.getId() + "", from.getFriendlyName(), location.getId(),
|
images.add(new ImageImpl(from.getId() + "", from.getFriendlyName(), location, null,
|
||||||
null, ImmutableMap.<String, String> of(), from.getDescription(), version, os,
|
ImmutableMap.<String, String> of(), from.getDescription(), version, os,
|
||||||
osDescription, arch, defaultCredentials));
|
osDescription, arch, defaultCredentials));
|
||||||
}
|
}
|
||||||
holder.logger.debug("<< images(%d)", images.size());
|
holder.logger.debug("<< images(%d)", images.size());
|
|
@ -0,0 +1,74 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.gogrid.compute.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.NodeState;
|
||||||
|
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
||||||
|
import org.jclouds.domain.Credentials;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.gogrid.domain.Server;
|
||||||
|
import org.jclouds.gogrid.services.GridServerClient;
|
||||||
|
|
||||||
|
import com.google.common.base.CharMatcher;
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Oleksiy Yarmula
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||||
|
private final Map<String, NodeState> serverStateToNodeState;
|
||||||
|
private final GridServerClient client;
|
||||||
|
private final Location location;
|
||||||
|
private final Map<String, ? extends Image> images;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ServerToNodeMetadata(Map<String, NodeState> serverStateToNodeState, GridServerClient client,
|
||||||
|
Map<String, ? extends Image> images, Location location) {
|
||||||
|
this.serverStateToNodeState = checkNotNull(serverStateToNodeState, "serverStateToNodeState");
|
||||||
|
this.client = checkNotNull(client, "client");
|
||||||
|
this.images = checkNotNull(images, "images");
|
||||||
|
this.location = checkNotNull(location, "location");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NodeMetadata apply(Server from) {
|
||||||
|
String tag = CharMatcher.JAVA_LETTER.retainFrom(from.getName());
|
||||||
|
Set<InetAddress> ipSet = ImmutableSet.of(from.getIp().getIp());
|
||||||
|
NodeState state = serverStateToNodeState.get(from.getState().getName());
|
||||||
|
Credentials creds = client.getServerCredentialsList().get(from.getName());
|
||||||
|
return new NodeMetadataImpl(from.getId() + "", from.getName(), location, null, ImmutableMap
|
||||||
|
.<String, String> of(), tag, images.get(from.getImage().getId() + ""), state, ipSet,
|
||||||
|
ImmutableList.<InetAddress> of(), ImmutableMap.<String, String> of(), creds);
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,6 +23,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.domain;
|
package org.jclouds.gogrid.domain;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
|
||||||
import com.google.common.primitives.Longs;
|
import com.google.common.primitives.Longs;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
@ -33,7 +35,7 @@ public class Ip implements Comparable<Ip> {
|
||||||
|
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
private String ip;
|
private InetAddress ip;
|
||||||
private String subnet;
|
private String subnet;
|
||||||
@SerializedName("public")
|
@SerializedName("public")
|
||||||
private boolean isPublic;
|
private boolean isPublic;
|
||||||
|
@ -46,16 +48,16 @@ public class Ip implements Comparable<Ip> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a generic IP address
|
* Constructs a generic IP address without any additional options.
|
||||||
* without any additional options.
|
|
||||||
*
|
*
|
||||||
* @param ip ip address
|
* @param ip
|
||||||
|
* ip address
|
||||||
*/
|
*/
|
||||||
public Ip(String ip) {
|
public Ip(InetAddress ip) {
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ip(long id, String ip, String subnet, boolean isPublic, IpState state) {
|
public Ip(long id, InetAddress ip, String subnet, boolean isPublic, IpState state) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
this.subnet = subnet;
|
this.subnet = subnet;
|
||||||
|
@ -67,7 +69,7 @@ public class Ip implements Comparable<Ip> {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIp() {
|
public InetAddress getIp() {
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,16 +87,23 @@ public class Ip implements Comparable<Ip> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o)
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
return true;
|
||||||
|
if (o == null || getClass() != o.getClass())
|
||||||
|
return false;
|
||||||
|
|
||||||
Ip ip1 = (Ip) o;
|
Ip ip1 = (Ip) o;
|
||||||
|
|
||||||
if (id != ip1.id) return false;
|
if (id != ip1.id)
|
||||||
if (isPublic != ip1.isPublic) return false;
|
return false;
|
||||||
if (!ip.equals(ip1.ip)) return false;
|
if (isPublic != ip1.isPublic)
|
||||||
if (state != null ? !state.equals(ip1.state) : ip1.state != null) return false;
|
return false;
|
||||||
if (subnet != null ? !subnet.equals(ip1.subnet) : ip1.subnet != null) return false;
|
if (!ip.equals(ip1.ip))
|
||||||
|
return false;
|
||||||
|
if (state != null ? !state.equals(ip1.state) : ip1.state != null)
|
||||||
|
return false;
|
||||||
|
if (subnet != null ? !subnet.equals(ip1.subnet) : ip1.subnet != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -111,13 +120,8 @@ public class Ip implements Comparable<Ip> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Ip{" +
|
return "Ip{" + "id=" + id + ", ip='" + ip + '\'' + ", subnet='" + subnet + '\''
|
||||||
"id=" + id +
|
+ ", isPublic=" + isPublic + ", state=" + state + '}';
|
||||||
", ip='" + ip + '\'' +
|
|
||||||
", subnet='" + subnet + '\'' +
|
|
||||||
", isPublic=" + isPublic +
|
|
||||||
", state=" + state +
|
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,8 +23,21 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.services;
|
package org.jclouds.gogrid.services;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
|
||||||
|
import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
|
||||||
|
import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_KEY;
|
||||||
|
import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_KEY;
|
||||||
|
import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
|
||||||
|
import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
|
||||||
|
import static org.jclouds.gogrid.reference.GoGridQueryParams.POWER_KEY;
|
||||||
|
import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_ID_OR_NAME_KEY;
|
||||||
|
import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_RAM_KEY;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
|
@ -43,13 +56,15 @@ import org.jclouds.gogrid.functions.ParseServerListFromJsonResponse;
|
||||||
import org.jclouds.gogrid.functions.ParseServerNameToCredentialsMapFromJsonResponse;
|
import org.jclouds.gogrid.functions.ParseServerNameToCredentialsMapFromJsonResponse;
|
||||||
import org.jclouds.gogrid.options.AddServerOptions;
|
import org.jclouds.gogrid.options.AddServerOptions;
|
||||||
import org.jclouds.gogrid.options.GetServerListOptions;
|
import org.jclouds.gogrid.options.GetServerListOptions;
|
||||||
import org.jclouds.rest.annotations.*;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
|
import org.jclouds.rest.annotations.ParamParser;
|
||||||
|
import org.jclouds.rest.annotations.QueryParams;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.annotations.ResponseParser;
|
||||||
|
|
||||||
import java.util.Map;
|
import com.google.common.base.Function;
|
||||||
import java.util.Set;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.*;
|
|
||||||
import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to GoGrid via their REST API.
|
* Provides asynchronous access to GoGrid via their REST API.
|
||||||
|
@ -79,7 +94,8 @@ public interface GridServerAsyncClient {
|
||||||
@GET
|
@GET
|
||||||
@ResponseParser(ParseServerListFromJsonResponse.class)
|
@ResponseParser(ParseServerListFromJsonResponse.class)
|
||||||
@Path("/grid/server/get")
|
@Path("/grid/server/get")
|
||||||
ListenableFuture<Set<Server>> getServersByName(@BinderParam(BindNamesToQueryParams.class) String... names);
|
ListenableFuture<Set<Server>> getServersByName(
|
||||||
|
@BinderParam(BindNamesToQueryParams.class) String... names);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see GridServerClient#getServersById(Long...)
|
* @see GridServerClient#getServersById(Long...)
|
||||||
|
@ -87,7 +103,8 @@ public interface GridServerAsyncClient {
|
||||||
@GET
|
@GET
|
||||||
@ResponseParser(ParseServerListFromJsonResponse.class)
|
@ResponseParser(ParseServerListFromJsonResponse.class)
|
||||||
@Path("/grid/server/get")
|
@Path("/grid/server/get")
|
||||||
ListenableFuture<Set<Server>> getServersById(@BinderParam(BindIdsToQueryParams.class) Long... ids);
|
ListenableFuture<Set<Server>> getServersById(
|
||||||
|
@BinderParam(BindIdsToQueryParams.class) Long... ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see GridServerClient#getServerCredentialsList
|
* @see GridServerClient#getServerCredentialsList
|
||||||
|
@ -98,17 +115,26 @@ public interface GridServerAsyncClient {
|
||||||
ListenableFuture<Map<String, Credentials>> getServerCredentialsList();
|
ListenableFuture<Map<String, Credentials>> getServerCredentialsList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see GridServerClient#addServer(String, String, String, String, org.jclouds.gogrid.options.AddServerOptions...)
|
* @see GridServerClient#addServer(String, String, String, String,
|
||||||
|
* org.jclouds.gogrid.options.AddServerOptions...)
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@ResponseParser(ParseServerFromJsonResponse.class)
|
@ResponseParser(ParseServerFromJsonResponse.class)
|
||||||
@Path("/grid/server/add")
|
@Path("/grid/server/add")
|
||||||
ListenableFuture<Server> addServer(@QueryParam(NAME_KEY) String name,
|
ListenableFuture<Server> addServer(@QueryParam(NAME_KEY) String name,
|
||||||
@QueryParam(IMAGE_KEY) String image,
|
@QueryParam(IMAGE_KEY) String image, @QueryParam(SERVER_RAM_KEY) String ram,
|
||||||
@QueryParam(SERVER_RAM_KEY) String ram,
|
@QueryParam(IP_KEY) @ParamParser(InetAddressHostName.class) InetAddress ip,
|
||||||
@QueryParam(IP_KEY) String ip,
|
|
||||||
AddServerOptions... addServerOptions);
|
AddServerOptions... addServerOptions);
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public static class InetAddressHostName implements Function<Object, String> {
|
||||||
|
|
||||||
|
public String apply(Object from) {
|
||||||
|
return ((InetAddress) from).getHostAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see GridServerClient#power(String, org.jclouds.gogrid.domain.PowerCommand)
|
* @see GridServerClient#power(String, org.jclouds.gogrid.domain.PowerCommand)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.services;
|
package org.jclouds.gogrid.services;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -101,7 +102,7 @@ public interface GridServerClient {
|
||||||
Server addServer(String name,
|
Server addServer(String name,
|
||||||
String image,
|
String image,
|
||||||
String ram,
|
String ram,
|
||||||
String ip,
|
InetAddress ip,
|
||||||
AddServerOptions... addServerOptions);
|
AddServerOptions... addServerOptions);
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,7 +146,7 @@ public interface GridServerClient {
|
||||||
* most cases, id or name will be used for {@link #addServer}.
|
* most cases, id or name will be used for {@link #addServer}.
|
||||||
*
|
*
|
||||||
* To see how RAM maps to CPU and disk space (as of March 2010),
|
* To see how RAM maps to CPU and disk space (as of March 2010),
|
||||||
* see {@link org.jclouds.gogrid.config.GoGridComputeServiceContextModule#provideSizeToRam}.
|
* see {@link org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule#provideSizeToRam}.
|
||||||
*
|
*
|
||||||
* @return supported ram sizes
|
* @return supported ram sizes
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -25,7 +25,6 @@ import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -345,8 +344,7 @@ public class GoGridLiveTest {
|
||||||
Credentials instanceCredentials = credsMap.get(createdServer.getName());
|
Credentials instanceCredentials = credsMap.get(createdServer.getName());
|
||||||
assertNotNull(instanceCredentials);
|
assertNotNull(instanceCredentials);
|
||||||
|
|
||||||
InetSocketAddress socket = new InetSocketAddress(InetAddress.getByName(createdServer.getIp()
|
InetSocketAddress socket = new InetSocketAddress(createdServer.getIp().getIp(), 22);
|
||||||
.getIp()), 22);
|
|
||||||
|
|
||||||
Predicate<InetSocketAddress> socketOpen = new RetryablePredicate<InetSocketAddress>(
|
Predicate<InetSocketAddress> socketOpen = new RetryablePredicate<InetSocketAddress>(
|
||||||
new SocketOpen(), 180, 5, TimeUnit.SECONDS);
|
new SocketOpen(), 180, 5, TimeUnit.SECONDS);
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
package org.jclouds.gogrid.compute.functions;
|
||||||
|
|
||||||
|
import static org.easymock.EasyMock.expect;
|
||||||
|
import static org.easymock.classextension.EasyMock.createMock;
|
||||||
|
import static org.easymock.classextension.EasyMock.replay;
|
||||||
|
import static org.easymock.classextension.EasyMock.verify;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.NodeState;
|
||||||
|
import org.jclouds.domain.Credentials;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.domain.LocationScope;
|
||||||
|
import org.jclouds.domain.internal.LocationImpl;
|
||||||
|
import org.jclouds.gogrid.domain.Ip;
|
||||||
|
import org.jclouds.gogrid.domain.Option;
|
||||||
|
import org.jclouds.gogrid.domain.Server;
|
||||||
|
import org.jclouds.gogrid.domain.ServerImage;
|
||||||
|
import org.jclouds.gogrid.services.GridServerClient;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "gogrid.ServerToNodeMetadataTest")
|
||||||
|
public class ServerToNodeMetadataTest {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Test
|
||||||
|
public void testApplySetsTagFromNameAndCredentialsFromName() throws UnknownHostException {
|
||||||
|
GridServerClient client = createMock(GridServerClient.class);
|
||||||
|
Map<String, NodeState> serverStateToNodeState = createMock(Map.class);
|
||||||
|
Map<String, org.jclouds.compute.domain.Image> images = createMock(Map.class);
|
||||||
|
Server server = createMock(Server.class);
|
||||||
|
|
||||||
|
expect(server.getId()).andReturn(1000l).atLeastOnce();
|
||||||
|
expect(server.getName()).andReturn("tag").atLeastOnce();
|
||||||
|
expect(server.getState()).andReturn(new Option("RUNNING")).atLeastOnce();
|
||||||
|
|
||||||
|
expect(serverStateToNodeState.get("RUNNING")).andReturn(NodeState.RUNNING);
|
||||||
|
Location location = new LocationImpl(LocationScope.ZONE, "sanfran", "description", null);
|
||||||
|
|
||||||
|
Map<String, Credentials> credentialsMap = createMock(Map.class);
|
||||||
|
expect(client.getServerCredentialsList()).andReturn(credentialsMap);
|
||||||
|
expect(credentialsMap.get("tag")).andReturn(new Credentials("user", "pass"));
|
||||||
|
|
||||||
|
expect(server.getIp()).andReturn(
|
||||||
|
new Ip(InetAddress.getByAddress(new byte[] { 12, 10, 10, 1 })));
|
||||||
|
|
||||||
|
ServerImage image = createMock(ServerImage.class);
|
||||||
|
expect(server.getImage()).andReturn(image).atLeastOnce();
|
||||||
|
expect(image.getId()).andReturn(2000l).atLeastOnce();
|
||||||
|
|
||||||
|
|
||||||
|
org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class);
|
||||||
|
expect(images.get("2000")).andReturn(jcImage);
|
||||||
|
|
||||||
|
|
||||||
|
replay(client);
|
||||||
|
replay(serverStateToNodeState);
|
||||||
|
replay(server);
|
||||||
|
replay(image);
|
||||||
|
replay(credentialsMap);
|
||||||
|
replay(images);
|
||||||
|
|
||||||
|
ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeState, client,
|
||||||
|
images, location);
|
||||||
|
|
||||||
|
NodeMetadata metadata = parser.apply(server);
|
||||||
|
assertEquals(metadata.getLocation(), location);
|
||||||
|
assertEquals(metadata.getImage(), jcImage);
|
||||||
|
assertEquals(metadata.getTag(), "tag");
|
||||||
|
assertEquals(metadata.getCredentials(), new Credentials("user", "pass"));
|
||||||
|
|
||||||
|
verify(client);
|
||||||
|
verify(serverStateToNodeState);
|
||||||
|
verify(image);
|
||||||
|
verify(credentialsMap);
|
||||||
|
verify(server);
|
||||||
|
verify(images);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -18,14 +18,16 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.config;
|
package org.jclouds.gogrid.config;
|
||||||
|
|
||||||
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
|
||||||
|
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
|
|
||||||
import org.jboss.resteasy.specimpl.UriBuilderImpl;
|
import org.jboss.resteasy.specimpl.UriBuilderImpl;
|
||||||
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||||
import org.jclouds.gogrid.handlers.GoGridErrorHandler;
|
import org.jclouds.gogrid.handlers.GoGridErrorHandler;
|
||||||
|
import org.jclouds.gogrid.reference.GoGridConstants;
|
||||||
import org.jclouds.http.HttpRetryHandler;
|
import org.jclouds.http.HttpRetryHandler;
|
||||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||||
import org.jclouds.http.functions.config.ParserModule;
|
import org.jclouds.http.functions.config.ParserModule;
|
||||||
|
@ -35,9 +37,7 @@ import org.jclouds.http.handlers.DelegatingRetryHandler;
|
||||||
import org.jclouds.http.handlers.RedirectionRetryHandler;
|
import org.jclouds.http.handlers.RedirectionRetryHandler;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.logging.Logger.LoggerFactory;
|
import org.jclouds.logging.Logger.LoggerFactory;
|
||||||
import org.jclouds.gogrid.reference.GoGridConstants;
|
|
||||||
import org.jclouds.util.Jsr330;
|
import org.jclouds.util.Jsr330;
|
||||||
import org.jclouds.Constants;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.gogrid.functions;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
@ -63,14 +64,14 @@ public class ParseLoadBalancersFromJsonResponseTest {
|
||||||
.getInstance(Gson.class));
|
.getInstance(Gson.class));
|
||||||
SortedSet<LoadBalancer> response = parser.apply(is);
|
SortedSet<LoadBalancer> response = parser.apply(is);
|
||||||
|
|
||||||
LoadBalancer loadBalancer = new LoadBalancer(6372L, "Balancer", null, new IpPortPair(
|
LoadBalancer loadBalancer = new LoadBalancer(6372L, "Balancer", null, new IpPortPair(new Ip(
|
||||||
new Ip(1313082L, "204.51.240.181", "204.51.240.176/255.255.255.240", true,
|
1313082L, InetAddress.getByName("204.51.240.181"), "204.51.240.176/255.255.255.240",
|
||||||
IpState.ASSIGNED), 80), ImmutableSortedSet.of(new IpPortPair(
|
true, IpState.ASSIGNED), 80), ImmutableSortedSet.of(new IpPortPair(new Ip(1313086L,
|
||||||
new Ip(1313086L, "204.51.240.185", "204.51.240.176/255.255.255.240", true,
|
InetAddress.getByName("204.51.240.185"), "204.51.240.176/255.255.255.240", true,
|
||||||
IpState.ASSIGNED), 80), new IpPortPair(new Ip(1313089L, "204.51.240.188",
|
IpState.ASSIGNED), 80), new IpPortPair(new Ip(1313089L, InetAddress
|
||||||
"204.51.240.176/255.255.255.240", true, IpState.ASSIGNED), 80)),
|
.getByName("204.51.240.188"), "204.51.240.176/255.255.255.240", true,
|
||||||
LoadBalancerType.ROUND_ROBIN, LoadBalancerPersistenceType.NONE, LoadBalancerOs.F5,
|
IpState.ASSIGNED), 80)), LoadBalancerType.ROUND_ROBIN,
|
||||||
LoadBalancerState.ON);
|
LoadBalancerPersistenceType.NONE, LoadBalancerOs.F5, LoadBalancerState.ON);
|
||||||
assertEquals(Iterables.getOnlyElement(response), loadBalancer);
|
assertEquals(Iterables.getOnlyElement(response), loadBalancer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ package org.jclouds.gogrid.functions;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -77,13 +78,14 @@ public class ParseServersFromJsonResponseTest {
|
||||||
Server server = new Server(75245L, false, "PowerServer",
|
Server server = new Server(75245L, false, "PowerServer",
|
||||||
"server to test the api. created by Alex", new Option(1L, "On",
|
"server to test the api. created by Alex", new Option(1L, "On",
|
||||||
"Server is in active state."), webServer, new Option(1L, "512MB",
|
"Server is in active state."), webServer, new Option(1L, "512MB",
|
||||||
"Server with 512MB RAM"), centOs, new Ip(1313079L, "204.51.240.178",
|
"Server with 512MB RAM"), centOs, new Ip(1313079L, InetAddress
|
||||||
"204.51.240.176/255.255.255.240", true, IpState.ASSIGNED), new ServerImage(
|
.getByName("204.51.240.178"), "204.51.240.176/255.255.255.240", true,
|
||||||
1946L, "GSI-f8979644-e646-4711-ad58-d98a5fa3612c",
|
IpState.ASSIGNED), new ServerImage(1946L,
|
||||||
"BitNami Gallery 2.3.1-0", "http://bitnami.org/stack/gallery", centOs,
|
"GSI-f8979644-e646-4711-ad58-d98a5fa3612c", "BitNami Gallery 2.3.1-0",
|
||||||
null, ServerImageType.WEB_APPLICATION_SERVER, ServerImageState.AVAILABLE,
|
"http://bitnami.org/stack/gallery", centOs, null,
|
||||||
0.0, "24732/GSI-f8979644-e646-4711-ad58-d98a5fa3612c.img", true, true,
|
ServerImageType.WEB_APPLICATION_SERVER, ServerImageState.AVAILABLE, 0.0,
|
||||||
new Date(1261504577971L), new Date(1262649582180L), ImmutableSortedSet.of(
|
"24732/GSI-f8979644-e646-4711-ad58-d98a5fa3612c.img", true, true, new Date(
|
||||||
|
1261504577971L), new Date(1262649582180L), ImmutableSortedSet.of(
|
||||||
new BillingToken(38L, "CentOS 5.2 32bit", 0.0), new BillingToken(
|
new BillingToken(38L, "CentOS 5.2 32bit", 0.0), new BillingToken(
|
||||||
56L, "BitNami: Gallery", 0.0)), new Customer(24732L,
|
56L, "BitNami: Gallery", 0.0)), new Customer(24732L,
|
||||||
"BitRock")));
|
"BitRock")));
|
||||||
|
|
|
@ -18,17 +18,20 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.services;
|
package org.jclouds.gogrid.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.encryption.EncryptionService;
|
import org.jclouds.encryption.EncryptionService;
|
||||||
import org.jclouds.gogrid.GoGrid;
|
import org.jclouds.gogrid.GoGrid;
|
||||||
|
import org.jclouds.gogrid.GoGridPropertiesBuilder;
|
||||||
import org.jclouds.gogrid.domain.ServerImageState;
|
import org.jclouds.gogrid.domain.ServerImageState;
|
||||||
import org.jclouds.gogrid.domain.ServerImageType;
|
import org.jclouds.gogrid.domain.ServerImageType;
|
||||||
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
|
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
|
||||||
|
@ -39,6 +42,7 @@ import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.RestClientTest;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.jclouds.util.Jsr330;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -173,6 +177,8 @@ public class GridImageAsyncClientTest extends RestClientTest<GridImageAsyncClien
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new GoGridPropertiesBuilder(
|
||||||
|
new Properties()).build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(GoGrid.class).toInstance(
|
bind(URI.class).annotatedWith(GoGrid.class).toInstance(
|
||||||
URI.create("https://api.gogrid.com/api"));
|
URI.create("https://api.gogrid.com/api"));
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new Logger.LoggerFactory() {
|
bind(Logger.LoggerFactory.class).toInstance(new Logger.LoggerFactory() {
|
||||||
|
|
|
@ -18,17 +18,20 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.services;
|
package org.jclouds.gogrid.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.encryption.EncryptionService;
|
import org.jclouds.encryption.EncryptionService;
|
||||||
import org.jclouds.gogrid.GoGrid;
|
import org.jclouds.gogrid.GoGrid;
|
||||||
|
import org.jclouds.gogrid.GoGridPropertiesBuilder;
|
||||||
import org.jclouds.gogrid.domain.IpType;
|
import org.jclouds.gogrid.domain.IpType;
|
||||||
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
|
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
|
||||||
import org.jclouds.gogrid.functions.ParseIpListFromJsonResponse;
|
import org.jclouds.gogrid.functions.ParseIpListFromJsonResponse;
|
||||||
|
@ -37,6 +40,7 @@ import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.RestClientTest;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.jclouds.util.Jsr330;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -118,6 +122,8 @@ public class GridIpAsyncClientTest extends RestClientTest<GridIpAsyncClient> {
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new GoGridPropertiesBuilder(
|
||||||
|
new Properties()).build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(GoGrid.class).toInstance(
|
bind(URI.class).annotatedWith(GoGrid.class).toInstance(
|
||||||
URI.create("https://api.gogrid.com/api"));
|
URI.create("https://api.gogrid.com/api"));
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new Logger.LoggerFactory() {
|
bind(Logger.LoggerFactory.class).toInstance(new Logger.LoggerFactory() {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.services;
|
package org.jclouds.gogrid.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -25,11 +26,13 @@ import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.encryption.EncryptionService;
|
import org.jclouds.encryption.EncryptionService;
|
||||||
import org.jclouds.gogrid.GoGrid;
|
import org.jclouds.gogrid.GoGrid;
|
||||||
|
import org.jclouds.gogrid.GoGridPropertiesBuilder;
|
||||||
import org.jclouds.gogrid.domain.JobState;
|
import org.jclouds.gogrid.domain.JobState;
|
||||||
import org.jclouds.gogrid.domain.ObjectType;
|
import org.jclouds.gogrid.domain.ObjectType;
|
||||||
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
|
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
|
||||||
|
@ -39,6 +42,7 @@ import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.RestClientTest;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.jclouds.util.Jsr330;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -159,6 +163,8 @@ public class GridJobAsyncClientTest extends RestClientTest<GridJobAsyncClient> {
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new GoGridPropertiesBuilder(
|
||||||
|
new Properties()).build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(GoGrid.class).toInstance(
|
bind(URI.class).annotatedWith(GoGrid.class).toInstance(
|
||||||
URI.create("https://api.gogrid.com/api"));
|
URI.create("https://api.gogrid.com/api"));
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new Logger.LoggerFactory() {
|
bind(Logger.LoggerFactory.class).toInstance(new Logger.LoggerFactory() {
|
||||||
|
|
|
@ -18,19 +18,23 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.services;
|
package org.jclouds.gogrid.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.encryption.EncryptionService;
|
import org.jclouds.encryption.EncryptionService;
|
||||||
import org.jclouds.gogrid.GoGrid;
|
import org.jclouds.gogrid.GoGrid;
|
||||||
|
import org.jclouds.gogrid.GoGridPropertiesBuilder;
|
||||||
import org.jclouds.gogrid.domain.Ip;
|
import org.jclouds.gogrid.domain.Ip;
|
||||||
import org.jclouds.gogrid.domain.IpPortPair;
|
import org.jclouds.gogrid.domain.IpPortPair;
|
||||||
import org.jclouds.gogrid.domain.LoadBalancerPersistenceType;
|
import org.jclouds.gogrid.domain.LoadBalancerPersistenceType;
|
||||||
|
@ -43,6 +47,7 @@ import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.RestClientTest;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.jclouds.util.Jsr330;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -87,10 +92,11 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
|
||||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("addLoadBalancer", String.class,
|
Method method = GridLoadBalancerAsyncClient.class.getMethod("addLoadBalancer", String.class,
|
||||||
IpPortPair.class, List.class, AddLoadBalancerOptions[].class);
|
IpPortPair.class, List.class, AddLoadBalancerOptions[].class);
|
||||||
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(
|
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(
|
||||||
method, "BalanceIt", new IpPortPair(new Ip("127.0.0.1"), 80), Arrays.asList(
|
method, "BalanceIt", new IpPortPair(new Ip(InetAddress.getByName("127.0.0.1")), 80),
|
||||||
new IpPortPair(new Ip("127.0.0.1"), 8080), new IpPortPair(new Ip(
|
Arrays.asList(new IpPortPair(new Ip(InetAddress.getByName("127.0.0.1")), 8080),
|
||||||
"127.0.0.1"), 9090)), new AddLoadBalancerOptions.Builder().create(
|
new IpPortPair(new Ip(InetAddress.getByName("127.0.0.1")), 9090)),
|
||||||
LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SSL_STICKY));
|
new AddLoadBalancerOptions.Builder().create(LoadBalancerType.LEAST_CONNECTED,
|
||||||
|
LoadBalancerPersistenceType.SSL_STICKY));
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
||||||
+ "add?v=1.4&name=BalanceIt&loadbalancer.type=Least%20Connect&"
|
+ "add?v=1.4&name=BalanceIt&loadbalancer.type=Least%20Connect&"
|
||||||
|
@ -122,8 +128,9 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
|
||||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancer", String.class,
|
Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancer", String.class,
|
||||||
List.class);
|
List.class);
|
||||||
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(
|
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(
|
||||||
method, "BalanceIt", Arrays.asList(new IpPortPair(new Ip("127.0.0.1"), 8080),
|
method, "BalanceIt", Arrays.asList(new IpPortPair(new Ip(InetAddress
|
||||||
new IpPortPair(new Ip("127.0.0.1"), 9090)));
|
.getByName("127.0.0.1")), 8080), new IpPortPair(new Ip(InetAddress
|
||||||
|
.getByName("127.0.0.1")), 9090)));
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
||||||
+ "edit?v=1.4&loadbalancer=BalanceIt&realiplist.0.ip=127.0.0.1&"
|
+ "edit?v=1.4&loadbalancer=BalanceIt&realiplist.0.ip=127.0.0.1&"
|
||||||
|
@ -215,6 +222,8 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new GoGridPropertiesBuilder(
|
||||||
|
new Properties()).build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(GoGrid.class).toInstance(
|
bind(URI.class).annotatedWith(GoGrid.class).toInstance(
|
||||||
URI.create("https://api.gogrid.com/api"));
|
URI.create("https://api.gogrid.com/api"));
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new Logger.LoggerFactory() {
|
bind(Logger.LoggerFactory.class).toInstance(new Logger.LoggerFactory() {
|
||||||
|
|
|
@ -41,17 +41,21 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid.services;
|
package org.jclouds.gogrid.services;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.encryption.EncryptionService;
|
import org.jclouds.encryption.EncryptionService;
|
||||||
import org.jclouds.gogrid.GoGrid;
|
import org.jclouds.gogrid.GoGrid;
|
||||||
|
import org.jclouds.gogrid.GoGridPropertiesBuilder;
|
||||||
import org.jclouds.gogrid.domain.PowerCommand;
|
import org.jclouds.gogrid.domain.PowerCommand;
|
||||||
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
|
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
|
||||||
import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
|
import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
|
||||||
|
@ -64,6 +68,7 @@ import org.jclouds.logging.Logger.LoggerFactory;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.RestClientTest;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.jclouds.util.Jsr330;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
@ -183,9 +188,9 @@ public class GridServerAsyncClientTest extends RestClientTest<GridServerAsyncCli
|
||||||
@Test
|
@Test
|
||||||
public void testAddServerNoOptions() throws NoSuchMethodException, IOException {
|
public void testAddServerNoOptions() throws NoSuchMethodException, IOException {
|
||||||
Method method = GridServerAsyncClient.class.getMethod("addServer", String.class,
|
Method method = GridServerAsyncClient.class.getMethod("addServer", String.class,
|
||||||
String.class, String.class, String.class, AddServerOptions[].class);
|
String.class, String.class, InetAddress.class, AddServerOptions[].class);
|
||||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method,
|
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method,
|
||||||
"serverName", "img55", "memory", "127.0.0.1");
|
"serverName", "img55", "memory", InetAddress.getByName("127.0.0.1"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/add?v=1.3&"
|
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/add?v=1.3&"
|
||||||
+ "name=serverName&server.ram=memory&image=img55&ip=127.0.0.1 " + "HTTP/1.1");
|
+ "name=serverName&server.ram=memory&image=img55&ip=127.0.0.1 " + "HTTP/1.1");
|
||||||
|
@ -209,10 +214,10 @@ public class GridServerAsyncClientTest extends RestClientTest<GridServerAsyncCli
|
||||||
@Test
|
@Test
|
||||||
public void testAddServerOptions() throws NoSuchMethodException, IOException {
|
public void testAddServerOptions() throws NoSuchMethodException, IOException {
|
||||||
Method method = GridServerAsyncClient.class.getMethod("addServer", String.class,
|
Method method = GridServerAsyncClient.class.getMethod("addServer", String.class,
|
||||||
String.class, String.class, String.class, AddServerOptions[].class);
|
String.class, String.class, InetAddress.class, AddServerOptions[].class);
|
||||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method,
|
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method,
|
||||||
"serverName", "img55", "memory", "127.0.0.1", new AddServerOptions()
|
"serverName", "img55", "memory", InetAddress.getByName("127.0.0.1"),
|
||||||
.asSandboxType().withDescription("fooy"));
|
new AddServerOptions().asSandboxType().withDescription("fooy"));
|
||||||
|
|
||||||
assertRequestLineEquals(
|
assertRequestLineEquals(
|
||||||
httpRequest,
|
httpRequest,
|
||||||
|
@ -330,6 +335,8 @@ public class GridServerAsyncClientTest extends RestClientTest<GridServerAsyncCli
|
||||||
return new AbstractModule() {
|
return new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new GoGridPropertiesBuilder(
|
||||||
|
new Properties()).build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(GoGrid.class).toInstance(
|
bind(URI.class).annotatedWith(GoGrid.class).toInstance(
|
||||||
URI.create("https://api.gogrid.com/api"));
|
URI.create("https://api.gogrid.com/api"));
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.mezeo.pcs2;
|
package org.jclouds.mezeo.pcs2;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -27,6 +28,7 @@ import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.ws.rs.HttpMethod;
|
import javax.ws.rs.HttpMethod;
|
||||||
|
@ -56,6 +58,7 @@ import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.jclouds.util.Jsr330;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -71,7 +74,7 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "pcs2.PCSClientTest")
|
@Test(groups = "unit", testName = "pcs2.PCSClientTest")
|
||||||
public class PCSClientTest extends RestClientTest<PCSAsyncClient> {
|
public class PCSAsyncClientTest extends RestClientTest<PCSAsyncClient> {
|
||||||
|
|
||||||
public void testList() throws SecurityException, NoSuchMethodException, IOException {
|
public void testList() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = PCSAsyncClient.class.getMethod("list");
|
Method method = PCSAsyncClient.class.getMethod("list");
|
||||||
|
@ -298,6 +301,8 @@ public class PCSClientTest extends RestClientTest<PCSAsyncClient> {
|
||||||
new TypeLiteral<PCSAsyncClient>() {
|
new TypeLiteral<PCSAsyncClient>() {
|
||||||
}, new TypeLiteral<PCSClient>() {
|
}, new TypeLiteral<PCSClient>() {
|
||||||
}));
|
}));
|
||||||
|
Jsr330.bindProperties(binder(), checkNotNull(new PCSPropertiesBuilder(
|
||||||
|
new Properties()).build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(PCS.class)
|
bind(URI.class).annotatedWith(PCS.class)
|
||||||
.toInstance(URI.create("http://localhost:8080"));
|
.toInstance(URI.create("http://localhost:8080"));
|
||||||
bind(URI.class).annotatedWith(RootContainer.class).toInstance(
|
bind(URI.class).annotatedWith(RootContainer.class).toInstance(
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.mezeo.pcs2;
|
package org.jclouds.mezeo.pcs2;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.mezeo.pcs2;
|
package org.jclouds.mezeo.pcs2;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.mezeo.pcs2.config;
|
package org.jclouds.mezeo.pcs2.config;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
|
@ -36,7 +36,6 @@ import org.jclouds.nirvanix.sdn.filters.AddSessionTokenToRequest;
|
||||||
import org.jclouds.nirvanix.sdn.filters.InsertUserContextIntoPath;
|
import org.jclouds.nirvanix.sdn.filters.InsertUserContextIntoPath;
|
||||||
import org.jclouds.nirvanix.sdn.functions.ParseMetadataFromJsonResponse;
|
import org.jclouds.nirvanix.sdn.functions.ParseMetadataFromJsonResponse;
|
||||||
import org.jclouds.nirvanix.sdn.functions.ParseUploadInfoFromJsonResponse;
|
import org.jclouds.nirvanix.sdn.functions.ParseUploadInfoFromJsonResponse;
|
||||||
import org.jclouds.nirvanix.sdn.reference.SDNConstants;
|
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.RestClientTest;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
@ -55,7 +54,7 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "sdn.SDNClient")
|
@Test(groups = "unit", testName = "sdn.SDNClient")
|
||||||
public class SDNClientTest extends RestClientTest<SDNAsyncClient> {
|
public class SDNAsyncClientTest extends RestClientTest<SDNAsyncClient> {
|
||||||
|
|
||||||
public void testGetStorageNode() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetStorageNode() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = SDNAsyncClient.class.getMethod("getStorageNode", String.class, long.class);
|
Method method = SDNAsyncClient.class.getMethod("getStorageNode", String.class, long.class);
|
||||||
|
@ -186,6 +185,8 @@ public class SDNClientTest extends RestClientTest<SDNAsyncClient> {
|
||||||
new TypeLiteral<SDNAsyncClient>() {
|
new TypeLiteral<SDNAsyncClient>() {
|
||||||
}, new TypeLiteral<SDNClient>() {
|
}, new TypeLiteral<SDNClient>() {
|
||||||
}));
|
}));
|
||||||
|
Jsr330.bindProperties(this.binder(), new SDNPropertiesBuilder("appKey", "appname",
|
||||||
|
"username", "password").build());
|
||||||
bind(URI.class).annotatedWith(SDN.class).toInstance(URI.create("http://stub:8080"));
|
bind(URI.class).annotatedWith(SDN.class).toInstance(URI.create("http://stub:8080"));
|
||||||
bind(String.class).annotatedWith(SessionToken.class).toInstance("sessiontoken");
|
bind(String.class).annotatedWith(SessionToken.class).toInstance("sessiontoken");
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||||
|
@ -193,12 +194,6 @@ public class SDNClientTest extends RestClientTest<SDNAsyncClient> {
|
||||||
return Logger.NULL;
|
return Logger.NULL;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bindConstant().annotatedWith(Jsr330.named(SDNConstants.PROPERTY_SDN_APPKEY)).to(
|
|
||||||
"appKey");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(SDNConstants.PROPERTY_SDN_APPNAME)).to(
|
|
||||||
"appname");
|
|
||||||
bindConstant().annotatedWith(Jsr330.named(SDNConstants.PROPERTY_SDN_USERNAME)).to(
|
|
||||||
"username");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.nirvanix.sdn;
|
package org.jclouds.nirvanix.sdn;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.nirvanix.sdn;
|
package org.jclouds.nirvanix.sdn;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.nirvanix.sdn.filters;
|
package org.jclouds.nirvanix.sdn.filters;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.nirvanix.sdn.filters;
|
package org.jclouds.nirvanix.sdn.filters;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||||
import static org.easymock.EasyMock.expect;
|
import static org.easymock.EasyMock.expect;
|
||||||
import static org.easymock.classextension.EasyMock.createMock;
|
import static org.easymock.classextension.EasyMock.createMock;
|
||||||
import static org.easymock.classextension.EasyMock.replay;
|
import static org.easymock.classextension.EasyMock.replay;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue