raid is ok
modified: di_dialog.py modified: di_main.py
This commit is contained in:
@@ -51,7 +51,7 @@ class SerialNumber(Dialog):
|
||||
|
||||
class Raid(Dialog):
|
||||
def __init__(self,height=10,width=30,text='making Raid devices'):
|
||||
Dialog.__init__(self,name='Raid')
|
||||
Dialog.__init__(self,name='raid')
|
||||
self.height=height
|
||||
self.width=width
|
||||
self.text=text
|
||||
@@ -86,31 +86,39 @@ class Raid(Dialog):
|
||||
if not list:
|
||||
return 0
|
||||
|
||||
s,check_list=Dialog.dialog.checklist(text='Plase select the active fd',height=self.height,width=self.width,choices=list,title='choices active fd',clear=1)
|
||||
s,actives=Dialog.dialog.checklist(text='Plase select the active fd',height=self.height,width=self.width,choices=list,title='choices active fd',clear=1)
|
||||
if s == 0 :
|
||||
if int(level) < 2 and len(actives) < 2 :
|
||||
Dialog.message('Making a raid0 or raid1 needs two or more partitions.')
|
||||
return
|
||||
elif str(level) == "5" and len(actives) < 3:
|
||||
Dialog.message('Making a raid5 needs three or more partitions')
|
||||
return
|
||||
#(dev, from_os, level, a_devs, s_devs=[]):
|
||||
if dname not in ri_data.Raid.dict.keys():
|
||||
ri_data.Raid(dname,'no',level,check_list,[])
|
||||
ri_data.Raid(dname,'no',level,actives,[])
|
||||
else:
|
||||
print 'get_next_name error in active?'
|
||||
print dname
|
||||
ri_data.Raid.dict[dname].active_components=check_list
|
||||
ri_data.Raid.dict[dname].active_components=actives
|
||||
return s
|
||||
|
||||
def raid_raw_to_spare(self,level,dname):
|
||||
list=self.raid_raw_map()
|
||||
if dname not in ri_data.Raid.dict.keys():
|
||||
return
|
||||
|
||||
list=self.raid_raw_map()
|
||||
if not list:
|
||||
return 0
|
||||
|
||||
s,check_list=Dialog.dialog.checklist(text='Plase select the active fd',height=self.height,width=self.width,choices=list,title='choices active fd',clear=1)
|
||||
s,spares=Dialog.dialog.checklist(text='Plase select the spare fd',height=self.height,width=self.width,choices=list,title='choices spare fd',clear=1)
|
||||
if s == 0 :
|
||||
#(dev, from_os, level, a_devs, s_devs=[]):
|
||||
if dname not in ri_data.Raid.dict.keys():
|
||||
ri_data.Raid(dname,'no',level,[],check_list)
|
||||
ri_data.Raid(dname,'no',level,[],spares)
|
||||
else:
|
||||
print 'get_next_name error in spare?'
|
||||
print dname
|
||||
ri_data.Raid.dict[dname].spare_components=check_list
|
||||
ri_data.Raid.dict[dname].spare_components=spares
|
||||
return s
|
||||
|
||||
def make_raid(self):
|
||||
@@ -136,38 +144,56 @@ class Raid(Dialog):
|
||||
return exit_info
|
||||
|
||||
def del_raid(self):
|
||||
pass
|
||||
# from os
|
||||
raid_text=''
|
||||
raid_choices=[]
|
||||
|
||||
for R in [ d for d in ri_data.Raid.dict.values() if d.from_os == 'no' ]:
|
||||
raid_text+='%s (%s):\n active %s; spare %s\n'%(R.device,R.from_os,R.active_components,R.spare_components)
|
||||
raid_choices.append((R.device,''))
|
||||
|
||||
exit_info,device=Dialog.dialog.menu(text='Plase select make raidX\n%s'%raid_text,
|
||||
height=self.height,width=self.width,menu_height=2,choices=raid_choices,title='Configure raid',clear=1)
|
||||
|
||||
if exit_info == 0:
|
||||
del ri_data.Raid.dict[device]
|
||||
return exit_info
|
||||
|
||||
|
||||
def set_data(self):
|
||||
while True:
|
||||
list = [('make a raid?',''),('delecte a raid?','')]
|
||||
list = [('Making the raid device',''),('Delect raid device','')]
|
||||
fd_devices=self.raid_raw_init()
|
||||
fd_devices_test=''
|
||||
raid_text=''
|
||||
|
||||
from_os_list= [ R.from_os for R in ri_data.Raid.dict.values() ]
|
||||
|
||||
if len(fd_devices) < 3 and not ri_data.Raid.dict.keys():
|
||||
if len(fd_devices) < 3 and not from_os_list :
|
||||
return 0
|
||||
|
||||
if not fd_devices :
|
||||
del list[0]
|
||||
else:
|
||||
fd_devices_test='fd: '+','.join(fd_devices)
|
||||
|
||||
from_os_list= [ R.from_os for R in ri_data.Raid.dict.values() ]
|
||||
|
||||
if not 'no' in from_os_list:
|
||||
if 'no' not in from_os_list:
|
||||
del list[1]
|
||||
else:
|
||||
for R in ri_data.Raid.dict.values():
|
||||
raid_text+='%s (%s):\n active %s; spare %s\n'%(R.device,R.from_os,R.active_components,R.spare_components)
|
||||
|
||||
exit_info,string=Dialog.dialog.menu(text='Plase select make raidX\n%s\n%s'%(raid_text,fd_devices_test),
|
||||
height=self.height,width=self.width,menu_height=2,choices=list,title='Configure raid')
|
||||
height=self.height,width=self.width,menu_height=2,choices=list,title='Configure raid',
|
||||
help_button=1,help_label='Next',clear=1)
|
||||
|
||||
if exit_info == 0 and string == list[0][0]:
|
||||
if exit_info == 0 and string == "Making the raid device":
|
||||
self.make_raid()
|
||||
elif exit_info == 0 and string == list[1][0]:
|
||||
pass
|
||||
elif exit_info == 0 and string == "Delect raid device" :
|
||||
self.del_raid()
|
||||
else:
|
||||
return
|
||||
return ( exit_info == 'help' and '0' or exit_info)
|
||||
|
||||
|
||||
class MountPoint(Dialog):
|
||||
@@ -392,9 +418,3 @@ class Prepar_installation(Dialog):
|
||||
return s
|
||||
else:
|
||||
return s
|
||||
|
||||
ri_data.init()
|
||||
R=Raid(20,50)
|
||||
R.set_data()
|
||||
#M=MountPoint(20,40)
|
||||
#M.set_data()
|
||||
|
||||
@@ -4,20 +4,21 @@ sys.path.append('../interface/')
|
||||
import ri_data
|
||||
import di_dialog
|
||||
|
||||
list=['welcome','mountpoint','serialnumber','network','group','service','information']
|
||||
list=['welcome','raid','mountpoint','serialnumber','network','group','service','information']
|
||||
|
||||
di_dialog.Welcome(15,50)
|
||||
di_dialog.MountPoint(20,50)
|
||||
di_dialog.Welcome(30,70)
|
||||
di_dialog.Raid(30,70)
|
||||
di_dialog.MountPoint(30,70)
|
||||
di_dialog.SerialNumber(10,50)
|
||||
di_dialog.Network(10,50)
|
||||
di_dialog.Group(20,50)
|
||||
di_dialog.Service(15,50)
|
||||
di_dialog.Group(30,70)
|
||||
di_dialog.Service(25,50)
|
||||
di_dialog.Prepar_installation(40,100)
|
||||
|
||||
count=0
|
||||
while True :
|
||||
s = di_dialog.Dialog.dict[list[count]].set_data()
|
||||
if s == 0:
|
||||
if int(s) == 0:
|
||||
count = count + 1
|
||||
else:
|
||||
count = count - 1
|
||||
|
||||
Reference in New Issue
Block a user