Merge pull request #1134 from jclouds/ec2-updates

Ec2 updates
This commit is contained in:
Adrian Cole 2013-01-02 06:47:42 -08:00
commit bc03708110
9 changed files with 118 additions and 45 deletions

View File

@ -43,6 +43,8 @@ import org.jclouds.ec2.domain.VirtualizationType;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableSet;
/**
*
@ -294,7 +296,23 @@ public class EC2HardwareBuilder extends HardwareBuilder {
ImmutableList.<Volume> of(new VolumeImpl(10.0f, "/dev/sda1", true, false), new VolumeImpl(840.0f,
"/dev/sdb", false, false), new VolumeImpl(840.0f, "/dev/sdc", false, false))).is64Bit(true);
}
/**
* @see InstanceType#M3_XLARGE
*/
public static EC2HardwareBuilder m3_xlarge() {
return new EC2HardwareBuilder(InstanceType.M3_XLARGE).ram(15360)
.processors(ImmutableList.of(new Processor(4.0, 3.25))).rootDeviceType(RootDeviceType.EBS).is64Bit(true);
}
/**
* @see InstanceType#M3_2XLARGE
*/
public static EC2HardwareBuilder m3_2xlarge() {
return new EC2HardwareBuilder(InstanceType.M3_2XLARGE).ram(30720)
.processors(ImmutableList.of(new Processor(8.0, 3.25))).rootDeviceType(RootDeviceType.EBS).is64Bit(true);
}
/**
* @see InstanceType#C1_MEDIUM
*/
@ -355,11 +373,27 @@ public class EC2HardwareBuilder extends HardwareBuilder {
public static EC2HardwareBuilder hi1_4xlarge() {
return new EC2HardwareBuilder(InstanceType.HI1_4XLARGE)
.ram(60 * 1024 + 512)
.processors(ImmutableList.of(new Processor(8.0, 5.5), new Processor(8.0, 5.5)))
.processors(ImmutableList.of(new Processor(16.0, 2.1875)))
.volumes(ImmutableList.<Volume> of(new VolumeImpl(1024.0f, "/dev/sda1", true, false),
new VolumeImpl(1024.0f, "/dev/sdb", false, false)));
new VolumeImpl(1024.0f, "/dev/sdb", false, false)))
.virtualizationType(VirtualizationType.HVM);
}
public static EC2HardwareBuilder hs1_8xlarge() {
float twoTB = 2048.0f * 1024.0f;
Builder<Volume> all24Volumes = ImmutableList.<Volume>builder();
all24Volumes.add(new VolumeImpl(twoTB, "/dev/sda1", true, false));
for (char letter : ImmutableSet.of('b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x')) {
all24Volumes.add(new VolumeImpl(twoTB, "/dev/sd" + letter, false, false));
}
return new EC2HardwareBuilder(InstanceType.HS1_8XLARGE)
.ram(117 * 1024)
.processors(ImmutableList.of(new Processor(16.0, 2.1875)))
.volumes(all24Volumes.build())
.virtualizationType(VirtualizationType.HVM);
}
@SuppressWarnings("unchecked")
@Override
public Hardware build() {

View File

@ -119,6 +119,28 @@ public class InstanceType {
* </ul>
*/
public static final String M2_4XLARGE = "m2.4xlarge";
/**
* M3 Extra Large Instance
* <ul>
* <li>15 GiB memory</li>
* <li>13 EC2 Compute Units (4 virtual cores with 3.25 EC2 Compute Units each)</li>
* <li>EBS storage only</li>
* <li>64-bit platform</li>
* <li>I/O Performance: Moderate</li>
* </ul>
*/
public static final String M3_XLARGE = "m3.xlarge";
/**
* M3 Double Extra Large Instance
* <ul>
* <li>30 GiB memory</li>
* <li>26 EC2 Compute Units (8 virtual cores with 3.25 EC2 Compute Units each)</li>
* <li>EBS storage only</li>
* <li>64-bit platform</li>
* <li>I/O Performance: High</li>
* </ul>
*/
public static final String M3_2XLARGE = "m3.2xlarge";
/**
* High-CPU Medium Instance
* <ul>
@ -197,4 +219,16 @@ public class InstanceType {
*/
public static final String HI1_4XLARGE = "hi1.4xlarge";
/**
* High Storage Eight Extra Large
* <ul>
* <li>117 GiB of memory</li>
* <li>35 EC2 Compute Units (16 virtual cores*)</li>
* <li>24 hard disk drives each with 2 TB of instance storage</li>
* <li>64-bit platform</li>
* <li>I/O Performance: Very High (10 Gigabit Ethernet)</li>
* <li>Storage I/O Performance: Very High**</li>
* </ul>
*/
public static final String HS1_8XLARGE = "hs1.8xlarge";
}

View File

@ -204,7 +204,7 @@ public class SecurityGroup extends ForwardingSet<IpPermission> {
@Override
public int hashCode() {
return Objects.hashCode(region, id, name, ownerId, description, ipPermissions);
return Objects.hashCode(region, id, name, ownerId);
}
@Override
@ -217,9 +217,7 @@ public class SecurityGroup extends ForwardingSet<IpPermission> {
return Objects.equal(this.region, that.region)
&& Objects.equal(this.id, that.id)
&& Objects.equal(this.name, that.name)
&& Objects.equal(this.ownerId, that.ownerId)
&& Objects.equal(this.description, that.description)
&& Objects.equal(this.ipPermissions, that.ipPermissions);
&& Objects.equal(this.ownerId, that.ownerId);
}
protected ToStringHelper string() {

View File

@ -18,10 +18,15 @@
*/
package org.jclouds.ec2.services;
import static com.google.common.base.Predicates.compose;
import static com.google.common.base.Predicates.in;
import static com.google.common.collect.Iterables.all;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import java.util.Iterator;
import java.util.Set;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
@ -34,10 +39,11 @@ import org.jclouds.ec2.domain.UserIdGroupPair;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
/**
* Tests behavior of {@code SecurityGroupClient}
@ -67,11 +73,19 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
Set<SecurityGroup> allResults = client.describeSecurityGroupsInRegion(region);
assertNotNull(allResults);
if (allResults.size() >= 1) {
SecurityGroup group = Iterables.getLast(allResults);
Set<SecurityGroup> result = client.describeSecurityGroupsInRegion(region, group.getName());
assertNotNull(result);
SecurityGroup compare = Iterables.getLast(result);
assertEquals(compare, group);
final SecurityGroup group = getLast(allResults);
// in case there are multiple groups with the same name, which is the case with VPC
ImmutableSet<SecurityGroup> expected = FluentIterable.from(allResults)
.filter(new Predicate<SecurityGroup>() {
@Override
public boolean apply(SecurityGroup in) {
return group.getName().equals(in.getName());
}
}).toSet();
ImmutableSet<SecurityGroup> result = ImmutableSet.copyOf(client.describeSecurityGroupsInRegion(region,
group.getName()));
// the above command has a chance of returning less groups than the original
assertTrue(expected.containsAll(result));
}
}
}
@ -197,7 +211,7 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
public void run() {
try {
Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group);
assert Iterables.all(Iterables.getOnlyElement(oneResult).getIpPermissions(), permission) : permission
assert all(getOnlyElement(oneResult), permission) : permission
+ ": " + oneResult;
} catch (Exception e) {
throw new AssertionError(e);
@ -220,7 +234,7 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
assertNotNull(oneResult);
assertEquals(oneResult.size(), 1);
SecurityGroup listPair = oneResult.iterator().next();
assertEquals(listPair.getIpPermissions().size(), 0);
assertEquals(listPair.size(), 0);
} catch (Exception e) {
throw new AssertionError(e);
}
@ -230,15 +244,15 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
protected void ensureGroupsExist(String group1Name, String group2Name) {
Set<SecurityGroup> twoResults = client.describeSecurityGroupsInRegion(null, group1Name, group2Name);
assertNotNull(twoResults);
assertEquals(twoResults.size(), 2);
Iterator<SecurityGroup> iterator = twoResults.iterator();
SecurityGroup listPair1 = iterator.next();
assertEquals(listPair1.getName(), group1Name);
assertEquals(listPair1.getDescription(), group1Name);
assertTrue(twoResults.size() >= 2);// in VPC could be multiple groups with the same name
SecurityGroup listPair2 = iterator.next();
assertEquals(listPair2.getName(), group2Name);
assertEquals(listPair2.getDescription(), group2Name);
assertTrue(all(twoResults, compose(in(ImmutableSet.of(group1Name, group2Name)),
new Function<SecurityGroup, String>() {
@Override
public String apply(SecurityGroup in) {
return in.getName();
}
})));
}
private static final int INCONSISTENCY_WINDOW = 5000;

View File

@ -40,7 +40,8 @@
<test.aws-ec2.identity>${test.aws.identity}</test.aws-ec2.identity>
<test.aws-ec2.credential>${test.aws.credential}</test.aws-ec2.credential>
<test.aws-ec2.template></test.aws-ec2.template>
<test.aws-ec2.ebs-template>hardwareId=m1.small,imageId=us-west-2/ami-38c64a08</test.aws-ec2.ebs-template>
<!-- https://aws.amazon.com/amazon-linux-ami/ EBS-Backed 32-bit Oregon -->
<test.aws-ec2.ebs-template>hardwareId=m1.small,imageId=us-west-2/ami-2231bf12</test.aws-ec2.ebs-template>
<!-- Windows_Server-2008-R2 with WinRM enabled (setup instructions at http://www.frontiertown.co.uk/2011/12/overthere-control-windows-from-java/) -->
<test.aws-ec2.windows-template>hardwareId=m1.small,imageId=us-east-1/ami-0cb76d65</test.aws-ec2.windows-template>
<jclouds.osgi.export>org.jclouds.aws.ec2*;version="${project.version}"</jclouds.osgi.export>

View File

@ -64,6 +64,7 @@ public class AWSEC2ApiMetadata extends EC2ApiMetadata {
public static Properties defaultProperties() {
Properties properties = EC2ApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_TIMEOUTS_PREFIX + "default", SECONDS.toMillis(90) + "");
properties.setProperty(PROPERTY_TIMEOUTS_PREFIX + "AWSAMIClient.describeImagesInRegion", MINUTES.toMillis(5) + "");
properties.setProperty(PROPERTY_TIMEOUTS_PREFIX + "SpotInstanceClient.describeSpotPriceHistoryInRegion", MINUTES.toMillis(2) + "");
properties.remove(PROPERTY_EC2_AMI_OWNERS);
// auth fail sometimes happens in EC2, as the rc.local script that injects the

View File

@ -24,6 +24,7 @@ import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cc1_4xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cc2_8xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cg1_4xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.hi1_4xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.hs1_8xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_large;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_medium;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small;
@ -31,6 +32,7 @@ import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_2xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_4xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m3_xlarge;
import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.t1_micro;
import java.util.Set;
@ -65,9 +67,11 @@ public class AWSEC2HardwareSupplier extends EC2HardwareSupplier {
sizes.add(cc1_4xlarge().supportsImageIds(ccAmis).build());
sizes.add(cg1_4xlarge().supportsImageIds(ccAmis).build());
sizes.add(cc2_8xlarge().supportsImageIds(ccAmis).build());
sizes.add(hi1_4xlarge().supportsImageIds(ccAmis).build());
sizes.add(hs1_8xlarge().supportsImageIds(ccAmis).build());
sizes.addAll(ImmutableSet.<Hardware> of(t1_micro().build(), c1_medium().build(), c1_xlarge().build(), m1_large()
.build(), m1_small().build(), m1_medium().build(), m1_xlarge().build(), m2_xlarge().build(),
m2_2xlarge().build(), m2_4xlarge().build(), hi1_4xlarge().build()));
m2_2xlarge().build(), m2_4xlarge().build(), m3_xlarge().build(), m3_xlarge().build()));
return sizes.build();
}
}

View File

@ -69,7 +69,6 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
@Override
protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
return Predicates.not(new Predicate<OsFamilyVersion64Bit>() {
@Override
public boolean apply(OsFamilyVersion64Bit input) {
switch (input.family) {
@ -168,7 +167,6 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
@Test
public void testDefaultTemplateBuilder() throws IOException {
Template defaultTemplate = view.getComputeService().templateBuilder().build();
assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate;
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "pv-2012.09.rc-1");
@ -200,26 +198,14 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
Template fastestTemplate = view.getComputeService().templateBuilder().fastest().osFamily(OsFamily.AMZN_LINUX)
.build();
assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate;
assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.HI1_4XLARGE);
assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "pv-2012.09.rc-1");
assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.CC2_8XLARGE);
assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "2011.09.2");
assertEquals(fastestTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
assertEquals(fastestTemplate.getLocation().getId(), "us-east-1");
assertEquals(getCores(fastestTemplate.getHardware()), 16.0d);
assertEquals(fastestTemplate.getImage().getOperatingSystem().getArch(), "paravirtual");
fastestTemplate = view.getComputeService().templateBuilder().fastest().build();
System.out.println(fastestTemplate.getImage());
assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate;
assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.HI1_4XLARGE);
assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "9.10");
assertEquals(fastestTemplate.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
assertEquals(fastestTemplate.getLocation().getId(), "us-east-1");
assertEquals(getCores(fastestTemplate.getHardware()), 16.0d);
assertEquals(fastestTemplate.getImage().getOperatingSystem().getArch(), "paravirtual");
assertEquals(fastestTemplate.getImage().getOperatingSystem().getArch(), "hvm");
}
@Test

View File

@ -107,7 +107,8 @@ public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTe
"Windows", "Windows (Amazon VPC)")).apply(spot.getProductDescription()) : spot;
assert 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", "t1.micro")).apply(
"m1.small", "m1.medium", "m1.xlarge", "m2.2xlarge", "m2.4xlarge", "m2.xlarge", "m3.xlarge",
"m3.2xlarge", "t1.micro")).apply(
spot.getInstanceType()) : spot;
}