|
Brooklyn | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbrooklyn.util.internal.ssh.ShellAbstractTool
brooklyn.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
|
static class |
SshjTool.SshjToolBuilder
|
Field Summary | |
---|---|
protected BackoffLimitedRetryHandler |
backoffLimitedRetryHandler
|
protected int |
sshTries
|
protected int |
sshTriesTimeout
|
Fields inherited from class SshAbstractTool | |
---|---|
allocatePTY, host, password, port, privateKeyData, privateKeyFile, privateKeyPassphrase, strictHostKeyChecking, toString, user |
Fields inherited from class ShellAbstractTool | |
---|---|
localTempDir |
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.SshjToolBuilder
|
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)
|
void
|
disconnect()
|
int
|
execCommands(java.util.Map props, java.util.List commands, java.util.Map env)
|
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
|
execShellDirect(java.util.Map props, java.util.List commands, java.util.Map env)
|
boolean
|
isConnected()
|
protected SshAction
|
newSessionAction()
|
Methods inherited from class SshAbstractTool | |
---|---|
SshAbstractTool, getHostAddress, getUsername, propagate, toString |
Methods inherited from class ShellAbstractTool | |
---|---|
asInt, buildRunScriptCommand, closeWhispering, closeWhispering, execCommands, execScript, getMandatoryVal, getMandatoryVal, getOptionalVal, getOptionalVal, getOptionalVal, hasVal, toCommandSequence, toScript, 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.SshjToolBuilder builder()
protected void checkConnected()
try { public void connect()
connect(); // FIXME Should callers instead configure sshTries? But that would apply to all ssh attempts public void connect(int maxAttempts)
Files.copy(new InputStreamSupplier(contents), localFile); public int copyFromServer(java.util.Map props, java.lang.String pathAndFileOnRemoteServer, java.io.File localFile)
} public int copyToServer(java.util.Map props, byte[] contents, java.lang.String pathAndFileOnRemoteServer)
* 1) to know the length of the InputStream to copy the file to perform copy; and public int copyToServer(java.util.Map props, java.io.InputStream contents, java.lang.String pathAndFileOnRemoteServer)
} public int copyToServer(java.util.Map props, java.io.File localFile, java.lang.String pathAndFileOnRemoteServer)
try { public void disconnect()
OutputStream out = getOptionalVal(props, PROP_OUT_STREAM); public int execCommands(java.util.Map props, java.util.List commands, java.util.Map env)
Boolean noExtraOutput = getOptionalVal(props, PROP_NO_EXTRA_OUTPUT); 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 execShellDirect(java.util.Map props, java.util.List commands, java.util.Map env)
} public boolean isConnected()
protected SshAction newSessionAction()
Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.