public class SshCliTool extends SshAbstractTool implements SshTool
Modifier and Type | Class and Description |
---|---|
static class |
SshCliTool.Builder<T extends SshCliTool,B extends SshCliTool.Builder<T,B>> |
SshAbstractTool.AbstractSshToolBuilder<T extends SshTool,B extends SshAbstractTool.AbstractSshToolBuilder<T,B>>, SshAbstractTool.SshAction<T>
Modifier and Type | Field and Description |
---|---|
static ConfigKey<java.lang.String> |
PROP_SCP_EXECUTABLE |
static ConfigKey<java.lang.String> |
PROP_SSH_EXECUTABLE |
static ConfigKey<java.lang.String> |
PROP_SSH_FLAGS |
BROOKLYN_CONFIG_KEY_PREFIX, PROP_ALLOCATE_PTY, PROP_CONNECT_TIMEOUT, PROP_HOST, PROP_LAST_ACCESS_DATE, PROP_LAST_MODIFICATION_DATE, PROP_OWNER_UID, PROP_PASSWORD, PROP_PERMISSIONS, PROP_PORT, PROP_PRIVATE_KEY_DATA, PROP_PRIVATE_KEY_FILE, PROP_PRIVATE_KEY_PASSPHRASE, PROP_SESSION_TIMEOUT, PROP_SSH_RETRY_DELAY, PROP_SSH_TRIES, PROP_SSH_TRIES_TIMEOUT, PROP_STRICT_HOST_KEY_CHECKING, PROP_TOOL_CLASS, PROP_USER
PROP_DIRECT_HEADER, PROP_ERR_STREAM, PROP_EXEC_ASYNC, PROP_EXEC_ASYNC_POLLING_TIMEOUT, PROP_EXEC_TIMEOUT, PROP_LOCAL_TEMP_DIR, PROP_NO_DELETE_SCRIPT, PROP_NO_EXTRA_OUTPUT, PROP_OUT_STREAM, PROP_RUN_AS_ROOT, PROP_SCRIPT_DIR, PROP_SCRIPT_HEADER, PROP_SEPARATOR, PROP_SUMMARY
Constructor and Description |
---|
SshCliTool(java.util.Map<java.lang.String,?> map) |
Modifier and Type | Method and Description |
---|---|
static SshCliTool.Builder<SshCliTool,?> |
builder() |
void |
connect() |
void |
connect(int maxAttempts) |
int |
copyFromServer(java.util.Map<java.lang.String,?> props,
java.lang.String pathAndFileOnRemoteServer,
java.io.File localFile)
Copies the file from the server at the given path.
|
int |
copyToServer(java.util.Map<java.lang.String,?> props,
byte[] contents,
java.lang.String pathAndFileOnRemoteServer) |
int |
copyToServer(java.util.Map<java.lang.String,?> props,
java.io.File f,
java.lang.String pathAndFileOnRemoteServer)
Copies the file to the server at the given path.
|
int |
copyToServer(java.util.Map<java.lang.String,?> props,
java.io.InputStream contents,
java.lang.String pathAndFileOnRemoteServer)
Closes the given input stream before returning.
|
void |
disconnect() |
int |
execCommands(java.util.Map<java.lang.String,?> props,
java.util.List<java.lang.String> commands,
java.util.Map<java.lang.String,?> env)
Executes the set of commands using ssh exec.
|
int |
execScript(java.util.Map<java.lang.String,?> props,
java.util.List<java.lang.String> commands,
java.util.Map<java.lang.String,?> env)
Executes the set of commands in a shell script.
|
boolean |
isConnected() |
getHostAddress, getUsername, toString
execCommands, execScript, getOptionalVal
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
execCommands, execScript
public static final ConfigKey<java.lang.String> PROP_SSH_EXECUTABLE
public static final ConfigKey<java.lang.String> PROP_SSH_FLAGS
public static final ConfigKey<java.lang.String> PROP_SCP_EXECUTABLE
public static SshCliTool.Builder<SshCliTool,?> builder()
public void disconnect()
disconnect
in interface SshTool
public boolean isConnected()
isConnected
in interface SshTool
public int copyToServer(java.util.Map<java.lang.String,?> props, byte[] contents, java.lang.String pathAndFileOnRemoteServer)
copyToServer
in interface SshTool
SshTool.copyToServer(Map, File, String)
public int copyToServer(java.util.Map<java.lang.String,?> props, java.io.InputStream contents, java.lang.String pathAndFileOnRemoteServer)
SshTool
KnownSizeInputStream
for efficiency when the size of the stream is known.copyToServer
in interface SshTool
SshTool.copyToServer(Map, File, String)
public int copyToServer(java.util.Map<java.lang.String,?> props, java.io.File f, java.lang.String pathAndFileOnRemoteServer)
SshTool
The file will not preserve the permission of last _access_ date. Optional properties are:
SshTool.PROP_PERMISSIONS
SshTool.PROP_LAST_MODIFICATION_DATE
; not supported by all SshTool implementations
SshTool.PROP_LAST_ACCESS_DATE
; not supported by all SshTool implementations
copyToServer
in interface SshTool
public int copyFromServer(java.util.Map<java.lang.String,?> props, java.lang.String pathAndFileOnRemoteServer, java.io.File localFile)
SshTool
copyFromServer
in interface SshTool
public int execScript(java.util.Map<java.lang.String,?> props, java.util.List<java.lang.String> commands, java.util.Map<java.lang.String,?> env)
ShellTool
Optional properties are the same common ones as for ShellTool.execCommands(Map, List, Map)
with the addition of:
execScript
in interface ShellTool
execScript
in interface SshTool
#execScript(Map, List, Map)}
public int execCommands(java.util.Map<java.lang.String,?> props, java.util.List<java.lang.String> commands, java.util.Map<java.lang.String,?> env)
ShellTool
ShellTool.execScript(Map, List, Map)
),
but is not suitable if you need env values which are only set on a fully-fledged shell,
or if you want the entire block executed with root permission.
Common optional properties (which also apply to ShellTool.execScript(Map, List, Map)
) are:
ShellTool.PROP_OUT_STREAM
ShellTool.PROP_ERR_STREAM
ShellTool.PROP_SEPARATOR
(for some modes)
ShellTool.PROP_NO_EXTRA_OUTPUT
(often there is no extra output here)
ShellTool.PROP_RUN_AS_ROOT
is not typically supported here. Prefer ShellTool.execScript(Map, List, Map)
).execCommands
in interface ShellTool
execCommands
in interface SshTool
#execCommands(Map, List, Map)}