Correct the funciton to calculate raid size

Correct the funciton to del raid

       modified:   interface/ri_data.py
       modified:   new_partition/interface_partition.py
       modified:   text/ri_main.py
       modified:   text/ri_newt.py
This commit is contained in:
Peng Zhihui
2014-02-13 13:14:24 +08:00
parent 2002522ad5
commit 99c32ef85c
4 changed files with 21 additions and 5 deletions

View File

@@ -330,11 +330,15 @@ p_node - xml node (parent node) '''
def get_size(dev):
''' calculate raid device size '''
rd = Raid.dict[dev]
sz = min([ float(interface_partition.get_num(p_d.Partition.dict[p_d.Partition.get_disk_from_partition('/dev/'+d)]\
Min = min([ float(interface_partition.get_num(p_d.Partition.dict[p_d.Partition.get_disk_from_partition('/dev/'+d)]\
['partition']['/dev/'+d]['size'])) for d in rd.active_components])
if rd.level == '0': return str(interface_partition.pretty_unit(sz*len(rd.active_components)))
elif rd.level == '1': return str(interface_partition.pretty_unit(sz*len(rd.active_components)/2))
elif rd.level == '5': return str(interface_partition.pretty_unit(sz*(len(rd.active_components)-1)))
Sum = sum([ float(interface_partition.get_num(p_d.Partition.dict[p_d.Partition.get_disk_from_partition('/dev/'+d)]\
['partition']['/dev/'+d]['size'])) for d in rd.active_components])
#if rd.level == '0': return str(interface_partition.pretty_unit(Min*len(rd.active_components)))
#elif rd.level == '1': return str(interface_partition.pretty_unit(Min*len(rd.active_components)/2))
if rd.level == '0': return str(interface_partition.pretty_unit(Sum))
elif rd.level == '1': return str(interface_partition.pretty_unit(Min))
elif rd.level == '5': return str(interface_partition.pretty_unit(Min*(len(rd.active_components)-1)))
@staticmethod
def get_next_device():

View File

@@ -247,6 +247,10 @@ def del_raid(dev):
raise StopIteration()
except StopIteration:
pass
try:
os.system('umount /dev/%s >/dev/null 2>&1' %(md))
except:
pass
try:
os.system('mdadm --stop /dev/%s >/dev/null 2>&1' %(md))
except:

View File

@@ -26,7 +26,7 @@ while True :
if init_flag:
ri_data.init()
init_flag = False
if len(ri_newt.Raid.init_from_internal()) < 2:
if len(ri_newt.Raid.init_from_internal()) < 2 and len(ri_data.Raid.dict) == 0:
if list[2] == 'raid':
del list[2]
else:

View File

@@ -417,6 +417,14 @@ class Raid(Screen):
if s == 0:
device = Screen.listbox.current()
del ri_data.Raid.dict[device]
try:
os.system('umount /dev/%s >/dev/null 2>&1' %(device))
except:
pass
try:
os.system('mdadm --stop /dev/%s >/dev/null 2>&1' %(device))
except:
pass
return s
def set_data(self):