Statistiques
| Révision :

root / src / gZFS / zfs.java @ 28

Historique | Voir | Annoter | Télécharger (55,33 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 disconnectAllServer(){
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
                        getCacheSession().remove(keyProp);
118
                }
119
        }
120
        public void disconnectServer(){
121
                this.setSession(getCacheSession().get(this.getZserver().zProperties.get("serverIP").getValue()));
122
                session.disconnect();
123
                getCacheSession().remove(this.getZserver().zProperties.get("serverIP").getValue());
124
        }
125

    
126

    
127
        public Boolean executeCmd(String cmd) {
128
                this.setOutCmd("");
129
                try {
130
                        
131
                        this.setSession(getCacheSession().get(this.getZserver().zProperties.get("serverIP").getValue()));
132
                        log.debug("executeCMD : "+this.getZserver().zProperties.get("serverIP").getValue());
133
                        ChannelExec channel = (ChannelExec) session.openChannel("exec");
134
                        //((ChannelExec) channel).setCommand("lqs");
135
                        ((ChannelExec) channel).setCommand(cmd);
136
                        InputStream in = channel.getInputStream();
137
                        OutputStream out = channel.getOutputStream();
138
                        ((ChannelExec) channel).setErrStream(System.err);
139
                        InputStream err = channel.getErrStream();
140
                        channel.connect();
141
                        log.debug("executeCmd "+cmd);
142
                        if (!cmd.equals("/sbin/show-infodisk-cache")){
143
                                BufferedReader reader = new BufferedReader(new InputStreamReader(err));
144
                                outErr = new StringBuilder();
145
                                String line;
146
                                while ((line = reader.readLine()) != null) {
147
                                        outErr.append(line);
148
                                }
149
                        }
150
                        
151
                        byte[] tmp = new byte[4096];
152

    
153
                        while (true) {
154

    
155
                                int ind = 0;
156
                                while (in.available() > 0) {
157
                                        int i = in.read(tmp, 0, 4096);
158
                                        if (i < 0)
159
                                                break;
160

    
161
                                        this.setOutCmd(this.getOutCmd()+new String(tmp, 0, i));
162
                                }
163
                                if (channel.isClosed()) {
164
                                        break;
165
                                }
166
                                try {
167
                                        Thread.sleep(900);
168
                                } catch (Exception ee) {
169
                                        log.debug(ee);
170
                                }
171
                        }
172
                        channel.disconnect();
173

    
174
                } catch (JSchException e) {
175
                        // TODO Auto-generated catch block
176
                        log.debug("executeCMD "+e.getMessage());
177
                        e.printStackTrace();
178
                        return false;
179
                } catch (IOException e) {
180
                        // TODO Auto-generated catch block
181
                        log.debug("executeCmd "+e.getMessage());
182
                        e.printStackTrace();
183
                        return false;
184
                }
185
                /*for (int cpt=0;cpt < outCmd.length;cpt++ ) {
186
                        log.debug(outCmd[cpt]);
187
                }*/
188
                //log.debug(this.getOutCmd());
189
                return true;
190
        }
191

    
192
        public Boolean zfsGetAllVolume(String volName){
193
                zfsGetAllList.clear();
194
                //clear this.getZvol properties
195
                String[] keysProp = (String[]) this.getZvol().zProperties.keySet().toArray(new String[0]);
196
                Arrays.sort(keysProp);
197
                for ( int i=0;i<keysProp.length;i++){
198
                        String keyProp = keysProp[i];
199
                        this.getZvol().zProperties.get(keyProp).setMultivalues(null);
200
                        this.getZvol().zProperties.get(keyProp).setValue("");;
201

    
202
                }
203
                if (  this.executeCmd("/sbin/zfs get all "+volName) ){
204
                        log.debug(this.getOutCmd());
205
                        String[] Tsplit = this.getOutCmd().split("\n");
206
                        for (int cpt=1;cpt<Tsplit.length;cpt++){
207

    
208
                                log.debug(Tsplit[cpt].replaceAll(volName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " "));
209
                                String[] TsplitLine = Tsplit[cpt].replaceAll(volName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " ").split(" ");
210
                                log.debug(TsplitLine[0]);
211
                                if ( "creation".equalsIgnoreCase(TsplitLine[0])){
212
                                        this.getZvol().zProperties.get("creation").setValue(TsplitLine[1]+" "+TsplitLine[2]+" "+TsplitLine[3]+" "+TsplitLine[4]+" "+TsplitLine[5]);;
213
                                }else{
214
                                        //this.getZvol().zProperties.containsKey(TsplitLine[0]);
215
                                        if (this.getZvol().zProperties.containsKey(TsplitLine[0])){
216
                                                this.getZvol().zProperties.get(TsplitLine[0]).setValue(TsplitLine[1]);
217
                                                log.debug("ZFS DEBUG "+this.getZvol().zProperties.get(TsplitLine[0]).getNameProperty()+" "+ this.getZvol().zProperties.get(TsplitLine[0]).getValue());
218
                                        }
219
                                }
220
                        }
221
                        this.getZvol().zProperties.get("name").setValue(volName);
222
                        //this.getZvol().zProperties.get("name").setValue(volName);
223
                }
224

    
225

    
226
                return true;
227
        }
228
        public void zfsGetInfoByProperty(String volName, String propertyName){
229
                zfsGetAllList.clear();
230
                if (  this.executeCmd("/sbin/zfs get "+propertyName+" -H "+volName) ){
231
                        log.debug(this.getOutCmd());
232
                        String[] Tsplit = this.getOutCmd().split("\n");
233
                        for (int cpt=0;cpt<Tsplit.length;cpt++){
234

    
235
                                log.debug(Tsplit[cpt].replaceAll(volName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " "));
236
                                String[] TsplitLine = Tsplit[cpt].replaceAll(volName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " ").split(" ");
237
                                log.debug(TsplitLine[0]);
238
                                if ( "creation".equalsIgnoreCase(TsplitLine[0])){
239
                                        this.getZvol().zProperties.get("creation").setValue(TsplitLine[1]+" "+TsplitLine[2]+" "+TsplitLine[3]+" "+TsplitLine[4]+" "+TsplitLine[5]);;
240
                                }else{
241
                                        //this.getZvol().zProperties.containsKey(TsplitLine[0]);
242
                                        if (this.getZvol().zProperties.containsKey(TsplitLine[0])){
243
                                                this.getZvol().zProperties.get(TsplitLine[0]).setValue(TsplitLine[1]);
244
                                                log.debug("ZFS DEBUG "+this.getZvol().zProperties.get(TsplitLine[0]).getNameProperty()+" "+ this.getZvol().zProperties.get(TsplitLine[0]).getValue());
245
                                        }
246
                                }
247
                        }
248
                        this.getZvol().zProperties.get("name").setValue(volName);
249
                        //this.getZvol().zProperties.get("name").setValue(volName);
250
                }
251

    
252
        }
253

    
254

    
255
        public Boolean zpoolGetAll(String zpoolName){
256
                zfsGetAllList.clear();
257
                //clear this.getZvol properties
258
                String[] keysProp = (String[]) this.getZpool().zProperties.keySet().toArray(new String[0]);
259
                Arrays.sort(keysProp);
260
                for ( int i=0;i<keysProp.length;i++){
261
                        String keyProp = keysProp[i];
262
                        this.getZpool().zProperties.get(keyProp).setMultivalues(null);
263
                        this.getZpool().zProperties.get(keyProp).setValue("");;
264

    
265
                }
266
                if (  this.executeCmd("/sbin/zpool get all "+zpoolName) ){
267
                        log.debug(this.getOutCmd());
268
                        String[] Tsplit = this.getOutCmd().split("\n");
269
                        for (int cpt=1;cpt<Tsplit.length;cpt++){
270

    
271
                                log.debug(Tsplit[cpt].replaceAll(zpoolName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " "));
272
                                String[] TsplitLine = Tsplit[cpt].replaceAll(zpoolName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " ").split(" ");
273
                                log.debug(TsplitLine[0]);
274
                                if ( "creation".equalsIgnoreCase(TsplitLine[0])){
275
                                        this.getZpool().zProperties.get("creation").setValue(TsplitLine[1]+" "+TsplitLine[2]+" "+TsplitLine[3]+" "+TsplitLine[4]+" "+TsplitLine[5]);;
276
                                }else{
277
                                        //this.getZpool().zProperties.containsKey(TsplitLine[0]);
278
                                        if (this.getZpool().zProperties.containsKey(TsplitLine[0])){
279
                                                this.getZpool().zProperties.get(TsplitLine[0]).setValue(TsplitLine[1]);
280
                                                log.debug("ZFS DEBUG "+this.getZpool().zProperties.get(TsplitLine[0]).getNameProperty()+" "+ this.getZpool().zProperties.get(TsplitLine[0]).getValue());
281
                                        }
282
                                }
283
                        }
284
                        this.getZpool().zProperties.get("name").setValue(zpoolName);
285
                        //this.getZvol().zProperties.get("name").setValue(volName);
286

    
287
                        this.getZpoolRealUseableSpace(zpoolName);
288
                        log.debug("zpoolGetAll "+this.getZpool().zProperties.get("realuseablespace").getValue());
289
                        this.getZpoolProvisionedSpace(zpoolName);
290
                        if (  this.executeCmd(this.getZserver().zProperties.get("binzpoolgetstate").getValue()+" -n "+this.getZpool().zProperties.get("name").getValue()) ){
291
                                log.debug(this.getOutCmd());
292
                                String[] TsplitOut = this.getOutCmd().split("\n");
293
                                for (int cpt=1;cpt<TsplitOut.length;cpt++){
294

    
295
                                        String[] TsplitLineState= TsplitOut[cpt].replaceAll("\n","").split(":");
296
                                        log.debug(TsplitLineState[0]);
297
                                        //this.getZpool().zProperties.containsKey(TsplitLine[0]);
298
                                        if (this.getZpool().zProperties.containsKey(TsplitLineState[0])){
299
                                                this.getZpool().zProperties.get(TsplitLineState[0]).setValue(TsplitLineState[1]);
300
                                                log.debug("ZFS DEBUG "+this.getZpool().zProperties.get(TsplitLineState[0]).getNameProperty()+" "+ this.getZpool().zProperties.get(TsplitLineState[0]).getValue());
301
                                        }
302
                                }
303
                                this.getZpool().zProperties.get("name").setValue(zpoolName);
304
                        }
305

    
306
                }
307

    
308

    
309
                return true;
310
        }
311

    
312

    
313
        public List<Object> zpoolList(){
314
                zpoolList.clear();
315

    
316
                if (  this.executeCmd("/sbin/zpool list -H") ){
317
                        String[] Tsplit = this.getOutCmd().split("\n");
318
                        for (int cpt=0;cpt<Tsplit.length;cpt++){
319
                                log.debug(Tsplit[cpt].split("\\s+")[0] );
320
                                zpoolList.add(Tsplit[cpt].split("\\s+")[0]);
321
                                //zpoolNames[ind] = Tsplit[cpt].split("\\s+")[0];
322
                        }
323
                }
324
                return zpoolList;
325
        }
326

    
327
        public List<Object> zfsListSnapshotsByVolFS(String nameVolFS){
328
                zfsListSnapshots.clear();
329

    
330
                log.debug("zfs list -H -r -t snapshot -oname,used,referenced "+nameVolFS);
331
                if (  this.executeCmd("/sbin/zfs list -H -r -t snapshot "+nameVolFS) ){
332
                        if ( this.getOutCmd().length() >0){
333
                                String[] Tsplit = this.getOutCmd().split("\n");
334
                                for (int cpt=0;cpt<Tsplit.length;cpt++){
335
                                        log.debug(Tsplit[cpt].split("\\s+")[0] );
336
                                        zfsListSnapshots.add(Tsplit[cpt].split("\\s+")[0]);
337
                                        //zpoolNames[ind] = Tsplit[cpt].split("\\s+")[0];
338
                                }        
339
                        }
340

    
341
                }
342
                return zfsListSnapshots;
343
        }
344

    
345
        public Boolean getIscsiListConfigVol(String nameVolFS){
346
                sidList = new ArrayList<Object>();
347
                ipList = new ArrayList<Object>();
348
                //sidList=null;
349
                //ipList=null;
350
                log.debug("get-conf-iscsi-volume nameVolFS");
351
                //Reset ziscsi object
352
                this.setZiscsi();
353
                if (  this.executeCmd("/sbin/get-conf-iscsi-volume "+nameVolFS) ){
354
                        String[] Tsplit = this.getOutCmd().split("\n");
355
                        for (int cpt=0;cpt<Tsplit.length;cpt++){
356

    
357
                                String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", " ").split(" ");
358
                                if ( "sid".equalsIgnoreCase(TsplitLine[0])){
359
                                        sidList.add(TsplitLine[1]);
360
                                }else{
361
                                        if ("sessionIP".equalsIgnoreCase(TsplitLine[0])){
362
                                                ipList.add(TsplitLine[1]);
363
                                                log.debug("sessionIP "+TsplitLine[1]);
364
                                        }else{
365
                                                //this.getZvol().zProperties.containsKey(TsplitLine[0]);
366
                                                if (this.getZiscsi().zProperties.containsKey(TsplitLine[0])&& TsplitLine.length ==2){
367
                                                        this.getZiscsi().zProperties.get(TsplitLine[0]).setValue(TsplitLine[1]);
368
                                                }
369
                                        }
370
                                }
371
                        }
372
                        this.getZiscsi().zProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue());
373
                        this.getZiscsi().zProperties.get("sid").setMultivalues(sidList);
374
                        this.getZiscsi().zProperties.get("sessionIP").setMultivalues(ipList);
375
                        return true;
376
                }else{
377
                        return false;
378
                }
379
        }
380

    
381

    
382
        public void getZpoolProvisionedSpace(String zpoolName){
383
                log.debug("getZpoolProvisionedSpace "+this.getZpool().zProperties.get("realuseablespace").getValue());
384
                if (  this.executeCmd("/sbin/get-provisioned-space "+zpoolName) ){
385
                        log.debug(this.getOutCmd());
386
                        String[] Tsplit = this.getOutCmd().split("\n");
387
                        log.debug("getZpoolProvisionedSpace "+this.getZpool().zProperties.get("realuseablespace").getValue().substring((this.getZpool().zProperties.get("realuseablespace").getValue().length())));
388

    
389
                        String refUnit = this.getZpool().zProperties.get("realuseablespace").getValue().substring((this.getZpool().zProperties.get("realuseablespace").getValue().length()-1), (this.getZpool().zProperties.get("realuseablespace").getValue().length()));
390

    
391

    
392
                        float totalProvisioned=0;
393
                        log.debug(String.valueOf(totalProvisioned)+refUnit);
394
                        for (int cpt=0;cpt<Tsplit.length;cpt++){
395

    
396
                                log.debug(Tsplit[cpt].replaceAll(zpoolName+"\\s+","").replaceAll("\n", "").replaceAll("\\s+", " "));
397
                                String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", " ").split(" ");
398
                                log.debug(TsplitLine[0]);
399
                                totalProvisioned=totalProvisioned+this.convertInReferenceUnit(TsplitLine[2], refUnit);
400

    
401
                        }
402
                        log.debug("getZpoolProvisionedSpace "+String.valueOf(totalProvisioned)+refUnit);
403
                        this.getZpool().zProperties.get("provisionspace").setValue(String.valueOf(BigDecimal.valueOf(totalProvisioned).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())+refUnit);
404
                        //this.getZvol().zProperties.get("name").setValue(volName);
405
                        log.debug(String.valueOf(totalProvisioned)+refUnit);
406

    
407

    
408
                }
409
        }
410

    
411
        public void getZpoolRealUseableSpace(String zpoolName){
412

    
413
                this.zfsGetInfoByProperty(zpoolName, "used");
414
                this.zfsGetInfoByProperty(zpoolName, "available");
415
                log.debug("getZpoolRealUseableSpace "+this.getZvol().zProperties.get("used").getValue());
416
                String refUnit = this.getZvol().zProperties.get("used").getValue().substring(this.getZvol().zProperties.get("used").getValue().length()-1, this.getZvol().zProperties.get("used").getValue().length());
417
                if (!refUnit.equalsIgnoreCase("T")&&!refUnit.equalsIgnoreCase("G")){
418
                        refUnit = this.getZvol().zProperties.get("available").getValue().substring(this.getZvol().zProperties.get("available").getValue().length()-1, this.getZvol().zProperties.get("available").getValue().length());
419
                }
420
                log.debug("getZpoolRealUseableSpace "+refUnit);
421
                float usedSize = this.convertInReferenceUnit(this.getZvol().zProperties.get("used").getValue(), refUnit);
422
                float availableSize = this.convertInReferenceUnit(this.getZvol().zProperties.get("available").getValue(), refUnit);
423
                log.debug("getZpoolRealUseableSpace "+String.valueOf(usedSize+availableSize)+refUnit);
424
                this.getZpool().zProperties.get("realuseablespace").setValue(String.valueOf(BigDecimal.valueOf(usedSize+availableSize).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())+refUnit);
425

    
426
        }
427

    
428
        public void getZpoolStatus(){
429
                error.clear();
430
                if ( !"".equalsIgnoreCase(getZpool().zProperties.get("name").getValue())){
431

    
432
                        log.debug("getZpoolStatus");
433
                        hashDisks.clear();
434
                        hashZRaid.clear();
435
                        this.setZraid();
436
                        if ( this.executeCmd("/sbin/show-infodisk-cache")){
437
                                log.debug("getZpoolStatus");
438
                                this.setZdisk();
439
                                if ( outErr.length() ==0){
440
                                        //log.debug(this.getOutCmd());
441
                                        String namePool="";
442
                                        if (this.getOutCmd().length()>0) {
443

    
444
                                                String[] Tsplit = this.getOutCmd().split("\n");
445
                                                for (int cpt=0;cpt<Tsplit.length;cpt++){
446
                                                        String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", "").replaceAll("'", "").split(":");
447
                                                        String propertyDisk=TsplitLine[0].toLowerCase();
448
                                                        String valuePropertyDisk="";
449

    
450
                                                        if (TsplitLine.length==2){
451
                                                                valuePropertyDisk=TsplitLine[1];        
452
                                                        }
453

    
454
                                                        if (Tsplit[cpt].equalsIgnoreCase("#infoDisk#")){
455
                                                                if (!this.getZdisk().zProperties.get("path").getValue().equalsIgnoreCase("") ){
456
                                                                        hashDisks.put("disk"+cpt, this.getZdisk());
457
                                                                        log.debug(this.getZraid().zProperties.get("poolname").getValue()+"-"+this.getZraid().zProperties.get("raidtype").getValue()+"-"+this.getZraid().zProperties.get("raidid").getValue());
458
                                                                        if (!hashZRaid.containsKey(this.getZraid().zProperties.get("poolname").getValue()+"-"+this.getZraid().zProperties.get("raidtype").getValue()+"-"+this.getZraid().zProperties.get("raidid").getValue())){
459
                                                                                this.getZraid().zProperties.get("name").setValue(this.getZraid().zProperties.get("poolname").getValue()+"-"+this.getZraid().zProperties.get("raidtype").getValue()+"-"+this.getZraid().zProperties.get("raidid").getValue());
460
                                                                                hashZRaid.put(this.getZraid().zProperties.get("poolname").getValue()+"-"+this.getZraid().zProperties.get("raidtype").getValue()+"-"+this.getZraid().zProperties.get("raidid").getValue(), this.getZraid());
461
                                                                                this.setZraid();
462
                                                                        }
463
                                                                }
464
                                                                this.setZdisk();
465
                                                        }else{
466
                                                                if (TsplitLine.length==2){
467
                                                                        valuePropertyDisk=TsplitLine[1];
468

    
469
                                                                        if (this.getZdisk().zProperties.containsKey(propertyDisk)){
470
                                                                                this.getZdisk().zProperties.get(propertyDisk).setValue(valuePropertyDisk);
471
                                                                                //log.debug(propertyDisk+" : "+valuePropertyDisk);
472
                                                                        }
473

    
474
                                                                        if (this.getZraid().zProperties.containsKey(propertyDisk)){
475
                                                                                this.getZraid().zProperties.get(propertyDisk).setValue(valuePropertyDisk);
476

    
477
                                                                                log.debug(propertyDisk+" : "+valuePropertyDisk);
478
                                                                        }
479
                                                                }
480
                                                        }
481

    
482
                                                }
483
                                        }
484
                                }
485
                        }
486
                        log.debug("getZpoolStatus : "+hashDisks.size());
487
                        log.debug("getZpoolStatus : "+hashZRaid.size());
488
                        this.setHashDisks(hashDisks);
489
                        this.setHashZRaid(hashZRaid);        
490

    
491
                }
492

    
493
        }
494

    
495

    
496
        public void getInfoDisk(){
497
                if ( this.executeCmd(this.getZserver().zProperties.get("bingetdiskinfo").getValue() +" "+this.getZdisk().zProperties.get("path").getValue())){
498
                        log.debug("getZpoolStatus");
499
                        if ( outErr.length() ==0){
500
                                log.debug(this.getOutCmd());
501
                                if (this.getOutCmd().length()>0) {
502
                                        String dataType="";
503
                                        String[] Tsplit = this.getOutCmd().split("\n");
504

    
505

    
506
                                        for (int cpt=0;cpt<Tsplit.length;cpt++){
507

    
508
                                                String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", "").replaceAll("'", "").split(":");
509
                                                String propertyDisk=TsplitLine[0];
510
                                                String valuePropertyDisk="";
511

    
512

    
513
                                        }
514
                                }
515
                        }
516
                }
517
        }
518

    
519

    
520
        public void getZsnapshotConfig(){
521
                log.debug("getZsnapshotConfig");
522
                this.setZsnapshots();
523
                if (  this.executeCmd(this.getZserver().zProperties.get("bingetconfsnapshot").getValue()+" "+this.getZvol().zProperties.get("name").getValue()) ){
524
                        if ( outErr.length() ==0){
525
                                log.debug(this.getOutCmd());
526
                                if (this.getOutCmd().length()>0) {
527
                                        String[] Tsplit = this.getOutCmd().split("\n");
528
                                        for (int cpt=0;cpt<Tsplit.length;cpt++){
529
                                                String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", " ").split("=");
530
                                                log.debug(TsplitLine.length);
531
                                                log.debug(TsplitLine[0]+" "+TsplitLine[1]);
532

    
533
                                                this.zsnapshots.zSchedulerProperties.get(TsplitLine[0]).setValue(TsplitLine[1]);
534
                                        }        
535
                                }
536

    
537
                        }else{
538
                                log.debug(this.getOutCmd());
539
                                this.setZsnapshots();
540
                                this.getZsnapshots().zSchedulerProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue());
541
                                this.getZsnapshots().zSchedulerProperties.get("type").setValue(this.getZvol().zProperties.get("type").getValue());
542
                        }
543
                }
544
                this.getZsnapshots().zSchedulerProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue());
545
                this.getZsnapshots().zSchedulerProperties.get("type").setValue(this.getZvol().zProperties.get("type").getValue());
546
        }
547
        
548
        public void getZreplicaConfig(){
549
                log.debug("getZreplicaConfig");
550
                this.setZreplicas();
551
                log.debug(this.getZserver().zProperties.get("bingetconfreplica").getValue()+" "+this.getZvol().zProperties.get("name").getValue());
552
                if (  this.executeCmd(this.getZserver().zProperties.get("bingetconfreplica").getValue()+" "+this.getZvol().zProperties.get("name").getValue()) ){
553
                        if ( outErr.length() ==0){
554
                                log.debug(this.getOutCmd());
555
                                if (this.getOutCmd().length()>0) {
556
                                        String[] Tsplit = this.getOutCmd().split("\n");
557
                                        for (int cpt=0;cpt<Tsplit.length;cpt++){
558
                                                String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", " ").split("=");
559
                                                log.debug(TsplitLine.length);
560
                                                if (TsplitLine.length>1){
561
                                                        log.debug(TsplitLine[0]+" "+TsplitLine[1]);
562
                                                        this.zreplicas.zSchedulerProperties.get(TsplitLine[0]).setValue(TsplitLine[1]);        
563
                                                }
564
                                        }        
565
                                }
566

    
567
                        }else{
568
                                log.debug(this.getOutCmd());
569
                                this.setZreplicas();
570
                                this.getZreplicas().zSchedulerProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue());
571
                                //this.getZreplicas().zSchedulerProperties.get("type").setValue(this.getZvol().zProperties.get("type").getValue());
572
                        }
573
                }
574
                
575
                
576
                //this.getZsnapshots().zSchedulerProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue());
577
                //this.getZreplicas().zSchedulerProperties.get("type").setValue(this.getZvol().zProperties.get("type").getValue());
578
        }
579

    
580
        public void zfsEnableSnapshots(){
581

    
582
                String[] keysProp = (String[]) this.getZsnapshots().zSchedulerProperties.keySet().toArray(new String[0]);
583
                Arrays.sort(keysProp);
584
                error.clear();
585

    
586
                for ( int i=0;i<keysProp.length;i++){
587
                        String keyProp = keysProp[i];
588
                        if ( !this.getZsnapshots().zSchedulerProperties.get(keyProp).getType().equals("nofreeentry") && this.getZsnapshots().zSchedulerProperties.get(keyProp).getValue().equals("") && !"fileconf".equalsIgnoreCase(keyProp)){
589
                                error.put(keyProp, keyProp+" cannot be empty");
590
                        }else{
591
                                if ( this.getZsnapshots().zSchedulerProperties.get(keyProp).getType().equals("nofreeentry") && this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().isEmpty()){
592
                                        error.put(keyProp, keyProp+" cannot be empty");
593
                                }else{
594
                                        if (this.getZsnapshots().zSchedulerProperties.get(keyProp).getType().equals("nofreeentry") && this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().contains("*") && this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().size()>1){
595
                                                error.put(keyProp, keyProp+ " All is not compatible with others selections");
596
                                        }
597
                                }
598

    
599
                        }
600
                        log.debug(this.getZsnapshots().zSchedulerProperties.get(keyProp).getType()+" "+this.getZsnapshots().zSchedulerProperties.get(keyProp).getValue()+" "+this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues());
601
                }
602

    
603
                log.debug("ERROR SIZE : "+error.size());
604
                if ( error.size() ==0){
605
                        //String contentFileCronSnapshot = this.getZsnapshots().formatCronValue(this.getZsnapshots().zSchedulerProperties.get("frequency").getValue(), this.getZsnapshots().zSchedulerProperties.get("dayofweeksnapshots").getValue());
606
                        for ( int i=0;i<keysProp.length;i++){
607
                                String keyProp = keysProp[i];
608
                                log.debug("zfsEnable "+keyProp);
609
                                if ( this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues() != null){
610
                                        if ( this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().size() ==1){
611
                                                this.getZsnapshots().zSchedulerProperties.get(keyProp).setValue(this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().get(0).toString());
612
                                        }else{
613
                                                this.getZsnapshots().zSchedulerProperties.get(keyProp).setValue("");
614
                                                for ( int cpt=0;cpt<this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().size();cpt++){
615
                                                        this.getZsnapshots().zSchedulerProperties.get(keyProp).setValue(this.getZsnapshots().zSchedulerProperties.get(keyProp).getValue()+this.getZsnapshots().zSchedulerProperties.get(keyProp).getMultivalues().get(cpt)+",");
616
                                                }
617
                                                this.getZsnapshots().zSchedulerProperties.get(keyProp).setValue(this.getZsnapshots().zSchedulerProperties.get(keyProp).getValue().substring(0, this.getZsnapshots().zSchedulerProperties.get(keyProp).getValue().length()-1));
618
                                        }
619
                                }
620
                        }
621
                        String cronMin = this.getZsnapshots().zSchedulerProperties.get("minutesofsnapshots").getValue();
622
                        String cronHour = this.getZsnapshots().zSchedulerProperties.get("hoursofsnapshots").getValue();
623
                        String cronMonth = this.getZsnapshots().zSchedulerProperties.get("monthsnapshots").getValue();
624
                        String cronDayofMonth = this.getZsnapshots().zSchedulerProperties.get("dayofmonthsnapshots").getValue();
625
                        String cronDayofWeek = this.getZsnapshots().zSchedulerProperties.get("dayofweeksnapshots").getValue();
626
                        String nameVolFS=this.getZsnapshots().zSchedulerProperties.get("name").getValue();
627
                        String typeZFS=this.getZsnapshots().zSchedulerProperties.get("type").getValue();
628
                        String nbsnapshots=this.getZsnapshots().zSchedulerProperties.get("nbsnapshots").getValue();
629
                        if (  this.executeCmd(this.getZserver().zProperties.get("binzfsenablesnapshots").getValue()+" -m "+"\""+cronMin+"\""+
630
                                        " -H "+"\""+cronHour+"\""+
631
                                        " -M "+"\""+cronMonth+"\""+
632
                                        " -D "+"\""+cronDayofMonth+"\""+
633
                                        " -d "+"\""+cronDayofWeek+"\""+
634
                                        " -N "+"\""+nameVolFS+"\""+
635
                                        " -t "+"\""+typeZFS+"\""+
636
                                        " -k "+"\""+nbsnapshots+"\"")){
637
                                if ( outErr.length() ==0){
638
                                        log.debug(this.getOutCmd());
639
                                        String[] Tsplit = this.getOutCmd().split("\n");
640
                                        for (int cpt=0;cpt<Tsplit.length;cpt++){
641
                                                /*String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", " ").split("=");
642
                                                log.debug(TsplitLine.length);
643
                                                log.debug(TsplitLine[0]+" "+TsplitLine[1]);
644
                                                this.zsnapshots.zSchedulerProperties.get(TsplitLine[0]).setValue(TsplitLine[1]);*/
645
                                        }
646
                                }else{
647
                                        log.debug(this.getOutCmd());
648
                                        this.setZsnapshots();
649
                                        this.getZsnapshots().zSchedulerProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue());
650
                                        this.getZsnapshots().zSchedulerProperties.get("type").setValue(this.getZvol().zProperties.get("type").getValue());
651
                                }
652
                        }
653
                }
654
        }
655

    
656

    
657
        public void zfsDisableSnapshots(){
658
                error.clear();
659
                if (  this.executeCmd(this.getZserver().zProperties.get("binzfsdisablesnapshots").getValue()+" -N "+"\""+this.getZsnapshots().zSchedulerProperties.get("name").getValue()+"\"" )){
660
                        if ( outErr.length() ==0){
661
                                log.debug(this.getOutCmd());
662
                        }else{
663
                                log.debug(this.getOutCmd());
664
                                if (outErr.length()>0){
665
                                        error.put("binzfsdisablesnapshots", outErr+"\n" );
666
                                }
667
                        }
668
                }
669
        }
670
        
671
        public void zfsSnapshots(){
672
                error.clear();
673
                if ( this.getZsnapshots().zSchedulerProperties.get("fileconf").getValue().isEmpty()){
674
                        error.put("fileconf ", "Please configure the Snapshots");
675
                }
676
                if ( error.size() < 1){
677
                        if (  this.executeCmd(this.getZserver().zProperties.get("binzfssnapshots").getValue()+" "+"\""+this.getZsnapshots().zSchedulerProperties.get("fileconf").getValue()+"\"" )){
678
                                if ( outErr.length() ==0){
679
                                        log.debug(this.getOutCmd());
680
                                }else{
681
                                        log.debug(this.getOutCmd());
682
                                        if (outErr.length()>0){
683
                                                error.put("binzfssnapshots", outErr+"\n" );
684
                                        }
685
                                }
686
                        }
687
                }
688
        }
689
        
690

    
691
        public void zfsEnableReplicas(){
692

    
693
                String[] keysProp = (String[]) this.getZreplicas().zSchedulerProperties.keySet().toArray(new String[0]);
694
                Arrays.sort(keysProp);
695
                error.clear();
696

    
697
                for ( int i=0;i<keysProp.length;i++){
698
                        String keyProp = keysProp[i];
699
                        log.debug("zfsEnableReplicas "+keyProp);
700
                        if ( !this.getZreplicas().zSchedulerProperties.get(keyProp).getType().equals("nofreeentry") && !this.getZreplicas().zSchedulerProperties.get(keyProp).getType().equals("noupdateable") && this.getZreplicas().zSchedulerProperties.get(keyProp).getValue().equals("")){
701
                                error.put(keyProp, keyProp+" cannot be empty");
702
                        }else{
703
                                if ( "nofreeentry".equalsIgnoreCase(this.getZreplicas().zSchedulerProperties.get(keyProp).getType()) && (this.getZreplicas().zSchedulerProperties.get(keyProp).getPermitValue() !=null)){
704
                                        if ( this.getZreplicas().zSchedulerProperties.get(keyProp).getType().equals("nofreeentry") && this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().isEmpty()){
705
                                                error.put(keyProp, keyProp+" cannot be empty");
706
                                        }else{
707
                                                if (this.getZreplicas().zSchedulerProperties.get(keyProp).getType().equals("nofreeentry") && this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().contains("*") && this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().size()>1){
708
                                                        error.put(keyProp, keyProp+ " All is not compatible with others selections");
709
                                                }
710
                                        }
711
                                }
712
                        }
713
                        log.debug(this.getZreplicas().zSchedulerProperties.get(keyProp).getType()+" "+this.getZreplicas().zSchedulerProperties.get(keyProp).getValue()+" "+this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues());
714
                }
715
                if ("".equalsIgnoreCase(this.getZreplicas().zSchedulerProperties.get("replicapool").getValue())){
716
                        error.put("replicaPool", "replicapool cannot be empty");
717
                }
718

    
719
                log.debug("ERROR SIZE : "+error.size());
720
                if ( error.size() ==0){
721
                        //String contentFileCronSnapshot = this.getZsnapshots().formatCronValue(this.getZsnapshots().zSchedulerProperties.get("frequency").getValue(), this.getZsnapshots().zSchedulerProperties.get("dayofweeksnapshots").getValue());
722
                        for ( int i=0;i<keysProp.length;i++){
723
                                String keyProp = keysProp[i];
724
                                log.debug("zfsEnable Replica"+keyProp);
725
                                if ( this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues() != null){
726
                                        if ( this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().size() ==1){
727
                                                this.getZreplicas().zSchedulerProperties.get(keyProp).setValue(this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().get(0).toString());
728
                                        }else{
729
                                                this.getZreplicas().zSchedulerProperties.get(keyProp).setValue("");
730
                                                for ( int cpt=0;cpt<this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().size();cpt++){
731
                                                        this.getZreplicas().zSchedulerProperties.get(keyProp).setValue(this.getZreplicas().zSchedulerProperties.get(keyProp).getValue()+this.getZreplicas().zSchedulerProperties.get(keyProp).getMultivalues().get(cpt)+",");
732
                                                }
733
                                                this.getZreplicas().zSchedulerProperties.get(keyProp).setValue(this.getZreplicas().zSchedulerProperties.get(keyProp).getValue().substring(0, this.getZreplicas().zSchedulerProperties.get(keyProp).getValue().length()-1));
734
                                        }
735
                                }
736
                        }
737
                        String cronMin = this.getZreplicas().zSchedulerProperties.get("minutesofreplicas").getValue();
738
                        String cronHour = this.getZreplicas().zSchedulerProperties.get("hoursofreplicas").getValue();
739
                        String cronMonth = this.getZreplicas().zSchedulerProperties.get("monthreplicas").getValue();
740
                        String cronDayofMonth = this.getZreplicas().zSchedulerProperties.get("dayofmonthreplicas").getValue();
741
                        String cronDayofWeek = this.getZreplicas().zSchedulerProperties.get("dayofweekreplicas").getValue();
742
                        String nameVolFS=this.getZreplicas().zSchedulerProperties.get("name").getValue();
743
                        String nameReplica=this.getZreplicas().zSchedulerProperties.get("replicapool").getValue()+"/"+this.getZvol().zProperties.get("name").getValue().split("/")[1];
744
                        String lastSnapshotsReplicated=this.getZreplicas().zSchedulerProperties.get("lastsnapshotreplicated").getValue();
745
                        String nbReplica=this.getZreplicas().zSchedulerProperties.get("nbreplica").getValue();
746
                        String cmd2exec = this.getZserver().zProperties.get("binzfsenablereplicas").getValue()+" -m "+"\""+cronMin+"\""+
747
                                        " -H "+"\""+cronHour+"\""+
748
                                        " -M "+"\""+cronMonth+"\""+
749
                                        " -D "+"\""+cronDayofMonth+"\""+
750
                                        " -d "+"\""+cronDayofWeek+"\""+
751
                                        " -o "+"\""+nameVolFS+"\""+
752
                                        " -r "+"\""+nameReplica+"\""+
753
                                        " -n "+"\""+nbReplica+"\"";
754
                        
755
                        if (!"".equalsIgnoreCase(this.getZreplicas().zSchedulerProperties.get("server").getValue()) && (!this.getZserver().zProperties.get("serverIP").getValue().equalsIgnoreCase(this.getZreplicas().zSchedulerProperties.get("server").getValue())) ){
756
                                cmd2exec = cmd2exec +" -s "+this.getZreplicas().zSchedulerProperties.get("server").getValue();
757
                        }
758
                        log.debug(cmd2exec+" "+this.getZreplicas().zSchedulerProperties.get("server").getValue()+" "+this.getZserver().zProperties.get("serverIP").getValue());
759
                        if (  this.executeCmd(cmd2exec)){
760
                                if ( outErr.length() ==0){
761
                                        log.debug(this.getOutCmd());
762
                                        String[] Tsplit = this.getOutCmd().split("\n");
763
                                        for (int cpt=0;cpt<Tsplit.length;cpt++){
764
                                                /*String[] TsplitLine = Tsplit[cpt].replaceAll("\n", "").replaceAll("\\s+", " ").split("=");
765
                                                log.debug(TsplitLine.length);
766
                                                log.debug(TsplitLine[0]+" "+TsplitLine[1]);
767
                                                this.zsnapshots.zSchedulerProperties.get(TsplitLine[0]).setValue(TsplitLine[1]);*/
768
                                        }
769
                                }else{
770
                                        log.debug(this.getOutCmd());
771
                                        this.setZreplicas();
772
                                        this.getZreplicas().zSchedulerProperties.get("name").setValue(this.getZvol().zProperties.get("name").getValue());
773
                                        //this.getZreplicas().zSchedulerProperties.get("type").setValue(this.getZvol().zProperties.get("type").getValue());
774
                                }
775
                        }
776
                }
777
        }
778
        
779

    
780
        public void zfsDisableReplicas(){
781
                error.clear();
782
                if (  this.executeCmd(this.getZserver().zProperties.get("binzfsdisablereplicas").getValue()+" -N "+"\""+this.getZreplicas().zSchedulerProperties.get("name").getValue()+"\"" )){
783
                        if ( outErr.length() ==0){
784
                                log.debug(this.getOutCmd());
785
                        }else{
786
                                log.debug(this.getOutCmd());
787
                                if (outErr.length()>0){
788
                                        error.put("binzfsdisablereplicas", outErr+"\n" );
789
                                }
790
                        }
791
                }
792
        }
793
        
794
        public void zfsReplicas(){
795
                error.clear();
796
                if ( this.getZreplicas().zSchedulerProperties.get("fileconf").getValue().isEmpty()){
797
                        error.put("fileconf ", "Please configure the replication");
798
                }
799
                if ( error.size() < 1){
800
                        if (  this.executeCmd(this.getZserver().zProperties.get("binzfsreplica").getValue()+" "+"\""+this.getZreplicas().zSchedulerProperties.get("fileconf").getValue()+"\" &" )){
801
                                if ( outErr.length() ==0){
802
                                        log.debug(this.getOutCmd());
803
                                }else{
804
                                        log.debug(this.getOutCmd());
805
                                        if (outErr.length()>0){
806
                                                error.put("binzfsreplica", outErr+"\n" );
807
                                        }
808
                                }
809
                        }
810
                }
811
        }
812
        
813
        
814
        public void zfsCreateVolFS(){
815
                error.clear();
816
                if (this.getZpool().zProperties.get("name").getValue().equals("")){
817
                        error.put("pool", "Please select a pool");
818
                }
819
                String[] keysProp = (String[]) this.getZvol().zProperties.keySet().toArray(new String[0]);
820
                Arrays.sort(keysProp);
821
                String optionsList="";
822
                for (int i = 0; i < keysProp.length; i++) {
823
                        String keyProp = keysProp[i];
824
                        log.debug(keyProp);
825
                        if ( ("volume".equalsIgnoreCase(this.getZvol().zProperties.get("type").getValue()) && 
826
                                        ("volume".equalsIgnoreCase(this.getZvol().zProperties.get(keyProp).getPropertyOf()) || 
827
                                                        "volandfs".equalsIgnoreCase(this.getZvol().zProperties.get(keyProp).getPropertyOf())))) {
828
                                if (this.getZvol().zProperties.get(keyProp).getValue().equals("")&&!this.getZvol().zProperties.get(keyProp).getType().equals("noupdateable")){
829
                                        error.put(keyProp, keyProp+" cannot be empty");
830
                                }
831
                                if ( keyProp.equals("volblocksize")&& "".equals(this.getZvol().zProperties.get(keyProp).getValue())){
832
                                        error.put(keyProp, keyProp+" cannot be empty");
833
                                }
834

    
835
                                String nameVolFS = this.getZvol().zProperties.get("name").getValue();
836
                                //Available space
837
                                if (keyProp.equals("volsize")&& !"".equals(this.getZvol().zProperties.get(keyProp).getValue())){
838
                                        String unit = this.getZvol().zProperties.get("volsize").getValue().substring(this.getZvol().zProperties.get("volsize").getValue().length()-1, this.getZvol().zProperties.get("volsize").getValue().length());
839

    
840
                                        if ( !unit.equalsIgnoreCase("T") && !unit.equalsIgnoreCase("G") && !unit.equalsIgnoreCase("M")){
841
                                                error.put("volsize", "Field size : Unit valid est T,G or M");
842
                                        }else{
843
                                                Float realUseableSpace = this.convertInReferenceUnit(this.getZpool().zProperties.get("realuseablespace").getValue(), unit);
844
                                                Float sizeVolFS = this.convertInReferenceUnit(this.getZvol().zProperties.get("volsize").getValue(), unit);
845
                                                this.zfsGetInfoByProperty(this.getZpool().zProperties.get("name").getValue(), "used");
846
                                                Float usedSpace = this.convertInReferenceUnit(this.getZvol().zProperties.get("used").getValue(), unit);
847
                                                this.getZvol().zProperties.get("name").setValue(nameVolFS);
848
                                                Float freeSpace = realUseableSpace - usedSpace;
849
                                                if ( sizeVolFS > freeSpace){
850
                                                        error.put("freespace", "No space available. Free Pool Space : "+String.valueOf(freeSpace)+unit);
851
                                                }        
852
                                        }
853
                                }
854
                                log.debug("zfsCreateVolFS : "+keyProp+" "+this.getZvol().zProperties.get(keyProp).getType());
855
                                if (!keyProp.equals("name") &&  !this.getZvol().zProperties.get(keyProp).getType().equals("noupdateable")){
856
                                        log.debug("zfsCreateVolFS :"+keyProp);
857
                                        optionsList = optionsList+keyProp+"="+this.getZvol().zProperties.get(keyProp).getValue()+",";
858
                                }
859
                        }else{
860
                                if (("filesystem".equalsIgnoreCase(this.getZvol().zProperties.get("type").getValue()) && 
861
                                                "fs".equalsIgnoreCase(this.getZvol().zProperties.get(keyProp).getPropertyOf())||"volandfs".equalsIgnoreCase(this.getZvol().zProperties.get(keyProp).getPropertyOf()))        ){
862
                                        if (this.getZvol().zProperties.get(keyProp).getValue().equals("")&&!this.getZvol().zProperties.get(keyProp).getType().equals("noupdateable")&&!"quota".equals(keyProp)&&!"reservation".equals(keyProp) ){
863
                                                error.put(keyProp, keyProp+" cannot be empty");
864
                                        }
865
                                        if (("quota".equals(keyProp)||"reservation".equals(keyProp))&&"".equals(this.getZvol().zProperties.get(keyProp).getValue())){
866
                                                this.getZvol().zProperties.get(keyProp).setValue("none");
867
                                        }
868
                                        if (("quota".equals(keyProp)||"reservation".equals(keyProp))&& !"none".equals(this.getZvol().zProperties.get(keyProp).getValue()) &&!"".equals(this.getZvol().zProperties.get(keyProp).getValue())){
869
                                                String nameVolFS = this.getZvol().zProperties.get("name").getValue();
870
                                                String unit = this.getZvol().zProperties.get(keyProp).getValue().substring(this.getZvol().zProperties.get(keyProp).getValue().length()-1, this.getZvol().zProperties.get(keyProp).getValue().length());        
871
                                                if ( !unit.equalsIgnoreCase("T") && !unit.equalsIgnoreCase("G") && !unit.equalsIgnoreCase("M")){
872
                                                        error.put(keyProp, "Field "+keyProp+" : Unit valid est T,G or M");
873
                                                }else{
874
                                                        Float realUseableSpace = this.convertInReferenceUnit(this.getZpool().zProperties.get("realuseablespace").getValue(), unit);
875
                                                        Float valueKeyProp = this.convertInReferenceUnit(this.getZvol().zProperties.get(keyProp).getValue(), unit);
876
                                                        this.zfsGetInfoByProperty(this.getZpool().zProperties.get("name").getValue(), "used");
877
                                                        Float usedSpace = this.convertInReferenceUnit(this.getZvol().zProperties.get("used").getValue(), unit);
878
                                                        this.getZvol().zProperties.get("name").setValue(nameVolFS);
879
                                                        Float freeSpace = realUseableSpace - usedSpace;
880
                                                        if ( valueKeyProp > freeSpace){
881
                                                                error.put(keyProp, "Error value for "+keyProp+" : No space available. Free Pool Space : "+String.valueOf(freeSpace)+unit);
882
                                                        }        
883
                                                }
884
                                        }
885
                                        log.debug("zfsCreateVolFS : "+keyProp+" "+this.getZvol().zProperties.get(keyProp).getType());
886
                                        if (!keyProp.equals("name") &&  !this.getZvol().zProperties.get(keyProp).getType().equals("noupdateable")){
887
                                                log.debug("zfsCreateVolFS :"+keyProp);
888
                                                optionsList = optionsList+keyProp+"="+this.getZvol().zProperties.get(keyProp).getValue()+",";
889
                                        }
890
                                }
891

    
892
                        }
893
                }
894
                if (error.size()==0){
895
                        log.debug(optionsList);
896
                        if ( optionsList.length()>0){
897
                                optionsList=optionsList.substring(0, optionsList.length()-1);        
898
                        }
899

    
900
                        if ( "volume".equals(this.getZvol().zProperties.get("type").getValue())&& this.executeCmd(this.getZserver().zProperties.get("binzfscreatevolume").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue()+
901
                                        " -p "+this.getZpool().zProperties.get("name").getValue()+
902
                                        " -b "+this.getZvol().zProperties.get("volblocksize").getValue()+
903
                                        " -s "+this.getZvol().zProperties.get("volsize").getValue()+
904
                                        " -o "+optionsList)){
905
                                if ( outErr.length() ==0){
906
                                        log.debug(this.getOutCmd());
907
                                }else{
908
                                        log.debug(this.getOutCmd());
909
                                        error.put("binzfscreatevolume", "Incoherence : Please connect you to server and launch manualy "+this.getZserver().zProperties.get("binzfscreatevolume").getValue() );
910
                                }
911
                        }else{
912
                                if ("filesystem".equals(this.getZvol().zProperties.get("type").getValue())&& this.executeCmd(this.getZserver().zProperties.get("binzfscreatefilesystem").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue()+
913
                                                " -p "+this.getZpool().zProperties.get("name").getValue()+
914
                                                " -o "+optionsList)){
915
                                        if ( outErr.length() ==0){
916
                                                log.debug(this.getOutCmd());
917
                                        }else{
918
                                                log.debug(this.getOutCmd());
919
                                                error.put("binzfscreatefilesystem", "Incoherence : Please connect you to server and launch manualy "+this.getZserver().zProperties.get("binzfscreatefilesystem").getValue() );
920
                                        }
921
                                }
922
                        }
923
                }else{
924
                        log.debug("Error : "+error.size());
925
                }
926
        }
927

    
928
        public void zfsUmountFS(){
929
                error.clear();
930
                if ("".equals(this.getZvol().zProperties.get("name").getValue())){
931
                        error.put("name", "Please select a ZFS FileSystem");
932
                }
933
                if (error.size()==0){
934
                        if (this.executeCmd(this.getZserver().zProperties.get("binzfs").getValue()+" umount "+this.getZvol().zProperties.get("name").getValue())){
935
                                if ( outErr.length() ==0){
936
                                        log.debug(this.getOutCmd());
937
                                }else{
938
                                        log.debug(this.getOutCmd());
939
                                        if (outErr.toString().contains("Error")){
940
                                                error.put("binzfs", "Incoherence : Please connect you to server and launch manualy "+this.getZserver().zProperties.get("binzfs").getValue() );
941
                                        }
942
                                }
943
                        }else{
944
                                error.put("executeCmd", "Problem with the command : "+this.getZserver().zProperties.get("binzfs").getValue()+" umount "+this.getZvol().zProperties.get("name").getValue());
945
                        }
946
                }
947

    
948
        }
949

    
950
        public void zfsDestroyVolFS(){
951
                error.clear();
952
                if ("".equals(this.getZvol().zProperties.get("name").getValue())){
953
                        error.put("name", "Please select a ZFS FileSystem");
954
                }
955
                if ( error.size()==0){
956
                        if ( "filesystem".equals(this.getZvol().zProperties.get("type").getValue())){
957
                                if ( this.executeCmd(this.getZserver().zProperties.get("binzfsdelfilesystem").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue() )) {
958
                                        if ( outErr.length() ==0){
959
                                                log.debug(this.getOutCmd());
960
                                        }else{
961
                                                log.debug(this.getOutCmd());
962
                                                if (outErr.length()>0){
963
                                                        error.put("binzfsdelvolume", outErr+"\n" );
964
                                                }
965
                                        }
966
                                }else{
967
                                        error.put("executeCmd", "Problem with the command : "+this.getZserver().zProperties.get("binzfsdelfilesystem").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue());
968
                                }        
969
                        }else{
970
                                if ( "volume".equals(this.getZvol().zProperties.get("type").getValue())){
971
                                        if ( this.executeCmd(this.getZserver().zProperties.get("binzfsdelvolume").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue() )) {
972
                                                if ( outErr.length() ==0){
973
                                                        log.debug(this.getOutCmd());
974
                                                }else{
975
                                                        log.debug(this.getOutCmd());
976
                                                        if (outErr.length()>0){
977
                                                                error.put("binzfsdelvolume", outErr+"\n" );
978
                                                        }
979
                                                }
980
                                        }else{
981
                                                error.put("executeCmd", "Problem with the command : "+this.getZserver().zProperties.get("binzfsdelvolume").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue());
982
                                        }
983
                                }else{
984
                                        if ( "snapshot".equals(this.getZvol().zProperties.get("type").getValue())){
985
                                                if ( this.executeCmd(this.getZserver().zProperties.get("binzfsdelvolume").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue() )) {
986
                                                        if ( outErr.length() ==0){
987
                                                                log.debug(this.getOutCmd());
988
                                                        }else{
989
                                                                log.debug(this.getOutCmd());
990
                                                                if (outErr.length()>0){
991
                                                                        error.put("binzfsdelvolume", outErr+"\n" );
992
                                                                }
993
                                                        }
994
                                                }else{
995
                                                        error.put("executeCmd", "Problem with the command : "+this.getZserver().zProperties.get("binzfsdelvolume").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue());
996
                                                }
997
                                        }
998
                                }
999
                        }
1000

    
1001
                }
1002
        }
1003

    
1004
        public void zfsCreateIscsi(){
1005
                String[] keysProp = (String[]) this.getZiscsi().zProperties.keySet().toArray(new String[0]);
1006
                Arrays.sort(keysProp);
1007
                error.clear();
1008
                if ("filesystem".equals(this.getZvol().zProperties.get("type").getValue())){
1009
                        error.put("type", "You cannot add a iscsi configuration for a zfs filesystem");
1010
                }
1011

    
1012
                for ( int i=0;i<keysProp.length;i++){
1013
                        String keyProp = keysProp[i];
1014
                        if (!this.getZiscsi().zProperties.get(keyProp).getType().contains("noupdateable") && !keyProp.equalsIgnoreCase("allowIP")){
1015
                                if ( "".equals(this.getZiscsi().zProperties.get(keyProp).getValue())) {
1016
                                        error.put(keyProp, this.getZiscsi().zProperties.get(keyProp).getLabelProperty()+" cannot be empty" );
1017
                                }
1018
                        }
1019
                }
1020
                if (!"".equals(this.getZiscsi().zProperties.get("tid").getValue())){
1021
                        error.put("tid", "Iscsi is already configured for this volume" );
1022
                }
1023

    
1024
                if ( error.size() ==0){
1025
                        String cmd = this.getZserver().zProperties.get("binzfsaddiscsi").getValue()+" -d "+this.getZserver().zProperties.get("pathzfsvoldevice").getValue()+this.getZiscsi().zProperties.get("name").getValue()
1026
                                        +" -T "+this.getZiscsi().zProperties.get("exportType").getValue()+
1027
                                        " -L 0"+
1028
                                        " -o "+this.getZiscsi().zProperties.get("iomode").getValue()+
1029
                                        " -l "+this.getZiscsi().zProperties.get("login").getValue()+
1030
                                        " -p "+this.getZiscsi().zProperties.get("passwd").getValue()+
1031
                                        " -t "+this.getZiscsi().zProperties.get("name").getValue();
1032
                        if (!this.getZiscsi().zProperties.get("allowIP").getValue().isEmpty()){
1033
                                cmd = cmd +" -R "+"\""+this.getZiscsi().zProperties.get("allowIP").getValue()+"\"";
1034
                        }
1035
                        if (  this.executeCmd(cmd)){
1036
                                if ( outErr.length() ==0){
1037
                                        //log.debug(this.getOutCmd());
1038
                                }else{
1039
                                        if (outErr.toString().contains("Error")){
1040
                                                error.put("pathzfsvoldevice", "Incoherence : Please connect you to server and launch manualy "+this.getZserver().zProperties.get("binzfsaddiscsi").getValue() );
1041
                                        }
1042
                                }
1043
                        }
1044
                }                
1045
        }
1046

    
1047
        public void zfsDelIscsi(){
1048
                error.clear();
1049
                if (!"".equals(this.getZiscsi().zProperties.get("tid").getValue())){
1050
                        if (  this.executeCmd(this.getZserver().zProperties.get("binzfsdeliscsi").getValue()+" -T "+"\""+this.getZiscsi().zProperties.get("tid").getValue()+"\"" )){
1051
                                if ( outErr.length() ==0){
1052
                                        log.debug(this.getOutCmd());
1053
                                }else{
1054
                                        log.debug("zdsdelIscsi Error : " +outErr);
1055
                                        if ( outErr.toString().contains("in use")){
1056
                                                error.put("binzfsdeliscsi", outErr.toString() );        
1057
                                        }else{
1058
                                                error.put("binzfsdeliscsi", outErr+"\n"+"Incoherence : Please connect you to server and launch manualy "+this.getZserver().zProperties.get("binzfsdeliscsi").getValue() );        
1059
                                        }
1060
                                }
1061
                        }        
1062
                }
1063

    
1064
        }
1065

    
1066

    
1067
        public void zfsClone(){
1068
                error.clear();
1069
                if ("".equals(this.getZvol().zProperties.get("name").getValue())){
1070
                        error.put("name", "Please, select a volume or filesystem to clone" );
1071
                }
1072

    
1073
                if ( error.size() ==0){
1074
                        String cmd = this.getZserver().zProperties.get("binzfsclone").getValue()+" -n "+this.getZvol().zProperties.get("name").getValue();
1075
                        if (  this.executeCmd(cmd)){
1076
                                if ( outErr.length() ==0){
1077
                                        log.debug(this.getOutCmd());
1078
                                        String[] TsplitOut = this.getOutCmd().split("\n");
1079
                                        if (TsplitOut.length>0){
1080
                                                String[] TsplitLine = TsplitOut[0].split("name:");
1081
                                                if (TsplitLine.length>0){
1082
                                                        this.zfsGetAllVolume(TsplitLine[1]);
1083
                                                        if ("".equalsIgnoreCase(this.getZvol().zProperties.get("name").getValue())){
1084
                                                                error.put("zfsclone", "Clone Creation failed");
1085
                                                        }
1086
                                                }
1087
                                        }
1088
                                }else{
1089
                                        if (outErr.length()>0){
1090
                                                error.put("zfsclone", outErr);
1091
                                        }
1092
                                }
1093
                        }
1094
                }
1095
        }
1096

    
1097

    
1098
        public float convertInReferenceUnit(String value2Convert, String refUnit){
1099

    
1100
                float convertedValue=0;
1101
                value2Convert = value2Convert.replace(",", ".");
1102
                log.debug("convertInReferenceUnit "+value2Convert+" "+refUnit);
1103
                if ( refUnit.equalsIgnoreCase("T")){
1104
                        if (value2Convert.contains("T")){
1105
                                convertedValue=Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)));
1106
                        }else{
1107
                                if (value2Convert.contains("G")){
1108
                                        convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)))/1024);
1109
                                }else{
1110
                                        if (value2Convert.contains("M")){
1111
                                                convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)))/1048576);
1112
                                        }else{
1113
                                                if (value2Convert.contains("K")){
1114
                                                        convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)))/1073741824);
1115
                                                }
1116
                                        }
1117
                                }
1118
                        }
1119

    
1120
                }
1121

    
1122
                if ( refUnit.equalsIgnoreCase("G")){
1123
                        if (value2Convert.contains("G")){
1124
                                convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1))));
1125
                        }else{
1126
                                if (value2Convert.contains("T")){
1127
                                        convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)))*1024);
1128
                                }else{
1129
                                        if (value2Convert.contains("M")){
1130
                                                convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)))/1024);
1131
                                        }else{
1132
                                                if (value2Convert.contains("K")){
1133
                                                        convertedValue=(Float.valueOf(value2Convert.substring(0, (value2Convert.length()-1)))/1048576);
1134
                                                }
1135
                                        }
1136
                                }
1137
                        }
1138
                }
1139
                log.debug("getZpoolProvisionedSpace "+convertedValue);
1140
                return convertedValue;
1141
        }
1142

    
1143
        public List<Object> zfsList(){
1144
                zfsList.clear();
1145

    
1146

    
1147
                if (  this.executeCmd("/sbin/zfs list -H") ){
1148
                        String[] Tsplit = this.getOutCmd().split("\n");
1149
                        for (int cpt=0;cpt<Tsplit.length;cpt++){
1150
                                log.debug(Tsplit[cpt].split("\\s+")[0] );
1151
                                zfsList.add(Tsplit[cpt].split("\\s+")[0]);
1152
                                //zpoolNames[ind] = Tsplit[cpt].split("\\s+")[0];
1153
                        }
1154
                }
1155
                return zfsList;
1156
        }
1157

    
1158

    
1159
        public boolean addServer(){
1160

    
1161
                if (!"".equalsIgnoreCase(this.getZserver().zProperties.get("serverIP").getValue())) {
1162
                        this.getZserver().add(System.getProperty("user.home")+prop.getProperty("serverConfDir")+this.getZserver().zProperties.get("serverIP").getValue()+".properties");
1163

    
1164
                }else{
1165
                        return false;
1166
                }
1167
                return true;
1168
        }
1169

    
1170
        public boolean removeServer(){
1171
                if (!"".equalsIgnoreCase(this.getZserver().zProperties.get("serverIP").getValue())) {
1172
                        this.getZserver().remove(System.getProperty("user.home")+prop.getProperty("serverConfDir")+this.getZserver().zProperties.get("serverIP").getValue()+".properties");
1173
                        this.getCacheSession().remove(this.getZserver().zProperties.get("serverIP").getValue());
1174
                }
1175
                return false;
1176
        }
1177

    
1178
        public List<Object> getListServer(){
1179
                String dirName = System.getProperty("user.home")+prop.getProperty("serverConfDir");
1180
                log.debug(System.getProperty("user.home")+prop.getProperty("serverConfDir"));
1181
                File dir = new File(dirName);
1182
                if ( !dir.exists()){
1183
                        dir.mkdir();
1184
                        log.debug((System.getProperty("user.home")+prop.getProperty("serverConfDir")));
1185
                }
1186
                log.debug((System.getProperty("user.home")+prop.getProperty("serverConfDir")));
1187
                File f = new File(System.getProperty("user.home")+prop.getProperty("serverConfDir"));
1188
                log.debug((System.getProperty("user.home")+prop.getProperty("serverConfDir")));
1189
                File[] list = f.listFiles();
1190
                List<Object> listServer = new ArrayList<Object>();
1191
                for (int i=0;i<list.length;i++){
1192
                        listServer.add(list[i].getName().split(".properties")[0]);
1193
                }
1194
                return listServer;
1195
        }
1196

    
1197
        public void getServer(String serverName){
1198
                this.getZserver().load(System.getProperty("user.home")+prop.getProperty("serverConfDir")+serverName+".properties");
1199
                String[] keysProp = (String[]) this.getZserver().zProperties.keySet().toArray(new String[0]);
1200
                Arrays.sort(keysProp);
1201
                error.clear();
1202
                for ( int i=0;i<keysProp.length;i++){
1203
                        String keyProp = keysProp[i];
1204
                        if (prop.containsKey(keyProp)){
1205
                                this.getZserver().zProperties.get(keyProp).setValue(prop.getProperty(keyProp));        
1206
                        }
1207

    
1208
                }
1209
        }
1210

    
1211
        public void checkBinEnv(){
1212
                String[] keysProp = (String[]) this.getZserver().zProperties.keySet().toArray(new String[0]);
1213
                Arrays.sort(keysProp);
1214
                error.clear();
1215
                for ( int i=0;i<keysProp.length;i++){
1216
                        String keyProp = keysProp[i];
1217
                        if ( !keyProp.equalsIgnoreCase("serverIP") && !keyProp.equalsIgnoreCase("userLogin") && !keyProp.equalsIgnoreCase("userPasswd")&&!keyProp.equalsIgnoreCase("pathzfsvoldevice")){
1218
                                if (  this.executeCmd(prop.getProperty(keyProp)) && ! outErr.toString().contains("No such file or directory")){
1219
                                        log.debug(prop.getProperty(keyProp));
1220
                                        log.debug("checkBinEnv "+outErr.toString().contains("No such file or directory"));
1221
                                }else{
1222
                                        error.put(keyProp, outErr.toString());
1223
                                }
1224
                        }
1225
                }
1226
        }
1227

    
1228
        public void loadConfig(){
1229

    
1230
                try {
1231
                        InputStream resource = getClass().getResourceAsStream("config.properties");
1232

    
1233
                        prop.load(resource);
1234
                        log.debug(prop);
1235
                } catch (FileNotFoundException e) {
1236
                        // TODO Auto-generated catch block
1237
                        e.printStackTrace();
1238
                } catch (IOException e) {
1239
                        // TODO Auto-generated catch block
1240
                        e.printStackTrace();
1241
                }
1242
        }
1243
        public String getUserPassword() {
1244
                return userPassword;
1245
        }
1246

    
1247

    
1248

    
1249
        public void setUserPassword(String userPassword) {
1250
                this.userPassword = userPassword;
1251
        }
1252

    
1253

    
1254

    
1255
        public String getUserLogin() {
1256
                return userLogin;
1257
        }
1258

    
1259

    
1260

    
1261
        public void setUserLogin(String userLogin) {
1262
                this.userLogin = userLogin;
1263
        }
1264

    
1265

    
1266

    
1267
        public String getSshHost() {
1268
                return sshHost;
1269
        }
1270

    
1271

    
1272

    
1273
        public void setSshHost(String sshHost) {
1274
                this.sshHost = sshHost;
1275
        }
1276

    
1277

    
1278

    
1279
        public int getSshPort() {
1280
                return sshPort;
1281
        }
1282

    
1283

    
1284

    
1285
        public void setSshPort(int sshPort) {
1286
                this.sshPort = sshPort;
1287
        }
1288

    
1289
        public String getOutCmd() {
1290
                return outCmd;
1291
        }
1292

    
1293
        public void setOutCmd(String out) {
1294
                this.outCmd=out;
1295
        }
1296

    
1297
        public Session getSession() {
1298
                return session;
1299
        }
1300

    
1301
        public void setSession(Session session) {
1302
                this.session = session;
1303
        }
1304

    
1305
        /**
1306
         * @return the zSnapshot
1307
         */
1308
        public zsnapshots getZsnapshots() {
1309
                return zsnapshots;
1310
        }
1311

    
1312
        /**
1313
         * @param zSnapshot the zSnapshot to set
1314
         */
1315
        public void setZsnapshots() {
1316
                this.zsnapshots = new zsnapshots();
1317
        }
1318

    
1319
        public zreplicas getZreplicas() {
1320
                return zreplicas;
1321
        }
1322

    
1323
        public void setZreplicas() {
1324
                this.zreplicas = new zreplicas();
1325
        }
1326

    
1327
        /**
1328
         * @return the ziscsi
1329
         */
1330
        public ziscsi getZiscsi() {
1331
                return ziscsi;
1332
        }
1333

    
1334
        /**
1335
         * @param ziscsi the ziscsi to set
1336
         */
1337
        public void setZiscsi() {
1338
                this.ziscsi = new ziscsi();
1339
        }
1340

    
1341
        /**
1342
         * @return the zserver
1343
         */
1344
        public zserver getZserver() {
1345
                return zserver;
1346
        }
1347

    
1348
        /**
1349
         * @param zserver the zserver to set
1350
         */
1351
        public void setZserver() {
1352
                this.zserver = new zserver();
1353
        }
1354

    
1355
        /**
1356
         * @return the cacheSession
1357
         */
1358
        public Hashtable<String,Session> getCacheSession() {
1359
                return cacheSession;
1360
        }
1361

    
1362
        /**
1363
         * @param cacheSession the cacheSession to set
1364
         */
1365
        public void setCacheSession(Hashtable<String,Session> cacheSession) {
1366
                this.cacheSession = cacheSession;
1367
        }
1368

    
1369
        /**
1370
         * @return the zpool
1371
         */
1372
        public zpool getZpool() {
1373
                return zpool;
1374
        }
1375

    
1376
        /**
1377
         * @param zpool the zpool to set
1378
         */
1379
        public void setZpool() {
1380
                this.zpool = new zpool();
1381
        }
1382

    
1383

    
1384
        public zdisk getZdisk() {
1385
                return zdisk;
1386
        }
1387

    
1388
        public void setZdisk() {
1389
                this.zdisk = new zdisk();
1390
        }
1391

    
1392
        /**
1393
         * @return the error
1394
         */
1395
        public Hashtable<String,Object> getError() {
1396
                return error;
1397
        }
1398

    
1399
        /**
1400
         * @param error the error to set
1401
         */
1402
        public void setError(Hashtable<String,Object> error) {
1403
                this.error = error;
1404
        }
1405

    
1406
        public Hashtable<String, zdisk> getHashDisks() {
1407
                return hashDisks;
1408
        }
1409

    
1410
        public void setHashDisks(Hashtable<String, zdisk> hashDisks) {
1411
                this.hashDisks = hashDisks;
1412
        }
1413

    
1414
        public zraid getZraid() {
1415
                return zraid;
1416
        }
1417

    
1418
        public void setZraid() {
1419
                this.zraid = new zraid();
1420
        }
1421

    
1422

    
1423

    
1424
        public Hashtable<String, zraid> getHashZRaid() {
1425
                return hashZRaid;
1426
        }
1427

    
1428
        public void setHashZRaid(Hashtable<String, zraid> hashZRaid) {
1429
                this.hashZRaid = hashZRaid;
1430
        }
1431

    
1432
}