@@ -433,12 +433,13 @@ def vdinfo(num):
433
433
return details1 (num )
434
434
else :
435
435
selectDG = int (li .current () - 1 )
436
- li2 = Listbox (height = 7 , width = 43 , returnExit = 1 , showCursor = 0 , scroll = 1 )
436
+ li2 = Listbox (height = 9 , width = 43 , returnExit = 1 , showCursor = 0 , scroll = 1 )
437
437
li2 .append ("查看" + str (vdshow [selectDG ].replace ('SPANNED DISK GROUP' ,'组合磁盘组' ).replace ('DISK GROUP' ,'普通磁盘组' )).strip ('\n ' ) + " 的详细信息" , 1 )
438
438
li2 .append ("指定" + str (vdshow [selectDG ].replace ('SPANNED DISK GROUP' ,'组合磁盘组' ).replace ('DISK GROUP' ,'普通磁盘组' )).strip ('\n ' ) + " 的热备盘" , 2 )
439
439
if int (vdhsp [selectDG ]) != 0 :
440
440
li2 .append ("查看" + str (vdshow [selectDG ].replace ('SPANNED DISK GROUP' ,'组合磁盘组' ).replace ('DISK GROUP' ,'普通磁盘组' )).strip ('\n ' ) + " 的热备盘" , 3 )
441
441
li2 .append ("指定" + str (vdshow [selectDG ].replace ('SPANNED DISK GROUP' ,'组合磁盘组' ).replace ('DISK GROUP' ,'普通磁盘组' )).strip ('\n ' ) + " 为BOOT磁盘组" , 4 )
442
+ li2 .append ("设定" + str (vdshow [selectDG ].replace ('SPANNED DISK GROUP' ,'组合磁盘组' ).replace ('DISK GROUP' ,'普通磁盘组' )).strip ('\n ' ) + " 的缓存策略" , 5 )
442
443
f = GridForm (screen , "请选择" , 1 , 10 )
443
444
f .add (li2 , 0 , 1 )
444
445
bb2 = CompactButton ('返回' )
@@ -510,6 +511,45 @@ def vdinfo(num):
510
511
return vdinfo (num )
511
512
warwindows (screen , "警告" , "BOOT磁盘组设置失败" )
512
513
return vdinfo (num )
514
+ elif li2 .current () == 5 :
515
+ r , t , y = client .exec_command (megacli + " -ldinfo -l" + str (selectDG ) + " -a" + num + " -nolog | egrep 'Current Cache Policy|Disk Cache Policy'" )
516
+ currentcachepolicy = t .read ()
517
+ CachePolicyRB = RadioBar (screen , (("强制打开" , " -ForcedWB" , 0 ), ("打开" , " -wt" , 0 ), ("关闭" , " -wb" , 1 )))
518
+ RAPolicyRB = RadioBar (screen , (("打开" , " -ra" , 1 ), ("关闭" , " -nora" , 0 ), ("自适应" , " -adra" , 0 )))
519
+ DiskCachePolicyRB = RadioBar (screen , (("关闭" , " -DisDskCache" , 1 ), ("打开" , " -EnDskCache" , 0 )))
520
+ BBUPolicyRB = RadioBar (screen , (("否" , " -nocachedbadbbu" , 1 ), ("是" , " -cachedbadbbu" , 0 )))
521
+ bb = ButtonBar (screen , (("确定" , "ok" ), ("取消" , "cancel" )))
522
+ g = GridForm (screen , str (vdshow [selectDG ].replace ('SPANNED DISK GROUP' ,'组合磁盘组' ).replace ('DISK GROUP' ,'普通磁盘组' )).strip ('\n ' ) + " 缓存策略" , 4 , 10 )
523
+ g .add (Textbox (40 , 5 , "当前缓存状态:\n " + currentcachepolicy , wrap = 1 ), 3 , 6 )
524
+ g .add (TextboxReflowed (10 , "RAID卡缓存" , flexDown = 5 , flexUp = 10 , maxHeight = - 1 ), 1 , 2 )
525
+ g .add (CachePolicyRB , 1 , 3 )
526
+ g .add (TextboxReflowed (10 , "预读选项" , flexDown = 5 , flexUp = 10 , maxHeight = - 1 ), 1 , 4 )
527
+ g .add (RAPolicyRB , 1 , 5 )
528
+ g .add (TextboxReflowed (10 , "磁盘缓存策略" , flexDown = 5 , flexUp = 10 , maxHeight = - 1 ), 2 , 2 )
529
+ g .add (DiskCachePolicyRB , 2 , 3 )
530
+ g .add (bb , 3 , 7 )
531
+ rc = g .runOnce (25 ,3 )
532
+ if rc == 'ESC' or bb .buttonPressed (rc ) == 'cancel' :
533
+ return details1 (num )
534
+ CachePolicy = str (CachePolicyRB .getSelection ()).strip ('\n ' )
535
+ RAPolicy = str (RAPolicyRB .getSelection ()).strip ('\n ' )
536
+ DiskCachePolicy = str (DiskCachePolicyRB .getSelection ()).strip ('\n ' )
537
+ k = []
538
+ if CachePolicy == ' -wb' :
539
+ k .append (megacli + " -LDSetProp -NoCachedBadBBU -l" + str (selectDG ) + " -a" + num + " -nolog" )
540
+ k .append (megacli + " -LDSetProp" + CachePolicy + " -l" + str (selectDG ) + " -a" + num + " -nolog" )
541
+ k .append (megacli + " -LDSetProp" + RAPolicy + " -l" + str (selectDG ) + " -a" + num + " -nolog" )
542
+ k .append (megacli + " -LDSetProp -Direct -l" + str (selectDG ) + " -a" + num + " -nolog" )
543
+ k .append (megacli + " -LDSetProp" + DiskCachePolicy + " -l" + str (selectDG ) + " -a" + num + " -nolog" )
544
+ for i in k :
545
+ r , t , y = client .exec_command (i )
546
+ success = t .read ()
547
+ if "success" not in success :
548
+ warwindows (screen , "警告" , "设置失败" )
549
+ break
550
+ return details1 (num )
551
+ warwindows (screen , "完成" , "已重新设置磁盘策略" )
552
+ return details1 (num )
513
553
else :
514
554
warwindows (screen , "警告" , "还未创建磁盘组" )
515
555
return details1 (num )
@@ -809,7 +849,7 @@ def AddSDGR10(num):
809
849
DiskCachePolicy = DiskCachePolicyRB .getSelection ()
810
850
BBUPolicy = BBUPolicyRB .getSelection ()
811
851
StripSize = StripSizeRB .getSelection ()
812
- k = megacli + " -cfgspanadd -r10" + arraygroup + str (RAPolicy ).strip ('\n ' ) + " -cached " + str (BBUPolicy ).strip ('\n ' ) + str (StripSize ).strip ('\n ' ) + " -a" + str (num ).strip ('\n ' ) + " -nolog | grep VD | awk -F ' ' '{print$5}'"
852
+ 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}'"
813
853
if str (DiskCachePolicy ).strip ('\n ' ) != "on" :
814
854
ss = ProWin (screen , "请等待" , "创建磁盘组中" )
815
855
ss .show ()
@@ -1048,7 +1088,7 @@ def AddSDGR50(num):
1048
1088
DiskCachePolicy = DiskCachePolicyRB .getSelection ()
1049
1089
BBUPolicy = BBUPolicyRB .getSelection ()
1050
1090
StripSize = StripSizeRB .getSelection ()
1051
- k = megacli + " -cfgspanadd -r50" + arraygroup + str (RAPolicy ).strip ('\n ' ) + " -cached " + str (BBUPolicy ).strip ('\n ' ) + str (StripSize ).strip ('\n ' ) + " -a" + str (num ).strip ('\n ' ) + " -nolog | grep VD | awk -F ' ' '{print$5}'"
1091
+ k = megacli + " -cfgspanadd -r50" + 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}'"
1052
1092
if str (DiskCachePolicy ).strip ('\n ' ) != "on" :
1053
1093
ss = ProWin (screen , "请等待" , "创建磁盘组中" )
1054
1094
ss .show ()
@@ -1287,7 +1327,7 @@ def AddSDGR60(num):
1287
1327
DiskCachePolicy = DiskCachePolicyRB .getSelection ()
1288
1328
BBUPolicy = BBUPolicyRB .getSelection ()
1289
1329
StripSize = StripSizeRB .getSelection ()
1290
- k = megacli + " -cfgspanadd -r60" + arraygroup + str (RAPolicy ).strip ('\n ' ) + " -cached " + str (BBUPolicy ).strip ('\n ' ) + str (StripSize ).strip ('\n ' ) + " -a" + str (num ).strip ('\n ' ) + " -nolog | grep VD | awk -F ' ' '{print$5}'"
1330
+ k = megacli + " -cfgspanadd -r60" + 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}'"
1291
1331
if str (DiskCachePolicy ).strip ('\n ' ) != "on" :
1292
1332
ss = ProWin (screen , "请等待" , "创建磁盘组中" )
1293
1333
ss .show ()
@@ -1493,7 +1533,7 @@ def AddDG(num):
1493
1533
for i in DiskSelection2 :
1494
1534
j = j + str (i ).strip ('\n ' )
1495
1535
j = j .rstrip (',' ) + "]"
1496
- k = megacli + " -cfgldadd" + str (RAIDLevel ).strip ('\n ' ) + j .strip ('\n ' ) + str (CachePolicy ).strip ('\n ' ) + str (RAPolicy ).strip ('\n ' ) + " -cached " + str (BBUPolicy ).strip ('\n ' ) + str (StripSize ).strip ('\n ' ) + " -a" + str (num ).strip ('\n ' ) + " -nolog | grep VD | awk -F ' ' '{print$5}'"
1536
+ k = megacli + " -cfgldadd" + str (RAIDLevel ).strip ('\n ' ) + j .strip ('\n ' ) + str (CachePolicy ).strip ('\n ' ) + 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}'"
1497
1537
if str (DiskCachePolicy ).strip ('\n ' ) != "on" :
1498
1538
ss = ProWin (screen , "请等待" , "创建磁盘组中" )
1499
1539
ss .show ()
@@ -1597,7 +1637,7 @@ def MakeAllRaid0(num):
1597
1637
ss = ProWin (screen , "请等待" , "创建磁盘组中" )
1598
1638
ss .show ()
1599
1639
ss .update (3 )
1600
- r , t , y = client .exec_command (megacli + " -CfgEachDskRaid0 -wt -ra -cached -nocachedbadbbu -strpsz128 -a" + str (num ).strip ('\n ' ) + " -nolog | grep 'Created VD' | awk -F ' ' '{print$5}'" )
1640
+ r , t , y = client .exec_command (megacli + " -CfgEachDskRaid0 -wt -ra -Direct -nocachedbadbbu -strpsz128 -a" + str (num ).strip ('\n ' ) + " -nolog | grep 'Created VD' | awk -F ' ' '{print$5}'" )
1601
1641
k = t .readlines ()
1602
1642
if k == []:
1603
1643
ss .close ()
@@ -1837,21 +1877,25 @@ def config(getconfig = None):
1837
1877
ss .close ()
1838
1878
connectok = 1
1839
1879
except :
1840
- screen .finish ()
1841
- print traceback .format_exc ()
1842
- print "指定的参数无效"
1843
- break
1880
+ ss .close ()
1881
+ warwindows (screen , "警告" , "指定的参数无效" )
1882
+ connectok = 0
1883
+ config ()
1884
+ continue
1844
1885
megacli = "/tmp/MegaCli64"
1845
1886
r , test , t = client .exec_command (megacli + " -v -nolog" )
1846
1887
test = test .read ()
1847
1888
if "Exit Code: 0x00" in test :
1848
1889
main ()
1849
1890
else :
1850
- screen .finish ()
1851
- print "远程命令执行失败"
1852
- break
1891
+ warwindows (screen , "警告" , "远程命令执行失败" )
1892
+ connectok = 0
1893
+ config ()
1894
+ continue
1853
1895
else :
1854
- warwindows (screen , "警告" , "远程链接建立失败" )
1855
- getconfig = config ()
1896
+ warwindows (screen , "警告" , "各项参数不能为空" )
1897
+ connectok = 0
1898
+ config ()
1899
+ continue
1856
1900
screen .finish ()
1857
1901
print "感谢使用!"
0 commit comments