From 4874f1c3c64b62a030045a26718a103213ec9ff0 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 1 Jan 2013 22:14:46 -0800 Subject: [PATCH 1/4] updated to latest aws linux ami --- providers/aws-ec2/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/providers/aws-ec2/pom.xml b/providers/aws-ec2/pom.xml index 854246fc85..d55cd4a719 100644 --- a/providers/aws-ec2/pom.xml +++ b/providers/aws-ec2/pom.xml @@ -40,7 +40,8 @@ ${test.aws.identity} ${test.aws.credential} - hardwareId=m1.small,imageId=us-west-2/ami-38c64a08 + + hardwareId=m1.small,imageId=us-west-2/ami-2231bf12 hardwareId=m1.small,imageId=us-east-1/ami-0cb76d65 org.jclouds.aws.ec2*;version="${project.version}" From b582d4a4a816707043b3339baa10cd345114f518 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 1 Jan 2013 22:15:59 -0800 Subject: [PATCH 2/4] added recent aws instance types --- .../compute/domain/EC2HardwareBuilder.java | 40 +++++++++++++++++-- .../org/jclouds/ec2/domain/InstanceType.java | 34 ++++++++++++++++ .../suppliers/AWSEC2HardwareSupplier.java | 6 ++- .../AWSEC2TemplateBuilderLiveTest.java | 22 ++-------- .../services/SpotInstanceClientLiveTest.java | 3 +- 5 files changed, 82 insertions(+), 23 deletions(-) diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java index a26f555e5e..35df073e2c 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java @@ -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. 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. 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 all24Volumes = ImmutableList.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() { diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/InstanceType.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/InstanceType.java index ddd7b516b2..acac242d1b 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/InstanceType.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/InstanceType.java @@ -119,6 +119,28 @@ public class InstanceType { * */ public static final String M2_4XLARGE = "m2.4xlarge"; + /** + * M3 Extra Large Instance + *
    + *
  • 15 GiB memory
  • + *
  • 13 EC2 Compute Units (4 virtual cores with 3.25 EC2 Compute Units each)
  • + *
  • EBS storage only
  • + *
  • 64-bit platform
  • + *
  • I/O Performance: Moderate
  • + *
+ */ + public static final String M3_XLARGE = "m3.xlarge"; + /** + * M3 Double Extra Large Instance + *
    + *
  • 30 GiB memory
  • + *
  • 26 EC2 Compute Units (8 virtual cores with 3.25 EC2 Compute Units each)
  • + *
  • EBS storage only
  • + *
  • 64-bit platform
  • + *
  • I/O Performance: High
  • + *
+ */ + public static final String M3_2XLARGE = "m3.2xlarge"; /** * High-CPU Medium Instance *
    @@ -197,4 +219,16 @@ public class InstanceType { */ public static final String HI1_4XLARGE = "hi1.4xlarge"; + /** + * High Storage Eight Extra Large + *
      + *
    • 117 GiB of memory
    • + *
    • 35 EC2 Compute Units (16 virtual cores*)
    • + *
    • 24 hard disk drives each with 2 TB of instance storage
    • + *
    • 64-bit platform
    • + *
    • I/O Performance: Very High (10 Gigabit Ethernet)
    • + *
    • Storage I/O Performance: Very High**
    • + *
    + */ + public static final String HS1_8XLARGE = "hs1.8xlarge"; } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java index a20f3d32ab..eba814594f 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java @@ -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. 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(); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index 0a78eb7dec..0546a38f62 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -69,7 +69,6 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { @Override protected Predicate defineUnsupportedOperatingSystems() { return Predicates.not(new Predicate() { - @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 diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java index 26188dc5f7..5b1e2497cc 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java @@ -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; } From 9237f1a4061ce3121ce6e821532c473caf37a509 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 1 Jan 2013 22:16:28 -0800 Subject: [PATCH 3/4] eliminated errors when multiple groups have the same name --- .../org/jclouds/ec2/domain/SecurityGroup.java | 6 +-- .../services/SecurityGroupClientLiveTest.java | 48 ++++++++++++------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java index a52ed5b900..34cade9369 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java @@ -204,7 +204,7 @@ public class SecurityGroup extends ForwardingSet { @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 { 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() { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java index 3cfa7738e2..9bb129bd14 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java @@ -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 allResults = client.describeSecurityGroupsInRegion(region); assertNotNull(allResults); if (allResults.size() >= 1) { - SecurityGroup group = Iterables.getLast(allResults); - Set 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 expected = FluentIterable.from(allResults) + .filter(new Predicate() { + @Override + public boolean apply(SecurityGroup in) { + return group.getName().equals(in.getName()); + } + }).toSet(); + ImmutableSet 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 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 twoResults = client.describeSecurityGroupsInRegion(null, group1Name, group2Name); assertNotNull(twoResults); - assertEquals(twoResults.size(), 2); - Iterator 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() { + @Override + public String apply(SecurityGroup in) { + return in.getName(); + } + }))); } private static final int INCONSISTENCY_WINDOW = 5000; From aaf41575d8144ee361a2d347711ba2af578ecd16 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 1 Jan 2013 22:16:47 -0800 Subject: [PATCH 4/4] missing timeout on describeinstances --- .../src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java | 1 + 1 file changed, 1 insertion(+) diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java index a232d3b08a..97ec444f8d 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java @@ -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