Skip to content

Commit

Permalink
[FIXED JENKINS-8946] Option to set Zone as well as region for instanc…
Browse files Browse the repository at this point in the history
…e creation (removed zone from slave instance)
  • Loading branch information
francisu committed Feb 22, 2012
1 parent f0e542f commit 9e89c6c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
14 changes: 4 additions & 10 deletions src/main/java/hudson/plugins/ec2/EC2Slave.java
Expand Up @@ -38,7 +38,6 @@ public final class EC2Slave extends Slave {
/**
* Comes from {@link SlaveTemplate#initScript}.
*/
public final String zone;
public final String initScript;
public final String remoteAdmin; // e.g. 'ubuntu'
public final String rootCommandPrefix; // e.g. 'sudo'
Expand All @@ -51,14 +50,13 @@ public final class EC2Slave extends Slave {

public static final String TEST_ZONE = "testZone";

public EC2Slave(String instanceId, String description, String zone, String remoteFS, int sshPort, int numExecutors, String labelString, String initScript, String remoteAdmin, String rootCommandPrefix, String jvmopts) throws FormException, IOException {
this(instanceId, description, zone, remoteFS, sshPort, numExecutors, Mode.NORMAL, labelString, initScript, Collections.<NodeProperty<?>>emptyList(), remoteAdmin, rootCommandPrefix, jvmopts);
public EC2Slave(String instanceId, String description, String remoteFS, int sshPort, int numExecutors, String labelString, String initScript, String remoteAdmin, String rootCommandPrefix, String jvmopts) throws FormException, IOException {
this(instanceId, description, remoteFS, sshPort, numExecutors, Mode.NORMAL, labelString, initScript, Collections.<NodeProperty<?>>emptyList(), remoteAdmin, rootCommandPrefix, jvmopts);
}

@DataBoundConstructor
public EC2Slave(String instanceId, String description, String zone, String remoteFS, int sshPort, int numExecutors, Mode mode, String labelString, String initScript, List<? extends NodeProperty<?>> nodeProperties, String remoteAdmin, String rootCommandPrefix, String jvmopts) throws FormException, IOException {
public EC2Slave(String instanceId, String description, String remoteFS, int sshPort, int numExecutors, Mode mode, String labelString, String initScript, List<? extends NodeProperty<?>> nodeProperties, String remoteAdmin, String rootCommandPrefix, String jvmopts) throws FormException, IOException {
super(instanceId, description, remoteFS, numExecutors, mode, labelString, new EC2UnixLauncher(), new EC2RetentionStrategy(), nodeProperties);
this.zone = zone;
this.initScript = initScript;
this.remoteAdmin = remoteAdmin;
this.rootCommandPrefix = rootCommandPrefix;
Expand All @@ -70,7 +68,7 @@ public EC2Slave(String instanceId, String description, String zone, String remot
* Constructor for debugging.
*/
public EC2Slave(String instanceId) throws FormException, IOException {
this(instanceId,"debug","zone", "/tmp/hudson", 22, 1, Mode.NORMAL, "debug", "", Collections.<NodeProperty<?>>emptyList(), null, null, null);
this(instanceId,"debug", "/tmp/hudson", 22, 1, Mode.NORMAL, "debug", "", Collections.<NodeProperty<?>>emptyList(), null, null, null);
}

/**
Expand Down Expand Up @@ -122,10 +120,6 @@ public void terminate() {
}
}

String getZone() {
return zone;
}

String getRemoteAdmin() {
if (remoteAdmin == null || remoteAdmin.length() == 0)
return "root";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hudson/plugins/ec2/SlaveTemplate.java
Expand Up @@ -161,7 +161,7 @@ public EC2Slave provision(TaskListener listener) throws AmazonClientException, I
}

private EC2Slave newSlave(Instance inst) throws FormException, IOException {
return new EC2Slave(inst.getInstanceId(), description, getZone(), remoteFS, getSshPort(), getNumExecutors(), labels, initScript, remoteAdmin, rootCommandPrefix, jvmopts);
return new EC2Slave(inst.getInstanceId(), description, remoteFS, getSshPort(), getNumExecutors(), labels, initScript, remoteAdmin, rootCommandPrefix, jvmopts);
}

/**
Expand Down
14 changes: 2 additions & 12 deletions src/main/resources/hudson/plugins/ec2/EC2Computer/configure.jelly
Expand Up @@ -47,16 +47,6 @@ THE SOFTWARE.
<f:textbox />
</f:entry>

<f:entry title="${%Availability Zone}" field="zone">
<!-- this is preferred but there is a problem with making it work FRU 22 Feb 12 -->
<!-- <f:select/>-->
<f:textbox/>
</f:entry>

<f:entry title="${%Remote FS root}" field="remoteFS">
<f:textbox />
</f:entry>

<f:entry title="${%Labels}" field="labelString">
<f:textbox />
</f:entry>
Expand All @@ -65,8 +55,6 @@ THE SOFTWARE.
<f:textarea />
</f:entry>

<f:descriptorList title="${%Node Properties}" descriptors="${h.getNodePropertyDescriptors(descriptor.clazz)}" field="nodeProperties" />

<f:entry title="${%Remote user}" field="remoteAdmin">
<f:textbox />
</f:entry>
Expand All @@ -75,6 +63,8 @@ THE SOFTWARE.
<f:textbox />
</f:entry>

<f:descriptorList title="${%Node Properties}" descriptors="${h.getNodePropertyDescriptors(descriptor.clazz)}" field="nodeProperties" />

<f:block>
<f:submit value="${%Save}"/>
</f:block>
Expand Down

0 comments on commit 9e89c6c

Please sign in to comment.