Search in sources :

Example 1 with SSHLauncher

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));
}
Also used : Slave(hudson.model.Slave) SSHLauncher(hudson.plugins.sshslaves.SSHLauncher) JNLPLauncher(hudson.slaves.JNLPLauncher) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 2 with SSHLauncher

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;
}
Also used : SSHLauncher(hudson.plugins.sshslaves.SSHLauncher) RunOnceCloudRetentionStrategy(org.jenkinsci.plugins.vsphere.RunOnceCloudRetentionStrategy) VSphereException(org.jenkinsci.plugins.vsphere.tools.VSphereException) FormException(hudson.model.Descriptor.FormException) IOException(java.io.IOException) VSphereDuplicateException(org.jenkinsci.plugins.vsphere.tools.VSphereDuplicateException)

Example 3 with SSHLauncher

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");
}
Also used : CommandLauncher(hudson.slaves.CommandLauncher) SSHLauncher(hudson.plugins.sshslaves.SSHLauncher) JNLPLauncher(hudson.slaves.JNLPLauncher)

Aggregations

SSHLauncher (hudson.plugins.sshslaves.SSHLauncher)3 JNLPLauncher (hudson.slaves.JNLPLauncher)2 FormException (hudson.model.Descriptor.FormException)1 Slave (hudson.model.Slave)1 CommandLauncher (hudson.slaves.CommandLauncher)1 ConfiguredWithReadme (io.jenkins.plugins.casc.misc.ConfiguredWithReadme)1 IOException (java.io.IOException)1 RunOnceCloudRetentionStrategy (org.jenkinsci.plugins.vsphere.RunOnceCloudRetentionStrategy)1 VSphereDuplicateException (org.jenkinsci.plugins.vsphere.tools.VSphereDuplicateException)1 VSphereException (org.jenkinsci.plugins.vsphere.tools.VSphereException)1 Test (org.junit.Test)1