提交 03dee8dd 编写于 作者: K kohsuke

started adding the ComputerConnector implementation

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@36128 71c3de6d-444a-0410-be80-ed276b4c234a
上级 9f2aa856
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<ComputerLauncher> {
public String getDisplayName() {
return Messages.ManagedWindowsServiceLauncher_DisplayName();
}
}
// used by Jelly
public static final Class CONFIG_DELEGATE_TO = ManagedWindowsServiceLauncher.class;
}
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<ComputerConnector> {
public abstract class ComputerConnector extends AbstractDescribableImpl<ComputerConnector> implements ExtensionPoint {
/**
* Creates a {@link ComputerLauncher} for connecting to the given host.
*
......@@ -18,4 +26,9 @@ public abstract class ComputerConnector extends AbstractDescribableImpl<Computer
* If
*/
public abstract ComputerLauncher launch(String host, TaskListener listener) throws IOException, InterruptedException;
@Override
public ComputerConnectorDescriptor getDescriptor() {
return (ComputerConnectorDescriptor)super.getDescriptor();
}
}
package hudson.slaves;
import hudson.DescriptorExtensionList;
import hudson.model.Descriptor;
import hudson.model.Hudson;
/**
* {@link Descriptor} for {@link ComputerConnector}.
*
* @author Kohsuke Kawaguchi
* @since 1.383
*/
public abstract class ComputerConnectorDescriptor extends Descriptor<ComputerConnector> {
public DescriptorExtensionList<ComputerConnector,ComputerConnectorDescriptor> all() {
return Hudson.getInstance().getDescriptorList(ComputerConnector.class);
}
}
......@@ -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<ComputerLauncher> implements ExtensionPoint {
/**
......@@ -63,7 +67,7 @@ public abstract class ComputerLauncher extends AbstractDescribableImpl<ComputerL
* Launches the slave agent for the given {@link Computer}.
*
* <p>
* 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}.)
......
<!--
The MIT License
Copyright (c) 2010, InfraDNA, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<st:include page="config.jelly" class="${instance.CONFIG_DELEGATE_TO}"/>
</j:jelly>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册