use of hudson.plugins.sshslaves.SSHLauncher in project configuration-as-code-plugin by jenkinsci.
the class BuildAgentsTest method configure_build_agents.
@Test
@ConfiguredWithReadme(value = "build_agents/README.md")
public void configure_build_agents() {
assertThat(j.getInstance().getComputers().length, is(3));
Slave slave = (Slave) j.getInstance().getNode("utility-node");
assertThat(slave.getRemoteFS(), is("/home/user1"));
JNLPLauncher jnlpLauncher = ((JNLPLauncher) slave.getLauncher());
assertThat(jnlpLauncher.getWorkDirSettings().getWorkDirPath(), is("/tmp"));
assertThat(jnlpLauncher.getWorkDirSettings().getInternalDir(), is("remoting"));
assertTrue(jnlpLauncher.getWorkDirSettings().isDisabled());
assertFalse(jnlpLauncher.getWorkDirSettings().isFailIfWorkDirIsMissing());
assertThat(j.getInstance().getNode("utility-node-2").getNumExecutors(), is(4));
assertThat(j.getInstance().getNode("utility-node-2").getMode(), is(Mode.NORMAL));
slave = (Slave) j.getInstance().getNode("utility-node-2");
assertThat(slave.getRemoteFS(), is("/home/user2"));
SSHLauncher launcher = ((SSHLauncher) slave.getLauncher());
assertThat(launcher.getHost(), is("192.168.1.1"));
assertThat(launcher.getPort(), is(22));
assertThat(launcher.getCredentialsId(), is("test"));
assertThat(launcher.getMaxNumRetries(), is(3));
assertThat(launcher.getRetryWaitTime(), is(30));
}
use of hudson.plugins.sshslaves.SSHLauncher in project vsphere-cloud-plugin by jenkinsci.
the class vSphereCloudSlaveTemplate method readResolve.
protected Object readResolve() {
this.labelSet = Label.parse(labelString);
if (this.templateInstanceCap == 0) {
this.templateInstanceCap = Integer.MAX_VALUE;
}
if (this.useSnapshot == null) {
this.useSnapshot = Boolean.valueOf(this.snapshotName != null);
}
/*
* If we've upgraded from an earlier version of the plugin
* where things were hard-coded instead of configurable
* then we'll need to transfer the data across to the new
* format.
*/
if (this.launcher == null) {
LOGGER.log(Level.CONFIG, "{0} loaded old configuration that had hard-coded SSHLauncher.", this);
try {
final String oldCredentialsIdOrNull = getCredentialsId();
final String oldCredentialsId = oldCredentialsIdOrNull == null ? "" : oldCredentialsIdOrNull;
// these were the old hard-coded settings
this.launcher = new SSHLauncher(null, 0, oldCredentialsId, null, null, null, null, this.launchDelay, 3, 60);
LOGGER.log(Level.CONFIG, " - now configured to use {0}(..., {1}, ...)", new Object[] { this.launcher.getClass().getSimpleName(), oldCredentialsId });
} catch (Exception ex) {
LOGGER.log(Level.CONFIG, " - Failed to reconfigure launcher", ex);
}
}
if (this.retentionStrategy == null) {
LOGGER.log(Level.CONFIG, "{0} loaded old configuration that had hard-coded RunOnceCloudRetentionStrategy.", this);
try {
// these were the old hard-coded settings
final int oldTimeout = 2;
this.retentionStrategy = new RunOnceCloudRetentionStrategy(oldTimeout);
LOGGER.log(Level.CONFIG, " - now configured to use {0}({1})", new Object[] { this.retentionStrategy.getClass().getSimpleName(), oldTimeout });
} catch (Exception ex) {
LOGGER.log(Level.CONFIG, " - Failed to reconfigure strategy", ex);
}
}
return this;
}
use of hudson.plugins.sshslaves.SSHLauncher in project vsphere-cloud-plugin by jenkinsci.
the class vSphereCloudSlaveTemplate method determineLauncher.
private ComputerLauncher determineLauncher(final VSphere vSphere, final String cloneName) throws VSphereException {
if (launcher instanceof JNLPLauncher) {
return launcher;
}
if (launcher instanceof CommandLauncher) {
return launcher;
}
if (launcher instanceof SSHLauncher) {
final SSHLauncher sshLauncher = (SSHLauncher) launcher;
LOGGER.log(Level.FINER, "Slave {0} uses SSHLauncher - obtaining IP address...", cloneName);
final String ip = vSphere.getIp(vSphere.getVmByName(cloneName), 1000);
LOGGER.log(Level.FINER, "Slave {0} has IP address {1}", new Object[] { cloneName, ip });
final SSHLauncher launcherWithIPAddress = new SSHLauncher(ip, sshLauncher.getPort(), sshLauncher.getCredentialsId(), sshLauncher.getJvmOptions(), sshLauncher.getJavaPath(), sshLauncher.getPrefixStartSlaveCmd(), sshLauncher.getSuffixStartSlaveCmd(), sshLauncher.getLaunchTimeoutSeconds(), sshLauncher.getMaxNumRetries(), sshLauncher.getRetryWaitTime());
return launcherWithIPAddress;
}
throw new IllegalStateException("Unsupported launcher (" + launcher + ") in template configuration");
}
Aggregations