From 23179f03c17e317eaee683b1c1de63e52d6b2e75 Mon Sep 17 00:00:00 2001 From: Lili Nader Date: Wed, 23 Jun 2010 15:39:55 -0400 Subject: [PATCH] added VPC support to EC2 ComputeService --- ...urityGroupsAsNeededAndReturnRunOptions.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java index b1d8818aca..569baa5620 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java @@ -73,14 +73,20 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions { "unexpected image type. should be EC2Size, was: " + template.getSize().getClass()); EC2Size ec2Size = EC2Size.class.cast(template.getSize()); + RunInstancesOptions instanceOptions = asType(ec2Size.getInstanceType()).withAdditionalInfo(tag); + String keyPairName = createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, template .getOptions()); - Set groups = getSecurityGroupsForTagAndOptions(region, tag, template.getOptions()); - - RunInstancesOptions instanceOptions = asType(ec2Size.getInstanceType())// - .withSecurityGroups(groups)// - .withAdditionalInfo(tag); - + + String subnetId = template.getOptions().as(EC2TemplateOptions.class).getSubnetId(); + if(subnetId != null) + instanceOptions.withSubnetId(subnetId); + + else { + Set groups = getSecurityGroupsForTagAndOptions(region, tag, template.getOptions()); + instanceOptions.withSecurityGroups(groups); + } + if (keyPairName != null) instanceOptions.withKeyName(keyPairName);