X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-netty-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fnettyutil%2Fhandler%2Fssh%2Fclient%2FSshSession.java;h=9cdc5926f042fcdc30129257597113c532581e9e;hp=8311554cdafde19ca8a2e994d22a0f2b2971b12c;hb=83f7f24d355f87d8c1a850098d5b7c82e5d746dd;hpb=478ce1fa1dc30974b7cf23fd5258f1af5366d547 diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshSession.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshSession.java index 8311554cda..9cdc5926f0 100644 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshSession.java +++ b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshSession.java @@ -9,8 +9,7 @@ package org.opendaylight.controller.netconf.nettyutil.handler.ssh.client; import ch.ethz.ssh2.Session; -import ch.ethz.ssh2.StreamGobbler; - +import ch.ethz.ssh2.channel.Channel; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; @@ -19,37 +18,23 @@ import java.io.OutputStream; /** * Wrapper class for proprietary SSH sessions implementations */ -public class SshSession implements Closeable { +class SshSession implements Closeable { private final Session session; - public SshSession(Session session) { + public SshSession(final Session session) { this.session = session; } - public void execCommand(String cmd) throws IOException { - session.execCommand(cmd); - } - - public void execCommand(String cmd, String charsetName) throws IOException { - session.execCommand(cmd, charsetName); - } - - public void startShell() throws IOException { - session.startShell(); - } - - public void startSubSystem(String name) throws IOException { + public void startSubSystem(final String name) throws IOException { session.startSubSystem(name); } - public int getState() { - return session.getState(); - } - public InputStream getStdout() { - return new StreamGobbler(session.getStdout()); + return session.getStdout(); } + // FIXME according to http://www.ganymed.ethz.ch/ssh2/FAQ.html#blocking you should read data from both stdout and stderr to prevent window filling up (since stdout and stderr share a window) + // FIXME stdErr is not used anywhere public InputStream getStderr() { return session.getStderr(); } @@ -58,24 +43,10 @@ public class SshSession implements Closeable { return session.getStdin(); } - public int waitUntilDataAvailable(long timeout) throws IOException { - return session.waitUntilDataAvailable(timeout); - } - - public int waitForCondition(int conditionSet, long timeout) { - return session.waitForCondition(conditionSet, timeout); - } - - public Integer getExitStatus() { - return session.getExitStatus(); - } - - public String getExitSignal() { - return session.getExitSignal(); - } - @Override public void close() { - session.close(); + if (session.getState() == Channel.STATE_OPEN || session.getState() == Channel.STATE_OPENING) { + session.close(); + } } }