-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmegamenu-remote.py
executable file
·1901 lines (1839 loc) · 76.3 KB
/
megamenu-remote.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
#encoding=utf-8
import traceback, os, re, time, sys, paramiko
from snack import * #导入图形界面
class ProWin:
#进度条
def __init__(self, screen, title, text):
self.screen = screen
self.g = GridForm(self.screen, title, 1, 2)
self.s = Scale(60, 100)
self.g.add(Textbox(60, 2, text), 0, 0)
self.g.add(self.s, 0, 1)
def show(self):
self.g.draw()
self.screen.refresh()
def update(self, progress):
self.s.set(progress)
self.g.draw()
self.screen.refresh()
def close(self):
self.update(70)
time.sleep(1)
self.update(98)
time.sleep(1)
self.update(100)
time.sleep(1)
self.screen.popWindow()
class GetVDInfo:
def __init__(self, n):
self.num = n
def vdnum(self):
r, t, y = client.exec_command(megacli + " -cfgdsply -a" + self.num + " -nolog | grep 'DISK GROUP:' -n | awk -F ':' '{print $1}'")
i = t.readlines()
return i
def vdtotalnum(self):
r, t, y = client.exec_command(megacli + " -cfgdsply -a" + self.num + " -nolog | grep 'DISK GROUP:' -n | wc -l")
i = t.read()
return i
def vdhsp(self):
r, t, y = client.exec_command(megacli + " -cfgdsply -a" + self.num + " -nolog | grep 'Number of dedicated Hotspares: ' | awk -F ': ' '{print$2}'")
i = t.readlines()
return i
def vdshow(self):
r, t, y = client.exec_command(megacli + " -cfgdsply -a" + self.num + " -nolog | grep 'DISK GROUP:'")
i = t.readlines()
return i
def vdsize(self):
r, t, y = client.exec_command(megacli + " -ldinfo -lall -a" + self.num + " -nolog | grep 'Size :' | awk -F ': ' '{print$2}'")
i = t.readlines()
return i
def vdstate(self):
r, t, y = client.exec_command(megacli + " -ldinfo -lall -a" + self.num + " -nolog | grep State | awk -F ': ' '{print$2}'")
i = t.readlines()
return i
def delvdnum(self):
r, t, y = client.exec_command(megacli + " -ldinfo -lall -a" + self.num + " -nolog | grep 'Virtual Drive:' | awk -F ' ' '{print$3}'")
i = t.readlines()
return i
def raidstate(self):
r, t, y = client.exec_command(megacli + " -ShowSummary -a" + self.num + " -nolog | grep 'RAID Level' | awk -F ': ' '{print$2}'")
i = t.readlines()
return i
class GetPDInfo:
def __init__(self, n):
self.num = n
def pdisknum(self):
r, t, y = client.exec_command(megacli + " -pdlist -a" + self.num + " -nolog | grep 'Enclosure Device ID' -n | awk -F ':' '{print $1}'")
i = t.readlines()
return i
def pdiskrnum(self):
r, t, y = client.exec_command(megacli + " -pdlist -a" + self.num + " -nolog | grep 'Enclosure Device ID' | awk -F ': ' '{print $2}'")
i = t.readlines()
return i
def pdtotalnum(self):
r, t, y = client.exec_command(megacli + " -pdlist -a" + self.num + " -nolog | grep 'Enclosure Device ID' -n | wc -l")
i = t.read()
return i
def pdshow(self):
r, t, y = client.exec_command(megacli + " -pdlist -a" + self.num + " -nolog | grep 'Slot Number:'")
i = t.readlines()
return i
def pdsize(self):
r, t, y = client.exec_command(megacli + " -pdlist -a" + self.num + " -nolog | grep 'Raw Size' | awk -F ' ' '{print$3$4}'")
i = t.readlines()
return i
def pdstate(self):
r, t, y = client.exec_command(megacli + " -pdlist -a" + self.num + " -nolog | grep 'Firmware state' | awk -F ': ' '{print$2}'")
i = t.readlines()
return i
def pdstate2(self):
r, t, y = client.exec_command(megacli + " -pdlist -a" + self.num + " -nolog | grep 'Firmware state' | awk -F ': ' '{print$2}'")
i = t.read()
return i
def pdedid(self):
r, t, y = client.exec_command(megacli + " -pdlist -a" + self.num + " -nolog | grep 'Enclosure Device ID' | awk -F ': ' '{print $2}'")
i = t.readlines()
return i
def pdslnum(self):
r, t, y = client.exec_command(megacli + " -pdlist -a" + self.num + " -nolog | grep 'Slot Number:' | awk -F ': ' '{print$2}'")
i = t.readlines()
return i
def pdforeign(self):
r, t, y = client.exec_command(megacli + " -pdlist -a" + self.num + " -nolog | grep 'Foreign State:'")
i = t.readlines()
return i
def warwindows(screen, title, text, help = None):
#警告窗口
btn = Button("确定")
war = GridForm(screen, title, 1, 15)
war.add(Label(text),0,1)
war.add(Label(""),0,2)
war.add(btn, 0, 3)
war.runOnce(35,10)
def conformwindows(screen, text, help = None):
#确认窗口
btns = ("是", "否")
le = len(text) + 3
bb = ButtonBar(screen, btns, compact = 1)
g = GridForm(screen, text, 20, 16)
g.add(Label(text),0,2)
g.add(bb,0,3,(10,0,10,0), growx = 1)
re = g.runOnce(30, 8)
return (bb.buttonPressed(re), re)
def sc():
#刷新屏幕
global screen
screen = SnackScreen()
screen.finish()
screen = SnackScreen()
screen.setColor("ROOT", "white", "blue")
screen.setColor("ENTRY","white","blue")
screen.setColor("LABEL","black","white")
screen.setColor("HELPLINE","white","blue")
screen.setColor("TEXTBOX","black","yellow")
def QUIT():
#调用退出到命令行,输入exit返回
global out
buttons = ("是", "否")
bb = ButtonBar(screen, buttons)
g = GridForm(screen, "返回登陆界面?" , 20,16)
g.add(bb,1,3,(10,0,10,0), growx = 1)
rq = g.runOnce(32,8)
screen.popWindow()
if rq == "ESC" or bb.buttonPressed(rq) == "否":
screen.finish()
return mainform()
else:
screen.finish()
out = 1
return
def details1(num):
re = []
n = 0
li = Listbox(height = 8, width = 24, returnExit = 1, showCursor = 0)
li.append("a)物理磁盘信息", 1)
li.append("b)虚拟磁盘组信息", 2)
li.append("c)磁盘组对应关系列表",3)
li.append("d)RAID卡及磁盘信息摘要",4)
li.append("e)RAID卡详细信息",5)
li.append("f)磁盘组初始化进度",6)
r, t, y = client.exec_command(megacli + " -adpallinfo -a" + num + " -nolog | grep Product")
re.append(t.readline())
r, t, y = client.exec_command(megacli + " -adpallinfo -a" + num + " -nolog | grep Disks")
re.append(t.readline())
r, t, y = client.exec_command(megacli + " -adpallinfo -a" + num + " -nolog | grep 'Critical Disks :'")
re.append(t.readline())
r, t, y = client.exec_command(megacli + " -adpallinfo -a" + num + " -nolog | grep 'Failed Disks :'")
re.append(t.readline())
r, t, y = client.exec_command(megacli + " -adpallinfo -a" + num + " -nolog | grep Virtual")
re.append(t.readline())
r, t, y = client.exec_command(megacli + " -adpallinfo -a" + num + " -nolog | grep 'Offline :'")
re.append(t.readline())
r, t, y = client.exec_command(megacli + " -adpallinfo -a" + num + " -nolog | grep Degraded")
re.append(t.readline())
r, t, y = client.exec_command(megacli + " -adpallinfo -a" + num + " -nolog | grep JBOD")
re.append(t.readline())
r, t, y = client.exec_command(megacli + " -pdlist -a" + num + " -nolog | grep 'Foreign State: Foreign' -c")
foreign = t.read()
r, t, y = client.exec_command(megacli + " -pdlist -a" + num + " -nolog | grep 'Firmware state: Hotspare' -c")
hsp = t.read()
r, t, y = client.exec_command(megacli + " -pdlist -a" + num + " -nolog | grep JBOD -c")
JBOD = t.read()
h = GridForm(screen, "概览", 1, 18)
r, t, y = client.exec_command(megacli + " -adpbootdrive -get -a" + num + " -nolog | grep Virtual | awk -F ' ' '{print$7}'")
bootdrv = t.read().replace('#','').strip('/n')
for i in re:
n = n + 1
h.add(TextboxReflowed(40, str(i).replace('Product Name','RAID卡名称').replace('Failed Disks :','失效磁盘:').replace('Critical Disks :','高危磁盘:').replace('Disks','物理磁盘数量').replace('Virtual Drives','已创建磁盘组').replace('Enable JBOD','开启JBOD模式').replace(' ','').replace('Offline:','下线磁盘组:').replace('Degraded:','降级磁盘组:').strip("\n"), flexDown = 5, flexUp = 10, maxHeight = -1), 0, n)
h.add(TextboxReflowed(40, "JBOD模式磁盘数量:%s" %JBOD, flexDown = 5, flexUp = 10, maxHeight = -1), 0, n + 1)
h.add(TextboxReflowed(40, "外来磁盘数量: " + str(foreign).strip('\n'), flexDown = 5, flexUp = 10, maxHeight = -1), 0, n + 2)
h.add(TextboxReflowed(40, "热备磁盘数量: " + str(hsp).strip('\n'), flexDown = 5, flexUp = 10, maxHeight = -1), 0, n + 3)
try:
int(bootdrv)
h.add(TextboxReflowed(40, "BOOT磁盘组: DG-" + str(bootdrv).strip('\n'), flexDown = 5, flexUp = 10, maxHeight = -1), 0, n + 4)
except:
h.add(TextboxReflowed(40, "BOOT磁盘组: 还未设定", flexDown = 5, flexUp = 10, maxHeight = -1), 0, n + 4)
h.add(li, 0, n + 5)
bb = CompactButton('返回')
h.add(bb, 0, 14)
rc = h.runOnce(43,3)
if rc == "ESC" or "snack.CompactButton" in str(rc):
return ADPSelect()
elif li.current() == 1:
pdinfo(num)
elif li.current() == 2:
vdinfo(num)
elif li.current() == 3:
vdpdinfo(num)
elif li.current() == 4:
infosum(num)
elif li.current() == 5:
moredetails(num)
elif li.current() == 6:
diskinit(num)
elif li.current() == 7:
dgrebulid(num)
def diskinit(num):
r, t, y = client.exec_command(megacli + " -ldbi -showprog -lall -a" + str(num).strip('\n') + " -nolog")
info = t.read()
h = GridForm(screen, "磁盘组初始化进度", 1, 5)
h.add(Textbox(90, 15, info, scroll = 1, wrap = 1), 0, 1)
bb = CompactButton('返回')
h.add(bb, 0, 2)
rc = h.runOnce(2,3)
return details1(num)
def infosum(num):
r, t, y = client.exec_command(megacli + " -ShowSummary -a" + str(num) + " -nolog".strip('\n'))
info = t.read()
h = GridForm(screen, "RAID卡及磁盘信息摘要", 1, 5)
h.add(Textbox(90, 15, info, scroll = 1, wrap = 1), 0, 1)
bb = CompactButton('返回')
h.add(bb, 0, 2)
rc = h.runOnce(2,3)
return details1(num)
def vdpdinfo(num):
more = ''
r, t, y = client.exec_command(megacli + " -cfgdsply –a" + str(num).strip('\n') + " -nolog | grep -E 'DISK\\ GROUP|Slot\\ Number|RAID\\ Level|Target'")
more1 = t.readlines()
for i in more1:
if 'DISK GROUP:' in i:
more = more + "----------------------------------\n|----" + (str(i)).strip('\n') + '----|\n' + "----------------------------------\n"
else:
more = more + (str(i))
h = GridForm(screen, "磁盘对应关系列表", 1, 5)
h.add(Textbox(80, 15, more, scroll = 1, wrap = 1), 0, 1)
bb = CompactButton('返回')
h.add(bb, 0, 2)
rc = h.runOnce(2,3)
return details1(num)
def moredetails(num):
r, t, y = client.exec_command(megacli + " -adpallinfo -a" + num + " -nolog")
more = t.read()
h = GridForm(screen, "RAID卡详细信息", 1, 10)
h.add(Textbox(55, 15, more, scroll = 1, wrap = 1), 0, 1)
bb = CompactButton('返回')
h.add(bb, 0, 2)
rc = h.runOnce(25,3)
return details1(num)
def pdinfo(num):
p = GetPDInfo(num)
pdisknum = p.pdisknum()
pdtotalnum = p.pdtotalnum()
pdshow = p.pdshow()
pdsize = p.pdsize()
pdstate = p.pdstate()
pdforeign = p.pdforeign()
pdiskrnum = p.pdiskrnum()
pdslnum = p.pdslnum()
n = 0
li = Listbox(height = 20, width = 100, returnExit = 1, showCursor = 0, scroll = 1)
try:
if pdisknum != []:
for i in pdshow:
if 'None' in pdforeign[n]:
li.append(str(i).strip('\n').replace('Slot Number','槽位') + "\t大小: " + str(pdsize[n]).strip('\n') + "\t状态: " + str(pdstate[n]).strip('\n').replace(' ',''), n + 1)
else:
li.append(str(i).strip('\n').replace('Slot Number','<Foreign>槽位') + "\t大小: " + str(pdsize[n]).strip('\n') + "\t\t状态: " + str(pdstate[n]).strip('\n').replace(' ',''), n + 1)
n = n + 1
g = GridForm(screen, "物理磁盘信息", 1, 10)
g.add(li, 0, 1)
bb = CompactButton('返回')
g.add(bb, 0, 2)
rc = g.runOnce(2,3)
if rc == 'ESC' or 'snack.CompactButton' in str(rc) :
return details1(num)
else:
selectPD = int(li.current() - 1)
li2 = Listbox(height = 5, width = 33, returnExit = 1, showCursor = 0, scroll = 1)
li2.append("查看槽位" + str(pdslnum[selectPD]).strip('\n') + "的磁盘详细信息", 1)
li2.append("查看槽位" + str(pdslnum[selectPD]).strip('\n') + "的磁盘重建信息", 2)
if 'Unconfigured(good)' in str(pdstate[selectPD]) :
li2.append("将槽位" + str(pdslnum[selectPD]).strip('\n') + "的磁盘作为全局热备盘", 3)
if 'Hotspare' in str(pdstate[selectPD]) :
li2.append("槽位" + str(pdslnum[selectPD]).strip('\n') + "的磁盘不再作为热备盘", 4)
f = GridForm(screen, "请选择", 1, 5)
f.add(li2, 0, 1)
bb2 = CompactButton('返回')
f.add(bb2, 0, 2)
rf = f.runOnce(43,3)
if rf == 'ESC' or 'snack.CompactButton' in str(rf) :
return pdinfo(num)
elif li2.current() == 1:
return pdinfo2(num,pdisknum,pdtotalnum,selectPD)
elif li2.current() == 2:
r, t, y = client.exec_command(megacli + " -pdrbld -ShowProg -physdrv [" + str(pdiskrnum[selectPD]).strip('\n') + ":" + str(pdslnum[selectPD]).strip('\n') + "] -a" + str(num) + " -nolog")
diskrebuild = t.read()
d = GridForm(screen, "磁盘详细信息", 1, 5)
d.add(Textbox(65, 5, str(diskrebuild), scroll = 1, wrap = 1), 0, 1)
bb3 = CompactButton('返回')
d.add(bb3, 0, 2)
rd = d.runOnce(15,3)
if rd == 'ESC' or 'snack.CompactButton' in str(rd) :
return pdinfo(num)
elif li2.current() == 3:
rx = conformwindows(screen, "确定将槽位" + str(pdslnum[selectPD]).strip('\n') + "的磁盘作为全局热备盘?")
if rx[0] == "否" or rx[1] == "ESC":
return pdinfo(num)
r, t, y = client.exec_command(megacli + " -pdhsp -set -physdrv[" + str(pdiskrnum[selectPD]).strip('\n') + ":" + str(pdslnum[selectPD]).strip('\n') + "] -a" + str(num) + " -nolog")
ghsp = t.read()
if 'Success' in ghsp:
warwindows(screen, "完成", "成功设置全局热备盘")
return pdinfo(num)
warwindows(screen, "警告", "设置全局热备盘失败")
return pdinfo(num)
elif li2.current() == 4:
rx = conformwindows(screen, "确定取消槽位" + str(pdslnum[selectPD]).strip('\n') + "的磁盘为热备盘?")
if rx[0] == "否" or rx[1] == "ESC":
return pdinfo(num)
r, t, y = client.exec_command(megacli + " -pdhsp -rmv -physdrv[" + str(pdiskrnum[selectPD]).strip('\n') + ":" + str(pdslnum[selectPD]).strip('\n') + "] -a" + str(num) + " -nolog")
nohsp = t.read()
if 'Success' in nohsp:
warwindows(screen, "完成", "已为磁盘取消热备盘")
return pdinfo(num)
warwindows(screen, "警告", "取消热备盘失败")
return pdinfo(num)
else:
warwindows(screen, "警告", "未能找到磁盘")
return details1(num)
except:
warwindows(screen, "警告", "MegaCLI运行错误,请手动检查")
return details1(num)
def pdinfo2(num,pdisknum,pdtotalnum,selectPD):
if int(selectPD) + 1 != int(pdtotalnum) :
r, t, y = client.exec_command(megacli + " -pdlist -a" + num + " -nolog | sed -n '" + str(pdisknum[int(str(selectPD).strip('\n'))]).strip('\n') + "," + str(int(str(pdisknum[int(str(selectPD).strip('\n')) + 1]).strip('\n')) - 3).strip('\n') + "p'")
pd = t.read()
#pdnum = str(selectDG) + " " + str(vdtotalnum)
else:
r, t, y = client.exec_command(megacli + " -pdlist -a" + num + " -nolog | sed -n '" + str(pdisknum[int(str(selectPD).strip('\n'))]).strip('\n') + ",999999p'")
pd = t.read()
#pdnum = str(selectDG) + " " + str(vdtotalnum)
h = GridForm(screen, "磁盘详细信息", 20, 20)
h.add(Textbox(95, 15, pd, scroll = 1, wrap = 1), 0, 1)
bb = CompactButton('返回')
h.add(bb, 0, 2)
rc = h.runOnce(2,3)
return pdinfo(num)
def vdinfo(num):
p = GetVDInfo(num)
vdnum = p.vdnum()
vdtotalnum = p.vdtotalnum()
vdshow = p.vdshow()
vdsize = p.vdsize()
vdstate = p.vdstate()
raidstate = p.raidstate()
vdhsp = p.vdhsp()
li = Listbox(height = 20, width = 100, returnExit = 1, showCursor = 0, scroll = 1)
n = 0
disknum = 0
try:
if vdnum != []:
for i in vdnum:
if n != int(vdtotalnum):
if n != int(vdtotalnum) - 1:
r, t, y = client.exec_command(megacli +" -cfgdsply -a" + num + " -nolog | sed -n '" + str(i).strip('\n') + "," + str(vdnum[n+1]).strip('\n') + "p' | grep 'Number of PDs:' | awk -F ': ' '{print$2}'")
pdnum = t.readlines()
for k in pdnum:
disknum = disknum + int(k.strip('\n'))
li.append(str(vdshow[n].replace('SPANNED DISK GROUP','组合磁盘组').replace('DISK GROUP','普通磁盘组')).strip('\n') + "\t磁盘数量:" + str(disknum).strip('\n') + "\tRAID后大小:" + str(vdsize[n]).strip('\n') + "\t状态:" + str(vdstate[n]).strip('\n') + "\tRAID级别:" + str(raidstate[n]), n + 1)
disknum = 0
n = n + 1
else:
r, t, y = client.exec_command(megacli +" -cfgdsply -a" + num + " -nolog | sed -n '" + str(i).strip('\n') + ",999999p' | grep 'Number of PDs:' | awk -F ': ' '{print$2}'")
pdnum = t.readlines()
for k in pdnum:
disknum = disknum + int(k.strip('\n'))
li.append(str(vdshow[n].replace('SPANNED DISK GROUP','组合磁盘组').replace('DISK GROUP','普通磁盘组')).strip('\n') + "\t磁盘数量:" + str(disknum).strip('\n') + "\tRAID后大小:" + str(vdsize[n]).strip('\n') + "\t状态:" + str(vdstate[n]).strip('\n') + "\tRAID级别:" + str(raidstate[n]), n + 1)
disknum = 0
n = n + 1
g = GridForm(screen, "DG&VG 信息", 1, 10)
g.add(li, 0, 1)
bb = CompactButton('返回')
g.add(bb, 0, 2)
rc = g.runOnce(2,3)
if rc == 'ESC' or 'snack.CompactButton' in str(rc):
return details1(num)
else:
selectDG = int(li.current() - 1)
li2 = Listbox(height = 9, width = 43, returnExit = 1, showCursor = 0, scroll = 1)
li2.append("查看" + str(vdshow[selectDG].replace('SPANNED DISK GROUP','组合磁盘组').replace('DISK GROUP','普通磁盘组')).strip('\n') + " 的详细信息", 1)
li2.append("指定" + str(vdshow[selectDG].replace('SPANNED DISK GROUP','组合磁盘组').replace('DISK GROUP','普通磁盘组')).strip('\n') + " 的热备盘", 2)
if int(vdhsp[selectDG]) != 0:
li2.append("查看" + str(vdshow[selectDG].replace('SPANNED DISK GROUP','组合磁盘组').replace('DISK GROUP','普通磁盘组')).strip('\n') + " 的热备盘", 3)
li2.append("指定" + str(vdshow[selectDG].replace('SPANNED DISK GROUP','组合磁盘组').replace('DISK GROUP','普通磁盘组')).strip('\n') + " 为BOOT磁盘组", 4)
li2.append("设定" + str(vdshow[selectDG].replace('SPANNED DISK GROUP','组合磁盘组').replace('DISK GROUP','普通磁盘组')).strip('\n') + " 的缓存策略", 5)
f = GridForm(screen, "请选择", 1, 10)
f.add(li2, 0, 1)
bb2 = CompactButton('返回')
f.add(bb2, 0, 2)
rf = f.runOnce(43,3)
if rf == 'ESC' or 'snack.CompactButton' in str(rf) :
return vdinfo(num)
elif li2.current() == 1:
return vdinfo2(num,vdnum,vdtotalnum,selectDG)
elif li2.current() == 2:
p = GetPDInfo(num)
pdisknum = p.pdisknum()
pdtotalnum = p.pdtotalnum()
pdshow = p.pdshow()
pdedid = p.pdedid()
pdslnum = p.pdslnum()
pdsize = p.pdsize()
pdstate = p.pdstate()
pdstate2 = p.pdstate2()
ct = CheckboxTree(height = 8, scroll = 1)
n = 0
pdedid2 = []
pdslnum2 = []
pdshow2 = []
pdsize2 = []
ok = False
li3 = Listbox(height = 15, width = 75, returnExit = 1, showCursor = 0, scroll = 1)
if pdisknum != []:
if "Unconfigured(good)" not in pdstate2 and "Hotspare" not in pdstate2:
warwindows(screen, "警告", "没有合适的磁盘")
return vdinfo(num)
n2 = 0
for i in pdshow:
if "Unconfigured(good)" in str(pdstate[n]).strip('\n') or "Hotspare" in str(pdstate[n]).strip('\n'):
li3.append(str(i).strip('\n').replace('Slot Number','槽位') + "\t大小: " + str(pdsize[n]).strip('\n') + "\t状态:" + str(pdstate[n].strip('\n')), n2)
pdedid2.append(str(pdedid[n]))
pdslnum2.append(str(pdslnum[n]))
n2 = n2 + 1
n = n + 1
bb = ButtonBar(screen, (("确定", "ok"), ("取消", "cancel")))
j = GridForm(screen, "选择热备磁盘", 1, 3)
j.add(li3, 0, 1)
j.add(bb, 0 ,2)
rq = j.runOnce(25, 3)
if rq == 'ESC' or str(bb.buttonPressed(rq)) == "cancel" :
return vdinfo(num)
hsp = megacli + " -PDHSP -set -dedicated -array " + str(selectDG) + " -physdrv[" + pdedid2[li3.current()].strip('\n') + ":" + pdslnum2[li3.current()].strip('\n') + "] -a" + str(num) + " -nolog"
r, t, y = client.exec_command(hsp)
hsp = t.read()
if 'Success' in hsp:
warwindows(screen, "完成", "已为DG" + str(selectDG) + " 设置热备盘")
return vdinfo(num)
warwindows(screen, "警告", "热备盘设置失败")
return vdinfo(num)
elif li2.current() == 3:
r, t, y = client.exec_command(megacli + " -ldinfo -l" + str(selectDG) +" -a" + num + " -nolog | egrep 'Number of Dedicated Hot Spares|EnclId'")
gethsp = t.read()
h = GridForm(screen, "热备盘信息", 1, 5)
bb = CompactButton('返回')
h.add(Textbox(55, 15, gethsp, scroll = 1, wrap = 1), 0, 1)
h.add(bb, 0, 2)
rq = h.runOnce(43,3)
return vdinfo(num)
elif li2.current() == 4:
r, t, y = client.exec_command(megacli + " -adpbootdrive -set -l" + str(selectDG) + " -a" + num + " -nolog")
setbootdrv = t.read()
if 'is set to' in setbootdrv:
warwindows(screen, "完成", "BOOT磁盘组设置成功")
return vdinfo(num)
warwindows(screen, "警告", "BOOT磁盘组设置失败")
return vdinfo(num)
elif li2.current() == 5:
r, t, y = client.exec_command(megacli + " -ldinfo -l" + str(selectDG) + " -a" + num + " -nolog | egrep 'Current Cache Policy|Disk Cache Policy'")
currentcachepolicy = t.read()
CachePolicyRB = RadioBar(screen, (("强制打开", " -ForcedWB", 0), ("打开", " -wt", 0), ("关闭", " -wb", 1)))
RAPolicyRB = RadioBar(screen, (("打开", " -ra", 1), ("关闭", " -nora", 0), ("自适应", " -adra", 0)))
DiskCachePolicyRB = RadioBar(screen, (("关闭", " -DisDskCache", 1), ("打开", " -EnDskCache", 0)))
BBUPolicyRB = RadioBar(screen, (("否", " -nocachedbadbbu", 1), ("是", " -cachedbadbbu", 0)))
bb = ButtonBar(screen, (("确定", "ok"), ("取消", "cancel")))
g = GridForm(screen, str(vdshow[selectDG].replace('SPANNED DISK GROUP','组合磁盘组').replace('DISK GROUP','普通磁盘组')).strip('\n') + " 缓存策略", 4, 10)
g.add(Textbox(40, 5, "当前缓存状态:\n" + currentcachepolicy, wrap = 1), 3, 6)
g.add(TextboxReflowed(10, "RAID卡缓存", flexDown = 5, flexUp = 10, maxHeight = -1), 1, 2)
g.add(CachePolicyRB, 1, 3)
g.add(TextboxReflowed(10, "预读选项", flexDown = 5, flexUp = 10, maxHeight = -1), 1, 4)
g.add(RAPolicyRB, 1, 5)
g.add(TextboxReflowed(10, "磁盘缓存策略", flexDown = 5, flexUp = 10, maxHeight = -1), 2, 2)
g.add(DiskCachePolicyRB, 2, 3)
g.add(bb, 3, 7)
rc = g.runOnce(25,3)
if rc == 'ESC' or bb.buttonPressed(rc) == 'cancel':
return details1(num)
CachePolicy = str(CachePolicyRB.getSelection()).strip('\n')
RAPolicy = str(RAPolicyRB.getSelection()).strip('\n')
DiskCachePolicy = str(DiskCachePolicyRB.getSelection()).strip('\n')
k = []
if CachePolicy == ' -wb':
k.append(megacli + " -LDSetProp -NoCachedBadBBU -l" +str(selectDG) + " -a" + num + " -nolog")
k.append(megacli + " -LDSetProp" + CachePolicy + " -l" +str(selectDG) + " -a" + num + " -nolog")
k.append(megacli + " -LDSetProp" + RAPolicy + " -l" +str(selectDG) + " -a" + num + " -nolog")
k.append(megacli + " -LDSetProp -Direct -l" +str(selectDG) + " -a" + num + " -nolog")
k.append(megacli + " -LDSetProp" + DiskCachePolicy + " -l" +str(selectDG) + " -a" + num + " -nolog")
for i in k:
r, t, y = client.exec_command(i)
success = t.read()
if "success" not in success:
warwindows(screen, "警告", "设置失败")
break
return details1(num)
warwindows(screen, "完成", "已重新设置磁盘策略")
return details1(num)
else:
warwindows(screen, "警告", "还未创建磁盘组")
return details1(num)
except:
warwindows(screen, "警告", "MegaCLI运行错误,请手动检查")
return details1(num)
def vdinfo2(num,vdnum,vdtotalnum,selectDG):
if int(selectDG) + 1 != int(vdtotalnum) :
r, t, y = client.exec_command(megacli + " -cfgdsply -a" + num + " -nolog | sed -n '" + str(vdnum[int(str(selectDG).strip('\n'))]).strip('\n') + "," + str(int(str(vdnum[int(str(selectDG).strip('\n')) + 1]).strip('\n')) - 3).strip('\n') + "p'")
vd = t.read()
#pdnum = str(selectDG) + " " + str(vdtotalnum)
else:
r, t, y = client.exec_command(megacli + " -cfgdsply -a" + num + " -nolog | sed -n '" + str(vdnum[int(str(selectDG).strip('\n'))]).strip('\n') + ",999999p'")
vd = t.read()
#pdnum = str(selectDG) + " " + str(vdtotalnum)
h = GridForm(screen, "磁盘组详细信息", 20, 20)
bb = CompactButton('返回')
h.add(Textbox(55, 15, vd, scroll = 1, wrap = 1), 0, 1)
h.add(bb, 0, 2)
rc = h.runOnce(25,3)
return vdinfo(num)
def CommandList(num):
li = Listbox(height = 12, width = 20, returnExit = 1, showCursor = 0, scroll = 1)
li.append("a)增加磁盘组", 1)
li.append("b)增加组合磁盘组", 2)
li.append("c)删除磁盘组", 3)
li.append("d)外来磁盘操作", 4)
li.append("e)标记磁盘状态", 5)
li.append("f)BBU配置", 6)
bb = CompactButton('返回')
g = GridForm(screen, "命令清单", 1, 10)
g.add(li, 0, 1)
g.add(bb, 0, 2)
rc = g.runOnce(43, 3)
if rc == 'ESC' or 'snack.CompactButton' in str(rc) :
return ADPSelect()
elif li.current() == 1:
return AddDG(num)
elif li.current() == 2:
return AddSDG(num)
elif li.current() == 3:
return DelDG(num)
elif li.current() == 4:
return ConfigFD(num)
elif li.current() == 5:
return ConfigPD(num)
elif li.current() == 6:
return ConfigBBU(num)
def AddSDG(num):
#选择raid级别
p = GetPDInfo(num)
pdshow = p.pdshow()
pdstate = p.pdstate()
pdforeign = p.pdforeign()
n = 0
diskcount = 0
for i in pdshow:
if "Unconfigured(good)" in str(pdstate[n]).strip('\n') and "None" in str(pdforeign[n]).strip('\n'):
diskcount = diskcount + 1
n = n + 1
li = Listbox(height = 5, width = 15, returnExit = 1, showCursor = 0)
li.append("\tRaid-10", 1)
li.append("\tRaid-50", 2)
li.append("\tRaid-60", 3)
g = GridForm(screen, "选择RAID级别", 1, 10)
bb = CompactButton('返回')
g.add(li, 0, 1)
g.add(bb, 0, 2)
rc = g.runOnce(43,3)
SelectRaidLevel = li.current()
if 'snack.CompactButton' in str(rc) or rc == 'ESC':
return CommandList(num)
if li.current() == 1:
if diskcount < 4 :
warwindows(screen, "警告", "剩余磁盘不足以构建RAID-10")
return AddSDG(num)
else:
return AddSDGR10(num)
if li.current() == 2:
if diskcount < 6 :
warwindows(screen, "警告", "剩余磁盘不足以构建RAID-50")
return AddSDG(num)
else:
return AddSDGR50(num)
if li.current() == 3:
if diskcount < 8 :
warwindows(screen, "警告", "剩余磁盘不足以构建RAID-60")
return AddSDG(num)
else:
return AddSDGR60(num)
def AddSDGR10(num):
p = GetPDInfo(num)
pdisknum = p.pdisknum()
pdtotalnum = p.pdtotalnum()
pdshow = p.pdshow()
pdedid = p.pdedid()
pdslnum = p.pdslnum()
pdsize = p.pdsize()
pdstate = p.pdstate()
pdforeign = p.pdforeign()
spannum = 1
j = []
while True:
arraydisknum = []
ct = CheckboxTree(height = 8, scroll = 1)
n = 0
unconfigdiskcount = 0
unconfigdiskcount2 = 0
pdedid2 = []
pdslnum2 = []
pdshow2 = []
pdsize2 = []
unconfigreok = False
bb = ButtonBar(screen, (("下一组", "next"), ("完成", "finish")))
if pdisknum != []:
for i in pdstate:
if "Unconfigured(good)" in str(i):
if pdforeign != []:
if "None" in str(pdforeign[unconfigdiskcount]).strip('\n') :
unconfigreok = True
unconfigdiskcount2 = unconfigdiskcount2 + 1
if "choose" in str(i):
unconfigdiskcount2 = unconfigdiskcount2 - 1
unconfigdiskcount = unconfigdiskcount + 1
if unconfigreok == True and unconfigdiskcount2 >= 2:
for i in pdshow:
if "Unconfigured(good)" in str(pdstate[n]).strip('\n') and "None" in str(pdforeign[n]).strip('\n'):
if "choose" not in str(pdstate[n]).strip('\n'):
ct.append("槽位:" + str(i).strip('\n').replace('Slot Number','槽位') + "\t大小: " + str(pdsize[n]).strip('\n') + " ")
pdshow2.append(str(pdshow[n]))
pdedid2.append(str(pdedid[n]))
pdslnum2.append(str(pdslnum[n]))
pdsize2.append(str(pdsize[n].replace('TB','')))
n = n + 1
g = GridForm(screen, "选择第" + str(spannum) + "组磁盘", 3, 10)
g.add(Label("选择磁盘"), 0, 1)
g.add(ct, 0, 2)
g.add(Label(" "), 1, 2)
g.add(bb, 0, 3, growx = 1)
rc = g.runOnce(43,3)
else:
warwindows(screen, "警告", "剩余磁盘不足")
return CommandList(num)
if rc == 'ESC' or str(bb.buttonPressed(rc)) == "finish" :
rx = conformwindows(screen, "磁盘组已经配置完毕?")
if rx[0] == "否" or rx[1] == "ESC":
rxx = conformwindows(screen, "要继续配置吗?")
if rxx[0] == "否" or rxx[1] == "ESC":
return CommandList(num)
else:
continue
else:
if spannum < 2:
warwindows(screen, "警告", "至少配置两组磁盘")
continue
n = 0
DiskSelection = ct.getSelection()
DiskSelection2 = []
for i in DiskSelection:
n = n + 1
if n == 0:
warwindows(screen, "警告", "至少选择一块磁盘")
continue
elif n != 2 :
warwindows(screen, "警告", "只能选择两块磁盘")
continue
size = str(pdsize2[0]).strip('\n')
for i in pdsize2:
if size != str(i).strip('\n'):
warwindows(screen, "警告", "请选择大小相同的磁盘")
continue
if spannum > 1:
if groupdiskcount != n:
warwindows(screen, "警告", "每组磁盘数量必须相同")
continue
groupdiskcount = n
j.append(' -array' + str(spannum - 1) + '[')
for i in DiskSelection:
n = 0
for k in pdshow2:
if k.strip('\n') in i.replace('槽位','Slot Number').strip('\n'):
DiskSelection2.append(str(pdedid2[n]).strip('\n') + ":")
DiskSelection2.append(str(pdslnum2[n]).strip('\n') + ",")
arraydisknum.append(str(pdslnum2[n]).strip('\n'))
n = n + 1
n = 0
pdstatebackup = pdstate
for i in arraydisknum:
n = 0
for k in pdslnum:
if int(i) == int(k):
pdstate[n] = str(pdstate[n]).strip('\n') + " choose"
n = n + 1
n = 0
for i in pdstate:
if " choose" in str(i):
if size not in str(pdsize[n].replace(' TB','')):
warwindows(screen, "警告" ,"每个磁盘组内的磁盘大小必须相同")
pdstate = pdstatebackup
continue
n = n + 1
for i in DiskSelection2:
j[spannum - 1] = str(j[spannum -1]).strip('\n') + str(i).strip('\n')
j[spannum - 1] = str(j[spannum -1]).strip('\n').rstrip(',') + "]"
break
else:
n = 0
DiskSelection = ct.getSelection()
DiskSelection2 = []
for i in DiskSelection:
n = n + 1
if n == 0:
warwindows(screen, "警告", "至少选择一块磁盘")
continue
elif n != 2:
warwindows(screen, "警告", "只能选择两块磁盘")
continue
size = str(pdsize2[0]).strip('\n')
for i in pdsize2:
if size != str(i).strip('\n'):
warwindows(screen, "警告", "请选择大小相同的磁盘")
continue
if spannum > 1:
if groupdiskcount != n:
warwindows(screen, "警告", "每组磁盘数量必须相同")
continue
groupdiskcount = n
j.append(' -array' + str(spannum - 1) + '[')
for i in DiskSelection:
n = 0
for k in pdshow2:
if k.strip('\n') in i.replace('槽位','Slot Number').strip('\n'):
DiskSelection2.append(str(pdedid2[n]).strip('\n') + ":")
DiskSelection2.append(str(pdslnum2[n]).strip('\n') + ",")
arraydisknum.append(str(pdslnum2[n]).strip('\n'))
n = n + 1
n = 0
pdstatebackup = pdstate
for i in arraydisknum:
n = 0
for k in pdslnum:
if int(i) == int(k):
pdstate[n] = str(pdstate[n]).strip('\n') + " choose"
n = n + 1
n = 0
for i in pdstate:
if " choose" in str(i):
if size not in str(pdsize[n].replace(' TB','')):
warwindows(screen, "警告" ,"每个磁盘组内的磁盘大小必须相同")
pdstate = pdstatebackup
continue
n = n + 1
for i in DiskSelection2:
j[spannum - 1] = str(j[spannum -1]).strip('\n') + str(i).strip('\n')
j[spannum - 1] = str(j[spannum -1]).strip('\n').rstrip(',') + "]"
rx = conformwindows(screen, "要配置下一组磁盘吗")
if rx[0] == "否" or rx[1] == "ESC":
if spannum < 2:
warwindows(screen, "警告", "至少配置两组磁盘")
continue
break
else:
spannum = spannum + 1
else:
warwindows(screen, "警告", "未能找到磁盘")
return CommandList(num)
CachePolicyRB = RadioBar(screen, (("打开", " -wt", 1), ("关闭", " -wb", 0)))
RAPolicyRB = RadioBar(screen, (("打开", " -ra", 1), ("关闭", " -nora", 0), ("自适应", " -adra", 0)))
DiskCachePolicyRB = RadioBar(screen, (("关闭", "off", 1), ("打开", "on", 0)))
BBUPolicyRB = RadioBar(screen, (("否", " -nocachedbadbbu", 1), ("是", " -cachedbadbbu", 0)))
StripSizeRB = RadioBar(screen, (("128KB", " -strpsz128", 1), ("256KB", " -strpsz256", 0), ("1024KB", " -strpsz1024", 0)))
bb = ButtonBar(screen, (("确定", "ok"), ("取消", "cancel")))
g = GridForm(screen, "配置DG选项", 4, 10)
g.add(TextboxReflowed(10, "条带大小", flexDown = 5, flexUp = 10, maxHeight = -1), 0, 1)
g.add(StripSizeRB, 0, 2)
g.add(TextboxReflowed(10, "预读选项", flexDown = 5, flexUp = 10, maxHeight = -1), 0, 3)
g.add(RAPolicyRB, 0, 4)
g.add(TextboxReflowed(10, "磁盘缓存策略", flexDown = 5, flexUp = 10, maxHeight = -1), 1, 1)
g.add(DiskCachePolicyRB, 1, 2)
g.add(TextboxReflowed(10, "无BBU也缓存", flexDown = 5, flexUp = 10, maxHeight = -1), 2, 1)
g.add(BBUPolicyRB, 2, 2)
g.add(TextboxReflowed(10, "RAID卡缓存策略", flexDown = 5, flexUp = 10, maxHeight = -1), 1, 3)
g.add(CachePolicyRB, 1, 4)
g.add(bb, 3, 2, growx = 1)
rc = g.runOnce(25,3)
if rc == 'ESC' or str(bb.buttonPressed(rc)) == "cancel" :
return AddSDG(num)
arraygroup = ''
for i in j:
arraygroup = arraygroup + str(i).strip('\n')
CachePolicy = CachePolicyRB.getSelection()
RAPolicy = RAPolicyRB.getSelection()
DiskCachePolicy = DiskCachePolicyRB.getSelection()
BBUPolicy = BBUPolicyRB.getSelection()
StripSize = StripSizeRB.getSelection()
k = megacli + " -cfgspanadd -r10" + arraygroup + str(RAPolicy).strip('\n') + " -Direct" + str(BBUPolicy).strip('\n') + str(StripSize).strip('\n') + " -a" + str(num).strip('\n') + " -nolog | grep VD | awk -F ' ' '{print$5}'"
if str(DiskCachePolicy).strip('\n') != "on":
ss = ProWin(screen, "请等待", "创建磁盘组中")
ss.show()
r, t, y = client.exec_command(k)
getre = t.readlines()
ss.update(40)
if getre == []:
ss.close()
warwindows(screen, "警告", "创建磁盘组失败")
return AddSDG(num)
else:
l = megacli + " -ldsetprop -disdskcache -l" + str(getre[0]).strip('\n') + " -a" + str(num).strip('\n') + " -nolog"
ss.update(60)
r, t, y = client.exec_command(l)
ss.close()
warwindows(screen, "已完成", "创建磁盘组成功")
return CommandList(num)
else:
r, t, y = client.exec_command(k)
getre = t.readlines()
if getre == []:
ss.close()
warwindows(screen, "警告", "创建磁盘组失败")
return AddSDG(num)
else:
l = megacli + " -ldsetprop -endskcache -l" + str(getre[0]).strip('\n') + " -a" + str(num).strip('\n') + " -nolog"
ss.update(60)
r, t, y = client.exec_command(l)
ss.close()
warwindows(screen, "已完成", "创建磁盘组成功")
return CommandList(num)
def AddSDGR50(num):
p = GetPDInfo(num)
pdisknum = p.pdisknum()
pdtotalnum = p.pdtotalnum()
pdshow = p.pdshow()
pdedid = p.pdedid()
pdslnum = p.pdslnum()
pdsize = p.pdsize()
pdstate = p.pdstate()
pdforeign = p.pdforeign()
groupdiskcount = 0
spannum = 1
j = []
while True:
arraydisknum = []
ct = CheckboxTree(height = 8, scroll = 1)
n = 0
unconfigdiskcount = 0
unconfigdiskcount2 = 0
pdedid2 = []
pdslnum2 = []
pdshow2 = []
pdsize2 = []
unconfigreok = False
bb = ButtonBar(screen, (("下一组", "next"), ("完成", "finish")))
if pdisknum != []:
for i in pdstate:
if "Unconfigured(good)" in str(i):
if pdforeign != []:
if "None" in str(pdforeign[unconfigdiskcount]).strip('\n') :
unconfigreok = True
unconfigdiskcount2 = unconfigdiskcount2 + 1
if "choose" in str(i):
unconfigdiskcount2 = unconfigdiskcount2 - 1
unconfigdiskcount = unconfigdiskcount + 1
if unconfigreok == True and unconfigdiskcount2 >= 2:
for i in pdshow:
if "Unconfigured(good)" in str(pdstate[n]).strip('\n') and "None" in str(pdforeign[n]).strip('\n'):
if "choose" not in str(pdstate[n]).strip('\n'):
ct.append("槽位:" + str(i).strip('\n').replace('Slot Number','槽位') + "\t大小: " + str(pdsize[n]).strip('\n') + " ")
pdshow2.append(str(pdshow[n]))
pdedid2.append(str(pdedid[n]))
pdslnum2.append(str(pdslnum[n]))
pdsize2.append(str(pdsize[n].replace('TB','')))
n = n + 1
g = GridForm(screen, "选择第" + str(spannum) + "组磁盘", 3, 10)
g.add(Label("选择磁盘"), 0, 1)
g.add(ct, 0, 2)
g.add(Label(" "), 1, 2)
g.add(bb, 0, 3, growx = 1)
rc = g.runOnce(35,3)
else:
warwindows(screen, "警告", "剩余磁盘不足")
return CommandList(num)
if rc == 'ESC' or str(bb.buttonPressed(rc)) == "finish" :
rx = conformwindows(screen, "磁盘组已经配置完毕?")
if rx[0] == "否" or rx[1] == "ESC":
rxx = conformwindows(screen, "要继续配置吗?")
if rxx[0] == "否" or rxx[1] == "ESC":
return CommandList(num)
else:
continue
else:
if spannum < 2:
warwindows(screen, "警告", "至少配置两组磁盘")
continue
n = 0
DiskSelection = ct.getSelection()
DiskSelection2 = []
for i in DiskSelection:
n = n + 1
if n == 0:
warwindows(screen, "警告", "至少选择一块磁盘")
continue
elif n < 3 :
warwindows(screen, "警告", "每个磁盘组至少需要3块磁盘")
continue
size = str(pdsize2[0]).strip('\n')
for i in pdsize2:
if size != str(i).strip('\n'):
warwindows(screen, "警告", "请选择大小相同的磁盘")
continue
if spannum > 1:
if groupdiskcount != n:
warwindows(screen, "警告", "每组磁盘数量必须相同")
continue
groupdiskcount = n
j.append(' -array' + str(spannum - 1) + '[')
for i in DiskSelection:
n = 0
for k in pdshow2:
if k.strip('\n') in i.replace('槽位','Slot Number').strip('\n'):
DiskSelection2.append(str(pdedid2[n]).strip('\n') + ":")
DiskSelection2.append(str(pdslnum2[n]).strip('\n') + ",")
arraydisknum.append(str(pdslnum2[n]).strip('\n'))
n = n + 1
n = 0
pdstatebackup = pdstate
for i in arraydisknum:
n = 0
for k in pdslnum:
if int(i) == int(k):
pdstate[n] = str(pdstate[n]).strip('\n') + " choose"
n = n + 1
n = 0
for i in pdstate:
if " choose" in str(i):
if size not in str(pdsize[n].replace(' TB','')):
warwindows(screen, "警告" ,"每个磁盘组内的磁盘大小必须相同")
pdstate = pdstatebackup
continue
n = n + 1
for i in DiskSelection2:
j[spannum - 1] = str(j[spannum -1]).strip('\n') + str(i).strip('\n')
j[spannum - 1] = str(j[spannum -1]).strip('\n').rstrip(',') + "]"
break