added VPC support to EC2 ComputeService

This commit is contained in:
Lili Nader 2010-06-23 15:39:37 -04:00
parent df54677e20
commit 4bc6434234
1 changed files with 33 additions and 3 deletions

View File

@ -53,6 +53,7 @@ public class EC2TemplateOptions extends TemplateOptions {
private Set<String> groupIds = ImmutableSet.of(); private Set<String> groupIds = ImmutableSet.of();
private String keyPair = null; private String keyPair = null;
private boolean noKeyPair; private boolean noKeyPair;
private String subnetId;
public static final EC2TemplateOptions NONE = new EC2TemplateOptions(); public static final EC2TemplateOptions NONE = new EC2TemplateOptions();
@ -95,6 +96,16 @@ public class EC2TemplateOptions extends TemplateOptions {
return this; 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 { public static class Builder {
/** /**
@ -178,6 +189,14 @@ public class EC2TemplateOptions extends TemplateOptions {
return EC2TemplateOptions.class.cast(options.withMetadata()); 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));
}
} }
// methods that only facilitate returning the correct object type // methods that only facilitate returning the correct object type
@ -257,7 +276,16 @@ public class EC2TemplateOptions extends TemplateOptions {
return !noKeyPair; return !noKeyPair;
} }
@Override
/**
* @return subnetId to use when running the instance or null.
*/
public String getSubnetId()
{
return subnetId;
}
@Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = super.hashCode(); int result = super.hashCode();
@ -288,6 +316,8 @@ public class EC2TemplateOptions extends TemplateOptions {
return false; return false;
if (noKeyPair != other.noKeyPair) if (noKeyPair != other.noKeyPair)
return false; return false;
if (!subnetId.equals(other.subnetId))
return false;
return true; return true;
} }
@ -296,8 +326,8 @@ public class EC2TemplateOptions extends TemplateOptions {
return "EC2TemplateOptions [groupIds=" + groupIds + ", keyPair=" + keyPair + ", noKeyPair=" return "EC2TemplateOptions [groupIds=" + groupIds + ", keyPair=" + keyPair + ", noKeyPair="
+ noKeyPair + ", inboundPorts=" + Arrays.toString(inboundPorts) + ", privateKey=" + noKeyPair + ", inboundPorts=" + Arrays.toString(inboundPorts) + ", privateKey="
+ (privateKey != null) + ", publicKey=" + (publicKey != null) + ", runScript=" + (privateKey != null) + ", publicKey=" + (publicKey != null) + ", runScript="
+ (script != null) + ", port:seconds=" + port + ":" + seconds + (script != null) + ", port:seconds=" + port + ":" + seconds + ", subnetId="
+ ", metadata/details: " + includeMetadata + "]"; + subnetId + ", metadata/details: " + includeMetadata + "]";
} }
} }