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