modified: ri_tk_cmd.py

add two showwarning messagebox for active devices that must be more than
    two
This commit is contained in:
fling
2010-10-14 15:05:40 +08:00
parent 4f81fc0f46
commit fb83d4b510
2 changed files with 30 additions and 15 deletions

View File

@@ -22,9 +22,9 @@ def mount_list_init():
devs=ri_data.Raid.dev_in_raid()
ri_data.MountPoint.init_from_internal()
for m in ri_data.MountPoint.list:
# get size from Partition info
if m.device in devs:
continue
# get size from Partition info
sz = ri_data.Partition.get_size(m.device)
if not sz:
sz = ri_data.Raid.get_size(m.device)
@@ -313,11 +313,11 @@ devs - raid component devices
'''
# all devs shall have same size.
unit=ri_data.Partition.unit
sz=99999999999
sz=999999999
for p in ri_data.Partition.list:
if p.device in devs:
if float(p.size[:-len(unit)])< float(sz):
sz = float(p.size[:-len(unit)])
if float(p.size)< float(sz):
sz = float(p.size)
if level == '0':
sz=sz*len(devs)
return str(sz)
@@ -330,19 +330,26 @@ devs - raid component devices
def raid_device_add():
''' add a new raid device '''
if display.var_dict['raid_active_devs'].get()=='':
ri_widget.MessageBox.dict["raid_add_active_warning"].show()
return
active=[]
else:
active = list(eval(display.var_dict['raid_active_devs'].get()))
if display.var_dict['raid_spare_devs'].get()=='':
spare=[]
else:
spare = list(eval(display.var_dict['raid_spare_devs'].get()))
level = display.var_dict['raid_level'].get()
if not active or not level:
ri_widget.MessageBox.dict["raid_add_warning"].show()
return
elif int(level) < 2 and len(active) < 2:
ri_widget.MessageBox.dict["raid_add_active_numbers"].show()
return
elif str(level) == "5" and len(active)<3:
ri_widget.MessageBox.dict["raid_add_active_2numbers"].show()
return
dev = ri_data.Raid.get_next_device()
ri_data.Raid(dev, "no", level, raid_calc_size(level, active), active, spare)