fastest ec2

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2642 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2010-01-12 03:14:05 +00:00
parent b29521ef41
commit e3c6b0e4e1
3 changed files with 17 additions and 9 deletions

View File

@ -85,15 +85,22 @@ public class EC2ComputeService implements ComputeService {
this.runningInstanceToServerMetadata = runningInstanceToServerMetadata; this.runningInstanceToServerMetadata = runningInstanceToServerMetadata;
} }
private Map<Image, String> imageAmiIdMap = ImmutableMap.<Image, String> builder().put( // TODO: handle regions
Image.UBUNTU_90, "ami-7e28ca17").put(Image.RHEL_53, "ami-368b685f").build();// todo ami private Map<InstanceType, Map<Image, String>> imageAmiIdMap = ImmutableMap
// matrix of .<InstanceType, Map<Image, String>> of(InstanceType.M1_SMALL,//
// region ImmutableMap.<Image, String> builder().put(Image.UBUNTU_90, "ami-1515f67c")
// 32/64 bit .put(Image.RHEL_53, "ami-368b685f").build(),//
InstanceType.C1_MEDIUM,//
ImmutableMap.<Image, String> builder().put(Image.UBUNTU_90, "ami-1515f67c")
.put(Image.RHEL_53, "ami-368b685f").build(), //
InstanceType.C1_XLARGE,//
ImmutableMap.<Image, String> builder().put(Image.UBUNTU_90, "ami-ab15f6c2")
.build());// todo ami
private Map<Profile, InstanceType> profileInstanceTypeMap = ImmutableMap private Map<Profile, InstanceType> profileInstanceTypeMap = ImmutableMap
.<Profile, InstanceType> builder().put(Profile.SMALLEST, InstanceType.M1_SMALL).put( .<Profile, InstanceType> builder().put(Profile.SMALLEST, InstanceType.M1_SMALL).put(
Profile.MEDIUM, InstanceType.C1_MEDIUM).build(); Profile.MEDIUM, InstanceType.C1_MEDIUM).put(Profile.FASTEST,
InstanceType.C1_XLARGE).build();
private static Map<InstanceState, ServerState> instanceToServerState = ImmutableMap private static Map<InstanceState, ServerState> instanceToServerState = ImmutableMap
.<InstanceState, ServerState> builder().put(InstanceState.PENDING, ServerState.PENDING) .<InstanceState, ServerState> builder().put(InstanceState.PENDING, ServerState.PENDING)
@ -103,9 +110,10 @@ public class EC2ComputeService implements ComputeService {
@Override @Override
public CreateServerResponse createServer(String name, Profile profile, Image image) { public CreateServerResponse createServer(String name, Profile profile, Image image) {
String ami = checkNotNull(imageAmiIdMap.get(image), "image not supported: " + image);
InstanceType type = checkNotNull(profileInstanceTypeMap.get(profile), InstanceType type = checkNotNull(profileInstanceTypeMap.get(profile),
"profile not supported: " + profile); "profile not supported: " + profile);
String ami = checkNotNull(imageAmiIdMap.get(type).get(image), "image not supported: " + image);
KeyPair keyPair = createKeyPair(name); KeyPair keyPair = createKeyPair(name);
String securityGroupName = name; String securityGroupName = name;
createSecurityGroup(securityGroupName, 22, 80, 8080, 443); createSecurityGroup(securityGroupName, 22, 80, 8080, 443);

View File

@ -22,5 +22,5 @@ package org.jclouds.compute.domain;
* @author Adrian Cole * @author Adrian Cole
*/ */
public enum Profile { public enum Profile {
SMALLEST, MEDIUM SMALLEST, MEDIUM, FASTEST
} }

View File

@ -62,7 +62,7 @@
<target name="create" description="create the server ${jclouds.compute.servername}"> <target name="create" description="create the server ${jclouds.compute.servername}">
<compute action="create" provider="${jclouds.compute.url}"> <compute action="create" provider="${jclouds.compute.url}">
<server name="${jclouds.compute.servername}" image="UBUNTU_90" profile="MEDIUM" hostproperty="host" usernameproperty="username" passwordproperty="password" /> <server name="${jclouds.compute.servername}" image="UBUNTU_90" profile="FASTEST" hostproperty="host" usernameproperty="username" passwordproperty="password" />
</compute> </compute>
</target> </target>