Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHE-3621 Move SSH machine implementation to separate plugin #3946

Merged
merged 16 commits into from
Feb 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions agents/exec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-machine</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.eclipse.che.api.agent.LSTypeScriptAgent;
import org.eclipse.che.api.agent.SshAgent;
import org.eclipse.che.api.agent.SshAgentLauncher;
import org.eclipse.che.api.agent.SshMachineExecAgentLauncher;
import org.eclipse.che.api.agent.UnisonAgent;
import org.eclipse.che.api.agent.WsAgent;
import org.eclipse.che.api.agent.WsAgentLauncher;
Expand Down Expand Up @@ -136,7 +135,6 @@ protected void configure() {
Multibinder<AgentLauncher> launchers = Multibinder.newSetBinder(binder(), AgentLauncher.class);
launchers.addBinding().to(WsAgentLauncher.class);
launchers.addBinding().to(ExecAgentLauncher.class);
launchers.addBinding().to(SshMachineExecAgentLauncher.class);
launchers.addBinding().to(SshAgentLauncher.class);

bindConstant().annotatedWith(Names.named("machine.ws_agent.run_command"))
Expand Down
16 changes: 16 additions & 0 deletions plugins/plugin-ssh-machine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
Expand All @@ -54,6 +58,10 @@
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-agent-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-core</artifactId>
Expand All @@ -66,6 +74,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-model</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-annotations</artifactId>
Expand All @@ -74,6 +86,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,38 @@
*******************************************************************************/
package org.eclipse.che.plugin.machine.ssh;

import com.google.inject.assistedinject.Assisted;
import com.jcraft.jsch.JSch;

import org.eclipse.che.api.core.model.machine.Command;
import org.eclipse.che.api.core.model.machine.Machine;
import org.eclipse.che.api.core.model.machine.ServerConf;
import org.eclipse.che.api.core.util.LineConsumer;
import org.eclipse.che.api.machine.server.exception.MachineException;
import org.eclipse.che.api.machine.server.spi.Instance;
import org.eclipse.che.plugin.machine.ssh.jsch.JschSshClient;

import javax.inject.Inject;
import javax.inject.Named;
import java.util.Map;
import java.util.Set;

/**
* Provides ssh machine implementation instances.
*
* @author Alexander Garagatyi
* @author Max Shaposhnik
*/
public interface SshMachineFactory {
public class SshMachineFactory {

private final int connectionTimeoutMs;
private final Set<ServerConf> machinesServers;

@Inject
public SshMachineFactory(@Named("che.workspace.ssh_connection_timeout_ms") int connectionTimeoutMs,
@Named("machine.ssh.machine_servers") Set<ServerConf> machinesServers) {
this.connectionTimeoutMs = connectionTimeoutMs;
this.machinesServers = machinesServers;
}


/**
* Creates {@link SshClient} to communicate with machine over SSH protocol.
Expand All @@ -35,31 +51,39 @@ public interface SshMachineFactory {
* @param envVars
* environment variables that should be injected into machine
*/
SshClient createSshClient(@Assisted SshMachineRecipe sshMachineRecipe,
@Assisted Map<String, String> envVars);
public SshClient createSshClient(SshMachineRecipe sshMachineRecipe, Map<String, String> envVars) {
return new JschSshClient(sshMachineRecipe, envVars, new JSch(), connectionTimeoutMs);
}

/**
* Creates ssh machine implementation of {@link Instance}.
* Creates ssh machine implementation instance.
*
* @param machine description of machine
* @param sshClient ssh client of machine
* @param outputConsumer consumer of output from container main process
* @throws MachineException if error occurs on creation of {@code Instance}
* @param machine
* description of machine
* @param sshClient
* ssh client of machine
* @param outputConsumer
* consumer of output from container main process
* @throws MachineException
* if error occurs on creation of {@code Instance}
*/
SshMachineInstance createInstance(@Assisted Machine machine,
@Assisted SshClient sshClient,
@Assisted LineConsumer outputConsumer) throws MachineException;
public SshMachineInstance createInstance(Machine machine, SshClient sshClient, LineConsumer outputConsumer) throws MachineException {
return new SshMachineInstance(machine, sshClient, outputConsumer, this, machinesServers);
}

/**
* Creates ssh machine implementation of {@link org.eclipse.che.api.machine.server.spi.InstanceProcess}.
* Creates ssh machine implementation of {@link SshMachineProcess}.
*
* @param command command that should be executed on process start
* @param outputChannel channel where output will be available on process execution
* @param pid virtual id of that process
* @param sshClient client to communicate with machine
* @param command
* command that should be executed on process start
* @param outputChannel
* channel where output will be available on process execution
* @param pid
* virtual id of that process
* @param sshClient
* client to communicate with machine
*/
SshMachineProcess createInstanceProcess(@Assisted Command command,
@Assisted("outputChannel") String outputChannel,
@Assisted int pid,
@Assisted SshClient sshClient);
public SshMachineProcess createInstanceProcess(Command command, String outputChannel, int pid, SshClient sshClient) {
return new SshMachineProcess(command, outputChannel, pid, sshClient);
}
}
Loading