Skip to content

Commit 11bbccf

Browse files
authored
bug fixed v0.92
1 parent 4a7316c commit 11bbccf

File tree

1 file changed

+58
-14
lines changed

1 file changed

+58
-14
lines changed

megamenu.py

+58-14
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def details1(num):
201201
h.add(li, 0, n + 5)
202202
bb = CompactButton('返回')
203203
h.add(bb, 0, 14)
204-
rc = h.runOnce(44,3)
204+
rc = h.runOnce(43,3)
205205
if rc == "ESC" or "snack.CompactButton" in str(rc):
206206
return ADPSelect()
207207
elif li.current() == 1:
@@ -279,7 +279,7 @@ def pdinfo(num):
279279
if 'None' in pdforeign[n]:
280280
li.append(str(i).strip('\n').replace('Slot Number','槽位') + "\t大小: " + str(pdsize[n]).strip('\n') + "\t状态: " + str(pdstate[n]).strip('\n').replace(' ',''), n + 1)
281281
else:
282-
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)
282+
li.append(str(i).strip('\n').replace('Slot Number','<Foreign>槽位') + "\t大小: " + str(pdsize[n]).strip('\n') + "\t状态: " + str(pdstate[n]).strip('\n').replace(' ',''), n + 1)
283283
n = n + 1
284284
g = GridForm(screen, "物理磁盘信息", 1, 10)
285285
g.add(li, 0, 1)
@@ -301,7 +301,7 @@ def pdinfo(num):
301301
f.add(li2, 0, 1)
302302
bb2 = CompactButton('返回')
303303
f.add(bb2, 0, 2)
304-
rf = f.runOnce(44,3)
304+
rf = f.runOnce(43,3)
305305
if rf == 'ESC' or 'snack.CompactButton' in str(rf) :
306306
return pdinfo(num)
307307
elif li2.current() == 1:
@@ -401,11 +401,12 @@ def vdinfo(num):
401401
if int(vdhsp[selectDG]) != 0:
402402
li2.append("查看" + str(vdshow[selectDG].replace('SPANNED DISK GROUP','组合磁盘组').replace('DISK GROUP','普通磁盘组')).strip('\n') + " 的热备盘", 3)
403403
li2.append("指定" + str(vdshow[selectDG].replace('SPANNED DISK GROUP','组合磁盘组').replace('DISK GROUP','普通磁盘组')).strip('\n') + " 为BOOT磁盘组", 4)
404+
li2.append("设定" + str(vdshow[selectDG].replace('SPANNED DISK GROUP','组合磁盘组').replace('DISK GROUP','普通磁盘组')).strip('\n') + " 的缓存策略", 5)
404405
f = GridForm(screen, "请选择", 1, 10)
405406
f.add(li2, 0, 1)
406407
bb2 = CompactButton('返回')
407408
f.add(bb2, 0, 2)
408-
rf = f.runOnce(44,3)
409+
rf = f.runOnce(43,3)
409410
if rf == 'ESC' or 'snack.CompactButton' in str(rf) :
410411
return vdinfo(num)
411412
elif li2.current() == 1:
@@ -460,7 +461,7 @@ def vdinfo(num):
460461
bb = CompactButton('返回')
461462
h.add(Textbox(55, 15, gethsp, scroll = 1, wrap = 1), 0, 1)
462463
h.add(bb, 0, 2)
463-
rq = h.runOnce(44,3)
464+
rq = h.runOnce(43,3)
464465
return vdinfo(num)
465466
elif li2.current() == 4:
466467
setbootdrv = os.popen(megacli + " -adpbootdrive -set -l" + str(selectDG) + " -a" + num + " -nolog").read()
@@ -469,6 +470,42 @@ def vdinfo(num):
469470
return vdinfo(num)
470471
warwindows(screen, "警告", "BOOT磁盘组设置失败")
471472
return vdinfo(num)
473+
elif li2.current() == 5:
474+
currentcachepolicy = os.popen(megacli + " -ldinfo -l" + str(selectDG) + " -a" + num + " -nolog | egrep 'Current Cache Policy|Disk Cache Policy'").read()
475+
CachePolicyRB = RadioBar(screen, (("强制打开", " -ForcedWB", 0), ("打开", " -wb", 0), ("关闭", " -wt", 1)))
476+
RAPolicyRB = RadioBar(screen, (("打开", " -ra", 1), ("关闭", " -nora", 0), ("自适应", " -adra", 0)))
477+
DiskCachePolicyRB = RadioBar(screen, (("关闭", " -DisDskCache", 1), ("打开", " -EnDskCache", 0)))
478+
bb = ButtonBar(screen, (("确定", "ok"), ("取消", "cancel")))
479+
g = GridForm(screen, str(vdshow[selectDG].replace('SPANNED DISK GROUP','组合磁盘组').replace('DISK GROUP','普通磁盘组')).strip('\n') + " 缓存策略", 4, 10)
480+
g.add(Textbox(40, 5, "当前缓存状态:\n" + currentcachepolicy, wrap = 1), 3, 6)
481+
g.add(TextboxReflowed(10, "RAID卡缓存", flexDown = 5, flexUp = 10, maxHeight = -1), 1, 2)
482+
g.add(CachePolicyRB, 1, 3)
483+
g.add(TextboxReflowed(10, "预读选项", flexDown = 5, flexUp = 10, maxHeight = -1), 1, 4)
484+
g.add(RAPolicyRB, 1, 5)
485+
g.add(TextboxReflowed(10, "磁盘缓存策略", flexDown = 5, flexUp = 10, maxHeight = -1), 2, 2)
486+
g.add(DiskCachePolicyRB, 2, 3)
487+
g.add(bb, 3, 7)
488+
rc = g.runOnce(25,3)
489+
if rc == 'ESC' or bb.buttonPressed(rc) == 'cancel':
490+
return details1(num)
491+
CachePolicy = str(CachePolicyRB.getSelection()).strip('\n')
492+
RAPolicy = str(RAPolicyRB.getSelection()).strip('\n')
493+
DiskCachePolicy = str(DiskCachePolicyRB.getSelection()).strip('\n')
494+
k = []
495+
if CachePolicy == ' -wb':
496+
k.append(megacli + " -LDSetProp -NoCachedBadBBU -l" +str(selectDG) + " -a" + num + " -nolog")
497+
k.append(megacli + " -LDSetProp" + CachePolicy + " -l" +str(selectDG) + " -a" + num + " -nolog")
498+
k.append(megacli + " -LDSetProp" + RAPolicy + " -l" +str(selectDG) + " -a" + num + " -nolog")
499+
k.append(megacli + " -LDSetProp -Direct -l" +str(selectDG) + " -a" + num + " -nolog")
500+
k.append(megacli + " -LDSetProp" + DiskCachePolicy + " -l" +str(selectDG) + " -a" + num + " -nolog")
501+
for i in k:
502+
success = os.popen(i).read()
503+
if "success" not in success:
504+
warwindows(screen, "警告", "设置失败")
505+
break
506+
return vdinfo(num)
507+
warwindows(screen, "完成", "已重新设置磁盘策略")
508+
return vdinfo(num)
472509
else:
473510
warwindows(screen, "警告", "还未创建磁盘组")
474511
return details1(num)
@@ -502,7 +539,7 @@ def CommandList(num):
502539
g = GridForm(screen, "命令清单", 1, 10)
503540
g.add(li, 0, 1)
504541
g.add(bb, 0, 2)
505-
rc = g.runOnce(44, 3)
542+
rc = g.runOnce(43, 3)
506543
if rc == 'ESC' or 'snack.CompactButton' in str(rc) :
507544
return ADPSelect()
508545
elif li.current() == 1:
@@ -534,12 +571,13 @@ def AddSDG(num):
534571
li.append("\tRaid-10", 1)
535572
li.append("\tRaid-50", 2)
536573
li.append("\tRaid-60", 3)
537-
li.append("\t 返回", 4)
538574
g = GridForm(screen, "选择RAID级别", 1, 10)
575+
bb = CompactButton('返回')
539576
g.add(li, 0, 1)
540-
rc = g.runOnce(44,3)
577+
g.add(bb, 0, 2)
578+
rc = g.runOnce(43,3)
541579
SelectRaidLevel = li.current()
542-
if li.current() == 4 or rc == 'ESC':
580+
if 'snack.CompactButton' in str(rc) or rc == 'ESC':
543581
return CommandList(num)
544582
if li.current() == 1:
545583
if diskcount < 4 :
@@ -609,7 +647,7 @@ def AddSDGR10(num):
609647
g.add(ct, 0, 2)
610648
g.add(Label(" "), 1, 2)
611649
g.add(bb, 0, 3, growx = 1)
612-
rc = g.runOnce(44,3)
650+
rc = g.runOnce(43,3)
613651
else:
614652
warwindows(screen, "警告", "剩余磁盘不足")
615653
return CommandList(num)
@@ -755,6 +793,8 @@ def AddSDGR10(num):
755793
g.add(CachePolicyRB, 1, 4)
756794
g.add(bb, 3, 2, growx = 1)
757795
rc = g.runOnce(25,3)
796+
if rc == 'ESC' or str(bb.buttonPressed(rc)) == "cancel" :
797+
return AddSDG(num)
758798
arraygroup = ''
759799
for i in j:
760800
arraygroup = arraygroup + str(i).strip('\n')
@@ -990,6 +1030,8 @@ def AddSDGR50(num):
9901030
g.add(CachePolicyRB, 1, 4)
9911031
g.add(bb, 3, 2, growx = 1)
9921032
rc = g.runOnce(25,3)
1033+
if rc == 'ESC' or str(bb.buttonPressed(rc)) == "cancel" :
1034+
return AddSDG(num)
9931035
arraygroup = ''
9941036
for i in j:
9951037
arraygroup = arraygroup + str(i).strip('\n')
@@ -1225,6 +1267,8 @@ def AddSDGR60(num):
12251267
g.add(CachePolicyRB, 1, 4)
12261268
g.add(bb, 3, 2, growx = 1)
12271269
rc = g.runOnce(25,3)
1270+
if rc == 'ESC' or str(bb.buttonPressed(rc)) == "cancel" :
1271+
return AddSDG(num)
12281272
arraygroup = ''
12291273
for i in j:
12301274
arraygroup = arraygroup + str(i).strip('\n')
@@ -1486,7 +1530,7 @@ def ADPSelect():
14861530
li.setCurrent(adpl)
14871531
h.add(li, 0, 1)
14881532
h.add(bb, 0, 9)
1489-
rc = h.run(25,3)
1533+
rc = h.run(24,3)
14901534
if "snack.CompactButton" in str(rc) or rc == 'ESC':
14911535
return mainform()
14921536
else :
@@ -1513,7 +1557,7 @@ def QCCMDList(num):
15131557
g = GridForm(screen, "命令清单", 1, 10)
15141558
g.add(li, 0, 1)
15151559
g.add(bb, 0, 2)
1516-
rc = g.runOnce(44, 3)
1560+
rc = g.runOnce(43, 3)
15171561
if rc == 'ESC' or "snack.CompactButton" in str(rc):
15181562
return ADPSelect()
15191563
elif li.current() == 1:
@@ -1661,7 +1705,7 @@ def mainform():
16611705
g.add(Label(" "),0,3)
16621706
g.add(Label("[LSI RAID卡]"),0,4)
16631707
g.add(Label("[配置程序]"),0,5)
1664-
screen.pushHelpLine("<Version 0.91 beta> Powered by Patrick Zheng...请使用TAB在选项间切换")
1708+
screen.pushHelpLine("<Version 0.92 beta> Powered by Patrick Zheng...请使用TAB在选项间切换")
16651709
rc=g.run(1,3)
16661710
mainl = li.current()
16671711
if rc == 'ESC' or 'snack.CompactButton' in str(rc) :
@@ -1709,4 +1753,4 @@ def main():
17091753
print "MegaCli/StorCli路径无效,请使用-s参数重新指定"
17101754
except:
17111755
print "指定的参数无效"
1712-
usage()
1756+
usage()

0 commit comments

Comments
 (0)