modified: ri_data.py
modified: ri_tk_cmd.py
when adding a raid,dynamic add the partitions into Mount.list or
when del a raid , dynamic del the partitions in Mount.list.
so the mothod of ri_tk_cmd.mp_top_init() is the correct.
This commit is contained in:
@@ -57,7 +57,7 @@ class Partition:
|
||||
def init_from_os():
|
||||
''' create a Partition instance from hardware info'''
|
||||
device_list=[]
|
||||
Partition.unit='GB'
|
||||
Partition.unit='MB'
|
||||
p = re.compile(r"\s*")
|
||||
cmd_cat = 'cat /proc/partitions'
|
||||
fs_list=["ext2","ext3","fat32","fat16","ntfs","reiserfs","xfs","jfs","linux-swap"]
|
||||
@@ -350,18 +350,15 @@ class MountPoint:
|
||||
@staticmethod
|
||||
def init_from_internal():
|
||||
''' init MountPoint from internal class Partition and class Raid '''
|
||||
# add raid device in dev_in_raid
|
||||
dves=Raid.dev_in_raid
|
||||
# add raid device in raid_devs
|
||||
raid_devs=Raid.dev_in_raid()
|
||||
devs = [ m.device for m in MountPoint.list ]
|
||||
for p in Partition.list:
|
||||
if p.device not in devs and p.device not in devs :
|
||||
if p.device not in devs and p.device not in raid_devs :
|
||||
MountPoint(p.device,fs=p.filesystem,sz=p.size)
|
||||
|
||||
for r in Raid.list:
|
||||
if r.device not in devs and r.from_os == 'yes':
|
||||
f_s = [p.filesystem for p in Partition.list if p.device == r.active_components[0]]
|
||||
MountPoint(r.device, fs=''.join(f_s),sz=r.size)
|
||||
elif r.device not in devs:
|
||||
if r.device not in devs:
|
||||
MountPoint(r.device,sz=r.size)
|
||||
|
||||
# now process whether a partition or raid was removed
|
||||
@@ -374,7 +371,27 @@ class MountPoint:
|
||||
break
|
||||
# sort
|
||||
MountPoint.list.sort(key=MountPoint.device)
|
||||
|
||||
@staticmethod
|
||||
def del_mount_dev(dev):
|
||||
'''del device in mount list'''
|
||||
devs = [ m.device for m in MountPoint.list ]
|
||||
for i in range(len(MountPoint.list)):
|
||||
if dev in devs and dev == MountPoint.list[i].device:
|
||||
del MountPoint.list[i]
|
||||
break
|
||||
MountPoint.list.sort(key=MountPoint.device)
|
||||
|
||||
@staticmethod
|
||||
def add_mount_dev(dev):
|
||||
'''add device into mount list'''
|
||||
devs = [ m.device for m in MountPoint.list ]
|
||||
for i in range(len(Partition.list)):
|
||||
if dev not in devs and dev == Partition.list[i].device:
|
||||
MountPoint(dev,fs=Partition.list[i].filesystem,sz=Partition.list[i].size)
|
||||
break
|
||||
MountPoint.list.sort(key=MountPoint.device)
|
||||
|
||||
@staticmethod
|
||||
def init_from_xml(node):
|
||||
''' create MountPoint instances from xml node '''
|
||||
|
||||
@@ -19,11 +19,8 @@ def serial_no_quit():
|
||||
def mount_list_init():
|
||||
''' initialize mount list '''
|
||||
l = []
|
||||
devs=ri_data.Raid.dev_in_raid()
|
||||
ri_data.MountPoint.init_from_internal()
|
||||
for m in ri_data.MountPoint.list:
|
||||
if m.device in devs:
|
||||
continue
|
||||
# get size from Partition info
|
||||
sz = ri_data.Partition.get_size(m.device)
|
||||
if not sz:
|
||||
@@ -41,6 +38,7 @@ def mp_top_init():
|
||||
''' mount dir top window initialize '''
|
||||
ml_win = ri_widget.Widget.dict['mount.list'].tk_widget
|
||||
idxs = ml_win.curselection()
|
||||
|
||||
if len(idxs) == 1:
|
||||
idx = int(idxs[0])
|
||||
mp = ri_data.MountPoint.list[idx]
|
||||
@@ -354,6 +352,9 @@ def raid_device_add():
|
||||
|
||||
dev = ri_data.Raid.get_next_device()
|
||||
ri_data.Raid(dev, "no", level, raid_calc_size(level, active), active, spare)
|
||||
for d in active+spare:
|
||||
ri_data.MountPoint.del_mount_dev(d)
|
||||
|
||||
raid_device_init()
|
||||
display.var_dict['raid_active_devs'].set(value='')
|
||||
display.var_dict['raid_spare_devs'].set(value='')
|
||||
@@ -386,6 +387,8 @@ def raid_device_delete():
|
||||
display.var_dict['raid_active_devs'].set(value=tuple(active))
|
||||
display.var_dict['raid_spare_devs'].set(value=tuple(spare))
|
||||
del ri_data.Raid.list[idx]
|
||||
for d in active+spare:
|
||||
ri_data.MountPoint.add_mount_dev(d)
|
||||
raid_device_init()
|
||||
|
||||
def raid_device_list_detail(*args):
|
||||
|
||||
Reference in New Issue
Block a user