|
Brooklyn | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbrooklyn.util.internal.ssh.SshAbstractTool
brooklyn.util.internal.ssh.sshj.SshjTool
public class SshjTool extends SshAbstractTool
For ssh and scp-style commands, using the sshj library.
The implementation is based on a combination of the existing brooklyn SshJschTool, and the jclouds SshjSshClient.
Not thread-safe. Use a different SshjTool for each concurrent thread. If passing from one thread to another, ensure code goes through a synchronized block.
Nested Class Summary | |
---|---|
static class |
SshjTool.Builder
|
Field Summary | |
---|---|
protected BackoffLimitedRetryHandler |
backoffLimitedRetryHandler
|
protected int |
sshTries
|
protected int |
sshTriesTimeout
|
Fields inherited from class SshAbstractTool | |
---|---|
allocatePTY, host, localTempDir, password, port, privateKeyData, privateKeyFile, privateKeyPassphrase, strictHostKeyChecking, toString, user |
Method Summary | |
---|---|
java.lang.Object
|
SshjTool(java.util.Map map)
|
protected java.lang.Object
|
SshjTool(SshjTool.Builder builder)
|
protected java.lang.Object
|
acquire(C connection)
|
protected void
|
allocatePTY(Session s)
|
protected void
|
backoffForAttempt(int retryAttempt, java.lang.String message)
|
static SshjTool.Builder
|
builder()
|
protected void
|
checkConnected()
|
void
|
connect()
|
void
|
connect(int maxAttempts)
|
int
|
copyFromServer(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.io.File localFile)
|
int
|
copyToServer(java.util.Map props, byte[] contents, java.lang.String pathAndFileOnRemoteServer)
|
int
|
copyToServer(java.util.Map props, java.io.InputStream contents, java.lang.String pathAndFileOnRemoteServer)
|
int
|
copyToServer(java.util.Map props, java.io.File localFile, java.lang.String pathAndFileOnRemoteServer)
|
int
|
createFile(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.io.InputStream input, long size)
|
int
|
createFile(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.lang.String contents)
|
int
|
createFile(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, byte[] contents)
|
void
|
disconnect()
|
int
|
execCommands(java.util.Map props, java.util.List commands)
|
int
|
execCommands(java.util.Map props, java.util.List commands, java.util.Map env)
|
int
|
execScript(java.util.Map props, java.util.List commands)
|
int
|
execScript(java.util.Map props, java.util.List commands, java.util.Map env)
This creates a script containing the user's commands, copies it to the remote server, and executes the script. |
int
|
execShell(java.util.Map props, java.util.List commands)
|
int
|
execShell(java.util.Map props, java.util.List commands, java.util.Map env)
|
int
|
execShellDirect(java.util.Map props, java.util.List commands, java.util.Map env)
|
boolean
|
isConnected()
|
protected SshAction
|
newSessionAction()
|
int
|
transferFileFrom(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.lang.String pathAndFileOnLocalServer)
|
int
|
transferFileTo(java.util.Map props, java.io.InputStream input, java.lang.String pathAndFileOnRemoteServer)
|
Methods inherited from class SshAbstractTool | |
---|---|
SshAbstractTool, closeWhispering, getHostAddress, getMandatoryVal, getMandatoryVal, getOptionalVal, getOptionalVal, getOptionalVal, getUsername, hasVal, propagate, toCommandSequence, toScript, toString, warnOnDeprecated, writeTempFile, writeTempFile, writeTempFile |
Field Detail |
---|
protected final BackoffLimitedRetryHandler backoffLimitedRetryHandler
protected final int sshTries
protected final int sshTriesTimeout
Method Detail |
---|
public java.lang.Object SshjTool(java.util.Map map)
protected java.lang.Object SshjTool(SshjTool.Builder builder)
protected java.lang.Object acquire(C connection)
protected void allocatePTY(Session s)
protected void backoffForAttempt(int retryAttempt, java.lang.String message)
public static SshjTool.Builder builder()
protected void checkConnected()
@Override public void connect()
@Override public void connect(int maxAttempts)
@Override public int copyFromServer(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.io.File localFile)
@Override public int copyToServer(java.util.Map props, byte[] contents, java.lang.String pathAndFileOnRemoteServer)
@Override public int copyToServer(java.util.Map props, java.io.InputStream contents, java.lang.String pathAndFileOnRemoteServer)
@Override public int copyToServer(java.util.Map props, java.io.File localFile, java.lang.String pathAndFileOnRemoteServer)
@Override public int createFile(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.io.InputStream input, long size)
@Override public int createFile(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.lang.String contents)
@Override public int createFile(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, byte[] contents)
@Override public void disconnect()
@Override public int execCommands(java.util.Map props, java.util.List commands)
@Override public int execCommands(java.util.Map props, java.util.List commands, java.util.Map env)
@Override public int execScript(java.util.Map props, java.util.List commands)
@Override public int execScript(java.util.Map props, java.util.List commands, java.util.Map env)
Executing commands directly is fraught with dangers! Here are other options, and their problems:
public int execShell(java.util.Map props, java.util.List commands)
public int execShell(java.util.Map props, java.util.List commands, java.util.Map env)
public int execShellDirect(java.util.Map props, java.util.List commands, java.util.Map env)
@Override public boolean isConnected()
protected SshAction newSessionAction()
@Override public int transferFileFrom(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.lang.String pathAndFileOnLocalServer)
@Override public int transferFileTo(java.util.Map props, java.io.InputStream input, java.lang.String pathAndFileOnRemoteServer)
Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.