Merge "creating a default subnet"
[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.IOException;
15 import java.io.InputStream;
16 import java.io.OutputStream;
17
18 /**
19  * Wrapper class for proprietary SSH sessions implementations
20  */
21 public class SshSession {
22     final Session session;
23
24     public SshSession(Session session) {
25         this.session = session;
26     }
27
28     public void execCommand(String cmd) throws IOException {
29         session.execCommand(cmd);
30     }
31
32     public void execCommand(String cmd, String charsetName) throws IOException {
33         session.execCommand(cmd, charsetName);
34     }
35
36     public void startShell() throws IOException {
37         session.startShell();
38     }
39
40     public void startSubSystem(String name) throws IOException {
41         session.startSubSystem(name);
42     }
43
44     public int getState() {
45         return session.getState();
46     }
47
48     public InputStream getStdout() {
49         return new StreamGobbler(session.getStdout());
50     }
51
52     public InputStream getStderr() {
53         return session.getStderr();
54     }
55
56     public OutputStream getStdin() {
57         return session.getStdin();
58     }
59
60     public int waitUntilDataAvailable(long timeout) throws IOException {
61         return session.waitUntilDataAvailable(timeout);
62     }
63
64     public int waitForCondition(int condition_set, long timeout) {
65         return session.waitForCondition(condition_set, timeout);
66     }
67
68     public Integer getExitStatus() {
69         return session.getExitStatus();
70     }
71
72     public String getExitSignal() {
73         return session.getExitSignal();
74     }
75 }