mirror of https://github.com/apache/jclouds.git
add deprecated flag to Hardware and prefer non-deprecated hardware types
deprecated hardware types in EC2 are flagged using this, according to latest AWS advice, to fix situations where deprecated hardware types would be chosen when a non-deprecated alternative exists. we also deprecate T2 because it requires a VPC. also fixes semantics of ImagesToRegionAndIdMap to match the logic used in the TemplateBuilderImpl; RegionAndName should contain the ID not the ProviderID. this is only really used in tests so no external impact. (previously the cache only worked if provider ID matched the non-location segment of the image ID.) however this does now assert that image id's are in the right format for AWS, as suggested by @nacx.
This commit is contained in:
parent
3b83e790c0
commit
cc88d99bb1
|
@ -136,13 +136,15 @@ public class EC2HardwareBuilder extends HardwareBuilder {
|
|||
}
|
||||
|
||||
public EC2HardwareBuilder virtualizationTypes(VirtualizationType ...virtualizationTypes) {
|
||||
Preconditions.checkNotNull(virtualizationTypes, "virtualizationTypes");
|
||||
Preconditions.checkArgument(virtualizationTypes.length > 0, "At least one virtualization type is required.");
|
||||
if (virtualizationTypes.length == 1) {
|
||||
this.virtualizationType = new RequiresVirtualizationType(virtualizationTypes[0]);
|
||||
} else {
|
||||
List<RequiresVirtualizationType> supportedVirtualizationTypes = Lists.newArrayList();
|
||||
for (VirtualizationType virtualizationType : virtualizationTypes) {
|
||||
supportedVirtualizationTypes.add(new RequiresVirtualizationType(virtualizationType));
|
||||
supportedVirtualizationTypes.add(new RequiresVirtualizationType(
|
||||
Preconditions.checkNotNull(virtualizationType, "virtualizationType")));
|
||||
}
|
||||
this.virtualizationType = Predicates.or(supportedVirtualizationTypes);
|
||||
}
|
||||
|
@ -215,6 +217,15 @@ public class EC2HardwareBuilder extends HardwareBuilder {
|
|||
|
||||
private EC2HardwareBuilder t2() {
|
||||
virtualizationTypes(VirtualizationType.HVM);
|
||||
|
||||
// TODO T2 is not deprecated, but it requires that you are using a VPC
|
||||
// until we have a way for hardware instances to be filtered based on network
|
||||
// we do NOT want T2 selected automatically.
|
||||
// You get: org.jclouds.aws.AWSResponseException: request POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1 failed with code 400, error: AWSError{requestId='2300b99e-ddc0-42ab-b1ed-9d628a161be4', requestToken='null', code='VPCResourceNotSpecified', message='The specified instance type can only be used in a VPC. A subnet ID or network interface ID is required to carry out the request.', context='{Response=, Errors=}'}
|
||||
// A user can explicitly request a t2.micro if they are also setting up a VPC,
|
||||
// but the small default will now be m3.medium which supports VPC and "classic".
|
||||
deprecated();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -264,21 +275,25 @@ public class EC2HardwareBuilder extends HardwareBuilder {
|
|||
// http://aws.amazon.com/ec2/previous-generation/
|
||||
private EC2HardwareBuilder m1() {
|
||||
virtualizationTypes(VirtualizationType.PARAVIRTUAL);
|
||||
deprecated();
|
||||
return this;
|
||||
}
|
||||
|
||||
private EC2HardwareBuilder c1() {
|
||||
virtualizationTypes(VirtualizationType.PARAVIRTUAL);
|
||||
deprecated();
|
||||
return this;
|
||||
}
|
||||
|
||||
private EC2HardwareBuilder cc2() {
|
||||
virtualizationTypes(VirtualizationType.HVM);
|
||||
deprecated();
|
||||
return this;
|
||||
}
|
||||
|
||||
private EC2HardwareBuilder m2() {
|
||||
virtualizationTypes(VirtualizationType.PARAVIRTUAL);
|
||||
deprecated();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -286,22 +301,26 @@ public class EC2HardwareBuilder extends HardwareBuilder {
|
|||
|
||||
private EC2HardwareBuilder hi1() {
|
||||
virtualizationTypes(VirtualizationType.HVM, VirtualizationType.PARAVIRTUAL);
|
||||
deprecated();
|
||||
return this;
|
||||
}
|
||||
|
||||
private EC2HardwareBuilder t1() {
|
||||
virtualizationTypes(VirtualizationType.PARAVIRTUAL);
|
||||
deprecated();
|
||||
return this;
|
||||
}
|
||||
|
||||
private EC2HardwareBuilder cg1() {
|
||||
virtualizationTypes(VirtualizationType.HVM);
|
||||
deprecated();
|
||||
return this;
|
||||
}
|
||||
|
||||
private EC2HardwareBuilder cc1() {
|
||||
// often no longer available - not adding capacity (use cc2)
|
||||
virtualizationTypes(VirtualizationType.HVM);
|
||||
deprecated();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.jclouds.compute.domain.Image;
|
|||
import org.jclouds.ec2.compute.domain.RegionAndName;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
@Singleton
|
||||
public class ImagesToRegionAndIdMap implements Function<Iterable<? extends Image>, Map<RegionAndName, ? extends Image>> {
|
||||
|
@ -43,7 +44,9 @@ public class ImagesToRegionAndIdMap implements Function<Iterable<? extends Image
|
|||
public RegionAndName apply(Image from) {
|
||||
checkState(from.getLocation() != null,
|
||||
"in ec2, image locations cannot be null; typically, they are Region-scoped");
|
||||
return new RegionAndName(from.getLocation().getId(), from.getProviderId());
|
||||
String[] segments = from.getId().split("/");
|
||||
Preconditions.checkArgument(segments.length == 2, "Wrong form for AWS image ID: " + from);
|
||||
return new RegionAndName(segments[0], segments[1]);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -22,7 +22,6 @@ import static org.easymock.EasyMock.expect;
|
|||
import static org.easymock.EasyMock.replay;
|
||||
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_medium;
|
||||
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_xlarge;
|
||||
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cc1_4xlarge;
|
||||
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.g2_2xlarge;
|
||||
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_large;
|
||||
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small;
|
||||
|
@ -47,6 +46,7 @@ import org.jclouds.compute.domain.OperatingSystem;
|
|||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.compute.domain.TemplateBuilder;
|
||||
import org.jclouds.compute.domain.internal.TemplateBuilderImpl;
|
||||
import org.jclouds.compute.options.TemplateOptions;
|
||||
import org.jclouds.compute.strategy.GetImageStrategy;
|
||||
import org.jclouds.compute.suppliers.ImageCacheSupplier;
|
||||
|
@ -57,6 +57,7 @@ import org.jclouds.domain.LoginCredentials;
|
|||
import org.jclouds.ec2.compute.domain.RegionAndName;
|
||||
import org.jclouds.ec2.compute.functions.ImagesToRegionAndIdMap;
|
||||
import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl;
|
||||
import org.jclouds.ec2.domain.VirtualizationType;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -84,7 +85,9 @@ public class EC2TemplateBuilderTest {
|
|||
protected Location location = new LocationBuilder().scope(LocationScope.REGION).id("us-east-1").description("us-east-1")
|
||||
.parent(provider).build();
|
||||
|
||||
public static final Hardware CC1_4XLARGE = cc1_4xlarge().supportsImageIds(ImmutableSet.of("us-east-1/cc-image"))
|
||||
public static final Hardware HARDWARE_SUPPORTING_BOGUS = g2_2xlarge().id("supporting-bogus")
|
||||
.supportsImageIds(ImmutableSet.of("us-east-1/bogus-image"))
|
||||
.virtualizationType(VirtualizationType.UNRECOGNIZED)
|
||||
.build();
|
||||
|
||||
/**
|
||||
|
@ -94,23 +97,23 @@ public class EC2TemplateBuilderTest {
|
|||
* Expected size: m2.xlarge
|
||||
*/
|
||||
@Test
|
||||
public void testTemplateChoiceForInstanceByhardwareId() throws Exception {
|
||||
public void testTemplateChoiceForInstanceByHardwareId() throws Exception {
|
||||
Template template = newTemplateBuilder().os64Bit(true).hardwareId("m2.xlarge").locationId("us-east-1").build();
|
||||
|
||||
assert template != null : "The returned template was null, but it should have a value.";
|
||||
// assert m2_xlarge().build().equals(template.getHardware()) : format(
|
||||
// "Incorrect image determined by the template. Expected: %s. Found: %s.", "m2.xlarge",
|
||||
// String.valueOf(template.getHardware()));
|
||||
assertEquals(m2_xlarge().build().getId(), template.getHardware().getId());
|
||||
assertEquals(template.getHardware().getId(), m2_xlarge().build().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemplateChoiceForInstanceByCChardwareId() throws Exception {
|
||||
public void testTemplateChoiceForInstanceByFastest() throws Exception {
|
||||
Template template = newTemplateBuilder().fastest().build();
|
||||
|
||||
assert template != null : "The returned template was null, but it should have a value.";
|
||||
assert CC1_4XLARGE.equals(template.getHardware()) : format(
|
||||
"Incorrect image determined by the template. Expected: %s. Found: %s.", CC1_4XLARGE.getId(), template
|
||||
assert g2_2xlarge().build().equals(template.getHardware()) : format(
|
||||
"Incorrect image determined by the template. Expected: %s. Found: %s.", g2_2xlarge(), template
|
||||
.getHardware().getId());
|
||||
}
|
||||
|
||||
|
@ -126,7 +129,7 @@ public class EC2TemplateBuilderTest {
|
|||
"us-east-1").build();
|
||||
|
||||
assert template != null : "The returned template was null, but it should have a value.";
|
||||
assertEquals(template.getHardware().getId(), "cc1.4xlarge");
|
||||
assertEquals(template.getHardware().getId(), m2_4xlarge().build().getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,10 +153,11 @@ public class EC2TemplateBuilderTest {
|
|||
|
||||
@Test
|
||||
public void testTemplateChoiceForInstanceByImageId() throws Exception {
|
||||
Template template = newTemplateBuilder().imageId("us-east-1/cc-image").build();
|
||||
Template template = newTemplateBuilder().imageId("us-east-1/bogus-image").build();
|
||||
|
||||
assert template != null : "The returned template was null, but it should have a value.";
|
||||
assertEquals(template.getImage().getId(), "us-east-1/cc-image");
|
||||
assertEquals(template.getImage().getId(), "us-east-1/bogus-image");
|
||||
assertEquals(template.getHardware().getId(), HARDWARE_SUPPORTING_BOGUS.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -162,22 +166,23 @@ public class EC2TemplateBuilderTest {
|
|||
Supplier<Set<? extends Image>> images = createMock(Supplier.class);
|
||||
replay(images);
|
||||
|
||||
final Image image = new ImageBuilder().providerId("cc-image").name("image").id("us-east-1/cc-image").location(location)
|
||||
.operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "hvm", "ubuntu", true))
|
||||
final Image image = new ImageBuilder().providerId("bogus-image-provider").name("image").id("us-east-1/bogus-image").location(location)
|
||||
.operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "bogus", "ubuntu", true))
|
||||
.description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build())
|
||||
.status(Image.Status.AVAILABLE)
|
||||
.build();
|
||||
Map<RegionAndName, Image> imageMap = ImmutableMap.of(
|
||||
new RegionAndName(image.getLocation().getId(), image.getProviderId()), image);
|
||||
new RegionAndName(image.getLocation().getId(), "bogus-image"), image);
|
||||
|
||||
// weird compilation error means have to declare extra generics for call to build() - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818
|
||||
Supplier<LoadingCache<RegionAndName, ? extends Image>> imageCache = Suppliers.<LoadingCache<RegionAndName, ? extends Image>> ofInstance(
|
||||
CacheBuilder.newBuilder().<RegionAndName, Image>build(CacheLoader.from(Functions.forMap(imageMap))));
|
||||
|
||||
Template template = newTemplateBuilder(images, imageCache).imageId("us-east-1/cc-image").build();
|
||||
Template template = newTemplateBuilder(images, imageCache).imageId("us-east-1/bogus-image").build();
|
||||
|
||||
assert template != null : "The returned template was null, but it should have a value.";
|
||||
assertEquals(template.getImage().getId(), "us-east-1/cc-image");
|
||||
assertEquals(template.getImage().getId(), "us-east-1/bogus-image");
|
||||
assertEquals(template.getHardware().getId(), HARDWARE_SUPPORTING_BOGUS.getId());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = {NoSuchElementException.class})
|
||||
|
@ -187,15 +192,20 @@ public class EC2TemplateBuilderTest {
|
|||
|
||||
private TemplateBuilder newTemplateBuilder() {
|
||||
final Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of(
|
||||
new ImageBuilder().providerId("cc-image").name("image").id("us-east-1/cc-image").location(location)
|
||||
new ImageBuilder().providerId("hvm-image-provider").name("image").id("us-east-1/hvm-image").location(location)
|
||||
.operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "hvm", "ubuntu", true))
|
||||
.description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build())
|
||||
.status(Image.Status.AVAILABLE)
|
||||
.build(),
|
||||
new ImageBuilder().providerId("normal-image").name("image").id("us-east-1/normal-image").location(location)
|
||||
new ImageBuilder().providerId("pv-image-provider").name("image").id("us-east-1/pv-image").location(location)
|
||||
.operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "paravirtual", "ubuntu", true))
|
||||
.description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build())
|
||||
.status(Image.Status.AVAILABLE)
|
||||
.build(),
|
||||
new ImageBuilder().providerId("bogus-image-provider").name("image").id("us-east-1/bogus-image").location(location)
|
||||
.operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "bogus", "ubuntu", true))
|
||||
.description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build())
|
||||
.status(Image.Status.AVAILABLE)
|
||||
.build()));
|
||||
|
||||
// weird compilation error means have to cast this - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818
|
||||
|
@ -224,7 +234,7 @@ public class EC2TemplateBuilderTest {
|
|||
Supplier<Set<? extends Hardware>> sizes = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
.<Hardware> of(t1_micro().build(), c1_medium().build(), c1_xlarge().build(), m1_large().build(),
|
||||
m1_small().build(), m1_xlarge().build(), m2_xlarge().build(), m2_2xlarge().build(),
|
||||
m2_4xlarge().build(), g2_2xlarge().build(), CC1_4XLARGE));
|
||||
m2_4xlarge().build(), g2_2xlarge().build(), HARDWARE_SUPPORTING_BOGUS));
|
||||
|
||||
return new EC2TemplateBuilderImpl(locations, new ImageCacheSupplier(images, 60), sizes, Suppliers.ofInstance(location), optionsProvider,
|
||||
templateBuilderProvider, getImageStrategy, imageCache) {
|
||||
|
|
|
@ -21,6 +21,7 @@ import static org.easymock.EasyMock.expect;
|
|||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_medium;
|
||||
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.r3_large;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
|
@ -109,7 +110,7 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
|
|||
Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(Sets
|
||||
.<Image> newLinkedHashSet());
|
||||
Supplier<Set<? extends Hardware>> sizes = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
.<Hardware> of(c1_medium().build()));
|
||||
.<Hardware> of(c1_medium().build(), r3_large().build()));
|
||||
|
||||
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
||||
Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
|
||||
|
@ -133,6 +134,54 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
|
|||
expect(os.getVersion()).andReturn(null).atLeastOnce();
|
||||
expect(os.getFamily()).andReturn(null).atLeastOnce();
|
||||
expect(os.getDescription()).andReturn(null).atLeastOnce();
|
||||
expect(os.getArch()).andReturn("hvm").atLeastOnce();
|
||||
expect(os.is64Bit()).andReturn(false).atLeastOnce();
|
||||
|
||||
replay(knownImage, os, defaultOptions, optionsProvider, templateBuilderProvider, getImageStrategy);
|
||||
|
||||
TemplateBuilderImpl template = createTemplateBuilder(knownImage, locations, images, sizes, region,
|
||||
optionsProvider, templateBuilderProvider, getImageStrategy);
|
||||
|
||||
assertEquals(template.imageId("us-east-1/ami").build().getImage(), knownImage);
|
||||
assertEquals(template.imageId("us-east-1/ami").build().getHardware(), r3_large().build());
|
||||
|
||||
verify(knownImage, os, defaultOptions, optionsProvider, templateBuilderProvider, getImageStrategy);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testParseOnDemandUsesDeprecatedHardwareIfNeeded() {
|
||||
|
||||
Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
.<Location> of(region));
|
||||
Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(Sets
|
||||
.<Image> newLinkedHashSet());
|
||||
Supplier<Set<? extends Hardware>> sizes = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
.<Hardware> of(c1_medium().build(), r3_large().build()));
|
||||
|
||||
Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
|
||||
Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
|
||||
TemplateOptions defaultOptions = createMock(TemplateOptions.class);
|
||||
Image knownImage = createMock(Image.class);
|
||||
OperatingSystem os = createMock(OperatingSystem.class);
|
||||
GetImageStrategy getImageStrategy = createMock(GetImageStrategy.class);
|
||||
|
||||
expect(optionsProvider.get()).andReturn(defaultOptions);
|
||||
|
||||
expect(knownImage.getId()).andReturn("us-east-1/ami").atLeastOnce();
|
||||
expect(knownImage.getLocation()).andReturn(region).atLeastOnce();
|
||||
expect(knownImage.getName()).andReturn(null).atLeastOnce();
|
||||
expect(knownImage.getDescription()).andReturn(null).atLeastOnce();
|
||||
expect(knownImage.getVersion()).andReturn(null).atLeastOnce();
|
||||
expect(knownImage.getProviderId()).andReturn("ami").atLeastOnce();
|
||||
|
||||
expect(knownImage.getOperatingSystem()).andReturn(os).atLeastOnce();
|
||||
|
||||
expect(os.getName()).andReturn(null).atLeastOnce();
|
||||
expect(os.getVersion()).andReturn(null).atLeastOnce();
|
||||
expect(os.getFamily()).andReturn(null).atLeastOnce();
|
||||
expect(os.getDescription()).andReturn(null).atLeastOnce();
|
||||
// paravirtual not compatible with r3 so deprecated c1 is forced
|
||||
expect(os.getArch()).andReturn("paravirtual").atLeastOnce();
|
||||
expect(os.is64Bit()).andReturn(false).atLeastOnce();
|
||||
|
||||
|
@ -142,6 +191,7 @@ public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest {
|
|||
optionsProvider, templateBuilderProvider, getImageStrategy);
|
||||
|
||||
assertEquals(template.imageId("us-east-1/ami").build().getImage(), knownImage);
|
||||
assertEquals(template.imageId("us-east-1/ami").build().getHardware(), c1_medium().build());
|
||||
|
||||
verify(knownImage, os, defaultOptions, optionsProvider, templateBuilderProvider, getImageStrategy);
|
||||
}
|
||||
|
|
|
@ -55,4 +55,9 @@ public interface Hardware extends ComputeMetadata {
|
|||
*/
|
||||
@Nullable
|
||||
String getHypervisor();
|
||||
|
||||
/**
|
||||
* True if usage of the hardware profile is now discouraged.
|
||||
*/
|
||||
boolean isDeprecated();
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public class HardwareBuilder extends ComputeMetadataBuilder {
|
|||
protected List<Volume> volumes = Lists.newArrayList();
|
||||
protected Predicate<Image> supportsImage = any();
|
||||
protected String hypervisor;
|
||||
protected boolean deprecated = false;
|
||||
|
||||
public HardwareBuilder() {
|
||||
super(ComputeType.HARDWARE);
|
||||
|
@ -78,6 +79,15 @@ public class HardwareBuilder extends ComputeMetadataBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public HardwareBuilder deprecated(boolean deprecated) {
|
||||
this.deprecated = deprecated;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HardwareBuilder deprecated() {
|
||||
return deprecated(true);
|
||||
}
|
||||
|
||||
public HardwareBuilder is64Bit(boolean is64Bit) {
|
||||
supportsImage(is64Bit ? ImagePredicates.is64Bit() : not(ImagePredicates.is64Bit()));
|
||||
return this;
|
||||
|
@ -126,7 +136,7 @@ public class HardwareBuilder extends ComputeMetadataBuilder {
|
|||
@Override
|
||||
public Hardware build() {
|
||||
return new HardwareImpl(providerId, name, id, location, uri, userMetadata, tags, processors, ram, volumes,
|
||||
supportsImage, hypervisor);
|
||||
supportsImage, hypervisor, deprecated);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -46,16 +46,18 @@ public class HardwareImpl extends ComputeMetadataImpl implements Hardware {
|
|||
private final List<Volume> volumes;
|
||||
private final Predicate<Image> supportsImage;
|
||||
private final String hypervisor;
|
||||
private final boolean deprecated;
|
||||
|
||||
public HardwareImpl(String providerId, String name, String id, @Nullable Location location, URI uri,
|
||||
Map<String, String> userMetadata, Set<String> tags, Iterable<? extends Processor> processors, int ram,
|
||||
Iterable<? extends Volume> volumes, Predicate<Image> supportsImage, @Nullable String hypervisor) {
|
||||
Iterable<? extends Volume> volumes, Predicate<Image> supportsImage, @Nullable String hypervisor, boolean deprecated) {
|
||||
super(ComputeType.HARDWARE, providerId, name, id, location, uri, userMetadata, tags);
|
||||
this.processors = ImmutableList.copyOf(checkNotNull(processors, "processors"));
|
||||
this.ram = ram;
|
||||
this.volumes = ImmutableList.copyOf(checkNotNull(volumes, "volumes"));
|
||||
this.supportsImage = supportsImage;
|
||||
this.hypervisor = hypervisor;
|
||||
this.deprecated = deprecated;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,6 +93,14 @@ public class HardwareImpl extends ComputeMetadataImpl implements Hardware {
|
|||
return hypervisor;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isDeprecated() {
|
||||
return deprecated;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -483,6 +483,12 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
|||
return Doubles.compare(getCoresAndSpeed(left), getCoresAndSpeed(right));
|
||||
}
|
||||
};
|
||||
static final Ordering<Hardware> NOT_DEPRECATED_ORDERING = new Ordering<Hardware>() {
|
||||
public int compare(Hardware left, Hardware right) {
|
||||
// we take max so deprecated items come first
|
||||
return ComparisonChain.start().compareTrueFirst(left.isDeprecated(), right.isDeprecated()).result();
|
||||
}
|
||||
};
|
||||
static final Ordering<Image> DEFAULT_IMAGE_ORDERING = new Ordering<Image>() {
|
||||
public int compare(Image left, Image right) {
|
||||
/* This currently, and for some time, has *preferred* images whose fields are null,
|
||||
|
@ -819,6 +825,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
|||
hardwareOrdering = hardwareOrdering.reverse();
|
||||
if (fastest)
|
||||
hardwareOrdering = Ordering.compound(ImmutableList.of(BY_CORES_ORDERING, hardwareOrdering));
|
||||
hardwareOrdering = Ordering.compound(ImmutableList.of(NOT_DEPRECATED_ORDERING, hardwareOrdering));
|
||||
return hardwareOrdering;
|
||||
}
|
||||
|
||||
|
|
|
@ -938,10 +938,11 @@ public class TemplateBuilderImplTest {
|
|||
public void testMatchesHardwareWithIdPredicate() {
|
||||
final Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
.<Location> of(region));
|
||||
String imageId = getProviderFormatId("Ubuntu 11.04 x64");
|
||||
final Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet
|
||||
.<Image> of(
|
||||
new ImageBuilder()
|
||||
.ids("Ubuntu 11.04 x64")
|
||||
.ids(imageId)
|
||||
.name("Ubuntu 11.04 x64")
|
||||
.description("Ubuntu 11.04 x64")
|
||||
.location(region)
|
||||
|
@ -950,7 +951,7 @@ public class TemplateBuilderImplTest {
|
|||
OperatingSystem.builder().name("Ubuntu 11.04 x64").description("Ubuntu 11.04 x64")
|
||||
.is64Bit(true).version("11.04").family(OsFamily.UBUNTU).build()).build(),
|
||||
new ImageBuilder()
|
||||
.ids("Ubuntu 11.04 64-bit")
|
||||
.ids(getProviderFormatId("Ubuntu 11.04 64-bit"))
|
||||
.name("Ubuntu 11.04 64-bit")
|
||||
.description("Ubuntu 11.04 64-bit")
|
||||
.location(region)
|
||||
|
@ -967,14 +968,14 @@ public class TemplateBuilderImplTest {
|
|||
.processors(ImmutableList.of(new Processor(1, 1.0)))
|
||||
.volumes(ImmutableList.<Volume> of(new VolumeImpl((float) 5, true, true))).hypervisor("Xen")
|
||||
.location(region)
|
||||
.supportsImage(ImagePredicates.idIn(ImmutableSet.of("Ubuntu 11.04 x64"))).build(),
|
||||
.supportsImage(ImagePredicates.idIn(ImmutableSet.of(imageId))).build(),
|
||||
new HardwareBuilder()
|
||||
.ids(String.format("datacenter(%s)platform(%s)cpuCores(%d)memorySizeMB(%d)diskSizeGB(%d)",
|
||||
"Falkenberg", "OpenVZ", 1, 512, 5)).ram(512)
|
||||
.processors(ImmutableList.of(new Processor(1, 1.0)))
|
||||
.volumes(ImmutableList.<Volume> of(new VolumeImpl((float) 5, true, true))).hypervisor("OpenVZ")
|
||||
.location(region)
|
||||
.supportsImage(ImagePredicates.idIn(ImmutableSet.of("Ubuntu 11.04 64-bit"))).build()));
|
||||
.supportsImage(ImagePredicates.idIn(ImmutableSet.of(imageId))).build()));
|
||||
|
||||
final Provider<TemplateOptions> optionsProvider = new Provider<TemplateOptions>() {
|
||||
|
||||
|
@ -1003,10 +1004,69 @@ public class TemplateBuilderImplTest {
|
|||
|
||||
Template template = templateBuilder.build();
|
||||
assertEquals(template.getHardware().getHypervisor(), "OpenVZ");
|
||||
assertEquals(template.getImage().getId(), "Ubuntu 11.04 64-bit");
|
||||
assertEquals(template.getImage().getId(), imageId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchesHardwarePrefersNonDeprecated() {
|
||||
final Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
.<Location> of(region));
|
||||
String imageId = getProviderFormatId("Ubuntu 11.04 x64");
|
||||
final Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet
|
||||
.<Image> of(
|
||||
new ImageBuilder()
|
||||
.ids(imageId)
|
||||
.name("Ubuntu 11.04 x64")
|
||||
.description("Ubuntu 11.04 x64")
|
||||
.location(region)
|
||||
.status(Status.AVAILABLE)
|
||||
.operatingSystem(
|
||||
OperatingSystem.builder().name("Ubuntu 11.04 x64").description("Ubuntu 11.04 x64")
|
||||
.is64Bit(true).version("11.04").family(OsFamily.UBUNTU).build()).build()));
|
||||
|
||||
final Supplier<Set<? extends Hardware>> hardwares = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
|
||||
.<Hardware> of(
|
||||
new HardwareBuilder()
|
||||
.ids(String.format("hardware-deprecated")).ram(512)
|
||||
.processors(ImmutableList.of(new Processor(1, 1.0)))
|
||||
.volumes(ImmutableList.<Volume> of(new VolumeImpl((float) 5, true, true))).hypervisor("Xen")
|
||||
.location(region)
|
||||
.deprecated()
|
||||
.supportsImage(ImagePredicates.idIn(ImmutableSet.of(imageId))).build(),
|
||||
new HardwareBuilder()
|
||||
.ids(String.format("hardware-good")).ram(512)
|
||||
.processors(ImmutableList.of(new Processor(1, 1.0)))
|
||||
.volumes(ImmutableList.<Volume> of(new VolumeImpl((float) 5, true, true))).hypervisor("Xen")
|
||||
.location(region)
|
||||
.supportsImage(ImagePredicates.idIn(ImmutableSet.of(imageId))).build()));
|
||||
|
||||
final Provider<TemplateOptions> optionsProvider = new Provider<TemplateOptions>() {
|
||||
|
||||
@Override
|
||||
public TemplateOptions get() {
|
||||
return new TemplateOptions();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
final GetImageStrategy getImageStrategy = createMock(GetImageStrategy.class);
|
||||
|
||||
Provider<TemplateBuilder> templateBuilderProvider = new Provider<TemplateBuilder>() {
|
||||
|
||||
@Override
|
||||
public TemplateBuilder get() {
|
||||
return createTemplateBuilder(null, locations, images, hardwares, region, optionsProvider, this, getImageStrategy);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
TemplateBuilder templateBuilder = templateBuilderProvider.get().minRam(512).osFamily(OsFamily.UBUNTU);
|
||||
|
||||
Template template = templateBuilder.build();
|
||||
assertEquals(template.getHardware().getId(), "hardware-good");
|
||||
assertEquals(template.getImage().getId(), imageId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImageLocationNonDefault() {
|
||||
final Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
|
||||
|
|
|
@ -32,6 +32,20 @@ import com.squareup.okhttp.mockwebserver.MockResponse;
|
|||
@Test(groups = "unit", testName = "AWSEC2ComputeServiceMockTest", singleThreaded = true)
|
||||
public class AWSEC2ComputeServiceApiMockTest extends BaseAWSEC2ApiMockTest {
|
||||
|
||||
protected String getDefaultSmallestInstanceType() {
|
||||
// NOT t2.xxx because that requires a VPC
|
||||
return "m3.medium";
|
||||
}
|
||||
|
||||
protected String getDefaultParavirtualInstanceType() {
|
||||
// smallest non-deprecated instance type supporting paravirtual
|
||||
return "m3.medium";
|
||||
}
|
||||
|
||||
protected String getDefaultImageId() {
|
||||
return "be3adfd7";
|
||||
}
|
||||
|
||||
public void launchVPCSpotInstanceSubnetId() throws Exception {
|
||||
enqueueRegions(DEFAULT_REGION);
|
||||
enqueueXml(DEFAULT_REGION, "/availabilityZones.xml");
|
||||
|
@ -56,7 +70,7 @@ public class AWSEC2ComputeServiceApiMockTest extends BaseAWSEC2ApiMockTest {
|
|||
assertPosted(DEFAULT_REGION, "Action=DescribeAvailabilityZones");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeImages&Filter.1.Name=owner-id&Filter.1.Value.1=137112412989&Filter.1.Value.2=801119661308&Filter.1.Value.3=063491364108&Filter.1.Value.4=099720109477&Filter.1.Value.5=411009282317&Filter.2.Name=state&Filter.2.Value.1=available&Filter.3.Name=image-type&Filter.3.Value.1=machine");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeImages&Filter.1.Name=virtualization-type&Filter.1.Value.1=hvm&Filter.2.Name=architecture&Filter.2.Value.1=x86_64&Filter.3.Name=owner-id&Filter.3.Value.1=137112412989&Filter.3.Value.2=099720109477&Filter.4.Name=hypervisor&Filter.4.Value.1=xen&Filter.5.Name=state&Filter.5.Value.1=available&Filter.6.Name=image-type&Filter.6.Value.1=machine&Filter.7.Name=root-device-type&Filter.7.Value.1=ebs");
|
||||
assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-be3adfd7&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.InstanceType=m1.small&LaunchSpecification.SubnetId=subnet-xyz&LaunchSpecification.KeyName=Demo&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK");
|
||||
assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-" + getDefaultImageId() + "&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.InstanceType=" + getDefaultSmallestInstanceType() + "&LaunchSpecification.SubnetId=subnet-xyz&LaunchSpecification.KeyName=Demo&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeSpotInstanceRequests&SpotInstanceRequestId.1=sir-228e6406");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeImages&ImageId.1=ami-595a0a1c");
|
||||
assertPosted(DEFAULT_REGION, "Action=CreateTags&Tag.1.Key=Name&Tag.1.Value=test-228e6406&ResourceId.1=sir-228e6406");
|
||||
|
@ -98,7 +112,7 @@ public class AWSEC2ComputeServiceApiMockTest extends BaseAWSEC2ApiMockTest {
|
|||
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
|
||||
assertPosted(DEFAULT_REGION, "Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=22&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0&IpPermissions.1.IpProtocol=tcp&IpPermissions.1.FromPort=0&IpPermissions.1.ToPort=65535&IpPermissions.1.Groups.0.UserId=993194456877&IpPermissions.1.Groups.0.GroupId=sg-3c6ef654&IpPermissions.2.IpProtocol=udp&IpPermissions.2.FromPort=0&IpPermissions.2.ToPort=65535&IpPermissions.2.Groups.0.UserId=993194456877&IpPermissions.2.Groups.0.GroupId=sg-3c6ef654");
|
||||
assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-be3adfd7&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.SecurityGroup.1=jclouds%23test&LaunchSpecification.InstanceType=m1.small&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&LaunchSpecification.IamInstanceProfile.Arn=arn%3Aaws%3Aiam%3A%3A123456789012%3Ainstance-profile/application_abc/component_xyz/Webserver");
|
||||
assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-" + getDefaultImageId() + "&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.SecurityGroup.1=jclouds%23test&LaunchSpecification.InstanceType=" + getDefaultSmallestInstanceType() + "&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&LaunchSpecification.IamInstanceProfile.Arn=arn%3Aaws%3Aiam%3A%3A123456789012%3Ainstance-profile/application_abc/component_xyz/Webserver");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeSpotInstanceRequests&SpotInstanceRequestId.1=sir-228e6406");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeImages&ImageId.1=ami-595a0a1c");
|
||||
assertPosted(DEFAULT_REGION, "Action=CreateTags&Tag.1.Key=Name&Tag.1.Value=test-228e6406&ResourceId.1=sir-228e6406");
|
||||
|
@ -138,7 +152,7 @@ public class AWSEC2ComputeServiceApiMockTest extends BaseAWSEC2ApiMockTest {
|
|||
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
|
||||
assertPosted(DEFAULT_REGION, "Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=22&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0&IpPermissions.1.IpProtocol=tcp&IpPermissions.1.FromPort=0&IpPermissions.1.ToPort=65535&IpPermissions.1.Groups.0.UserId=993194456877&IpPermissions.1.Groups.0.GroupId=sg-3c6ef654&IpPermissions.2.IpProtocol=udp&IpPermissions.2.FromPort=0&IpPermissions.2.ToPort=65535&IpPermissions.2.Groups.0.UserId=993194456877&IpPermissions.2.Groups.0.GroupId=sg-3c6ef654");
|
||||
assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-be3adfd7&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.SecurityGroup.1=jclouds%23test&LaunchSpecification.InstanceType=m1.small&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&LaunchSpecification.IamInstanceProfile.Name=Webserver");
|
||||
assertPosted(DEFAULT_REGION, "Action=RequestSpotInstances&SpotPrice=1.0&InstanceCount=1&LaunchSpecification.ImageId=ami-" + getDefaultImageId() + "&LaunchSpecification.Placement.AvailabilityZone=us-east-1a&LaunchSpecification.SecurityGroup.1=jclouds%23test&LaunchSpecification.InstanceType=" + getDefaultSmallestInstanceType() + "&LaunchSpecification.UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&LaunchSpecification.IamInstanceProfile.Name=Webserver");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeSpotInstanceRequests&SpotInstanceRequestId.1=sir-228e6406");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeImages&ImageId.1=ami-595a0a1c");
|
||||
assertPosted(DEFAULT_REGION, "Action=CreateTags&Tag.1.Key=Name&Tag.1.Value=test-228e6406&ResourceId.1=sir-228e6406");
|
||||
|
@ -174,7 +188,7 @@ public class AWSEC2ComputeServiceApiMockTest extends BaseAWSEC2ApiMockTest {
|
|||
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
|
||||
assertPosted(DEFAULT_REGION, "Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=22&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0&IpPermissions.1.IpProtocol=tcp&IpPermissions.1.FromPort=0&IpPermissions.1.ToPort=65535&IpPermissions.1.Groups.0.UserId=993194456877&IpPermissions.1.Groups.0.GroupId=sg-3c6ef654&IpPermissions.2.IpProtocol=udp&IpPermissions.2.FromPort=0&IpPermissions.2.ToPort=65535&IpPermissions.2.Groups.0.UserId=993194456877&IpPermissions.2.Groups.0.GroupId=sg-3c6ef654");
|
||||
assertPosted(DEFAULT_REGION, "Action=RunInstances&ImageId=ami-8ce4b5c9&MinCount=1&MaxCount=1&InstanceType=t1.micro&SecurityGroup.1=jclouds%23test&UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&IamInstanceProfile.Arn=arn%3Aaws%3Aiam%3A%3A123456789012%3Ainstance-profile/application_abc/component_xyz/Webserver");
|
||||
assertPosted(DEFAULT_REGION, "Action=RunInstances&ImageId=ami-8ce4b5c9&MinCount=1&MaxCount=1&InstanceType=" + getDefaultParavirtualInstanceType() + "&SecurityGroup.1=jclouds%23test&UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&IamInstanceProfile.Arn=arn%3Aaws%3Aiam%3A%3A123456789012%3Ainstance-profile/application_abc/component_xyz/Webserver");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeInstances&InstanceId.1=i-2baa5550");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeImages&ImageId.1=ami-aecd60c7");
|
||||
assertPosted(DEFAULT_REGION, "Action=CreateTags&Tag.1.Key=Name&Tag.1.Value=test-2baa5550&ResourceId.1=i-2baa5550");
|
||||
|
@ -210,7 +224,7 @@ public class AWSEC2ComputeServiceApiMockTest extends BaseAWSEC2ApiMockTest {
|
|||
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupName.1=jclouds%23test");
|
||||
assertPosted(DEFAULT_REGION, "Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=22&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0&IpPermissions.1.IpProtocol=tcp&IpPermissions.1.FromPort=0&IpPermissions.1.ToPort=65535&IpPermissions.1.Groups.0.UserId=993194456877&IpPermissions.1.Groups.0.GroupId=sg-3c6ef654&IpPermissions.2.IpProtocol=udp&IpPermissions.2.FromPort=0&IpPermissions.2.ToPort=65535&IpPermissions.2.Groups.0.UserId=993194456877&IpPermissions.2.Groups.0.GroupId=sg-3c6ef654");
|
||||
assertPosted(DEFAULT_REGION, "Action=RunInstances&ImageId=ami-8ce4b5c9&MinCount=1&MaxCount=1&InstanceType=t1.micro&SecurityGroup.1=jclouds%23test&UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&IamInstanceProfile.Name=Webserver");
|
||||
assertPosted(DEFAULT_REGION, "Action=RunInstances&ImageId=ami-8ce4b5c9&MinCount=1&MaxCount=1&InstanceType=" + getDefaultParavirtualInstanceType() + "&SecurityGroup.1=jclouds%23test&UserData=I2Nsb3VkLWNvbmZpZwpyZXBvX3VwZ3JhZGU6IG5vbmUK&IamInstanceProfile.Name=Webserver");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeInstances&InstanceId.1=i-2baa5550");
|
||||
assertPosted(DEFAULT_REGION, "Action=DescribeImages&ImageId.1=ami-aecd60c7");
|
||||
assertPosted(DEFAULT_REGION, "Action=CreateTags&Tag.1.Key=Name&Tag.1.Value=test-2baa5550&ResourceId.1=i-2baa5550");
|
||||
|
|
|
@ -93,7 +93,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUbuntuInstanceStoreGoesM1SmallNegativeLookaroundDoesntMatchTestImages() {
|
||||
public void testUbuntuInstanceStoreGoesM3MediumNegativeLookaroundDoesntMatchTestImages() {
|
||||
|
||||
Template template = view.getComputeService().templateBuilder()
|
||||
.imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE))
|
||||
|
@ -114,12 +114,12 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
|
|||
assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
||||
assertEquals(template.getLocation().getId(), "us-east-1");
|
||||
assertEquals(getCores(template.getHardware()), 1.0d);
|
||||
assertEquals(template.getHardware().getId(), InstanceType.M1_SMALL);
|
||||
assertEquals(template.getHardware().getId(), InstanceType.M3_MEDIUM); // smallest non-deprecated supporting PV
|
||||
assertEquals(template.getImage().getOperatingSystem().getArch(), "paravirtual");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemplateBuilderCanUseImageIdAndhardwareIdAndAZ() {
|
||||
public void testTemplateBuilderCanUseImageIdAndHardwareIdAndAZ() {
|
||||
|
||||
Template template = view.getComputeService().templateBuilder().imageId("us-east-1/ami-ccb35ea5")
|
||||
.hardwareId(InstanceType.M2_2XLARGE).locationId("us-east-1a").build();
|
||||
|
@ -141,15 +141,15 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
|
|||
public void testDefaultTemplateBuilder() throws IOException {
|
||||
Template defaultTemplate = view.getComputeService().templateBuilder().build();
|
||||
assert defaultTemplate.getImage().getProviderId().startsWith("ami-") : defaultTemplate;
|
||||
assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().contains("pv-201"),
|
||||
"Default template version should include 'pv-201' but is "
|
||||
assertTrue(defaultTemplate.getImage().getOperatingSystem().getVersion().contains("201"),
|
||||
"Default template version should include '201' but is "
|
||||
+ defaultTemplate.getImage().getOperatingSystem().getVersion());
|
||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), AMZN_LINUX);
|
||||
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
|
||||
assertEquals(defaultTemplate.getLocation().getId(), "us-east-1");
|
||||
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
|
||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getArch(), "paravirtual");
|
||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getArch(), "hvm");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -158,7 +158,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
|
|||
Template defaultTemplate = view.getComputeService().templateBuilder().osFamily(AMZN_LINUX)
|
||||
.imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build();
|
||||
assert defaultTemplate.getImage().getProviderId().startsWith("ami-") : defaultTemplate;
|
||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "pv-2014.09.2");
|
||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "pv-2015.03.rc-1");
|
||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), AMZN_LINUX);
|
||||
assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
||||
|
@ -172,13 +172,13 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
|
|||
Template fastestTemplate = view.getComputeService().templateBuilder().fastest().osFamily(AMZN_LINUX).build();
|
||||
assert fastestTemplate.getImage().getProviderId().startsWith("ami-") : fastestTemplate;
|
||||
assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.C4_8XLARGE);
|
||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "vpc-nat-pv-2014.09.1");
|
||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "2011.09.2");
|
||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), AMZN_LINUX);
|
||||
assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
|
||||
assertEquals(fastestTemplate.getLocation().getId(), "us-east-1");
|
||||
assertEquals(getCores(fastestTemplate.getHardware()), 36.0d);
|
||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().getArch(), "paravirtual");
|
||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().getArch(), "hvm");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -219,7 +219,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
|
|||
assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
||||
assertEquals(template.getLocation().getId(), "us-east-1");
|
||||
assertEquals(getCores(template.getHardware()), 1.0d);
|
||||
assertEquals(template.getHardware().getId(), "m1.small");
|
||||
assertEquals(template.getHardware().getId(), "m3.medium"); // smallest non-deprecated supporting PV
|
||||
|
||||
// ensure we cache the new image for next time
|
||||
assertEquals(context.getComputeService().listImages().size(), 1);
|
||||
|
@ -252,7 +252,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
|
|||
assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
||||
assertEquals(template.getLocation().getId(), "us-east-1");
|
||||
assertEquals(getCores(template.getHardware()), 1.0d);
|
||||
assertEquals(template.getHardware().getId(), "m1.small");
|
||||
assertEquals(template.getHardware().getId(), "m3.medium"); // smallest non-deprecated supporting PV
|
||||
|
||||
// ensure we cache the new image for next time
|
||||
assertEquals(context.getComputeService().listImages().size(), 1);
|
||||
|
@ -297,7 +297,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
|
|||
assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
||||
assertEquals(template.getLocation().getId(), "eu-west-1");
|
||||
assertEquals(getCores(template.getHardware()), 1.0d);
|
||||
assertEquals(template.getHardware().getId(), "m1.small");
|
||||
assertEquals(template.getHardware().getId(), "m3.medium"); // smallest non-deprecated supporting PV
|
||||
|
||||
} finally {
|
||||
if (context != null)
|
||||
|
|
|
@ -45,7 +45,6 @@ import org.jclouds.compute.domain.Template;
|
|||
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||
import org.jclouds.compute.options.TemplateOptions;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.ec2.compute.EC2TemplateBuilderTest;
|
||||
import org.jclouds.ec2.compute.domain.EC2HardwareBuilder;
|
||||
import org.jclouds.ec2.compute.domain.RegionAndName;
|
||||
import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules;
|
||||
|
@ -140,7 +139,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
// setup constants
|
||||
String region = Region.US_EAST_1;
|
||||
String group = "group";
|
||||
Hardware size = EC2TemplateBuilderTest.CC1_4XLARGE;
|
||||
Hardware size = EC2HardwareBuilder.cc1_4xlarge().build();
|
||||
String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
|
||||
String generatedGroup = "group";
|
||||
Set<String> generatedGroups = ImmutableSet.of(generatedGroup);
|
||||
|
@ -205,7 +204,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
// setup constants
|
||||
String region = Region.US_EAST_1;
|
||||
String group = "group";
|
||||
Hardware size = EC2TemplateBuilderTest.CC1_4XLARGE;
|
||||
Hardware size = EC2HardwareBuilder.cc1_4xlarge().build();
|
||||
String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
|
||||
String generatedGroup = "group";
|
||||
Set<String> generatedGroups = ImmutableSet.of(generatedGroup);
|
||||
|
|
|
@ -165,13 +165,12 @@ public class PlacementGroupApiLiveTest extends BaseComputeServiceContextLiveTest
|
|||
assert availableTester.apply(group) : group;
|
||||
}
|
||||
|
||||
public void testStartCCInstance() throws Exception {
|
||||
public void testStartHS1Instance() throws Exception {
|
||||
|
||||
Template template = view.getComputeService().templateBuilder()
|
||||
.fromHardware(EC2HardwareBuilder.cc2_8xlarge().build()).osFamily(OsFamily.AMZN_LINUX).build();
|
||||
.fromHardware(EC2HardwareBuilder.hs1_8xlarge().build()).osFamily(OsFamily.AMZN_LINUX).build();
|
||||
assert template != null : "The returned template was null, but it should have a value.";
|
||||
assertEquals(template.getHardware().getProviderId(), InstanceType.CC2_8XLARGE);
|
||||
assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
|
||||
assertEquals(template.getHardware().getProviderId(), InstanceType.HS1_8XLARGE);
|
||||
assertEquals(template.getImage().getUserMetadata().get("virtualizationType"), "hvm");
|
||||
assertEquals(template.getImage().getUserMetadata().get("hypervisor"), "xen");
|
||||
|
||||
|
|
|
@ -139,10 +139,11 @@ public class SpotInstanceApiLiveTest extends BaseComputeServiceContextLiveTest
|
|||
assert spot.getSpotPrice() > 0 : spots;
|
||||
assertEquals(spot.getRegion(), region);
|
||||
assert in(
|
||||
ImmutableSet.of("Linux/UNIX", "Linux/UNIX (Amazon VPC)", "SUSE Linux", "SUSE Linux (Amazon VPC)",
|
||||
ImmutableSet.of("Linux/UNIX", "Linux/UNIX (Amazon VPC)", "SUSE Linux", "SUSE Linux (Amazon VPC)",
|
||||
"Windows", "Windows (Amazon VPC)")).apply(spot.getProductDescription()) : spot;
|
||||
assert in(
|
||||
ImmutableSet.of("c1.medium", "c1.xlarge", "cc1.4xlarge", "cg1.4xlarge", "cc2.8xlarge", "m1.large",
|
||||
assert // sometimes get D2 type, which we don't yet enumerate
|
||||
spot.getInstanceType().startsWith("d2.") ||
|
||||
in(ImmutableSet.of("c1.medium", "c1.xlarge", "cc1.4xlarge", "cg1.4xlarge", "cc2.8xlarge", "m1.large",
|
||||
"m1.small", "m1.medium", "m1.xlarge", "m2.2xlarge", "m2.4xlarge", "m2.xlarge", "m3.xlarge",
|
||||
"m3.2xlarge", "t1.micro", "cr1.8xlarge", "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge",
|
||||
"c4.8xlarge")).apply(spot.getInstanceType()) : spot;
|
||||
|
|
Loading…
Reference in New Issue