diff --git a/core/src/main/java/hudson/os/windows/ManagedWindowsServiceConnector.java b/core/src/main/java/hudson/os/windows/ManagedWindowsServiceConnector.java new file mode 100644 index 0000000000000000000000000000000000000000..8337f4cba3588fd51a176f4d9dc55b9e844d834e --- /dev/null +++ b/core/src/main/java/hudson/os/windows/ManagedWindowsServiceConnector.java @@ -0,0 +1,51 @@ +package hudson.os.windows; + +import hudson.Extension; +import hudson.model.Computer; +import hudson.model.Descriptor; +import hudson.model.TaskListener; +import hudson.slaves.ComputerConnector; +import hudson.slaves.ComputerLauncher; +import hudson.util.Secret; +import org.kohsuke.stapler.DataBoundConstructor; + +import java.io.IOException; + +/** + * {@link ComputerConnector} that delegates to {@link ManagedWindowsServiceLauncher}. + * @author Kohsuke Kawaguchi + */ +public class ManagedWindowsServiceConnector extends ComputerConnector { + /** + * "[DOMAIN\\]USERNAME" to follow the Windows convention. + */ + public final String userName; + + public final Secret password; + + @DataBoundConstructor + public ManagedWindowsServiceConnector(String userName, String password) { + this.userName = userName; + this.password = Secret.fromString(password); + } + + @Override + public ManagedWindowsServiceLauncher launch(final String host, TaskListener listener) throws IOException, InterruptedException { + return new ManagedWindowsServiceLauncher(userName,Secret.toString(password)) { + @Override + protected String determineHost(Computer c) throws IOException, InterruptedException { + return host; + } + }; + } + + @Extension + public static class DescriptorImpl extends Descriptor { + public String getDisplayName() { + return Messages.ManagedWindowsServiceLauncher_DisplayName(); + } + } + + // used by Jelly + public static final Class CONFIG_DELEGATE_TO = ManagedWindowsServiceLauncher.class; +} diff --git a/core/src/main/java/hudson/slaves/ComputerConnector.java b/core/src/main/java/hudson/slaves/ComputerConnector.java index b891ed7bd8aeffa2fef831b807b8075d89b14c44..abee2402ec6e7911ddc0d96cba2d9b6ec7f71b9a 100644 --- a/core/src/main/java/hudson/slaves/ComputerConnector.java +++ b/core/src/main/java/hudson/slaves/ComputerConnector.java @@ -1,14 +1,22 @@ package hudson.slaves; +import hudson.ExtensionPoint; import hudson.model.AbstractDescribableImpl; import hudson.model.TaskListener; import java.io.IOException; /** + * Factory of {@link ComputerLauncher}. + * + * When writing a {@link Cloud} implementation, one needs to dynamically create {@link ComputerLauncher} + * by supplying a host name. This is the abstraction for that. + * * @author Kohsuke Kawaguchi + * @since 1.383 + * @see ComputerLauncher */ -public abstract class ComputerConnector extends AbstractDescribableImpl { +public abstract class ComputerConnector extends AbstractDescribableImpl implements ExtensionPoint { /** * Creates a {@link ComputerLauncher} for connecting to the given host. * @@ -18,4 +26,9 @@ public abstract class ComputerConnector extends AbstractDescribableImpl { + public DescriptorExtensionList all() { + return Hudson.getInstance().getDescriptorList(ComputerConnector.class); + } +} diff --git a/core/src/main/java/hudson/slaves/ComputerLauncher.java b/core/src/main/java/hudson/slaves/ComputerLauncher.java index 149122bfab963f9d6a3c67ff7a3bebf9387d1b58..99fe69366f1c6c99a15074fdef171f9cac1c1c22 100644 --- a/core/src/main/java/hudson/slaves/ComputerLauncher.java +++ b/core/src/main/java/hudson/slaves/ComputerLauncher.java @@ -30,10 +30,13 @@ import hudson.model.Computer; import hudson.model.Hudson; import hudson.model.TaskListener; import hudson.remoting.Channel; +import hudson.remoting.Channel.Listener; import hudson.util.DescriptorList; import hudson.util.StreamTaskListener; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; /** * Extension point to allow control over how {@link Computer}s are "launched", @@ -49,6 +52,7 @@ import java.io.IOException; * * @author Stephen Connolly * @since 24-Apr-2008 22:12:35 + * @see ComputerConnector */ public abstract class ComputerLauncher extends AbstractDescribableImpl implements ExtensionPoint { /** @@ -63,7 +67,7 @@ public abstract class ComputerLauncher extends AbstractDescribableImpl - * If the slave agent is launched successfully, {@link SlaveComputer#setChannel(InputStream, OutputStream, OutputStream, Channel.Listener)} + * If the slave agent is launched successfully, {@link SlaveComputer#setChannel(InputStream, OutputStream, TaskListener, Listener)} * should be invoked in the end to notify Hudson of the established connection. * The operation could also fail, in which case there's no need to make any callback notification, * (except to notify the user of the failure through {@link StreamTaskListener}.) diff --git a/core/src/main/resources/hudson/os/windows/ManagedWindowsServiceConnector/config.jelly b/core/src/main/resources/hudson/os/windows/ManagedWindowsServiceConnector/config.jelly new file mode 100644 index 0000000000000000000000000000000000000000..6d752f2cea3bb42b532437cf0a489f8813bf0d74 --- /dev/null +++ b/core/src/main/resources/hudson/os/windows/ManagedWindowsServiceConnector/config.jelly @@ -0,0 +1,27 @@ + + + + + \ No newline at end of file