From 4bc64342340734e8191931adf1808a925dafe243 Mon Sep 17 00:00:00 2001 From: Lili Nader Date: Wed, 23 Jun 2010 15:39:37 -0400 Subject: [PATCH] added VPC support to EC2 ComputeService --- .../compute/options/EC2TemplateOptions.java | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/options/EC2TemplateOptions.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/options/EC2TemplateOptions.java index d603f6f1be..6c1891e0c4 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/options/EC2TemplateOptions.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/options/EC2TemplateOptions.java @@ -53,6 +53,7 @@ public class EC2TemplateOptions extends TemplateOptions { private Set groupIds = ImmutableSet.of(); private String keyPair = null; private boolean noKeyPair; + private String subnetId; public static final EC2TemplateOptions NONE = new EC2TemplateOptions(); @@ -94,6 +95,16 @@ public class EC2TemplateOptions extends TemplateOptions { this.noKeyPair = true; return this; } + + /** + * Specifies the subnetId used to run instances in + */ + public EC2TemplateOptions withSubnetId(String subnetId) { + checkNotNull(subnetId, "subnetId cannot be null"); + Utils.checkNotEmpty(subnetId, "subnetId must be non-empty"); + this.subnetId = subnetId; + return this; + } public static class Builder { @@ -177,6 +188,14 @@ public class EC2TemplateOptions extends TemplateOptions { EC2TemplateOptions options = new EC2TemplateOptions(); return EC2TemplateOptions.class.cast(options.withMetadata()); } + + /** + * @see TemplateOptions#withSubnetId + */ + public static EC2TemplateOptions withSubnetId(String subnetId) { + EC2TemplateOptions options = new EC2TemplateOptions(); + return EC2TemplateOptions.class.cast(options.withSubnetId(subnetId)); + } } @@ -256,8 +275,17 @@ public class EC2TemplateOptions extends TemplateOptions { public boolean shouldAutomaticallyCreateKeyPair() { return !noKeyPair; } + + + /** + * @return subnetId to use when running the instance or null. + */ + public String getSubnetId() + { + return subnetId; + } - @Override +@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); @@ -288,6 +316,8 @@ public class EC2TemplateOptions extends TemplateOptions { return false; if (noKeyPair != other.noKeyPair) return false; + if (!subnetId.equals(other.subnetId)) + return false; return true; } @@ -296,8 +326,8 @@ public class EC2TemplateOptions extends TemplateOptions { return "EC2TemplateOptions [groupIds=" + groupIds + ", keyPair=" + keyPair + ", noKeyPair=" + noKeyPair + ", inboundPorts=" + Arrays.toString(inboundPorts) + ", privateKey=" + (privateKey != null) + ", publicKey=" + (publicKey != null) + ", runScript=" - + (script != null) + ", port:seconds=" + port + ":" + seconds - + ", metadata/details: " + includeMetadata + "]"; + + (script != null) + ", port:seconds=" + port + ":" + seconds + ", subnetId=" + + subnetId + ", metadata/details: " + includeMetadata + "]"; } }