Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
making progress with the EC2 support
- Loading branch information
kohsuke
committed
Oct 30, 2008
1 parent
6dfe01b
commit 8377e25
Showing
6 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package hudson.plugins.ec2; | ||
|
||
import com.xerox.amazonws.ec2.InstanceType; | ||
import hudson.model.Descriptor.FormException; | ||
import hudson.model.Slave; | ||
import hudson.slaves.ComputerLauncher; | ||
import hudson.slaves.NodeDescriptor; | ||
import hudson.slaves.RetentionStrategy; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* Slave running on EC2. | ||
* | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
public final class EC2Slave extends Slave { | ||
@DataBoundConstructor | ||
public EC2Slave(String instanceId, String description, String remoteFS, InstanceType type, String label, ComputerLauncher launcher) throws FormException { | ||
// TODO: retention policy for Amazon | ||
super(instanceId, description, remoteFS, toNumExecutors(type), Mode.NORMAL, label, launcher, RetentionStrategy.NOOP); | ||
} | ||
|
||
/** | ||
* See http://aws.amazon.com/ec2/instance-types/ | ||
*/ | ||
private static int toNumExecutors(InstanceType it) { | ||
switch (it) { | ||
case DEFAULT: return 1; | ||
case MEDIUM_HCPU: return 5; | ||
case LARGE: return 4; | ||
case XLARGE: return 8; | ||
case XLARGE_HCPU: return 20; | ||
default: throw new AssertionError(); | ||
} | ||
} | ||
|
||
public NodeDescriptor getDescriptor() { | ||
return DescriptorImpl.INSTANCE; | ||
} | ||
|
||
public static final class DescriptorImpl extends NodeDescriptor { | ||
public static final DescriptorImpl INSTANCE = new DescriptorImpl(); | ||
|
||
private DescriptorImpl() { | ||
super(EC2Slave.class); | ||
} | ||
|
||
public String getDisplayName() { | ||
return "Amazon EC2"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package hudson.plugins.ec2; | ||
|
||
import com.xerox.amazonws.ec2.InstanceType; | ||
import hudson.slaves.ComputerLauncher; | ||
import hudson.model.Describable; | ||
import hudson.model.Descriptor; | ||
|
||
/** | ||
* Template of {@link EC2Slave} to launch. | ||
* | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
public class SlaveTemplate implements Describable<SlaveTemplate> { | ||
public final String ami; | ||
public final String remoteFS; | ||
public final InstanceType type; | ||
public final String label; | ||
public final ComputerLauncher launcher; | ||
|
||
public SlaveTemplate(String ami, String remoteFS, InstanceType type, String label, ComputerLauncher launcher) { | ||
this.ami = ami; | ||
this.remoteFS = remoteFS; | ||
this.type = type; | ||
this.label = label; | ||
this.launcher = launcher; | ||
} | ||
|
||
public DescriptorImpl getDescriptor() { | ||
return DescriptorImpl.INSTANCE; | ||
} | ||
|
||
public static final class DescriptorImpl extends Descriptor<SlaveTemplate> { | ||
public static final DescriptorImpl INSTANCE = new DescriptorImpl(); | ||
private DescriptorImpl() { | ||
super(SlaveTemplate.class); | ||
} | ||
|
||
public String getDisplayName() { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div> | ||
Choose the instance type you'd want to launch. | ||
</div> |