Skip to content

Package: SshReboot

SshReboot

nameinstructionbranchcomplexitylinemethod
rebootNow(SshSession)
M: 23 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package update.remote.ssh;
2:
3: import com.jcraft.jsch.Channel;
4: import com.jcraft.jsch.ChannelExec;
5: import com.jcraft.jsch.JSchException;
6: import com.jcraft.jsch.Session;
7:
8: /**
9: * Diese Klasse dient zum Rebooten eines Servers per SSH.
10: *
11: * @author Muri
12: *
13: */
14: public final class SshReboot {
15:         /**
16:          *
17:          * @param sshSession
18:          * sshSession
19:          * @throws JSchException
20:          * JSchException
21:          */
22:         public static void rebootNow(final SshSession sshSession) throws JSchException {
23:                 final Session session = sshSession.getSession();
24:                 final Channel channel = session.openChannel("exec");
25:                 ((ChannelExec) channel).setCommand("/sbin/reboot -d 1;");
26:                 channel.setInputStream(null);
27:                 ((ChannelExec) channel).setErrStream(System.err);
28:                 channel.connect();
29:                 channel.disconnect();
30:         }
31:
32:         /**
33:          * private constructor.
34:          */
35:         private SshReboot() {
36:                 super();
37:                 // TODO Auto-generated constructor stub
38:         }
39: }