root / src / gZFS / zfs.java @ 56
Historique | Voir | Annoter | Télécharger (55,6 ko)
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 |
package gZFS; |
9 |
|
10 |
import java.io.BufferedReader; |
11 |
import java.io.File; |
12 |
import java.io.FileInputStream; |
13 |
import java.io.FileNotFoundException; |
14 |
import java.io.IOException; |
15 |
import java.io.InputStream; |
16 |
import java.io.InputStreamReader; |
17 |
import java.io.OutputStream; |
18 |
import java.net.URL; |
19 |
import java.text.ParseException; |
20 |
import java.text.SimpleDateFormat; |
21 |
import java.util.ArrayList; |
22 |
import java.util.Arrays; |
23 |
import java.util.Hashtable; |
24 |
import java.util.List; |
25 |
import java.util.Properties; |
26 |
|
27 |
import org.apache.log4j.Level; |
28 |
import org.apache.log4j.Logger; |
29 |
import org.jfree.util.Log; |
30 |
|
31 |
import com.ibm.icu.math.BigDecimal; |
32 |
import com.jcraft.jsch.ChannelExec; |
33 |
import com.jcraft.jsch.JSch; |
34 |
import com.jcraft.jsch.JSchException; |
35 |
import com.jcraft.jsch.Session; |
36 |
|
37 |
public class zfs { |
38 |
|
39 |
|
40 |
private Logger log = Logger.getLogger(getClass().getPackage().getName()+" "+getClass().getCanonicalName()); |
41 |
|
42 |
private String userLogin; |
43 |
private String userPassword; |
44 |
private String sshHost; |
45 |
private int sshPort; |
46 |
private Session session;
|
47 |
private Hashtable<String,Session> cacheSession = new Hashtable<String, Session>(); |
48 |
private JSch jsch = new JSch(); |
49 |
private String outCmd = null ; |
50 |
private StringBuilder outErr ; |
51 |
private List<Object> zpoolList = new ArrayList<Object>(); |
52 |
private List<Object> zfsList = new ArrayList<Object>(); |
53 |
private List<Object> zfsListSnapshots = new ArrayList<Object>(); |
54 |
private List<Object> zfsGetAllList = new ArrayList<Object>(); |
55 |
private List<Object> iscsiListConfigVol = new ArrayList<Object>(); |
56 |
private Hashtable<String,Object> modelZfsVolAndFS = new Hashtable<String, Object>(); |
57 |
private Hashtable<String,Object> error = new Hashtable<String, Object>(); |
58 |
private Hashtable<String,zdisk> hashDisks = new Hashtable<String, zdisk>(); |
59 |
private Hashtable<String,zraid> hashZRaid = new Hashtable<String, zraid>(); |
60 |
|
61 |
private zpool zpool;
|
62 |
private zserver zserver;
|
63 |
private zvol zvol ;
|
64 |
private zsnapshots zsnapshots;
|
65 |
private zreplicas zreplicas;
|
66 |
private ziscsi ziscsi;
|
67 |
private zdisk zdisk;
|
68 |
private zraid zraid;
|
69 |
private List<Object> sidList; |
70 |
private List<Object> ipList; |
71 |
private Properties prop = new Properties(); |
72 |
zfs(){ |
73 |
this.loadConfig();
|
74 |
this.setZserver();
|
75 |
this.setZpool();
|
76 |
this.setZdisk();
|
77 |
this.setZvol();
|
78 |
this.setZsnapshots();
|
79 |
this.setZreplicas();
|
80 |
this.setZiscsi();
|
81 |
this.setZraid();
|
82 |
log.setLevel((Level) Level.DEBUG); |
83 |
} |
84 |
|
85 |
public void setZvol(){ |
86 |
zvol= new zvol();
|
87 |
} |
88 |
|
89 |
public gZFS.zvol getZvol(){
|
90 |
return zvol;
|
91 |
} |
92 |
|
93 |
public boolean connectServer(String host, int port, String userLogin, String userPasswd){ |
94 |
try {
|
95 |
setSession(jsch.getSession(userLogin, host, port)); |
96 |
session.setPassword(userPasswd); |
97 |
Properties config = new Properties(); |
98 |
config.put("StrictHostKeyChecking", "no"); |
99 |
session.setConfig(config); |
100 |
session.connect(); |
101 |
getCacheSession().put(host, session); |
102 |
if ( session.isConnected()){
|
103 |
log.debug("Connected");
|
104 |
return true; |
105 |
}else{
|
106 |
log.debug("not Connected");
|
107 |
return false; |
108 |
} |
109 |
|
110 |
} catch (JSchException e) {
|
111 |
// TODO Auto-generated catch block
|
112 |
e.printStackTrace(); |
113 |
return false; |
114 |
} |
115 |
} |
116 |
|
117 |
public void disconnectAllServer(){ |
118 |
String[] keysProp = (String[]) this.getCacheSession().keySet().toArray(new String[0]); |
119 |
Arrays.sort(keysProp);
|
120 |
for ( int i=0;i<keysProp.length;i++){ |
121 |
String keyProp = keysProp[i];
|
122 |
this.setSession(getCacheSession().get(keyProp));
|
123 |
session.disconnect(); |
124 |
getCacheSession().remove(keyProp); |
125 |
} |
126 |
} |
127 |
public void disconnectServer(){ |
128 |
this.setSession(getCacheSession().get(this.getZserver().zProperties.get("serverIP").getValue())); |
129 |
session.disconnect(); |
130 |
getCacheSession().remove(this.getZserver().zProperties.get("serverIP").getValue()); |
131 |
} |
132 |
|
133 |
|
134 |
public Boolean executeCmd(String cmd) { |
135 |
this.setOutCmd(""); |
136 |
try {
|
137 |
|
138 |
this.setSession(getCacheSession().get(this.getZserver().zProperties.get("serverIP").getValue())); |
139 |
log.debug("executeCMD : "+this.getZserver().zProperties.get("serverIP").getValue()); |
140 |
ChannelExec channel = (ChannelExec) session.openChannel("exec");
|
141 |
//((ChannelExec) channel).setCommand("lqs");
|
142 |
((ChannelExec) channel).setCommand(cmd); |
143 |
InputStream in = channel.getInputStream();
|
144 |
OutputStream out = channel.getOutputStream();
|
145 |
((ChannelExec) channel).setErrStream(System.err);
|
146 |
InputStream err = channel.getErrStream();
|
147 |
channel.connect(); |
148 |
log.debug("executeCmd "+cmd);
|
149 |
if (!cmd.equals("/sbin/show-infodisk-cache")){ |
150 |
BufferedReader reader = new BufferedReader(new InputStreamReader(err)); |
151 |
outErr = new StringBuilder(); |
152 |
String line;
|
153 |
while ((line = reader.readLine()) != null) { |
154 |
outErr.append(line); |
155 |
} |
156 |
} |
157 |
|
158 |
byte[] tmp = new byte[4096]; |
159 |
|
160 |
while (true) { |
161 |
|
162 |
int ind = 0; |
163 |
while (in.available() > 0) { |
164 |
int i = in.read(tmp, 0, 4096); |
165 |
if (i < 0) |
166 |
break;
|
167 |
|
168 |
this.setOutCmd(this.getOutCmd()+new String(tmp, 0, i)); |
169 |
} |
170 |
if (channel.isClosed()) {
|
171 |
break;
|
172 |
} |
173 |
try {
|
174 |
Thread.sleep(900); |
175 |
} catch (Exception ee) { |
176 |
log.debug(ee); |
177 |
} |
178 |
} |
179 |
channel.disconnect(); |
180 |
|
181 |
} catch (JSchException e) {
|
182 |
// TODO Auto-generated catch block
|
183 |
log.debug("executeCMD "+e.getMessage());
|
184 |
e.printStackTrace(); |
185 |
return false; |
186 |
} catch (IOException e) { |
187 |
// TODO Auto-generated catch block
|
188 |
log.debug("executeCmd "+e.getMessage());
|
189 |
e.printStackTrace(); |
190 |
return false; |
191 |
} |
192 |
/*for (int cpt=0;cpt < outCmd.length;cpt++ ) {
|
193 |
log.debug(outCmd[cpt]);
|
194 |
}*/
|
195 |
//log.debug(this.getOutCmd());
|
196 |
return true; |
197 |
} |
198 |
|
199 |
public Boolean zfsGetAllVolume(String volName){ |
200 |
zfsGetAllList.clear(); |
201 |
//clear this.getZvol properties
|
202 |
String[] keysProp = (String[]) this.getZvol().zProperties.keySet().toArray(new String[0]); |
203 |
Arrays.sort(keysProp);
|
204 |
for ( int i=0;i<keysProp.length;i++){ |
205 |
String keyProp = keysProp[i];
|
206 |
this.getZvol().zProperties.get(keyProp).setMultivalues(null); |
207 |
this.getZvol().zProperties.get(keyProp).setValue("");; |
208 |
|
209 |
} |
210 |
if ( this.executeCmd("/sbin/zfs get all "+volName) ){ |
211 |
log.debug(this.getOutCmd());
|
212 |
String[] Tsplit = this.getOutCmd().split("\n"); |
213 |
for (int cpt=1;cpt<Tsplit.length;cpt++){ |
214 |
|
215 |
log.debug(Tsplit[cpt].replaceAll(volName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " ")); |
216 |
String[] TsplitLine = Tsplit[cpt].replaceAll(volName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " ").split(" "); |
217 |
log.debug(TsplitLine[0]);
|
218 |
if ( "creation".equalsIgnoreCase(TsplitLine[0])){ |
219 |
this.getZvol().zProperties.get("creation").setValue(TsplitLine[1]+" "+TsplitLine[2]+" "+TsplitLine[3]+" "+TsplitLine[4]+" "+TsplitLine[5]);; |
220 |
}else{
|
221 |
//this.getZvol().zProperties.containsKey(TsplitLine[0]);
|
222 |
if (this.getZvol().zProperties.containsKey(TsplitLine[0])){ |
223 |
this.getZvol().zProperties.get(TsplitLine[0]).setValue(TsplitLine[1]); |
224 |
log.debug("ZFS DEBUG "+this.getZvol().zProperties.get(TsplitLine[0]).getNameProperty()+" "+ this.getZvol().zProperties.get(TsplitLine[0]).getValue()); |
225 |
} |
226 |
} |
227 |
} |
228 |
this.getZvol().zProperties.get("name").setValue(volName); |
229 |
//this.getZvol().zProperties.get("name").setValue(volName);
|
230 |
} |
231 |
|
232 |
|
233 |
return true; |
234 |
} |
235 |
public void zfsGetInfoByProperty(String volName, String propertyName){ |
236 |
zfsGetAllList.clear(); |
237 |
if ( this.executeCmd("/sbin/zfs get "+propertyName+" -H "+volName) ){ |
238 |
log.debug(this.getOutCmd());
|
239 |
String[] Tsplit = this.getOutCmd().split("\n"); |
240 |
for (int cpt=0;cpt<Tsplit.length;cpt++){ |
241 |
|
242 |
log.debug(Tsplit[cpt].replaceAll(volName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " ")); |
243 |
String[] TsplitLine = Tsplit[cpt].replaceAll(volName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " ").split(" "); |
244 |
log.debug(TsplitLine[0]);
|
245 |
if ( "creation".equalsIgnoreCase(TsplitLine[0])){ |
246 |
this.getZvol().zProperties.get("creation").setValue(TsplitLine[1]+" "+TsplitLine[2]+" "+TsplitLine[3]+" "+TsplitLine[4]+" "+TsplitLine[5]);; |
247 |
}else{
|
248 |
//this.getZvol().zProperties.containsKey(TsplitLine[0]);
|
249 |
if (this.getZvol().zProperties.containsKey(TsplitLine[0])){ |
250 |
this.getZvol().zProperties.get(TsplitLine[0]).setValue(TsplitLine[1]); |
251 |
log.debug("ZFS DEBUG "+this.getZvol().zProperties.get(TsplitLine[0]).getNameProperty()+" "+ this.getZvol().zProperties.get(TsplitLine[0]).getValue()); |
252 |
} |
253 |
} |
254 |
} |
255 |
this.getZvol().zProperties.get("name").setValue(volName); |
256 |
//this.getZvol().zProperties.get("name").setValue(volName);
|
257 |
} |
258 |
|
259 |
} |
260 |
|
261 |
|
262 |
public Boolean zpoolGetAll(String zpoolName){ |
263 |
zfsGetAllList.clear(); |
264 |
//clear this.getZvol properties
|
265 |
String[] keysProp = (String[]) this.getZpool().zProperties.keySet().toArray(new String[0]); |
266 |
Arrays.sort(keysProp);
|
267 |
for ( int i=0;i<keysProp.length;i++){ |
268 |
String keyProp = keysProp[i];
|
269 |
this.getZpool().zProperties.get(keyProp).setMultivalues(null); |
270 |
this.getZpool().zProperties.get(keyProp).setValue("");; |
271 |
|
272 |
} |
273 |
if ( this.executeCmd("/sbin/zpool get all "+zpoolName) ){ |
274 |
log.debug(this.getOutCmd());
|
275 |
String[] Tsplit = this.getOutCmd().split("\n"); |
276 |
for (int cpt=1;cpt<Tsplit.length;cpt++){ |
277 |
|
278 |
log.debug(Tsplit[cpt].replaceAll(zpoolName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " ")); |
279 |
String[] TsplitLine = Tsplit[cpt].replaceAll(zpoolName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " ").split(" "); |
280 |
log.debug(TsplitLine[0]);
|
281 |
if ( "creation".equalsIgnoreCase(TsplitLine[0])){ |
282 |
this.getZpool().zProperties.get("creation").setValue(TsplitLine[1]+" "+TsplitLine[2]+" "+TsplitLine[3]+" "+TsplitLine[4]+" "+TsplitLine[5]);; |
283 |
}else{
|
284 |
//this.getZpool().zProperties.containsKey(TsplitLine[0]);
|
285 |
if (this.getZpool().zProperties.containsKey(TsplitLine[0])){ |
286 |
this.getZpool().zProperties.get(TsplitLine[0]).setValue(TsplitLine[1]); |
287 |
log.debug("ZFS DEBUG "+this.getZpool().zProperties.get(TsplitLine[0]).getNameProperty()+" "+ this.getZpool().zProperties.get(TsplitLine[0]).getValue()); |
288 |
} |
289 |
} |
290 |
} |
291 |
this.getZpool().zProperties.get("name").setValue(zpoolName); |
292 |
//this.getZvol().zProperties.get("name").setValue(volName);
|
293 |
|
294 |
this.getZpoolRealUseableSpace(zpoolName);
|
295 |
log.debug("zpoolGetAll "+this.getZpool().zProperties.get("realuseablespace").getValue()); |
296 |
this.getZpoolProvisionedSpace(zpoolName);
|
297 |
if ( this.executeCmd(this.getZserver().zProperties.get("binzpoolgetstate").getValue()+" -n "+this.getZpool().zProperties.get("name").getValue()) ){ |
298 |
log.debug(this.getOutCmd());
|
299 |
String[] TsplitOut = this.getOutCmd().split("\n"); |
300 |
for (int cpt=1;cpt<TsplitOut.length;cpt++){ |
301 |
|
302 |
String[] TsplitLineState= TsplitOut[cpt].replaceAll("\n","").split(":"); |
303 |
log.debug(TsplitLineState[0]);
|
304 |
//this.getZpool().zProperties.containsKey(TsplitLine[0]);
|
305 |
if (this.getZpool().zProperties.containsKey(TsplitLineState[0])){ |
306 |
this.getZpool().zProperties.get(TsplitLineState[0]).setValue(TsplitLineState[1]); |
307 |
log.debug("ZFS DEBUG "+this.getZpool().zProperties.get(TsplitLineState[0]).getNameProperty()+" "+ this.getZpool().zProperties.get(TsplitLineState[0]).getValue()); |
308 |
} |
309 |
} |
310 |
this.getZpool().zProperties.get("name").setValue(zpoolName); |
311 |
} |
312 |
|
313 |
} |
314 |
|
315 |
|
316 |
return true; |
317 |
} |
318 |
|
319 |
|
320 |
public List<Object> zpoolList(){ |
321 |
zpoolList.clear(); |
322 |
|
323 |
if ( this.executeCmd("/sbin/zpool list -H") ){ |
324 |
String[] Tsplit = this.getOutCmd().split("\n"); |
325 |
for (int cpt=0;cpt<Tsplit.length;cpt++){ |
326 |
log.debug(Tsplit[cpt].split("\\s+")[0] ); |
327 |
zpoolList.add(Tsplit[cpt].split("\\s+")[0]); |
328 |
//zpoolNames[ind] = Tsplit[cpt].split("\\s+")[0];
|
329 |
} |
330 |
} |
331 |
return zpoolList;
|
332 |
} |
333 |
|
334 |
public List<Object> zfsListSnapshotsByVolFS(String nameVolFS){ |
335 |
zfsListSnapshots.clear(); |
336 |
|
337 |
log.debug("zfs list -H -r -t snapshot -oname,used,referenced "+nameVolFS);
|
338 |
if ( this.executeCmd("/sbin/zfs list -H -r -t snapshot "+nameVolFS) ){ |
339 |
if ( this.getOutCmd().length() >0){ |
340 |
String[] Tsplit = this.getOutCmd().split("\n"); |
341 |
for (int cpt=0;cpt<Tsplit.length;cpt++){ |
342 |
log.debug(Tsplit[cpt].split("\\s+")[0] ); |
343 |
zfsListSnapshots.add(Tsplit[cpt].split("\\s+")[0]); |
344 |
//zpoolNames[ind] = Tsplit[cpt].split("\\s+")[0];
|
345 |
} |
346 |
} |
347 |
|
348 |
} |
349 |
return zfsListSnapshots;
|
350 |
} |
351 |
|
352 |
public Boolean getIscsiListConfigVol(String nameVolFS){ |
353 |
sidList = new ArrayList<Object>(); |
354 |
ipList = new ArrayList<Object>(); |
355 |
//sidList=null;
|
356 |
//ipList=null;
|
357 |
log.debug("get-conf-iscsi-volume nameVolFS");
|
358 |
//Reset ziscsi object
|
359 |
this.setZiscsi();
|
360 |
if ( this.executeCmd("/sbin/get-conf-iscsi-volume "+nameVolFS) ){ |
361 |
String[] Tsplit = this.getOutCmd().split("\n"); |
362 |
for (int cpt=0;cpt<Tsplit.length;cpt++){ |
363 |
|
364 |
String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", " ").split(" "); |
365 |
if ( "sid".equalsIgnoreCase(TsplitLine[0])){ |
366 |
sidList.add(TsplitLine[1]);
|
367 |
}else{
|
368 |
if ("sessionIP".equalsIgnoreCase(TsplitLine[0])){ |
369 |
ipList.add(TsplitLine[1]);
|
370 |
log.debug("sessionIP "+TsplitLine[1]); |
371 |
}else{
|
372 |
//this.getZvol().zProperties.containsKey(TsplitLine[0]);
|
373 |
if (this.getZiscsi().zProperties.containsKey(TsplitLine[0])&& TsplitLine.length ==2){ |
374 |
this.getZiscsi().zProperties.get(TsplitLine[0]).setValue(TsplitLine[1]); |
375 |
} |
376 |
} |
377 |
} |
378 |
} |
379 |
this.getZiscsi().zProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue()); |
380 |
this.getZiscsi().zProperties.get("sid").setMultivalues(sidList); |
381 |
this.getZiscsi().zProperties.get("sessionIP").setMultivalues(ipList); |
382 |
return true; |
383 |
}else{
|
384 |
return false; |
385 |
} |
386 |
} |
387 |
|
388 |
|
389 |
public void getZpoolProvisionedSpace(String zpoolName){ |
390 |
log.debug("getZpoolProvisionedSpace "+this.getZpool().zProperties.get("realuseablespace").getValue()); |
391 |
if ( this.executeCmd("/sbin/get-provisioned-space "+zpoolName) ){ |
392 |
log.debug(this.getOutCmd());
|
393 |
String[] Tsplit = this.getOutCmd().split("\n"); |
394 |
log.debug("getZpoolProvisionedSpace "+this.getZpool().zProperties.get("realuseablespace").getValue().substring((this.getZpool().zProperties.get("realuseablespace").getValue().length()))); |
395 |
|
396 |
String refUnit = this.getZpool().zProperties.get("realuseablespace").getValue().substring((this.getZpool().zProperties.get("realuseablespace").getValue().length()-1), (this.getZpool().zProperties.get("realuseablespace").getValue().length())); |
397 |
|
398 |
|
399 |
float totalProvisioned=0; |
400 |
log.debug(String.valueOf(totalProvisioned)+refUnit);
|
401 |
for (int cpt=0;cpt<Tsplit.length;cpt++){ |
402 |
|
403 |
log.debug(Tsplit[cpt].replaceAll(zpoolName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " ")); |
404 |
String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", " ").split(" "); |
405 |
log.debug(TsplitLine[0]);
|
406 |
totalProvisioned=totalProvisioned+this.convertInReferenceUnit(TsplitLine[2], refUnit); |
407 |
|
408 |
} |
409 |
log.debug("getZpoolProvisionedSpace "+String.valueOf(totalProvisioned)+refUnit); |
410 |
this.getZpool().zProperties.get("provisionspace").setValue(String.valueOf(BigDecimal.valueOf(totalProvisioned).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())+refUnit); |
411 |
//this.getZvol().zProperties.get("name").setValue(volName);
|
412 |
log.debug(String.valueOf(totalProvisioned)+refUnit);
|
413 |
|
414 |
|
415 |
} |
416 |
} |
417 |
|
418 |
public void getZpoolRealUseableSpace(String zpoolName){ |
419 |
|
420 |
this.zfsGetInfoByProperty(zpoolName, "used"); |
421 |
this.zfsGetInfoByProperty(zpoolName, "available"); |
422 |
log.debug("getZpoolRealUseableSpace "+this.getZvol().zProperties.get("used").getValue()); |
423 |
String refUnit = this.getZvol().zProperties.get("used").getValue().substring(this.getZvol().zProperties.get("used").getValue().length()-1, this.getZvol().zProperties.get("used").getValue().length()); |
424 |
if (!refUnit.equalsIgnoreCase("T")&&!refUnit.equalsIgnoreCase("G")){ |
425 |
refUnit = this.getZvol().zProperties.get("available").getValue().substring(this.getZvol().zProperties.get("available").getValue().length()-1, this.getZvol().zProperties.get("available").getValue().length()); |
426 |
} |
427 |
log.debug("getZpoolRealUseableSpace "+refUnit);
|
428 |
float usedSize = this.convertInReferenceUnit(this.getZvol().zProperties.get("used").getValue(), refUnit); |
429 |
float availableSize = this.convertInReferenceUnit(this.getZvol().zProperties.get("available").getValue(), refUnit); |
430 |
log.debug("getZpoolRealUseableSpace "+String.valueOf(usedSize+availableSize)+refUnit); |
431 |
this.getZpool().zProperties.get("realuseablespace").setValue(String.valueOf(BigDecimal.valueOf(usedSize+availableSize).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())+refUnit); |
432 |
|
433 |
} |
434 |
|
435 |
public void getZpoolStatus(){ |
436 |
error.clear(); |
437 |
if ( !"".equalsIgnoreCase(getZpool().zProperties.get("name").getValue())){ |
438 |
|
439 |
log.debug("getZpoolStatus");
|
440 |
hashDisks.clear(); |
441 |
hashZRaid.clear(); |
442 |
this.setZraid();
|
443 |
if ( this.executeCmd("/sbin/show-infodisk-cache")){ |
444 |
log.debug("getZpoolStatus");
|
445 |
this.setZdisk();
|
446 |
if ( outErr.length() ==0){ |
447 |
//log.debug(this.getOutCmd());
|
448 |
String namePool=""; |
449 |
if (this.getOutCmd().length()>0) { |
450 |
|
451 |
String[] Tsplit = this.getOutCmd().split("\n"); |
452 |
for (int cpt=0;cpt<Tsplit.length;cpt++){ |
453 |
String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", "").replaceAll("'", "").split(":"); |
454 |
String propertyDisk=TsplitLine[0].toLowerCase(); |
455 |
String valuePropertyDisk=""; |
456 |
|
457 |
if (TsplitLine.length==2){ |
458 |
valuePropertyDisk=TsplitLine[1];
|
459 |
} |
460 |
|
461 |
if (Tsplit[cpt].equalsIgnoreCase("#infoDisk#")){ |
462 |
if (!this.getZdisk().zProperties.get("path").getValue().equalsIgnoreCase("") ){ |
463 |
hashDisks.put("disk"+cpt, this.getZdisk()); |
464 |
log.debug(this.getZraid().zProperties.get("poolname").getValue()+"-"+this.getZraid().zProperties.get("raidtype").getValue()+"-"+this.getZraid().zProperties.get("raidid").getValue()); |
465 |
if (!hashZRaid.containsKey(this.getZraid().zProperties.get("poolname").getValue()+"-"+this.getZraid().zProperties.get("raidtype").getValue()+"-"+this.getZraid().zProperties.get("raidid").getValue())){ |
466 |
this.getZraid().zProperties.get("name").setValue(this.getZraid().zProperties.get("poolname").getValue()+"-"+this.getZraid().zProperties.get("raidtype").getValue()+"-"+this.getZraid().zProperties.get("raidid").getValue()); |
467 |
hashZRaid.put(this.getZraid().zProperties.get("poolname").getValue()+"-"+this.getZraid().zProperties.get("raidtype").getValue()+"-"+this.getZraid().zProperties.get("raidid").getValue(), this.getZraid()); |
468 |
this.setZraid();
|
469 |
} |
470 |
} |
471 |
this.setZdisk();
|
472 |
}else{
|
473 |
if (TsplitLine.length==2){ |
474 |
valuePropertyDisk=TsplitLine[1];
|
475 |
|
476 |
if (this.getZdisk().zProperties.containsKey(propertyDisk)){ |
477 |
this.getZdisk().zProperties.get(propertyDisk).setValue(valuePropertyDisk);
|
478 |
//log.debug(propertyDisk+" : "+valuePropertyDisk);
|
479 |
} |
480 |
|
481 |
if (this.getZraid().zProperties.containsKey(propertyDisk)){ |
482 |
this.getZraid().zProperties.get(propertyDisk).setValue(valuePropertyDisk);
|
483 |
|
484 |
log.debug(propertyDisk+" : "+valuePropertyDisk);
|
485 |
} |
486 |
} |
487 |
} |
488 |
|
489 |
} |
490 |
} |
491 |
} |
492 |
} |
493 |
log.debug("getZpoolStatus : "+hashDisks.size());
|
494 |
log.debug("getZpoolStatus : "+hashZRaid.size());
|
495 |
this.setHashDisks(hashDisks);
|
496 |
this.setHashZRaid(hashZRaid);
|
497 |
|
498 |
} |
499 |
|
500 |
} |
501 |
|
502 |
|
503 |
public void getInfoDisk(){ |
504 |
if ( this.executeCmd(this.getZserver().zProperties.get("bingetdiskinfo").getValue() +" "+this.getZdisk().zProperties.get("path").getValue())){ |
505 |
log.debug("getZpoolStatus");
|
506 |
if ( outErr.length() ==0){ |
507 |
log.debug(this.getOutCmd());
|
508 |
if (this.getOutCmd().length()>0) { |
509 |
String dataType=""; |
510 |
String[] Tsplit = this.getOutCmd().split("\n"); |
511 |
|
512 |
|
513 |
for (int cpt=0;cpt<Tsplit.length;cpt++){ |
514 |
|
515 |
String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", "").replaceAll("'", "").split(":"); |
516 |
String propertyDisk=TsplitLine[0]; |
517 |
String valuePropertyDisk=""; |
518 |
|
519 |
|
520 |
} |
521 |
} |
522 |
} |
523 |
} |
524 |
} |
525 |
|
526 |
|
527 |
public void getZsnapshotConfig(){ |
528 |
log.debug("getZsnapshotConfig");
|
529 |
this.setZsnapshots();
|
530 |
if ( this.executeCmd(this.getZserver().zProperties.get("bingetconfsnapshot").getValue()+" "+this.getZvol().zProperties.get("name").getValue()) ){ |
531 |
if ( outErr.length() ==0){ |
532 |
log.debug(this.getOutCmd());
|
533 |
if (this.getOutCmd().length()>0) { |
534 |
String[] Tsplit = this.getOutCmd().split("\n"); |
535 |
for (int cpt=0;cpt<Tsplit.length;cpt++){ |
536 |
String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", " ").split("="); |
537 |
log.debug(TsplitLine.length); |
538 |
log.debug(TsplitLine[0]+" "+TsplitLine[1]); |
539 |
|
540 |
this.zsnapshots.zSchedulerProperties.get(TsplitLine[0]).setValue(TsplitLine[1]); |
541 |
} |
542 |
} |
543 |
|
544 |
}else{
|
545 |
log.debug(this.getOutCmd());
|
546 |
this.setZsnapshots();
|
547 |
this.getZsnapshots().zSchedulerProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue()); |
548 |
this.getZsnapshots().zSchedulerProperties.get("type").setValue(this.getZvol().zProperties.get("type").getValue()); |
549 |
} |
550 |
} |
551 |
this.getZsnapshots().zSchedulerProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue()); |
552 |
this.getZsnapshots().zSchedulerProperties.get("type").setValue(this.getZvol().zProperties.get("type").getValue()); |
553 |
} |
554 |
|
555 |
public void getZreplicaConfig(){ |
556 |
log.debug("getZreplicaConfig");
|
557 |
this.setZreplicas();
|
558 |
log.debug(this.getZserver().zProperties.get("bingetconfreplica").getValue()+" "+this.getZvol().zProperties.get("name").getValue()); |
559 |
if ( this.executeCmd(this.getZserver().zProperties.get("bingetconfreplica").getValue()+" "+this.getZvol().zProperties.get("name").getValue()) ){ |
560 |
if ( outErr.length() ==0){ |
561 |
log.debug(this.getOutCmd());
|
562 |
if (this.getOutCmd().length()>0) { |
563 |
String[] Tsplit = this.getOutCmd().split("\n"); |
564 |
for (int cpt=0;cpt<Tsplit.length;cpt++){ |
565 |
String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", " ").split("="); |
566 |
log.debug(TsplitLine.length); |
567 |
if (TsplitLine.length>1){ |
568 |
log.debug(TsplitLine[0]+" "+TsplitLine[1]); |
569 |
this.zreplicas.zSchedulerProperties.get(TsplitLine[0]).setValue(TsplitLine[1]); |
570 |
} |
571 |
} |
572 |
} |
573 |
|
574 |
}else{
|
575 |
log.debug(this.getOutCmd());
|
576 |
this.setZreplicas();
|
577 |
this.getZreplicas().zSchedulerProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue()); |
578 |
//this.getZreplicas().zSchedulerProperties.get("type").setValue(this.getZvol().zProperties.get("type").getValue());
|
579 |
} |
580 |
} |
581 |
|
582 |
|
583 |
//this.getZsnapshots().zSchedulerProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue());
|
584 |
//this.getZreplicas().zSchedulerProperties.get("type").setValue(this.getZvol().zProperties.get("type").getValue());
|
585 |
} |
586 |
|
587 |
public void zfsEnableSnapshots(){ |
588 |
|
589 |
String[] keysProp = (String[]) this.getZsnapshots().zSchedulerProperties.keySet().toArray(new String[0]); |
590 |
Arrays.sort(keysProp);
|
591 |
error.clear(); |
592 |
|
593 |
for ( int i=0;i<keysProp.length;i++){ |
594 |
String keyProp = keysProp[i];
|
595 |
if ( !this.getZsnapshots().zSchedulerProperties.get(keyProp).getType().equals("nofreeentry") && this.getZsnapshots().zSchedulerProperties.get(keyProp).getValue().equals("") && !"fileconf".equalsIgnoreCase(keyProp)){ |
596 |
error.put(keyProp, keyProp+" cannot be empty");
|
597 |
}else{
|
598 |
if ( this.getZsnapshots().zSchedulerProperties.get(keyProp).getType().equals("nofreeentry") && this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().isEmpty()){ |
599 |
error.put(keyProp, keyProp+" cannot be empty");
|
600 |
}else{
|
601 |
if (this.getZsnapshots().zSchedulerProperties.get(keyProp).getType().equals("nofreeentry") && this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().contains("*") && this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().size()>1){ |
602 |
error.put(keyProp, keyProp+ " All is not compatible with others selections");
|
603 |
} |
604 |
} |
605 |
|
606 |
} |
607 |
log.debug(this.getZsnapshots().zSchedulerProperties.get(keyProp).getType()+" "+this.getZsnapshots().zSchedulerProperties.get(keyProp).getValue()+" "+this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues()); |
608 |
} |
609 |
|
610 |
log.debug("ERROR SIZE : "+error.size());
|
611 |
if ( error.size() ==0){ |
612 |
//String contentFileCronSnapshot = this.getZsnapshots().formatCronValue(this.getZsnapshots().zSchedulerProperties.get("frequency").getValue(), this.getZsnapshots().zSchedulerProperties.get("dayofweeksnapshots").getValue());
|
613 |
for ( int i=0;i<keysProp.length;i++){ |
614 |
String keyProp = keysProp[i];
|
615 |
log.debug("zfsEnable "+keyProp);
|
616 |
if ( this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues() != null){ |
617 |
if ( this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().size() ==1){ |
618 |
this.getZsnapshots().zSchedulerProperties.get(keyProp).setValue(this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().get(0).toString()); |
619 |
}else{
|
620 |
this.getZsnapshots().zSchedulerProperties.get(keyProp).setValue(""); |
621 |
for ( int cpt=0;cpt<this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().size();cpt++){ |
622 |
this.getZsnapshots().zSchedulerProperties.get(keyProp).setValue(this.getZsnapshots().zSchedulerProperties.get(keyProp).getValue()+this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().get(cpt)+","); |
623 |
} |
624 |
this.getZsnapshots().zSchedulerProperties.get(keyProp).setValue(this.getZsnapshots().zSchedulerProperties.get(keyProp).getValue().substring(0, this.getZsnapshots().zSchedulerProperties.get(keyProp).getValue().length()-1)); |
625 |
} |
626 |
} |
627 |
} |
628 |
String cronMin = this.getZsnapshots().zSchedulerProperties.get("minutesofsnapshots").getValue(); |
629 |
String cronHour = this.getZsnapshots().zSchedulerProperties.get("hoursofsnapshots").getValue(); |
630 |
String cronMonth = this.getZsnapshots().zSchedulerProperties.get("monthsnapshots").getValue(); |
631 |
String cronDayofMonth = this.getZsnapshots().zSchedulerProperties.get("dayofmonthsnapshots").getValue(); |
632 |
String cronDayofWeek = this.getZsnapshots().zSchedulerProperties.get("dayofweeksnapshots").getValue(); |
633 |
String nameVolFS=this.getZsnapshots().zSchedulerProperties.get("name").getValue(); |
634 |
String typeZFS=this.getZsnapshots().zSchedulerProperties.get("type").getValue(); |
635 |
String nbsnapshots=this.getZsnapshots().zSchedulerProperties.get("nbsnapshots").getValue(); |
636 |
if ( this.executeCmd(this.getZserver().zProperties.get("binzfsenablesnapshots").getValue()+" -m "+"\""+cronMin+"\""+ |
637 |
" -H "+"\""+cronHour+"\""+ |
638 |
" -M "+"\""+cronMonth+"\""+ |
639 |
" -D "+"\""+cronDayofMonth+"\""+ |
640 |
" -d "+"\""+cronDayofWeek+"\""+ |
641 |
" -N "+"\""+nameVolFS+"\""+ |
642 |
" -t "+"\""+typeZFS+"\""+ |
643 |
" -k "+"\""+nbsnapshots+"\"")){ |
644 |
if ( outErr.length() ==0){ |
645 |
log.debug(this.getOutCmd());
|
646 |
String[] Tsplit = this.getOutCmd().split("\n"); |
647 |
for (int cpt=0;cpt<Tsplit.length;cpt++){ |
648 |
/*String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", " ").split("=");
|
649 |
log.debug(TsplitLine.length);
|
650 |
log.debug(TsplitLine[0]+" "+TsplitLine[1]);
|
651 |
this.zsnapshots.zSchedulerProperties.get(TsplitLine[0]).setValue(TsplitLine[1]);*/
|
652 |
} |
653 |
}else{
|
654 |
log.debug(this.getOutCmd());
|
655 |
this.setZsnapshots();
|
656 |
this.getZsnapshots().zSchedulerProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue()); |
657 |
this.getZsnapshots().zSchedulerProperties.get("type").setValue(this.getZvol().zProperties.get("type").getValue()); |
658 |
} |
659 |
} |
660 |
} |
661 |
} |
662 |
|
663 |
|
664 |
public void zfsDisableSnapshots(){ |
665 |
error.clear(); |
666 |
if ( this.executeCmd(this.getZserver().zProperties.get("binzfsdisablesnapshots").getValue()+" -N "+"\""+this.getZsnapshots().zSchedulerProperties.get("name").getValue()+"\"" )){ |
667 |
if ( outErr.length() ==0){ |
668 |
log.debug(this.getOutCmd());
|
669 |
}else{
|
670 |
log.debug(this.getOutCmd());
|
671 |
if (outErr.length()>0){ |
672 |
error.put("binzfsdisablesnapshots", outErr+"\n" ); |
673 |
} |
674 |
} |
675 |
} |
676 |
} |
677 |
|
678 |
public void zfsSnapshots(){ |
679 |
error.clear(); |
680 |
if ( this.getZsnapshots().zSchedulerProperties.get("fileconf").getValue().isEmpty()){ |
681 |
error.put("fileconf ", "Please configure the Snapshots"); |
682 |
} |
683 |
if ( error.size() < 1){ |
684 |
if ( this.executeCmd(this.getZserver().zProperties.get("binzfssnapshots").getValue()+" "+"\""+this.getZsnapshots().zSchedulerProperties.get("fileconf").getValue()+"\"" )){ |
685 |
if ( outErr.length() ==0){ |
686 |
log.debug(this.getOutCmd());
|
687 |
}else{
|
688 |
log.debug(this.getOutCmd());
|
689 |
if (outErr.length()>0){ |
690 |
error.put("binzfssnapshots", outErr+"\n" ); |
691 |
} |
692 |
} |
693 |
} |
694 |
} |
695 |
} |
696 |
|
697 |
|
698 |
public void zfsEnableReplicas(){ |
699 |
|
700 |
String[] keysProp = (String[]) this.getZreplicas().zSchedulerProperties.keySet().toArray(new String[0]); |
701 |
Arrays.sort(keysProp);
|
702 |
error.clear(); |
703 |
|
704 |
for ( int i=0;i<keysProp.length;i++){ |
705 |
String keyProp = keysProp[i];
|
706 |
log.debug("zfsEnableReplicas "+keyProp);
|
707 |
if ( !this.getZreplicas().zSchedulerProperties.get(keyProp).getType().equals("nofreeentry") && !this.getZreplicas().zSchedulerProperties.get(keyProp).getType().equals("noupdateable") && this.getZreplicas().zSchedulerProperties.get(keyProp).getValue().equals("")){ |
708 |
error.put(keyProp, keyProp+" cannot be empty");
|
709 |
}else{
|
710 |
if ( "nofreeentry".equalsIgnoreCase(this.getZreplicas().zSchedulerProperties.get(keyProp).getType()) && (this.getZreplicas().zSchedulerProperties.get(keyProp).getPermitValue() !=null)){ |
711 |
if ( this.getZreplicas().zSchedulerProperties.get(keyProp).getType().equals("nofreeentry") && this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().isEmpty()){ |
712 |
error.put(keyProp, keyProp+" cannot be empty");
|
713 |
}else{
|
714 |
if (this.getZreplicas().zSchedulerProperties.get(keyProp).getType().equals("nofreeentry") && this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().contains("*") && this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().size()>1){ |
715 |
error.put(keyProp, keyProp+ " All is not compatible with others selections");
|
716 |
} |
717 |
} |
718 |
} |
719 |
} |
720 |
log.debug(this.getZreplicas().zSchedulerProperties.get(keyProp).getType()+" "+this.getZreplicas().zSchedulerProperties.get(keyProp).getValue()+" "+this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues()); |
721 |
} |
722 |
if ("".equalsIgnoreCase(this.getZreplicas().zSchedulerProperties.get("replicapool").getValue())){ |
723 |
error.put("replicaPool", "replicapool cannot be empty"); |
724 |
} |
725 |
|
726 |
log.debug("ERROR SIZE : "+error.size());
|
727 |
if ( error.size() ==0){ |
728 |
//String contentFileCronSnapshot = this.getZsnapshots().formatCronValue(this.getZsnapshots().zSchedulerProperties.get("frequency").getValue(), this.getZsnapshots().zSchedulerProperties.get("dayofweeksnapshots").getValue());
|
729 |
for ( int i=0;i<keysProp.length;i++){ |
730 |
String keyProp = keysProp[i];
|
731 |
log.debug("zfsEnable Replica"+keyProp);
|
732 |
if ( this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues() != null){ |
733 |
if ( this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().size() ==1){ |
734 |
this.getZreplicas().zSchedulerProperties.get(keyProp).setValue(this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().get(0).toString()); |
735 |
}else{
|
736 |
this.getZreplicas().zSchedulerProperties.get(keyProp).setValue(""); |
737 |
for ( int cpt=0;cpt<this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().size();cpt++){ |
738 |
this.getZreplicas().zSchedulerProperties.get(keyProp).setValue(this.getZreplicas().zSchedulerProperties.get(keyProp).getValue()+this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().get(cpt)+","); |
739 |
} |
740 |
this.getZreplicas().zSchedulerProperties.get(keyProp).setValue(this.getZreplicas().zSchedulerProperties.get(keyProp).getValue().substring(0, this.getZreplicas().zSchedulerProperties.get(keyProp).getValue().length()-1)); |
741 |
} |
742 |
} |
743 |
} |
744 |
String cronMin = this.getZreplicas().zSchedulerProperties.get("minutesofreplicas").getValue(); |
745 |
String cronHour = this.getZreplicas().zSchedulerProperties.get("hoursofreplicas").getValue(); |
746 |
String cronMonth = this.getZreplicas().zSchedulerProperties.get("monthreplicas").getValue(); |
747 |
String cronDayofMonth = this.getZreplicas().zSchedulerProperties.get("dayofmonthreplicas").getValue(); |
748 |
String cronDayofWeek = this.getZreplicas().zSchedulerProperties.get("dayofweekreplicas").getValue(); |
749 |
String nameVolFS=this.getZreplicas().zSchedulerProperties.get("name").getValue(); |
750 |
String nameReplica=this.getZreplicas().zSchedulerProperties.get("replicapool").getValue()+"/"+this.getZvol().zProperties.get("name").getValue().split("/")[1]; |
751 |
String lastSnapshotsReplicated=this.getZreplicas().zSchedulerProperties.get("lastsnapshotreplicated").getValue(); |
752 |
String nbReplica=this.getZreplicas().zSchedulerProperties.get("nbreplica").getValue(); |
753 |
String cmd2exec = this.getZserver().zProperties.get("binzfsenablereplicas").getValue()+" -m "+"\""+cronMin+"\""+ |
754 |
" -H "+"\""+cronHour+"\""+ |
755 |
" -M "+"\""+cronMonth+"\""+ |
756 |
" -D "+"\""+cronDayofMonth+"\""+ |
757 |
" -d "+"\""+cronDayofWeek+"\""+ |
758 |
" -o "+"\""+nameVolFS+"\""+ |
759 |
" -r "+"\""+nameReplica+"\""+ |
760 |
" -n "+"\""+nbReplica+"\""; |
761 |
|
762 |
if (!"".equalsIgnoreCase(this.getZreplicas().zSchedulerProperties.get("server").getValue()) && (!this.getZserver().zProperties.get("serverIP").getValue().equalsIgnoreCase(this.getZreplicas().zSchedulerProperties.get("server").getValue())) ){ |
763 |
cmd2exec = cmd2exec +" -s "+this.getZreplicas().zSchedulerProperties.get("server").getValue(); |
764 |
} |
765 |
log.debug(cmd2exec+" "+this.getZreplicas().zSchedulerProperties.get("server").getValue()+" "+this.getZserver().zProperties.get("serverIP").getValue()); |
766 |
if ( this.executeCmd(cmd2exec)){ |
767 |
if ( outErr.length() ==0){ |
768 |
log.debug(this.getOutCmd());
|
769 |
String[] Tsplit = this.getOutCmd().split("\n"); |
770 |
for (int cpt=0;cpt<Tsplit.length;cpt++){ |
771 |
/*String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", " ").split("=");
|
772 |
log.debug(TsplitLine.length);
|
773 |
log.debug(TsplitLine[0]+" "+TsplitLine[1]);
|
774 |
this.zsnapshots.zSchedulerProperties.get(TsplitLine[0]).setValue(TsplitLine[1]);*/
|
775 |
} |
776 |
}else{
|
777 |
log.debug(this.getOutCmd());
|
778 |
this.setZreplicas();
|
779 |
this.getZreplicas().zSchedulerProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue()); |
780 |
//this.getZreplicas().zSchedulerProperties.get("type").setValue(this.getZvol().zProperties.get("type").getValue());
|
781 |
} |
782 |
} |
783 |
} |
784 |
} |
785 |
|
786 |
|
787 |
public void zfsDisableReplicas(){ |
788 |
error.clear(); |
789 |
if ( this.executeCmd(this.getZserver().zProperties.get("binzfsdisablereplicas").getValue()+" -N "+"\""+this.getZreplicas().zSchedulerProperties.get("name").getValue()+"\"" )){ |
790 |
if ( outErr.length() ==0){ |
791 |
log.debug(this.getOutCmd());
|
792 |
}else{
|
793 |
log.debug(this.getOutCmd());
|
794 |
if (outErr.length()>0){ |
795 |
error.put("binzfsdisablereplicas", outErr+"\n" ); |
796 |
} |
797 |
} |
798 |
} |
799 |
} |
800 |
|
801 |
public void zfsReplicas(){ |
802 |
error.clear(); |
803 |
if ( this.getZreplicas().zSchedulerProperties.get("fileconf").getValue().isEmpty()){ |
804 |
error.put("fileconf ", "Please configure the replication"); |
805 |
} |
806 |
if ( error.size() < 1){ |
807 |
if ( this.executeCmd(this.getZserver().zProperties.get("binzfsreplica").getValue()+" "+"\""+this.getZreplicas().zSchedulerProperties.get("fileconf").getValue()+"\" &" )){ |
808 |
if ( outErr.length() ==0){ |
809 |
log.debug(this.getOutCmd());
|
810 |
}else{
|
811 |
log.debug(this.getOutCmd());
|
812 |
if (outErr.length()>0){ |
813 |
error.put("binzfsreplica", outErr+"\n" ); |
814 |
} |
815 |
} |
816 |
} |
817 |
} |
818 |
} |
819 |
|
820 |
|
821 |
public void zfsCreateVolFS(){ |
822 |
error.clear(); |
823 |
if (this.getZpool().zProperties.get("name").getValue().equals("")){ |
824 |
error.put("pool", "Please select a pool"); |
825 |
} |
826 |
String[] keysProp = (String[]) this.getZvol().zProperties.keySet().toArray(new String[0]); |
827 |
Arrays.sort(keysProp);
|
828 |
String optionsList=""; |
829 |
for (int i = 0; i < keysProp.length; i++) { |
830 |
String keyProp = keysProp[i];
|
831 |
log.debug(keyProp); |
832 |
if ( ("volume".equalsIgnoreCase(this.getZvol().zProperties.get("type").getValue()) && |
833 |
("volume".equalsIgnoreCase(this.getZvol().zProperties.get(keyProp).getPropertyOf()) || |
834 |
"volandfs".equalsIgnoreCase(this.getZvol().zProperties.get(keyProp).getPropertyOf())))) { |
835 |
if (this.getZvol().zProperties.get(keyProp).getValue().equals("")&&!this.getZvol().zProperties.get(keyProp).getType().equals("noupdateable")){ |
836 |
error.put(keyProp, keyProp+" cannot be empty");
|
837 |
} |
838 |
if ( keyProp.equals("volblocksize")&& "".equals(this.getZvol().zProperties.get(keyProp).getValue())){ |
839 |
error.put(keyProp, keyProp+" cannot be empty");
|
840 |
} |
841 |
|
842 |
String nameVolFS = this.getZvol().zProperties.get("name").getValue(); |
843 |
//Available space
|
844 |
if (keyProp.equals("volsize")&& !"".equals(this.getZvol().zProperties.get(keyProp).getValue())){ |
845 |
String unit = this.getZvol().zProperties.get("volsize").getValue().substring(this.getZvol().zProperties.get("volsize").getValue().length()-1, this.getZvol().zProperties.get("volsize").getValue().length()); |
846 |
|
847 |
if ( !unit.equalsIgnoreCase("T") && !unit.equalsIgnoreCase("G") && !unit.equalsIgnoreCase("M")){ |
848 |
error.put("volsize", "Field size : Unit valid est T,G or M"); |
849 |
}else{
|
850 |
Float realUseableSpace = this.convertInReferenceUnit(this.getZpool().zProperties.get("realuseablespace").getValue(), unit); |
851 |
Float sizeVolFS = this.convertInReferenceUnit(this.getZvol().zProperties.get("volsize").getValue(), unit); |
852 |
this.zfsGetInfoByProperty(this.getZpool().zProperties.get("name").getValue(), "used"); |
853 |
Float usedSpace = this.convertInReferenceUnit(this.getZvol().zProperties.get("used").getValue(), unit); |
854 |
this.getZvol().zProperties.get("name").setValue(nameVolFS); |
855 |
Float freeSpace = realUseableSpace - usedSpace;
|
856 |
if ( sizeVolFS > freeSpace){
|
857 |
error.put("freespace", "No space available. Free Pool Space : "+String.valueOf(freeSpace)+unit); |
858 |
} |
859 |
} |
860 |
} |
861 |
log.debug("zfsCreateVolFS : "+keyProp+" "+this.getZvol().zProperties.get(keyProp).getType()); |
862 |
if (!keyProp.equals("name") && !this.getZvol().zProperties.get(keyProp).getType().equals("noupdateable")){ |
863 |
log.debug("zfsCreateVolFS :"+keyProp);
|
864 |
optionsList = optionsList+keyProp+"="+this.getZvol().zProperties.get(keyProp).getValue()+","; |
865 |
} |
866 |
}else{
|
867 |
if (("filesystem".equalsIgnoreCase(this.getZvol().zProperties.get("type").getValue()) && |
868 |
"fs".equalsIgnoreCase(this.getZvol().zProperties.get(keyProp).getPropertyOf())||"volandfs".equalsIgnoreCase(this.getZvol().zProperties.get(keyProp).getPropertyOf())) ){ |
869 |
if (this.getZvol().zProperties.get(keyProp).getValue().equals("")&&!this.getZvol().zProperties.get(keyProp).getType().equals("noupdateable")&&!"quota".equals(keyProp)&&!"reservation".equals(keyProp) ){ |
870 |
error.put(keyProp, keyProp+" cannot be empty");
|
871 |
} |
872 |
if (("quota".equals(keyProp)||"reservation".equals(keyProp))&&"".equals(this.getZvol().zProperties.get(keyProp).getValue())){ |
873 |
this.getZvol().zProperties.get(keyProp).setValue("none"); |
874 |
} |
875 |
if (("quota".equals(keyProp)||"reservation".equals(keyProp))&& !"none".equals(this.getZvol().zProperties.get(keyProp).getValue()) &&!"".equals(this.getZvol().zProperties.get(keyProp).getValue())){ |
876 |
String nameVolFS = this.getZvol().zProperties.get("name").getValue(); |
877 |
String unit = this.getZvol().zProperties.get(keyProp).getValue().substring(this.getZvol().zProperties.get(keyProp).getValue().length()-1, this.getZvol().zProperties.get(keyProp).getValue().length()); |
878 |
if ( !unit.equalsIgnoreCase("T") && !unit.equalsIgnoreCase("G") && !unit.equalsIgnoreCase("M")){ |
879 |
error.put(keyProp, "Field "+keyProp+" : Unit valid est T,G or M"); |
880 |
}else{
|
881 |
Float realUseableSpace = this.convertInReferenceUnit(this.getZpool().zProperties.get("realuseablespace").getValue(), unit); |
882 |
Float valueKeyProp = this.convertInReferenceUnit(this.getZvol().zProperties.get(keyProp).getValue(), unit); |
883 |
this.zfsGetInfoByProperty(this.getZpool().zProperties.get("name").getValue(), "used"); |
884 |
Float usedSpace = this.convertInReferenceUnit(this.getZvol().zProperties.get("used").getValue(), unit); |
885 |
this.getZvol().zProperties.get("name").setValue(nameVolFS); |
886 |
Float freeSpace = realUseableSpace - usedSpace;
|
887 |
if ( valueKeyProp > freeSpace){
|
888 |
error.put(keyProp, "Error value for "+keyProp+" : No space available. Free Pool Space : "+String.valueOf(freeSpace)+unit); |
889 |
} |
890 |
} |
891 |
} |
892 |
log.debug("zfsCreateVolFS : "+keyProp+" "+this.getZvol().zProperties.get(keyProp).getType()); |
893 |
if (!keyProp.equals("name") && !this.getZvol().zProperties.get(keyProp).getType().equals("noupdateable")){ |
894 |
log.debug("zfsCreateVolFS :"+keyProp);
|
895 |
optionsList = optionsList+keyProp+"="+this.getZvol().zProperties.get(keyProp).getValue()+","; |
896 |
} |
897 |
} |
898 |
|
899 |
} |
900 |
} |
901 |
if (error.size()==0){ |
902 |
log.debug(optionsList); |
903 |
if ( optionsList.length()>0){ |
904 |
optionsList=optionsList.substring(0, optionsList.length()-1); |
905 |
} |
906 |
|
907 |
if ( "volume".equals(this.getZvol().zProperties.get("type").getValue())&& this.executeCmd(this.getZserver().zProperties.get("binzfscreatevolume").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue()+ |
908 |
" -p "+this.getZpool().zProperties.get("name").getValue()+ |
909 |
" -b "+this.getZvol().zProperties.get("volblocksize").getValue()+ |
910 |
" -s "+this.getZvol().zProperties.get("volsize").getValue()+ |
911 |
" -o "+optionsList)){
|
912 |
if ( outErr.length() ==0){ |
913 |
log.debug(this.getOutCmd());
|
914 |
}else{
|
915 |
log.debug(this.getOutCmd());
|
916 |
error.put("binzfscreatevolume", "Incoherence : Please connect you to server and launch manualy "+this.getZserver().zProperties.get("binzfscreatevolume").getValue() ); |
917 |
} |
918 |
}else{
|
919 |
if ("filesystem".equals(this.getZvol().zProperties.get("type").getValue())&& this.executeCmd(this.getZserver().zProperties.get("binzfscreatefilesystem").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue()+ |
920 |
" -p "+this.getZpool().zProperties.get("name").getValue()+ |
921 |
" -o "+optionsList)){
|
922 |
if ( outErr.length() ==0){ |
923 |
log.debug(this.getOutCmd());
|
924 |
}else{
|
925 |
log.debug(this.getOutCmd());
|
926 |
error.put("binzfscreatefilesystem", "Incoherence : Please connect you to server and launch manualy "+this.getZserver().zProperties.get("binzfscreatefilesystem").getValue() ); |
927 |
} |
928 |
} |
929 |
} |
930 |
}else{
|
931 |
log.debug("Error : "+error.size());
|
932 |
} |
933 |
} |
934 |
|
935 |
public void zfsUmountFS(){ |
936 |
error.clear(); |
937 |
if ("".equals(this.getZvol().zProperties.get("name").getValue())){ |
938 |
error.put("name", "Please select a ZFS FileSystem"); |
939 |
} |
940 |
if (error.size()==0){ |
941 |
if (this.executeCmd(this.getZserver().zProperties.get("binzfs").getValue()+" umount "+this.getZvol().zProperties.get("name").getValue())){ |
942 |
if ( outErr.length() ==0){ |
943 |
log.debug(this.getOutCmd());
|
944 |
}else{
|
945 |
log.debug(this.getOutCmd());
|
946 |
if (outErr.toString().contains("Error")){ |
947 |
error.put("binzfs", "Incoherence : Please connect you to server and launch manualy "+this.getZserver().zProperties.get("binzfs").getValue() ); |
948 |
} |
949 |
} |
950 |
}else{
|
951 |
error.put("executeCmd", "Problem with the command : "+this.getZserver().zProperties.get("binzfs").getValue()+" umount "+this.getZvol().zProperties.get("name").getValue()); |
952 |
} |
953 |
} |
954 |
|
955 |
} |
956 |
|
957 |
public void zfsDestroyVolFS(){ |
958 |
error.clear(); |
959 |
if ("".equals(this.getZvol().zProperties.get("name").getValue())){ |
960 |
error.put("name", "Please select a ZFS FileSystem"); |
961 |
} |
962 |
if ( error.size()==0){ |
963 |
if ( "filesystem".equals(this.getZvol().zProperties.get("type").getValue())){ |
964 |
if ( this.executeCmd(this.getZserver().zProperties.get("binzfsdelfilesystem").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue() )) { |
965 |
if ( outErr.length() ==0){ |
966 |
log.debug(this.getOutCmd());
|
967 |
}else{
|
968 |
log.debug(this.getOutCmd());
|
969 |
if (outErr.length()>0){ |
970 |
error.put("binzfsdelvolume", outErr+"\n" ); |
971 |
} |
972 |
} |
973 |
}else{
|
974 |
error.put("executeCmd", "Problem with the command : "+this.getZserver().zProperties.get("binzfsdelfilesystem").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue()); |
975 |
} |
976 |
}else{
|
977 |
if ( "volume".equals(this.getZvol().zProperties.get("type").getValue())){ |
978 |
if ( this.executeCmd(this.getZserver().zProperties.get("binzfsdelvolume").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue() )) { |
979 |
if ( outErr.length() ==0){ |
980 |
log.debug(this.getOutCmd());
|
981 |
}else{
|
982 |
log.debug(this.getOutCmd());
|
983 |
if (outErr.length()>0){ |
984 |
error.put("binzfsdelvolume", outErr+"\n" ); |
985 |
} |
986 |
} |
987 |
}else{
|
988 |
error.put("executeCmd", "Problem with the command : "+this.getZserver().zProperties.get("binzfsdelvolume").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue()); |
989 |
} |
990 |
}else{
|
991 |
if ( "snapshot".equals(this.getZvol().zProperties.get("type").getValue())){ |
992 |
if ( this.executeCmd(this.getZserver().zProperties.get("binzfsdelvolume").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue() )) { |
993 |
if ( outErr.length() ==0){ |
994 |
log.debug(this.getOutCmd());
|
995 |
}else{
|
996 |
log.debug(this.getOutCmd());
|
997 |
if (outErr.length()>0){ |
998 |
error.put("binzfsdelvolume", outErr+"\n" ); |
999 |
} |
1000 |
} |
1001 |
}else{
|
1002 |
error.put("executeCmd", "Problem with the command : "+this.getZserver().zProperties.get("binzfsdelvolume").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue()); |
1003 |
} |
1004 |
} |
1005 |
} |
1006 |
} |
1007 |
|
1008 |
} |
1009 |
} |
1010 |
|
1011 |
public void zfsCreateIscsi(){ |
1012 |
String[] keysProp = (String[]) this.getZiscsi().zProperties.keySet().toArray(new String[0]); |
1013 |
Arrays.sort(keysProp);
|
1014 |
error.clear(); |
1015 |
if ("filesystem".equals(this.getZvol().zProperties.get("type").getValue())){ |
1016 |
error.put("type", "You cannot add a iscsi configuration for a zfs filesystem"); |
1017 |
} |
1018 |
|
1019 |
for ( int i=0;i<keysProp.length;i++){ |
1020 |
String keyProp = keysProp[i];
|
1021 |
if (!this.getZiscsi().zProperties.get(keyProp).getType().contains("noupdateable") && !keyProp.equalsIgnoreCase("allowIP")){ |
1022 |
if ( "".equals(this.getZiscsi().zProperties.get(keyProp).getValue())) { |
1023 |
error.put(keyProp, this.getZiscsi().zProperties.get(keyProp).getLabelProperty()+" cannot be empty" ); |
1024 |
} |
1025 |
} |
1026 |
} |
1027 |
if (!"".equals(this.getZiscsi().zProperties.get("tid").getValue())){ |
1028 |
error.put("tid", "Iscsi is already configured for this volume" ); |
1029 |
} |
1030 |
|
1031 |
if ( error.size() ==0){ |
1032 |
String cmd = this.getZserver().zProperties.get("binzfsaddiscsi").getValue()+" -d "+this.getZserver().zProperties.get("pathzfsvoldevice").getValue()+this.getZiscsi().zProperties.get("name").getValue() |
1033 |
+" -T "+this.getZiscsi().zProperties.get("exportType").getValue()+ |
1034 |
" -L 0"+
|
1035 |
" -o "+this.getZiscsi().zProperties.get("iomode").getValue()+ |
1036 |
" -l "+this.getZiscsi().zProperties.get("login").getValue()+ |
1037 |
" -p "+this.getZiscsi().zProperties.get("passwd").getValue()+ |
1038 |
" -t "+this.getZiscsi().zProperties.get("name").getValue(); |
1039 |
if (!this.getZiscsi().zProperties.get("allowIP").getValue().isEmpty()){ |
1040 |
cmd = cmd +" -R "+"\""+this.getZiscsi().zProperties.get("allowIP").getValue()+"\""; |
1041 |
} |
1042 |
if ( this.executeCmd(cmd)){ |
1043 |
if ( outErr.length() ==0){ |
1044 |
//log.debug(this.getOutCmd());
|
1045 |
}else{
|
1046 |
if (outErr.toString().contains("Error")){ |
1047 |
error.put("pathzfsvoldevice", "Incoherence : Please connect you to server and launch manualy "+this.getZserver().zProperties.get("binzfsaddiscsi").getValue() ); |
1048 |
} |
1049 |
} |
1050 |
} |
1051 |
} |
1052 |
} |
1053 |
|
1054 |
public void zfsDelIscsi(){ |
1055 |
error.clear(); |
1056 |
if (!"".equals(this.getZiscsi().zProperties.get("tid").getValue())){ |
1057 |
if ( this.executeCmd(this.getZserver().zProperties.get("binzfsdeliscsi").getValue()+" -T "+"\""+this.getZiscsi().zProperties.get("tid").getValue()+"\"" )){ |
1058 |
if ( outErr.length() ==0){ |
1059 |
log.debug(this.getOutCmd());
|
1060 |
}else{
|
1061 |
log.debug("zdsdelIscsi Error : " +outErr);
|
1062 |
if ( outErr.toString().contains("in use")){ |
1063 |
error.put("binzfsdeliscsi", outErr.toString() );
|
1064 |
}else{
|
1065 |
error.put("binzfsdeliscsi", outErr+"\n"+"Incoherence : Please connect you to server and launch manualy "+this.getZserver().zProperties.get("binzfsdeliscsi").getValue() ); |
1066 |
} |
1067 |
} |
1068 |
} |
1069 |
} |
1070 |
|
1071 |
} |
1072 |
|
1073 |
|
1074 |
public void zfsClone(){ |
1075 |
error.clear(); |
1076 |
if ("".equals(this.getZvol().zProperties.get("name").getValue())){ |
1077 |
error.put("name", "Please, select a volume or filesystem to clone" ); |
1078 |
} |
1079 |
|
1080 |
if ( error.size() ==0){ |
1081 |
String cmd = this.getZserver().zProperties.get("binzfsclone").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue(); |
1082 |
if ( this.executeCmd(cmd)){ |
1083 |
if ( outErr.length() ==0){ |
1084 |
log.debug(this.getOutCmd());
|
1085 |
String[] TsplitOut = this.getOutCmd().split("\n"); |
1086 |
if (TsplitOut.length>0){ |
1087 |
String[] TsplitLine = TsplitOut[0].split("name:"); |
1088 |
if (TsplitLine.length>0){ |
1089 |
this.zfsGetAllVolume(TsplitLine[1]); |
1090 |
if ("".equalsIgnoreCase(this.getZvol().zProperties.get("name").getValue())){ |
1091 |
error.put("zfsclone", "Clone Creation failed"); |
1092 |
} |
1093 |
} |
1094 |
} |
1095 |
}else{
|
1096 |
if (outErr.length()>0){ |
1097 |
error.put("zfsclone", outErr);
|
1098 |
} |
1099 |
} |
1100 |
} |
1101 |
} |
1102 |
} |
1103 |
|
1104 |
|
1105 |
public float convertInReferenceUnit(String value2Convert, String refUnit){ |
1106 |
|
1107 |
float convertedValue=0; |
1108 |
value2Convert = value2Convert.replace(",", "."); |
1109 |
log.debug("convertInReferenceUnit "+value2Convert+" "+refUnit); |
1110 |
if ( refUnit.equalsIgnoreCase("T")){ |
1111 |
if (value2Convert.contains("T")){ |
1112 |
convertedValue=Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1))); |
1113 |
}else{
|
1114 |
if (value2Convert.contains("G")){ |
1115 |
convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)))/1024); |
1116 |
}else{
|
1117 |
if (value2Convert.contains("M")){ |
1118 |
convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)))/1048576); |
1119 |
}else{
|
1120 |
if (value2Convert.contains("K")){ |
1121 |
convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)))/1073741824); |
1122 |
} |
1123 |
} |
1124 |
} |
1125 |
} |
1126 |
|
1127 |
} |
1128 |
|
1129 |
if ( refUnit.equalsIgnoreCase("G")){ |
1130 |
if (value2Convert.contains("G")){ |
1131 |
convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)))); |
1132 |
}else{
|
1133 |
if (value2Convert.contains("T")){ |
1134 |
convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)))*1024); |
1135 |
}else{
|
1136 |
if (value2Convert.contains("M")){ |
1137 |
convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)))/1024); |
1138 |
}else{
|
1139 |
if (value2Convert.contains("K")){ |
1140 |
convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)))/1048576); |
1141 |
} |
1142 |
} |
1143 |
} |
1144 |
} |
1145 |
} |
1146 |
log.debug("getZpoolProvisionedSpace "+convertedValue);
|
1147 |
return convertedValue;
|
1148 |
} |
1149 |
|
1150 |
public List<Object> zfsList(){ |
1151 |
zfsList.clear(); |
1152 |
|
1153 |
|
1154 |
if ( this.executeCmd("/sbin/zfs list -H") ){ |
1155 |
String[] Tsplit = this.getOutCmd().split("\n"); |
1156 |
for (int cpt=0;cpt<Tsplit.length;cpt++){ |
1157 |
log.debug(Tsplit[cpt].split("\\s+")[0] ); |
1158 |
zfsList.add(Tsplit[cpt].split("\\s+")[0]); |
1159 |
//zpoolNames[ind] = Tsplit[cpt].split("\\s+")[0];
|
1160 |
} |
1161 |
} |
1162 |
return zfsList;
|
1163 |
} |
1164 |
|
1165 |
|
1166 |
public boolean addServer(){ |
1167 |
|
1168 |
if (!"".equalsIgnoreCase(this.getZserver().zProperties.get("serverIP").getValue())) { |
1169 |
this.getZserver().add(System.getProperty("user.home")+prop.getProperty("serverConfDir")+this.getZserver().zProperties.get("serverIP").getValue()+".properties"); |
1170 |
|
1171 |
}else{
|
1172 |
return false; |
1173 |
} |
1174 |
return true; |
1175 |
} |
1176 |
|
1177 |
public boolean removeServer(){ |
1178 |
if (!"".equalsIgnoreCase(this.getZserver().zProperties.get("serverIP").getValue())) { |
1179 |
this.getZserver().remove(System.getProperty("user.home")+prop.getProperty("serverConfDir")+this.getZserver().zProperties.get("serverIP").getValue()+".properties"); |
1180 |
this.getCacheSession().remove(this.getZserver().zProperties.get("serverIP").getValue()); |
1181 |
} |
1182 |
return false; |
1183 |
} |
1184 |
|
1185 |
public List<Object> getListServer(){ |
1186 |
String dirName = System.getProperty("user.home")+prop.getProperty("serverConfDir"); |
1187 |
log.debug(System.getProperty("user.home")+prop.getProperty("serverConfDir")); |
1188 |
File dir = new File(dirName); |
1189 |
if ( !dir.exists()){
|
1190 |
dir.mkdir(); |
1191 |
log.debug((System.getProperty("user.home")+prop.getProperty("serverConfDir"))); |
1192 |
} |
1193 |
log.debug((System.getProperty("user.home")+prop.getProperty("serverConfDir"))); |
1194 |
File f = new File(System.getProperty("user.home")+prop.getProperty("serverConfDir")); |
1195 |
log.debug((System.getProperty("user.home")+prop.getProperty("serverConfDir"))); |
1196 |
File[] list = f.listFiles(); |
1197 |
List<Object> listServer = new ArrayList<Object>(); |
1198 |
for (int i=0;i<list.length;i++){ |
1199 |
listServer.add(list[i].getName().split(".properties")[0]); |
1200 |
} |
1201 |
return listServer;
|
1202 |
} |
1203 |
|
1204 |
public void getServer(String serverName){ |
1205 |
this.getZserver().load(System.getProperty("user.home")+prop.getProperty("serverConfDir")+serverName+".properties"); |
1206 |
String[] keysProp = (String[]) this.getZserver().zProperties.keySet().toArray(new String[0]); |
1207 |
Arrays.sort(keysProp);
|
1208 |
error.clear(); |
1209 |
for ( int i=0;i<keysProp.length;i++){ |
1210 |
String keyProp = keysProp[i];
|
1211 |
if (prop.containsKey(keyProp)){
|
1212 |
this.getZserver().zProperties.get(keyProp).setValue(prop.getProperty(keyProp));
|
1213 |
} |
1214 |
|
1215 |
} |
1216 |
} |
1217 |
|
1218 |
public void checkBinEnv(){ |
1219 |
String[] keysProp = (String[]) this.getZserver().zProperties.keySet().toArray(new String[0]); |
1220 |
Arrays.sort(keysProp);
|
1221 |
error.clear(); |
1222 |
for ( int i=0;i<keysProp.length;i++){ |
1223 |
String keyProp = keysProp[i];
|
1224 |
if ( !keyProp.equalsIgnoreCase("serverIP") && !keyProp.equalsIgnoreCase("userLogin") && !keyProp.equalsIgnoreCase("userPasswd")&&!keyProp.equalsIgnoreCase("pathzfsvoldevice")){ |
1225 |
if ( this.executeCmd(prop.getProperty(keyProp)) && ! outErr.toString().contains("No such file or directory")){ |
1226 |
log.debug(prop.getProperty(keyProp)); |
1227 |
log.debug("checkBinEnv "+outErr.toString().contains("No such file or directory")); |
1228 |
}else{
|
1229 |
error.put(keyProp, outErr.toString()); |
1230 |
} |
1231 |
} |
1232 |
} |
1233 |
} |
1234 |
|
1235 |
public void loadConfig(){ |
1236 |
|
1237 |
try {
|
1238 |
InputStream resource = getClass().getResourceAsStream("config.properties"); |
1239 |
|
1240 |
prop.load(resource); |
1241 |
log.debug(prop); |
1242 |
} catch (FileNotFoundException e) { |
1243 |
// TODO Auto-generated catch block
|
1244 |
e.printStackTrace(); |
1245 |
} catch (IOException e) { |
1246 |
// TODO Auto-generated catch block
|
1247 |
e.printStackTrace(); |
1248 |
} |
1249 |
} |
1250 |
public String getUserPassword() { |
1251 |
return userPassword;
|
1252 |
} |
1253 |
|
1254 |
|
1255 |
|
1256 |
public void setUserPassword(String userPassword) { |
1257 |
this.userPassword = userPassword;
|
1258 |
} |
1259 |
|
1260 |
|
1261 |
|
1262 |
public String getUserLogin() { |
1263 |
return userLogin;
|
1264 |
} |
1265 |
|
1266 |
|
1267 |
|
1268 |
public void setUserLogin(String userLogin) { |
1269 |
this.userLogin = userLogin;
|
1270 |
} |
1271 |
|
1272 |
|
1273 |
|
1274 |
public String getSshHost() { |
1275 |
return sshHost;
|
1276 |
} |
1277 |
|
1278 |
|
1279 |
|
1280 |
public void setSshHost(String sshHost) { |
1281 |
this.sshHost = sshHost;
|
1282 |
} |
1283 |
|
1284 |
|
1285 |
|
1286 |
public int getSshPort() { |
1287 |
return sshPort;
|
1288 |
} |
1289 |
|
1290 |
|
1291 |
|
1292 |
public void setSshPort(int sshPort) { |
1293 |
this.sshPort = sshPort;
|
1294 |
} |
1295 |
|
1296 |
public String getOutCmd() { |
1297 |
return outCmd;
|
1298 |
} |
1299 |
|
1300 |
public void setOutCmd(String out) { |
1301 |
this.outCmd=out;
|
1302 |
} |
1303 |
|
1304 |
public Session getSession() {
|
1305 |
return session;
|
1306 |
} |
1307 |
|
1308 |
public void setSession(Session session) { |
1309 |
this.session = session;
|
1310 |
} |
1311 |
|
1312 |
/**
|
1313 |
* @return the zSnapshot
|
1314 |
*/
|
1315 |
public zsnapshots getZsnapshots() {
|
1316 |
return zsnapshots;
|
1317 |
} |
1318 |
|
1319 |
/**
|
1320 |
* @param zSnapshot the zSnapshot to set
|
1321 |
*/
|
1322 |
public void setZsnapshots() { |
1323 |
this.zsnapshots = new zsnapshots(); |
1324 |
} |
1325 |
|
1326 |
public zreplicas getZreplicas() {
|
1327 |
return zreplicas;
|
1328 |
} |
1329 |
|
1330 |
public void setZreplicas() { |
1331 |
this.zreplicas = new zreplicas(); |
1332 |
} |
1333 |
|
1334 |
/**
|
1335 |
* @return the ziscsi
|
1336 |
*/
|
1337 |
public ziscsi getZiscsi() {
|
1338 |
return ziscsi;
|
1339 |
} |
1340 |
|
1341 |
/**
|
1342 |
* @param ziscsi the ziscsi to set
|
1343 |
*/
|
1344 |
public void setZiscsi() { |
1345 |
this.ziscsi = new ziscsi(); |
1346 |
} |
1347 |
|
1348 |
/**
|
1349 |
* @return the zserver
|
1350 |
*/
|
1351 |
public zserver getZserver() {
|
1352 |
return zserver;
|
1353 |
} |
1354 |
|
1355 |
/**
|
1356 |
* @param zserver the zserver to set
|
1357 |
*/
|
1358 |
public void setZserver() { |
1359 |
this.zserver = new zserver(); |
1360 |
} |
1361 |
|
1362 |
/**
|
1363 |
* @return the cacheSession
|
1364 |
*/
|
1365 |
public Hashtable<String,Session> getCacheSession() { |
1366 |
return cacheSession;
|
1367 |
} |
1368 |
|
1369 |
/**
|
1370 |
* @param cacheSession the cacheSession to set
|
1371 |
*/
|
1372 |
public void setCacheSession(Hashtable<String,Session> cacheSession) { |
1373 |
this.cacheSession = cacheSession;
|
1374 |
} |
1375 |
|
1376 |
/**
|
1377 |
* @return the zpool
|
1378 |
*/
|
1379 |
public zpool getZpool() {
|
1380 |
return zpool;
|
1381 |
} |
1382 |
|
1383 |
/**
|
1384 |
* @param zpool the zpool to set
|
1385 |
*/
|
1386 |
public void setZpool() { |
1387 |
this.zpool = new zpool(); |
1388 |
} |
1389 |
|
1390 |
|
1391 |
public zdisk getZdisk() {
|
1392 |
return zdisk;
|
1393 |
} |
1394 |
|
1395 |
public void setZdisk() { |
1396 |
this.zdisk = new zdisk(); |
1397 |
} |
1398 |
|
1399 |
/**
|
1400 |
* @return the error
|
1401 |
*/
|
1402 |
public Hashtable<String,Object> getError() { |
1403 |
return error;
|
1404 |
} |
1405 |
|
1406 |
/**
|
1407 |
* @param error the error to set
|
1408 |
*/
|
1409 |
public void setError(Hashtable<String,Object> error) { |
1410 |
this.error = error;
|
1411 |
} |
1412 |
|
1413 |
public Hashtable<String, zdisk> getHashDisks() { |
1414 |
return hashDisks;
|
1415 |
} |
1416 |
|
1417 |
public void setHashDisks(Hashtable<String, zdisk> hashDisks) { |
1418 |
this.hashDisks = hashDisks;
|
1419 |
} |
1420 |
|
1421 |
public zraid getZraid() {
|
1422 |
return zraid;
|
1423 |
} |
1424 |
|
1425 |
public void setZraid() { |
1426 |
this.zraid = new zraid(); |
1427 |
} |
1428 |
|
1429 |
|
1430 |
|
1431 |
public Hashtable<String, zraid> getHashZRaid() { |
1432 |
return hashZRaid;
|
1433 |
} |
1434 |
|
1435 |
public void setHashZRaid(Hashtable<String, zraid> hashZRaid) { |
1436 |
this.hashZRaid = hashZRaid;
|
1437 |
} |
1438 |
|
1439 |
} |