Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow to tie slave AMI to RESTRICTED jobs

  • Loading branch information...
commit eda782973b1e8f75cdc4131a2df2246ad57d8c76 1 parent e3e579a
@ndeloof ndeloof authored
View
8 src/main/java/hudson/plugins/ec2/EC2Slave.java
@@ -71,12 +71,12 @@
public static final String TEST_ZONE = "testZone";
- public EC2Slave(String instanceId, String description, String remoteFS, int sshPort, int numExecutors, String labelString, String initScript, String remoteAdmin, String rootCommandPrefix, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags) throws FormException, IOException {
- this(instanceId, description, remoteFS, sshPort, numExecutors, Mode.NORMAL, labelString, initScript, Collections.<NodeProperty<?>>emptyList(), remoteAdmin, rootCommandPrefix, jvmopts, stopOnTerminate, idleTerminationMinutes, publicDNS, privateDNS, tags, false);
+ public EC2Slave(String instanceId, String description, String remoteFS, int sshPort, int numExecutors, String labelString, Mode mode, String initScript, String remoteAdmin, String rootCommandPrefix, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags) throws FormException, IOException {
+ this(instanceId, description, remoteFS, sshPort, numExecutors, mode, labelString, initScript, Collections.<NodeProperty<?>>emptyList(), remoteAdmin, rootCommandPrefix, jvmopts, stopOnTerminate, idleTerminationMinutes, publicDNS, privateDNS, tags, false);
}
- public EC2Slave(String instanceId, String description, String remoteFS, int sshPort, int numExecutors, String labelString, String initScript, String remoteAdmin, String rootCommandPrefix, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags, boolean usePrivateDnsName) throws FormException, IOException {
- this(instanceId, description, remoteFS, sshPort, numExecutors, Mode.NORMAL, labelString, initScript, Collections.<NodeProperty<?>>emptyList(), remoteAdmin, rootCommandPrefix, jvmopts, stopOnTerminate, idleTerminationMinutes, publicDNS, privateDNS, tags, usePrivateDnsName);
+ public EC2Slave(String instanceId, String description, String remoteFS, int sshPort, int numExecutors, String labelString, Mode mode, String initScript, String remoteAdmin, String rootCommandPrefix, String jvmopts, boolean stopOnTerminate, String idleTerminationMinutes, String publicDNS, String privateDNS, List<EC2Tag> tags, boolean usePrivateDnsName) throws FormException, IOException {
+ this(instanceId, description, remoteFS, sshPort, numExecutors, mode, labelString, initScript, Collections.<NodeProperty<?>>emptyList(), remoteAdmin, rootCommandPrefix, jvmopts, stopOnTerminate, idleTerminationMinutes, publicDNS, privateDNS, tags, usePrivateDnsName);
}
View
10 src/main/java/hudson/plugins/ec2/SlaveTemplate.java
@@ -42,6 +42,7 @@
public final String sshPort;
public final InstanceType type;
public final String labels;
+ public final Node.Mode mode;
public final String initScript;
public final String userData;
public final String numExecutors;
@@ -61,7 +62,7 @@
private transient /*almost final*/ Set<String> securityGroupSet;
@DataBoundConstructor
- public SlaveTemplate(String ami, String zone, String securityGroups, String remoteFS, String sshPort, InstanceType type, String labelString, String description, String initScript, String userData, String numExecutors, String remoteAdmin, String rootCommandPrefix, String jvmopts, boolean stopOnTerminate, String subnetId, List<EC2Tag> tags, String idleTerminationMinutes, boolean usePrivateDnsName, String instanceCapStr) {
+ public SlaveTemplate(String ami, String zone, String securityGroups, String remoteFS, String sshPort, InstanceType type, String labelString, Node.Mode mode, String description, String initScript, String userData, String numExecutors, String remoteAdmin, String rootCommandPrefix, String jvmopts, boolean stopOnTerminate, String subnetId, List<EC2Tag> tags, String idleTerminationMinutes, boolean usePrivateDnsName, String instanceCapStr) {
this.ami = ami;
this.zone = zone;
this.securityGroups = securityGroups;
@@ -69,6 +70,7 @@ public SlaveTemplate(String ami, String zone, String securityGroups, String remo
this.sshPort = sshPort;
this.type = type;
this.labels = Util.fixNull(labelString);
+ this.mode = mode;
this.description = description;
this.initScript = initScript;
this.userData = userData;
@@ -99,6 +101,10 @@ public String getLabelString() {
return labels;
}
+ public Node.Mode getMode() {
+ return mode;
+ }
+
public String getDisplayName() {
return description+" ("+ami+")";
}
@@ -328,7 +334,7 @@ public EC2Slave provision(TaskListener listener) throws AmazonClientException, I
private EC2Slave newSlave(Instance inst) throws FormException, IOException {
- return new EC2Slave(inst.getInstanceId(), description, remoteFS, getSshPort(), getNumExecutors(), labels, initScript, remoteAdmin, rootCommandPrefix, jvmopts, stopOnTerminate, idleTerminationMinutes, inst.getPublicDnsName(), inst.getPrivateDnsName(), EC2Tag.fromAmazonTags(inst.getTags()), usePrivateDnsName);
+ return new EC2Slave(inst.getInstanceId(), description, remoteFS, getSshPort(), getNumExecutors(), labels, mode, initScript, remoteAdmin, rootCommandPrefix, jvmopts, stopOnTerminate, idleTerminationMinutes, inst.getPublicDnsName(), inst.getPrivateDnsName(), EC2Tag.fromAmazonTags(inst.getTags()), usePrivateDnsName);
}
/**
View
2  src/main/resources/hudson/plugins/ec2/EC2Computer/configure.jelly
@@ -62,6 +62,8 @@ THE SOFTWARE.
<f:textbox />
</f:entry>
+ <f:slave-mode name="mode" node="${instance}" />
+
<f:entry title="${%Init Script}" field="initScript">
<f:textarea />
</f:entry>
View
2  src/main/resources/hudson/plugins/ec2/SlaveTemplate/config.jelly
@@ -65,6 +65,8 @@ THE SOFTWARE.
<f:textbox />
</f:entry>
+ <f:slave-mode name="mode" node="${instance}" />
+
<f:entry title="${%Idle termination time}" field="idleTerminationMinutes">
<f:textbox default="30" />
</f:entry>
View
5 src/test/java/hudson/plugins/ec2/SlaveTemplateTest.java
@@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.List;
+import hudson.model.Node;
import org.jvnet.hudson.test.HudsonTestCase;
import com.amazonaws.services.ec2.model.InstanceType;
@@ -31,7 +32,7 @@ public void testConfigRoundtrip() throws Exception {
tags.add( tag1 );
tags.add( tag2 );
- SlaveTemplate orig = new SlaveTemplate(ami, EC2Slave.TEST_ZONE, "default", "foo", "22", InstanceType.M1Large, "ttt", "foo ami", "bar", "aaa", "10", "rrr", "fff", "-Xmx1g", false, "subnet 456", tags, null, false, null);
+ SlaveTemplate orig = new SlaveTemplate(ami, EC2Slave.TEST_ZONE, "default", "foo", "22", InstanceType.M1Large, "ttt", Node.Mode.NORMAL, "foo ami", "bar", "aaa", "10", "rrr", "fff", "-Xmx1g", false, "subnet 456", tags, null, false, null);
List<SlaveTemplate> templates = new ArrayList<SlaveTemplate>();
templates.add(orig);
@@ -53,7 +54,7 @@ public void testConfigRoundtripWithPrivateDns() throws Exception {
tags.add( tag1 );
tags.add( tag2 );
- SlaveTemplate orig = new SlaveTemplate(ami, EC2Slave.TEST_ZONE, "default", "foo", "22", InstanceType.M1Large, "ttt", "foo ami", "bar", "aaa", "10", "rrr", "fff", "-Xmx1g", false, "subnet 456", tags, null, true, null);
+ SlaveTemplate orig = new SlaveTemplate(ami, EC2Slave.TEST_ZONE, "default", "foo", "22", InstanceType.M1Large, "ttt", Node.Mode.NORMAL,"foo ami", "bar", "aaa", "10", "rrr", "fff", "-Xmx1g", false, "subnet 456", tags, null, true, null);
List<SlaveTemplate> templates = new ArrayList<SlaveTemplate>();
templates.add(orig);
View
5 src/test/java/hudson/plugins/ec2/TemplateLabelsTest.java
@@ -1,6 +1,7 @@
package hudson.plugins.ec2;
import hudson.model.Label;
+import hudson.model.Node;
import hudson.model.labels.LabelAtom;
import java.util.ArrayList;
@@ -26,7 +27,7 @@ public void setUp() throws Exception{
tags.add( tag1 );
tags.add( tag2 );
- SlaveTemplate template = new SlaveTemplate("ami", "foo", "default", "zone", "22", InstanceType.M1Large, LABEL1 + " " + LABEL2, "foo ami", "bar", "aaa", "10", "rrr", "fff", "-Xmx1g", true, "subnet 456", tags, null, false, null);
+ SlaveTemplate template = new SlaveTemplate("ami", "foo", "default", "zone", "22", InstanceType.M1Large, LABEL1 + " " + LABEL2, Node.Mode.NORMAL,"foo ami", "bar", "aaa", "10", "rrr", "fff", "-Xmx1g", true, "subnet 456", tags, null, false, null);
List<SlaveTemplate> templates = new ArrayList<SlaveTemplate>();
templates.add(template);
@@ -55,7 +56,7 @@ public void testEmptyLabel() throws Exception{
tags.add( tag1 );
tags.add( tag2 );
- SlaveTemplate temp = new SlaveTemplate("ami", "foo", "default", "zone", "22", InstanceType.M1Large, "", "foo ami", "bar", "aaa", "10", "rrr", "fff", "-Xmx1g", true, "subnet 456", tags, null, false, null);
+ SlaveTemplate temp = new SlaveTemplate("ami", "foo", "default", "zone", "22", InstanceType.M1Large, "", Node.Mode.NORMAL, "foo ami", "bar", "aaa", "10", "rrr", "fff", "-Xmx1g", true, "subnet 456", tags, null, false, null);
List<SlaveTemplate> templates = new ArrayList<SlaveTemplate>();
templates.add(temp);
Please sign in to comment.
Something went wrong with that request. Please try again.