diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/EC2ComputeService.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/EC2ComputeService.java index d9dcefbb55..df653f5e5d 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/EC2ComputeService.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/EC2ComputeService.java @@ -48,6 +48,7 @@ import org.jclouds.compute.strategy.RebootNodeStrategy; import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy; import org.jclouds.compute.util.ComputeUtils; import org.jclouds.domain.Location; +import static org.jclouds.util.Utils.*; import com.google.common.base.Function; import com.google.common.base.Predicate; @@ -88,19 +89,21 @@ public class EC2ComputeService extends BaseComputeService { } private void deleteSecurityGroup(String region, String tag) { - if (ec2Client.getSecurityGroupServices().describeSecurityGroupsInRegion(region, tag).size() > 0) { - logger.debug(">> deleting securityGroup(%s)", tag); - ec2Client.getSecurityGroupServices().deleteSecurityGroupInRegion(region, tag); + checkNotEmpty(tag, "tag"); + String group = "jclouds#" + tag; + if (ec2Client.getSecurityGroupServices().describeSecurityGroupsInRegion(region, group).size() > 0) { + logger.debug(">> deleting securityGroup(%s)", group); + ec2Client.getSecurityGroupServices().deleteSecurityGroupInRegion(region, group); securityGroupMap.remove(new PortsRegionTag(region, tag, null)); // TODO: test this clear // happens - logger.debug("<< deleted securityGroup(%s)", tag); + logger.debug("<< deleted securityGroup(%s)", group); } } private void deleteKeyPair(String region, String tag) { for (KeyPair keyPair : ec2Client.getKeyPairServices().describeKeyPairsInRegion(region)) { - if (keyPair.getKeyName().matches(tag + "-[0-9]+")) { - logger.debug(">> deleting keyPair(%s)", tag); + if (keyPair.getKeyName().matches("jclouds#" + tag + "-[0-9]+")) { + logger.debug(">> deleting keyPair(%s)", keyPair.getKeyName()); ec2Client.getKeyPairServices().deleteKeyPairInRegion(region, keyPair.getKeyName()); credentialsMap.remove(new RegionTag(region, keyPair.getKeyName())); // TODO: test this // clear happens diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/CreateNewKeyPair.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/CreateNewKeyPair.java index 790344ece1..435144ab3f 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/CreateNewKeyPair.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/CreateNewKeyPair.java @@ -66,7 +66,7 @@ public class CreateNewKeyPair implements Function { while (keyPair == null) { try { keyPair = ec2Client.getKeyPairServices().createKeyPairInRegion(region, - tag + "-" + new SecureRandom().nextInt(100)); + "jclouds#" + tag + "-" + new SecureRandom().nextInt(100)); logger.debug("<< created keyPair(%s)", keyPair.getKeyName()); } catch (AWSResponseException e) { if (!e.getError().getCode().equals("InvalidKeyPair.Duplicate")) { diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadata.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadata.java index 3a2872e0c9..b5043e7889 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadata.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadata.java @@ -114,11 +114,29 @@ public class RunningInstanceToNodeMetadata implements Function() { + + @Override + public boolean apply(String input) { + return input.startsWith("jclouds#"); + } + + })).substring(8); + } catch (NoSuchElementException e) { + logger + .warn("no tag parsed from %s's groups: %s", instance.getId(), instance + .getGroupIds()); + } catch (IllegalArgumentException e) { + logger.warn("too many groups match %s; %s's groups: %s", "jclouds#", instance.getId(), + instance.getGroupIds()); + } + Credentials credentials = null;// default if no keypair exists - String tag = String.format("NOTAG-%s", instance.getId());// default if no keypair exists if (instance.getKeyName() != null) { - tag = instance.getKeyName().replaceAll("-[0-9]+", ""); credentials = new Credentials(getLoginAccountFor(instance), getPrivateKeyOrNull(instance, tag)); } diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategy.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategy.java index 1d8c78f896..479031e91f 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategy.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/EC2RunNodesAndAddToSetStrategy.java @@ -139,7 +139,8 @@ public class EC2RunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrate credentialsMap.put(new RegionTag(region, keyPair.getKeyName()), keyPair); TemplateOptions options = template.getOptions(); - PortsRegionTag portsRegionTag = new PortsRegionTag(region, tag, options.getInboundPorts()); + String group = "jclouds#" +tag; + PortsRegionTag portsRegionTag = new PortsRegionTag(region, group, options.getInboundPorts()); if (!securityGroupMap.containsKey(portsRegionTag)) { securityGroupMap.put(portsRegionTag, createSecurityGroupIfNeeded.apply(portsRegionTag)); } @@ -148,10 +149,10 @@ public class EC2RunNodesAndAddToSetStrategy implements RunNodesAndAddToSetStrate .debug( ">> running %d instance region(%s) zone(%s) ami(%s) type(%s) keyPair(%s) securityGroup(%s)", count, region, zone, template.getImage().getId(), - ec2Size.getInstanceType(), tag, tag); + ec2Size.getInstanceType(), keyPair.getKeyName(), group); RunInstancesOptions instanceOptions = withKeyName(keyPair.getKeyName())// key .asType(ec2Size.getInstanceType())// instance size - .withSecurityGroup(tag)// group I created above + .withSecurityGroup(group)// group I created above .withAdditionalInfo(tag); Reservation reservation = ec2Client.getInstanceServices().runInstancesInRegion(region, zone, diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java index 4ab29511d7..a0dd220b2d 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/domain/RunningInstance.java @@ -27,7 +27,9 @@ import java.util.Set; import org.jclouds.aws.ec2.domain.Attachment.Status; +import com.google.common.collect.Iterables; import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import com.google.inject.internal.Nullable; /** @@ -45,7 +47,7 @@ public class RunningInstance implements Comparable { private final boolean deleteOnTermination; public EbsBlockDevice(String volumeId, Status attachmentStatus, Date attachTime, - boolean deleteOnTermination) { + boolean deleteOnTermination) { super(); this.volumeId = volumeId; this.attachmentStatus = attachmentStatus; @@ -116,6 +118,8 @@ public class RunningInstance implements Comparable { } private final String region; + private final Set groupIds = Sets.newLinkedHashSet(); + private final String amiLaunchIndex; @Nullable private final String dnsName; @@ -156,15 +160,17 @@ public class RunningInstance implements Comparable { return (this == o) ? 0 : getId().compareTo(o.getId()); } - public RunningInstance(String region, @Nullable String amiLaunchIndex, @Nullable String dnsName, - String imageId, String instanceId, InstanceState instanceState, - String instanceType, @Nullable InetAddress ipAddress, @Nullable String kernelId, - @Nullable String keyName, Date launchTime, boolean monitoring, - String availabilityZone, @Nullable String platform, - @Nullable String privateDnsName, @Nullable InetAddress privateIpAddress, - Set productCodes, @Nullable String ramdiskId, @Nullable String reason, - @Nullable String subnetId, @Nullable String vpcId, RootDeviceType rootDeviceType, - @Nullable String rootDeviceName, Map ebsBlockDevices) { + public RunningInstance(String region, Iterable groupIds, + @Nullable String amiLaunchIndex, @Nullable String dnsName, String imageId, + String instanceId, InstanceState instanceState, String instanceType, + @Nullable InetAddress ipAddress, @Nullable String kernelId, @Nullable String keyName, + Date launchTime, boolean monitoring, String availabilityZone, + @Nullable String platform, @Nullable String privateDnsName, + @Nullable InetAddress privateIpAddress, Set productCodes, + @Nullable String ramdiskId, @Nullable String reason, @Nullable String subnetId, + @Nullable String vpcId, RootDeviceType rootDeviceType, @Nullable String rootDeviceName, + Map ebsBlockDevices) { + Iterables.addAll(this.groupIds, checkNotNull(groupIds, "groupIds")); this.region = checkNotNull(region, "region"); this.amiLaunchIndex = amiLaunchIndex; // nullable on runinstances. this.dnsName = dnsName; // nullable on runinstances. @@ -351,7 +357,7 @@ public class RunningInstance implements Comparable { public String getRootDeviceName() { return rootDeviceName; } - + /** * EBS volumes associated with the instance. */ @@ -359,6 +365,13 @@ public class RunningInstance implements Comparable { return ebsBlockDevices; } + /** + * Names of the security groups. + */ + public Set getGroupIds() { + return groupIds; + } + @Override public int hashCode() { final int prime = 31; @@ -367,6 +380,7 @@ public class RunningInstance implements Comparable { result = prime * result + ((availabilityZone == null) ? 0 : availabilityZone.hashCode()); result = prime * result + ((dnsName == null) ? 0 : dnsName.hashCode()); result = prime * result + ((ebsBlockDevices == null) ? 0 : ebsBlockDevices.hashCode()); + result = prime * result + ((groupIds == null) ? 0 : groupIds.hashCode()); result = prime * result + ((imageId == null) ? 0 : imageId.hashCode()); result = prime * result + ((instanceId == null) ? 0 : instanceId.hashCode()); result = prime * result + ((instanceState == null) ? 0 : instanceState.hashCode()); @@ -417,6 +431,11 @@ public class RunningInstance implements Comparable { return false; } else if (!ebsBlockDevices.equals(other.ebsBlockDevices)) return false; + if (groupIds == null) { + if (other.groupIds != null) + return false; + } else if (!groupIds.equals(other.groupIds)) + return false; if (imageId == null) { if (other.imageId != null) return false; @@ -511,15 +530,15 @@ public class RunningInstance implements Comparable { public String toString() { return "RunningInstance [amiLaunchIndex=" + amiLaunchIndex + ", availabilityZone=" + availabilityZone + ", dnsName=" + dnsName + ", ebsBlockDevices=" + ebsBlockDevices - + ", imageId=" + imageId + ", instanceId=" + instanceId + ", instanceState=" - + instanceState + ", instanceType=" + instanceType + ", ipAddress=" + ipAddress - + ", kernelId=" + kernelId + ", keyName=" + keyName + ", launchTime=" + launchTime - + ", monitoring=" + monitoring + ", platform=" + platform + ", privateDnsName=" - + privateDnsName + ", privateIpAddress=" + privateIpAddress + ", productCodes=" - + productCodes + ", ramdiskId=" + ramdiskId + ", reason=" + reason + ", region=" - + region + ", rootDeviceName=" + rootDeviceName + ", rootDeviceType=" - + rootDeviceType + ", subnetId=" + subnetId + ", vpcId=" + vpcId + "]"; + + ", groupIds=" + groupIds + ", imageId=" + imageId + ", instanceId=" + instanceId + + ", instanceState=" + instanceState + ", instanceType=" + instanceType + + ", ipAddress=" + ipAddress + ", kernelId=" + kernelId + ", keyName=" + keyName + + ", launchTime=" + launchTime + ", monitoring=" + monitoring + ", platform=" + + platform + ", privateDnsName=" + privateDnsName + ", privateIpAddress=" + + privateIpAddress + ", productCodes=" + productCodes + ", ramdiskId=" + ramdiskId + + ", reason=" + reason + ", region=" + region + ", rootDeviceName=" + rootDeviceName + + ", rootDeviceType=" + rootDeviceType + ", subnetId=" + subnetId + ", vpcId=" + + vpcId + "]"; } - } \ No newline at end of file diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java index 29365ce7db..6eb72262af 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java @@ -208,11 +208,11 @@ public abstract class BaseReservationHandler extends HandlerWithResult { String region = EC2Utils.findRegionInArgsOrNull(request); if (region == null) region = defaultRegion; - instances.add(new RunningInstance(region, amiLaunchIndex, dnsName, imageId, instanceId, - instanceState, instanceType, ipAddress, kernelId, keyName, launchTime, - monitoring, availabilityZone, platform, privateDnsName, privateIpAddress, - productCodes, ramdiskId, reason, subnetId, vpcId, rootDeviceType, rootDeviceName, - ebsBlockDevices)); + instances.add(new RunningInstance(region, groupIds, amiLaunchIndex, dnsName, imageId, + instanceId, instanceState, instanceType, ipAddress, kernelId, keyName, + launchTime, monitoring, availabilityZone, platform, privateDnsName, + privateIpAddress, productCodes, ramdiskId, reason, subnetId, vpcId, + rootDeviceType, rootDeviceName, ebsBlockDevices)); this.amiLaunchIndex = null; this.dnsName = null; this.imageId = null; diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java index 2a4298db8d..a05815b638 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java @@ -55,10 +55,9 @@ import com.google.common.collect.ImmutableSet; */ @Test(groups = "unit", testName = "ec2.RunningInstanceToNodeMetadataTest") public class RunningInstanceToNodeMetadataTest { - @SuppressWarnings("unchecked") @Test - public void testApplyWithNoKeyPairCreatesTagOfIdPrefixedByTagAndNullCredentials() + public void testApplyWithNoSecurityGroupCreatesTagOfIdPrefixedByTagAndNullCredentials() throws UnknownHostException { AMIClient amiClient = createMock(AMIClient.class); Map credentialsMap = createMock(Map.class); @@ -73,6 +72,7 @@ public class RunningInstanceToNodeMetadataTest { RunningInstance instance = createMock(RunningInstance.class); expect(instance.getId()).andReturn("id").atLeastOnce(); + expect(instance.getGroupIds()).andReturn(ImmutableSet. of()).atLeastOnce(); expect(instance.getKeyName()).andReturn(null).atLeastOnce(); expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); @@ -114,7 +114,64 @@ public class RunningInstanceToNodeMetadataTest { @SuppressWarnings("unchecked") @Test - public void testApplyWithKeyPairCreatesTagOfParsedKeyPairAndCredentialsBasedOnIt() + public void testApplyWithNoKeyPairCreatesTagOfParsedSecurityGroupAndNullCredentials() + throws UnknownHostException { + AMIClient amiClient = createMock(AMIClient.class); + Map credentialsMap = createMock(Map.class); + org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); + + Set images = ImmutableSet + . of(jcImage); + + Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null); + Set locations = ImmutableSet. of(location); + PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class); + RunningInstance instance = createMock(RunningInstance.class); + + expect(instance.getId()).andReturn("id").atLeastOnce(); + expect(instance.getGroupIds()).andReturn(ImmutableSet.of("jclouds#tag")).atLeastOnce(); + expect(instance.getKeyName()).andReturn(null).atLeastOnce(); + expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); + + expect(instance.getIpAddress()).andReturn( + InetAddress.getByAddress(new byte[] { 12, 10, 10, 1 })); + expect(instance.getPrivateIpAddress()).andReturn( + InetAddress.getByAddress(new byte[] { 10, 10, 10, 1 })); + + expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce(); + + expect(instance.getImageId()).andReturn("imageId").atLeastOnce(); + expect(jcImage.getId()).andReturn("imageId").atLeastOnce(); + expect(jcImage.getLocation()).andReturn(location).atLeastOnce(); + + expect(instance.getInstanceType()).andReturn(InstanceType.C1_XLARGE).atLeastOnce(); + + replay(jcImage); + replay(amiClient); + replay(credentialsMap); + replay(credentialProvider); + replay(instance); + + RunningInstanceToNodeMetadata parser = new RunningInstanceToNodeMetadata(amiClient, + credentialsMap, credentialProvider, images, locations, + new RunningInstanceToStorageMappingUnix()); + + NodeMetadata metadata = parser.apply(instance); + assertEquals(metadata.getLocation(), locations.iterator().next()); + assertEquals(metadata.getImage(), jcImage); + assertEquals(metadata.getTag(), "tag"); + assertEquals(metadata.getCredentials(), null); + + verify(jcImage); + verify(amiClient); + verify(credentialsMap); + verify(credentialProvider); + verify(instance); + } + + @SuppressWarnings("unchecked") + @Test + public void testApplyWithKeyPairCreatesTagOfParsedSecurityGroupAndCredentialsBasedOnIt() throws UnknownHostException { AMIClient amiClient = createMock(AMIClient.class); Map credentialsMap = createMock(Map.class); @@ -124,7 +181,8 @@ public class RunningInstanceToNodeMetadataTest { Image image = createMock(Image.class); expect(instance.getId()).andReturn("id").atLeastOnce(); - expect(instance.getKeyName()).andReturn("keyName-100").atLeastOnce(); + expect(instance.getGroupIds()).andReturn(ImmutableSet.of("jclouds#tag")).atLeastOnce(); + expect(instance.getKeyName()).andReturn("jclouds#keyName").atLeastOnce(); expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null); @@ -149,8 +207,8 @@ public class RunningInstanceToNodeMetadataTest { expect(credentialProvider.execute(image)).andReturn(new Credentials("user", "pass")); - expect(credentialsMap.get(new RegionTag(Region.US_EAST_1, "keyName-100"))).andReturn( - new KeyPair(Region.US_EAST_1, "keyName-100", "keyFingerprint", "pass")); + expect(credentialsMap.get(new RegionTag(Region.US_EAST_1, "jclouds#keyName"))).andReturn( + new KeyPair(Region.US_EAST_1, "jclouds#keyName", "keyFingerprint", "pass")); expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce(); @@ -168,7 +226,7 @@ public class RunningInstanceToNodeMetadataTest { NodeMetadata metadata = parser.apply(instance); - assertEquals(metadata.getTag(), "keyName"); + assertEquals(metadata.getTag(), "tag"); assertEquals(metadata.getLocation(), location); assertEquals(metadata.getImage(), jcImage); @@ -182,4 +240,74 @@ public class RunningInstanceToNodeMetadataTest { } + @SuppressWarnings("unchecked") + @Test + public void testApplyWithTwoSecurityGroups() + throws UnknownHostException { + AMIClient amiClient = createMock(AMIClient.class); + Map credentialsMap = createMock(Map.class); + + PopulateDefaultLoginCredentialsForImageStrategy credentialProvider = createMock(PopulateDefaultLoginCredentialsForImageStrategy.class); + RunningInstance instance = createMock(RunningInstance.class); + Image image = createMock(Image.class); + + expect(instance.getId()).andReturn("id").atLeastOnce(); + expect(instance.getGroupIds()).andReturn(ImmutableSet.of("jclouds#tag","jclouds#tag2")).atLeastOnce(); + expect(instance.getKeyName()).andReturn("jclouds#keyName").atLeastOnce(); + expect(instance.getInstanceState()).andReturn(InstanceState.RUNNING); + + Location location = new LocationImpl(LocationScope.ZONE, "us-east-1a", "description", null); + Set locations = ImmutableSet. of(location); + org.jclouds.compute.domain.Image jcImage = createMock(org.jclouds.compute.domain.Image.class); + Set images = ImmutableSet + . of(jcImage); + + expect(instance.getIpAddress()).andReturn( + InetAddress.getByAddress(new byte[] { 12, 10, 10, 1 })); + expect(instance.getPrivateIpAddress()).andReturn( + InetAddress.getByAddress(new byte[] { 10, 10, 10, 1 })); + + expect(instance.getRegion()).andReturn(Region.US_EAST_1).atLeastOnce(); + + expect(instance.getImageId()).andReturn("imageId").atLeastOnce(); + expect(jcImage.getId()).andReturn("imageId").atLeastOnce(); + expect(jcImage.getLocation()).andReturn(location).atLeastOnce(); + + expect(amiClient.describeImagesInRegion(Region.US_EAST_1, imageIds("imageId"))).andReturn( + ImmutableSet. of(image)); + + expect(credentialProvider.execute(image)).andReturn(new Credentials("user", "pass")); + + expect(credentialsMap.get(new RegionTag(Region.US_EAST_1, "jclouds#keyName"))).andReturn( + new KeyPair(Region.US_EAST_1, "jclouds#keyName", "keyFingerprint", "pass")); + + expect(instance.getAvailabilityZone()).andReturn(AvailabilityZone.US_EAST_1A).atLeastOnce(); + + expect(instance.getInstanceType()).andReturn(InstanceType.C1_XLARGE).atLeastOnce(); + + replay(amiClient); + replay(credentialsMap); + replay(credentialProvider); + replay(instance); + replay(jcImage); + + RunningInstanceToNodeMetadata parser = new RunningInstanceToNodeMetadata(amiClient, + credentialsMap, credentialProvider, images, locations, + new RunningInstanceToStorageMappingUnix()); + + NodeMetadata metadata = parser.apply(instance); + + assertEquals(metadata.getTag(), "NOTAG-id"); + assertEquals(metadata.getLocation(), location); + assertEquals(metadata.getImage(), jcImage); + + assertEquals(metadata.getCredentials(), new Credentials("user", "pass")); + + verify(jcImage); + verify(amiClient); + verify(credentialsMap); + verify(credentialProvider); + verify(instance); + + } } diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/xml/DescribeInstancesResponseHandlerTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/xml/DescribeInstancesResponseHandlerTest.java index 99c3c4f631..d81c616693 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/xml/DescribeInstancesResponseHandlerTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/xml/DescribeInstancesResponseHandlerTest.java @@ -70,7 +70,8 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest { Set contents = Sets.newTreeSet(); contents.add(new Reservation(defaultRegion, ImmutableSet.of("adriancole.ec2ingress"), - ImmutableSet.of(new RunningInstance(defaultRegion, "0", + ImmutableSet.of(new RunningInstance(defaultRegion, ImmutableSet + .of("adriancole.ec2ingress"), "0", "ec2-174-129-81-68.compute-1.amazonaws.com", "ami-1fd73376", "i-0799056f", InstanceState.RUNNING, InstanceType.M1_SMALL, InetAddress .getByName("174.129.81.68"), "aki-a71cf9ce", "adriancole.ec21", @@ -92,17 +93,19 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest { Set contents = Sets.newTreeSet(); contents.add(new Reservation(defaultRegion, ImmutableSet.of("default"), ImmutableSet.of( - new RunningInstance(defaultRegion, "23", "ec2-72-44-33-4.compute-1.amazonaws.com", - "ami-6ea54007", "i-28a64341", InstanceState.RUNNING, InstanceType.M1_LARGE, - (InetAddress) null, "aki-ba3adfd3", "example-key-name", dateService + new RunningInstance(defaultRegion, ImmutableSet.of("default"), "23", + "ec2-72-44-33-4.compute-1.amazonaws.com", "ami-6ea54007", "i-28a64341", + InstanceState.RUNNING, InstanceType.M1_LARGE, (InetAddress) null, + "aki-ba3adfd3", "example-key-name", dateService .iso8601DateParse("2007-08-07T11:54:42.000Z"), false, AvailabilityZone.US_EAST_1B, null, "10-251-50-132.ec2.internal", null, ImmutableSet.of("774F4FF8"), "ari-badbad00", null, null, null, RootDeviceType.INSTANCE_STORE, null, ImmutableMap . of()), new RunningInstance( - defaultRegion, "23", "ec2-72-44-33-6.compute-1.amazonaws.com", - "ami-6ea54007", "i-28a64435", InstanceState.RUNNING, InstanceType.M1_LARGE, - (InetAddress) null, "aki-ba3adfd3", "example-key-name", dateService + defaultRegion, ImmutableSet.of("default"), "23", + "ec2-72-44-33-6.compute-1.amazonaws.com", "ami-6ea54007", "i-28a64435", + InstanceState.RUNNING, InstanceType.M1_LARGE, (InetAddress) null, + "aki-ba3adfd3", "example-key-name", dateService .iso8601DateParse("2007-08-07T11:54:42.000Z"), false, AvailabilityZone.US_EAST_1B, null, "10-251-50-134.ec2.internal", null, ImmutableSet.of("774F4FF8"), "ari-badbad00", null, null, null, @@ -121,7 +124,8 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest { Set contents = Sets.newTreeSet(); contents.add(new Reservation(defaultRegion, ImmutableSet.of("adriancole.ec2ebsingress"), - ImmutableSet.of(new RunningInstance(defaultRegion, "0", + ImmutableSet.of(new RunningInstance(defaultRegion, ImmutableSet + .of("adriancole.ec2ebsingress"), "0", "ec2-75-101-203-146.compute-1.amazonaws.com", "ami-849875ed", "i-e564438d", InstanceState.RUNNING, InstanceType.M1_SMALL, InetAddress .getByName("75.101.203.146"), "aki-a71cf9ce", diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/xml/RunInstancesResponseHandlerTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/xml/RunInstancesResponseHandlerTest.java index a9fe32153f..f502792cbe 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/xml/RunInstancesResponseHandlerTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/xml/RunInstancesResponseHandlerTest.java @@ -67,25 +67,25 @@ public class RunInstancesResponseHandlerTest extends BaseEC2HandlerTest { InputStream is = getClass().getResourceAsStream("/ec2/run_instances.xml"); Reservation expected = new Reservation(defaultRegion, ImmutableSortedSet.of("default"), - ImmutableSet.of(new RunningInstance(defaultRegion, "0", null, "ami-60a54009", - "i-2ba64342", InstanceState.PENDING, InstanceType.M1_SMALL, + ImmutableSet.of(new RunningInstance(defaultRegion, ImmutableSortedSet.of("default"), + "0", null, "ami-60a54009", "i-2ba64342", InstanceState.PENDING, + InstanceType.M1_SMALL, (InetAddress) null, null, "example-key-name", + dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"), true, + AvailabilityZone.US_EAST_1B, null, null, (InetAddress) null, Sets + . newTreeSet(), null, null, null, null, + RootDeviceType.INSTANCE_STORE, null, ImmutableMap + . of()), new RunningInstance( + defaultRegion, ImmutableSortedSet.of("default"), "1", null, "ami-60a54009", + "i-2bc64242", InstanceState.PENDING, InstanceType.M1_SMALL, (InetAddress) null, null, "example-key-name", dateService .iso8601DateParse("2007-08-07T11:51:50.000Z"), true, AvailabilityZone.US_EAST_1B, null, null, (InetAddress) null, Sets . newTreeSet(), null, null, null, null, RootDeviceType.INSTANCE_STORE, null, ImmutableMap . of()), new RunningInstance( - defaultRegion, "1", null, "ami-60a54009", "i-2bc64242", - InstanceState.PENDING, InstanceType.M1_SMALL, (InetAddress) null, null, - "example-key-name", dateService - .iso8601DateParse("2007-08-07T11:51:50.000Z"), true, - AvailabilityZone.US_EAST_1B, null, null, (InetAddress) null, Sets - . newTreeSet(), null, null, null, null, - RootDeviceType.INSTANCE_STORE, null, ImmutableMap - . of()), new RunningInstance( - defaultRegion, "2", null, "ami-60a54009", "i-2be64332", - InstanceState.PENDING, InstanceType.M1_SMALL, (InetAddress) null, null, - "example-key-name", dateService + defaultRegion, ImmutableSortedSet.of("default"), "2", null, "ami-60a54009", + "i-2be64332", InstanceState.PENDING, InstanceType.M1_SMALL, + (InetAddress) null, null, "example-key-name", dateService .iso8601DateParse("2007-08-07T11:51:50.000Z"), true, AvailabilityZone.US_EAST_1B, null, null, (InetAddress) null, Sets . newTreeSet(), null, null, null, null,