Search in sources :

Example 1 with RunOnceCloudRetentionStrategy

use of org.jenkinsci.plugins.vsphere.RunOnceCloudRetentionStrategy 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 2 with RunOnceCloudRetentionStrategy

use of org.jenkinsci.plugins.vsphere.RunOnceCloudRetentionStrategy in project vsphere-cloud-plugin by jenkinsci.

the class vSphereCloudSlaveTemplate method determineRetention.

private RetentionStrategy<?> determineRetention() {
    if (retentionStrategy instanceof RunOnceCloudRetentionStrategy) {
        final RunOnceCloudRetentionStrategy templateStrategy = (RunOnceCloudRetentionStrategy) retentionStrategy;
        final RunOnceCloudRetentionStrategy cloneStrategy = new RunOnceCloudRetentionStrategy(templateStrategy.getIdleMinutes());
        return cloneStrategy;
    }
    if (retentionStrategy instanceof VSphereCloudRetentionStrategy) {
        final VSphereCloudRetentionStrategy templateStrategy = (VSphereCloudRetentionStrategy) retentionStrategy;
        final VSphereCloudRetentionStrategy cloneStrategy = new VSphereCloudRetentionStrategy(templateStrategy.getIdleMinutes());
        return cloneStrategy;
    }
    throw new IllegalStateException("Unsupported retentionStrategy (" + retentionStrategy + ") in template configuration");
}
Also used : RunOnceCloudRetentionStrategy(org.jenkinsci.plugins.vsphere.RunOnceCloudRetentionStrategy) VSphereCloudRetentionStrategy(org.jenkinsci.plugins.vsphere.VSphereCloudRetentionStrategy)

Aggregations

RunOnceCloudRetentionStrategy (org.jenkinsci.plugins.vsphere.RunOnceCloudRetentionStrategy)2 FormException (hudson.model.Descriptor.FormException)1 SSHLauncher (hudson.plugins.sshslaves.SSHLauncher)1 IOException (java.io.IOException)1 VSphereCloudRetentionStrategy (org.jenkinsci.plugins.vsphere.VSphereCloudRetentionStrategy)1 VSphereDuplicateException (org.jenkinsci.plugins.vsphere.tools.VSphereDuplicateException)1 VSphereException (org.jenkinsci.plugins.vsphere.tools.VSphereException)1