Package org.opennms.smoketest.utils
Class SshClient
- java.lang.Object
- 
- org.opennms.smoketest.utils.SshClient
 
- 
- All Implemented Interfaces:
- AutoCloseable
 
 public class SshClient extends Object implements AutoCloseable A simple SSH client wrapper used to run shell commands.- Author:
- jwhite
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classSshClient.Streams
 - 
Field SummaryFields Modifier and Type Field Description static intDEFAULT_TIMEOUT_MS
 - 
Constructor SummaryConstructors Constructor Description SshClient(InetSocketAddress addr, String username, String password)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Callable<Boolean>canConnectViaSsh(InetSocketAddress addr, String username, String password)voidclose()InetSocketAddressgetAddr()StringgetStderr()StringgetStdout()StringgetStdoutOrNull()SshClient.StreamsgetStreams()booleanisShellClosed()Checks if the shell's channel is closed.Callable<Boolean>isShellClosedCallable()PrintStreamopenShell()voidsetTimeout(int timeoutInMs)
 
- 
- 
- 
Field Detail- 
DEFAULT_TIMEOUT_MSpublic static final int DEFAULT_TIMEOUT_MS - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
SshClientpublic SshClient(InetSocketAddress addr, String username, String password) 
 
- 
 - 
Method Detail- 
openShellpublic PrintStream openShell() throws Exception - Throws:
- Exception
 
 - 
getStdoutpublic String getStdout() throws IOException - Throws:
- IOException
 
 - 
getStdoutOrNullpublic String getStdoutOrNull() 
 - 
getStderrpublic String getStderr() throws IOException - Throws:
- IOException
 
 - 
setTimeoutpublic void setTimeout(int timeoutInMs) 
 - 
getAddrpublic InetSocketAddress getAddr() 
 - 
closepublic void close() throws Exception- Specified by:
- closein interface- AutoCloseable
- Throws:
- Exception
 
 - 
isShellClosedpublic 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.
 - 
getStreamspublic SshClient.Streams getStreams() 
 - 
canConnectViaSshpublic static Callable<Boolean> canConnectViaSsh(InetSocketAddress addr, String username, String password) 
 
- 
 
-