Bug 1029: Remove dead code: sal-schema-repository-api
[controller.git] / opendaylight / netconf / netconf-util / src / main / java / org / opendaylight / controller / netconf / util / handler / ssh / client / SshSession.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.netconf.util.handler.ssh.client;
10
11 import ch.ethz.ssh2.Session;
12 import ch.ethz.ssh2.StreamGobbler;
13
14 import java.io.Closeable;
15 import java.io.IOException;
16 import java.io.InputStream;
17 import java.io.OutputStream;
18
19 /**
20  * Wrapper class for proprietary SSH sessions implementations
21  */
22 public class SshSession implements Closeable {
23     private final Session session;
24
25     public SshSession(Session session) {
26         this.session = session;
27     }
28
29     public void execCommand(String cmd) throws IOException {
30         session.execCommand(cmd);
31     }
32
33     public void execCommand(String cmd, String charsetName) throws IOException {
34         session.execCommand(cmd, charsetName);
35     }
36
37     public void startShell() throws IOException {
38         session.startShell();
39     }
40
41     public void startSubSystem(String name) throws IOException {
42         session.startSubSystem(name);
43     }
44
45     public int getState() {
46         return session.getState();
47     }
48
49     public InputStream getStdout() {
50         return new StreamGobbler(session.getStdout());
51     }
52
53     public InputStream getStderr() {
54         return session.getStderr();
55     }
56
57     public OutputStream getStdin() {
58         return session.getStdin();
59     }
60
61     public int waitUntilDataAvailable(long timeout) throws IOException {
62         return session.waitUntilDataAvailable(timeout);
63     }
64
65     public int waitForCondition(int conditionSet, long timeout) {
66         return session.waitForCondition(conditionSet, timeout);
67     }
68
69     public Integer getExitStatus() {
70         return session.getExitStatus();
71     }
72
73     public String getExitSignal() {
74         return session.getExitSignal();
75     }
76
77     @Override
78     public void close() {
79         session.close();
80     }
81 }