Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/jcmoore3/jclouds-plugin int…
Browse files Browse the repository at this point in the history
…o JENKINS-25865

Conflicts:
	jclouds-plugin/src/main/java/jenkins/plugins/jclouds/compute/JCloudsSlave.java
	jclouds-plugin/src/main/java/jenkins/plugins/jclouds/compute/JCloudsSlaveTemplate.java
	jclouds-plugin/src/main/resources/jenkins/plugins/jclouds/compute/JCloudsSlaveTemplate/config.jelly
	jclouds-plugin/src/test/java/jenkins/plugins/jclouds/compute/JCloudsSlaveTemplateTest.java
  • Loading branch information
felfert committed Sep 11, 2015
2 parents 1e02b26 + d2d8494 commit dea2906
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
Expand Up @@ -45,6 +45,8 @@ public class JCloudsSlave extends AbstractCloudSlave {
private final boolean authSudo;
private final String jvmOptions;
private final String credentialsId;
private final Mode mode;

private transient PhoneHomeMonitor phm;

private static final class PhoneHomeMonitor {
Expand Down Expand Up @@ -88,6 +90,7 @@ public JCloudsSlave(String cloudName, String name, String nodeDescription, Strin
this.waitPhoneHome = waitPhoneHome;
this.waitPhoneHomeTimeout = waitPhoneHomeTimeout;
this.credentialsId = credentialsId;
this.mode = mode;
phm = new PhoneHomeMonitor();
}

Expand All @@ -113,13 +116,15 @@ protected Object readResolve() {
* @param waitPhoneHome - if {@code true}, delay initial SSH connect until slave has "phoned home" back to jenkins.
* @param waitPhoneHomeTimeout - Timeout in minutes util giving up waiting for the "phone home" POST.
* @param credentialsId - Id of the credentials in Jenkin's global credentials database.
* @param mode - Jenkins usage mode for this node
* @throws IOException
* @throws Descriptor.FormException
*/
public JCloudsSlave(final String cloudName, final String fsRoot, NodeMetadata metadata, final String labelString,

final String description, final String numExecutors, final boolean stopOnTerminate, final Integer overrideRetentionTime,
String jvmOptions, final boolean waitPhoneHome, final int waitPhoneHomeTimeout, final String credentialsId) throws IOException, Descriptor.FormException {
this(cloudName, metadata.getName(), description, fsRoot, numExecutors, Mode.EXCLUSIVE, labelString,
String jvmOptions, final boolean waitPhoneHome, final int waitPhoneHomeTimeout, final String credentialsId, final Mode mode) throws IOException, Descriptor.FormException {
this(cloudName, metadata.getName(), description, fsRoot, numExecutors, mode, labelString,
new JCloudsLauncher(), new JCloudsRetentionStrategy(), Collections.<NodeProperty<?>>emptyList(),
stopOnTerminate, overrideRetentionTime, metadata.getCredentials().getUser(),
metadata.getCredentials().getPassword(), metadata.getCredentials().getPrivateKey(),
Expand Down Expand Up @@ -221,6 +226,10 @@ public String getCredentialsId() {
return credentialsId;
}

public Mode getMode() {
return mode;
}

/**
* {@inheritDoc}
*/
Expand Down
Expand Up @@ -29,6 +29,7 @@
import hudson.model.Descriptor;
import hudson.model.Label;
import hudson.model.Hudson;
import hudson.model.Node.Mode;
import hudson.model.ItemGroup;
import hudson.model.TaskListener;
import hudson.model.labels.LabelAtom;
Expand Down Expand Up @@ -132,6 +133,7 @@ public class JCloudsSlaveTemplate implements Describable<JCloudsSlaveTemplate>,
public final boolean assignPublicIp;
public final String networks;
public final String securityGroups;
public final Mode mode;
private String credentialsId;
private String adminCredentialsId;

Expand Down Expand Up @@ -162,7 +164,8 @@ public JCloudsSlaveTemplate(final String name, final String imageId, final Strin
final String jvmOptions, final boolean preExistingJenkinsUser,
final String fsRoot, final boolean allowSudo, final boolean installPrivateKey, final Integer overrideRetentionTime, final int spoolDelayMs,
final boolean assignFloatingIp, final boolean waitPhoneHome, final int waitPhoneHomeTimeout, final String keyPairName,
final boolean assignPublicIp, final String networks, final String securityGroups, final String credentialsId, final String adminCredentialsId) {
final boolean assignPublicIp, final String networks, final String securityGroups, final String credentialsId,
final String adminCredentialsId, final Mode mode) {

this.name = Util.fixEmptyAndTrim(name);
this.imageId = Util.fixEmptyAndTrim(imageId);
Expand Down Expand Up @@ -196,6 +199,7 @@ public JCloudsSlaveTemplate(final String name, final String imageId, final Strin
this.securityGroups = securityGroups;
this.credentialsId = Util.fixEmptyAndTrim(credentialsId);
this.adminCredentialsId = Util.fixEmptyAndTrim(adminCredentialsId);
this.mode = Mode.valueOf(Util.fixNull(mode));
readResolve();
this.vmPassword = null; // Not used anymore, but retained for backward compatibility.
this.vmUser = null; // Not used anymore, but retained for backward compatibility.
Expand Down Expand Up @@ -291,7 +295,7 @@ public JCloudsSlave provisionSlave(TaskListener listener) throws IOException {
try {
return new JCloudsSlave(getCloud().getDisplayName(), getFsRoot(), nodeMetadata, labelString, description,
numExecutors, stopOnTerminate, overrideRetentionTime, getJvmOptions(), waitPhoneHome,
waitPhoneHomeTimeout, credentialsId);
waitPhoneHomeTimeout, credentialsId, mode);
} catch (Descriptor.FormException e) {
throw new AssertionError("Invalid configuration " + e.getMessage());
}
Expand Down
Expand Up @@ -19,6 +19,8 @@
<f:textbox />
</f:entry>

<f:slave-mode name="mode" node="${it}" />

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

<f:block>
Expand Down
Expand Up @@ -12,6 +12,7 @@
<f:entry title="${%Labels}" field="labelString">
<f:textbox/>
</f:entry>
<f:slave-mode name="mode" node="${it}"/>
<f:entry title="${%Number of Executors}" field="numExecutors">
<f:textbox default="2" />
</f:entry>
Expand Down
Expand Up @@ -25,7 +25,7 @@ public void testConfigRoundtrip() throws Exception {
true /* assignFloatingIp */, false /* waitPhoneHome */, 0 /* waitPhoneHomeTimeout */,
null /* keyPairName */, true /* assignPublicIp */, "network1_id,network2_id",
"security_group1,security_group2", null /* credentialsId */,
null /* adminCredentialsId */);
null /* adminCredentialsId */, "NORMAL" /* mode */);

final List<JCloudsSlaveTemplate> templates = new ArrayList<>();
templates.add(beforeTemplate);
Expand All @@ -43,7 +43,7 @@ public void testConfigRoundtrip() throws Exception {
j.assertEqualBeans(beforeCloud, afterCloud,
"profile,providerName,identity,credential,endPointUrl");
j.assertEqualBeans(beforeTemplate, afterTemplate,
"name,cores,ram,osFamily,osVersion,labelString,description,initScript,numExecutors,stopOnTerminate");
"name,cores,ram,osFamily,osVersion,labelString,description,initScript,numExecutors,stopOnTerminate,mode");
}

}

0 comments on commit dea2906

Please sign in to comment.