Package org.opennms.alec.smoke.util.ssh
Class SshClient
- java.lang.Object
-
- org.opennms.alec.smoke.util.ssh.SshClient
-
- All Implemented Interfaces:
AutoCloseable
public class SshClient extends Object implements AutoCloseable
A simple SSH client wrapper used to run shell commands.- Author:
- jwhite
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_TIMEOUT_MS
-
Constructor Summary
Constructors Constructor Description SshClient(InetSocketAddress addr, String username, String password)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Callable<Boolean>canConnectViaSsh(InetSocketAddress addr, String username, String password)voidclose()StringgetStderr()StringgetStdout()booleanisShellClosed()Checks if the shell's channel is closed.Callable<Boolean>isShellClosedCallable()PrintStreamopenShell()voidsetTimeout(int timeoutInMs)
-
-
-
Field Detail
-
DEFAULT_TIMEOUT_MS
public static final int DEFAULT_TIMEOUT_MS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SshClient
public SshClient(InetSocketAddress addr, String username, String password)
-
-
Method Detail
-
openShell
public PrintStream openShell() throws Exception
- Throws:
Exception
-
getStdout
public String getStdout() throws IOException
- Throws:
IOException
-
getStderr
public String getStderr() throws IOException
- Throws:
IOException
-
setTimeout
public void setTimeout(int timeoutInMs)
-
close
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
isShellClosed
public boolean isShellClosed()
Checks if the shell's channel is closed. Can be used to make sure that stdout/stderr get fully populated after an exit/logout command is issued in the shell.
-
canConnectViaSsh
public static Callable<Boolean> canConnectViaSsh(InetSocketAddress addr, String username, String password)
-
-