Révision 53

src/gZFS/libConnect.java (revision 53)
1
package gZFS;
2

  
3
import java.io.BufferedReader;
4
import java.io.IOException;
5
import java.io.InputStream;
6
import java.io.InputStreamReader;
7
import java.io.OutputStream;
8
import java.io.PipedInputStream;
9
import java.io.PipedOutputStream;
10
import java.io.PrintStream;
11
import java.util.ArrayList;
12
import java.util.Properties;
13

  
14
import com.jcraft.jsch.Channel;
15
import com.jcraft.jsch.ChannelExec;
16
import com.jcraft.jsch.JSch;
17
import com.jcraft.jsch.JSchException;
18
import com.jcraft.jsch.Session;
19

  
20
public class libConnect {
21

  
22
	private String userLogin;
23
	private String userPassword;
24
	private String sshHost;
25
	private int sshPort;
26
	private Session session;
27
	private JSch jsch = new JSch();
28

  
29
	public String connect(String cmd) {
30
		String outCmd = null ;
31
		try {
32
			
33
			setSession(jsch.getSession(getUserLogin(), getSshHost(), getSshPort()));
34
			session.setPassword(this.getUserPassword());
35
			Properties config = new Properties();
36
			config.put("StrictHostKeyChecking", "no");
37
			session.setConfig(config);
38
			session.connect();
39
			if ( session.isConnected()){
40
				System.out.println("Connected");
41
			}else{
42
				System.out.println("not Connected");
43
			}
44
			ChannelExec channel = (ChannelExec) session.openChannel("exec");
45
			//((ChannelExec) channel).setCommand("ls");
46
			((ChannelExec) channel).setCommand(cmd);
47
			InputStream in = channel.getInputStream();
48
			OutputStream out = channel.getOutputStream();
49
			((ChannelExec) channel).setErrStream(System.err);
50

  
51
			channel.connect();
52
			byte[] tmp = new byte[1024];
53
			
54
			while (true) {
55
				
56
				int ind = 0;
57
				while (in.available() > 0) {
58
					int i = in.read(tmp, 0, 1024);
59
					if (i < 0)
60
						break;
61
					
62
					outCmd= new String(tmp, 0, i);
63
					//System.out.println(toto);
64
					System.out.println(outCmd);
65
					//System.out.print(new String(tmp, 0, i));
66
					
67
				}
68
				if (channel.isClosed()) {
69
					break;
70
				}
71
				try {
72
					Thread.sleep(1000);
73
				} catch (Exception ee) {
74
					System.out.println(ee);
75
				}
76
			}
77
			channel.disconnect();
78
					
79
		} catch (JSchException e) {
80
			// TODO Auto-generated catch block
81
			e.printStackTrace();
82
			return null;
83
		} catch (IOException e) {
84
			// TODO Auto-generated catch block
85
			e.printStackTrace();
86
			return null;
87
		}
88
		/*for (int cpt=0;cpt < outCmd.length;cpt++ ) {
89
			System.out.println(outCmd[cpt]);
90
		}*/
91
		System.out.println(outCmd);
92
		return outCmd;
93
	}
94

  
95
 
96
  
97
  public String zfsGetAllVolume(String volume){
98
	 return connect("zfs list");
99
	
100
//	  return this.executeCmd("/sbin/zfs get all "+volume);
101
  }
102
	public String getSshHost() {
103
		return sshHost;
104
	}
105

  
106
	public void setSshHost(String sshHost) {
107
		this.sshHost = sshHost;
108
	}
109

  
110
	public String getUserLogin() {
111
		return userLogin;
112
	}
113

  
114
	public void setUserLogin(String userLogin) {
115
		this.userLogin = userLogin;
116
	}
117

  
118

  
119
	public int getSshPort() {
120
		return sshPort;
121
	}
122

  
123

  
124
	public void setSshPort(int sshPort) {
125
		this.sshPort = sshPort;
126
	}
127

  
128
	public Session getSession() {
129
		return session;
130
	}
131

  
132
	public void setSession(Session session) {
133
		this.session = session;
134
	}
135

  
136
	public String getUserPassword() {
137
		return userPassword;
138
	}
139

  
140
	public void setUserPassword(String userPassword) {
141
		this.userPassword = userPassword;
142
	}
143

  
144
}
src/gZFS/zfsVolandFs.java (revision 53)
1
package gZFS;
2

  
3
import java.util.ArrayList;
4
import java.util.Hashtable;
5
import java.util.List;
6
import java.util.Properties;
7

  
8
import org.eclipse.ui.internal.Model;
9

  
10
public class zfsVolandFs {
11
	
12
	
13
}
src/gZFS/guiConfig.java (revision 53)
1
package gZFS;
2

  
3
public class guiConfig {
4

  
5
}
src/gZFS/zfs.java (revision 53)
1
/*******************************************************************
2
 * 
3
 * Copyright (C) 2013 Kevin Reverchon
4
 * This file/program is part of gZFS free software
5
 * See COPYING file for details
6
 * 
7
 *******************************************************************/
1 8
package gZFS;
2 9

  
3 10
import java.io.BufferedReader;
src/gZFS/zpool.java (revision 53)
1
/*******************************************************************
2
 * 
3
 * Copyright (C) 2013 Kevin Reverchon
4
 * This file/program is part of gZFS free software
5
 * See COPYING file for details
6
 * 
7
 *******************************************************************/
1 8
package gZFS;
2 9

  
3 10
import java.util.ArrayList;
src/gZFS/ziscsi.java (revision 53)
1
/*******************************************************************
2
 * 
3
 * Copyright (C) 2013 Kevin Reverchon
4
 * This file/program is part of gZFS free software
5
 * See COPYING file for details
6
 * 
7
 *******************************************************************/
1 8
package gZFS;
2 9

  
3 10
import java.util.ArrayList;
src/gZFS/guiProgress.java (revision 53)
1
/*******************************************************************
2
 * 
3
 * Copyright (C) 2013 Kevin Reverchon
4
 * This file/program is part of gZFS free software
5
 * See COPYING file for details
6
 * 
7
 *******************************************************************/
1 8
package gZFS;
2 9

  
3 10
import org.eclipse.swt.SWT;
4
import org.eclipse.swt.graphics.Rectangle;
5
import org.eclipse.swt.layout.GridData;
6
import org.eclipse.swt.layout.GridLayout;
7
import org.eclipse.swt.widgets.Composite;
8 11
import org.eclipse.swt.widgets.Display;
9
import org.eclipse.swt.widgets.Monitor;
10 12
import org.eclipse.swt.widgets.ProgressBar;
11 13
import org.eclipse.swt.widgets.Shell;
12
import org.eclipse.swt.widgets.Label;
13 14
import org.eclipse.swt.layout.FillLayout;
14 15

  
15 16
public class guiProgress {
......
40 41
	    public void close(){
41 42
	    	s.dispose();
42 43
	    }
43
	}
44
		
45
	 
44
	}
src/gZFS/zraid.java (revision 53)
1
/*******************************************************************
2
 * 
3
 * Copyright (C) 2013 Kevin Reverchon
4
 * This file/program is part of gZFS free software
5
 * See COPYING file for details
6
 * 
7
 *******************************************************************/
1 8
package gZFS;
2 9

  
3 10
import java.util.Hashtable;
src/gZFS/zsnapshots.java (revision 53)
1
/*******************************************************************
2
 * 
3
 * Copyright (C) 2013 Kevin Reverchon
4
 * This file/program is part of gZFS free software
5
 * See COPYING file for details
6
 * 
7
 *******************************************************************/
1 8
package gZFS;
2 9

  
3 10
import java.text.DateFormat;
src/gZFS/guiTrt.java (revision 53)
1
/*******************************************************************
2
 * 
3
 * Copyright (C) 2013 Kevin Reverchon
4
 * This file/program is part of gZFS free software
5
 * See COPYING file for details
6
 * 
7
 *******************************************************************/
1 8
package gZFS;
2 9

  
3 10
import java.util.Arrays;
src/gZFS/config.properties (revision 53)
1
#
2
#
3
# Copyright (C) 2013 Kevin Reverchon
4
# This file/program is part of gZFS free software
5
# See COPYING file for details
6
####################################################
7

  
8

  
1 9
biniscsigetconf=/sbin/get-conf-iscsi-volume
2 10
bingetprovisionedspace=/sbin/get-provisioned-space
3 11
bingetconfsnapshot=/sbin/get-conf-snapshot
src/gZFS/gui.java (revision 53)
1

  
2
/*******************************************************************
3
 * 
4
 * Copyright (C) 2013 Kevin Reverchon
5
 * This file/program is part of gZFS free software
6
 * See COPYING file for details
7
 * 
8
 *******************************************************************/
9

  
10

  
11

  
1 12
package gZFS;
2 13

  
3 14
import java.util.ArrayList;
src/gZFS/main.java (revision 53)
1
/*******************************************************************
2
 * 
3
 * Copyright (C) 2013 Kevin Reverchon
4
 * This file/program is part of gZFS free software
5
 * See COPYING file for details
6
 * 
7
 *******************************************************************/
1 8
package gZFS;
2 9

  
3 10
import org.apache.log4j.Logger;
src/gZFS/zdisk.java (revision 53)
1
/*******************************************************************
2
 * 
3
 * Copyright (C) 2013 Kevin Reverchon
4
 * This file/program is part of gZFS free software
5
 * See COPYING file for details
6
 * 
7
 *******************************************************************/
1 8
package gZFS;
2 9

  
3 10
import java.util.Hashtable;
src/gZFS/zProperties.java (revision 53)
1
/*******************************************************************
2
 * 
3
 * Copyright (C) 2013 Kevin Reverchon
4
 * This file/program is part of gZFS free software
5
 * See COPYING file for details
6
 * 
7
 *******************************************************************/
1 8
package gZFS;
2 9

  
3 10
import java.util.ArrayList;
src/gZFS/log4j.properties (revision 53)
1
# Licensed to the Apache Software Foundation (ASF) under one or more
1
 # Licensed to the Apache Software Foundation (ASF) under one or more
2 2
# contributor license agreements.  See the NOTICE file distributed with
3 3
# this work for additional information regarding copyright ownership.
4 4
# The ASF licenses this file to You under the Apache License, Version 2.0
src/gZFS/zvol.java (revision 53)
1
/*******************************************************************
2
 * 
3
 * Copyright (C) 2013 Kevin Reverchon
4
 * This file/program is part of gZFS free software
5
 * See COPYING file for details
6
 * 
7
 *******************************************************************/
1 8
package gZFS;
2 9

  
3 10
import java.util.ArrayList;
src/gZFS/zreplicas.java (revision 53)
1
/*******************************************************************
2
 * 
3
 * Copyright (C) 2013 Kevin Reverchon
4
 * This file/program is part of gZFS free software
5
 * See COPYING file for details
6
 * 
7
 *******************************************************************/
1 8
package gZFS;
2 9

  
3 10
import java.text.DateFormat;
src/gZFS/zserver.java (revision 53)
1
/*******************************************************************
2
 * 
3
 * Copyright (C) 2013 Kevin Reverchon
4
 * This file/program is part of gZFS free software
5
 * See COPYING file for details
6
 * 
7
 *******************************************************************/
1 8
package gZFS;
2 9

  
3 10
import java.io.File;

Formats disponibles : Unified diff