add make a raid
modified: di_dialog.py
This commit is contained in:
@@ -1,13 +1,9 @@
|
||||
import sys
|
||||
import sys,re
|
||||
import dialog
|
||||
|
||||
sys.path.append('../interface/')
|
||||
import ri_data
|
||||
|
||||
from xml.dom import minidom
|
||||
from xml.dom.ext import PrettyPrint
|
||||
|
||||
|
||||
config_xml="../xml/config.xml"
|
||||
|
||||
class Dialog:
|
||||
@@ -39,7 +35,7 @@ class Welcome(Dialog):
|
||||
if s == 0 :
|
||||
ri_data.init()
|
||||
return s
|
||||
|
||||
|
||||
class SerialNumber(Dialog):
|
||||
def __init__(self,height=10, width=30,text='plase input a serial number'):
|
||||
Dialog.__init__(self,name='serialnumber')
|
||||
@@ -60,9 +56,116 @@ class Raid(Dialog):
|
||||
self.width=width
|
||||
self.text=text
|
||||
|
||||
def set_data(self):
|
||||
def check_device(self):
|
||||
print ri_data.Raid.dict.keys()
|
||||
if ri_data.Raid.dict.keys():
|
||||
return True
|
||||
return False
|
||||
|
||||
def raid_raw_init(self):
|
||||
''' initialize raid raw devices (parttion with id 'fd' '''
|
||||
#global raid_raw_initialized
|
||||
# get all component devices already in raid
|
||||
dev_in_raid = ri_data.Raid.dev_in_raid()
|
||||
|
||||
raw_devs = [ d for d in ri_data.Partition.dict.keys()
|
||||
if re.search('raid', ri_data.Partition.dict[d].flags) and d not in dev_in_raid ]
|
||||
raw_devs.sort()
|
||||
return raw_devs
|
||||
|
||||
def raid_raw_map(self):
|
||||
list=[]
|
||||
fd=self.raid_raw_init()
|
||||
for d in fd:
|
||||
list.append((d,'','off'))
|
||||
return list
|
||||
|
||||
def raid_raw_to_active(self,level,dname):
|
||||
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)
|
||||
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,[])
|
||||
else:
|
||||
print 'get_next_name error in active?'
|
||||
print dname
|
||||
ri_data.Raid.dict[dname].active_components=check_list
|
||||
return s
|
||||
|
||||
def raid_raw_to_spare(self,level,dname):
|
||||
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)
|
||||
if s == 0 :
|
||||
if dname not in ri_data.Raid.dict.keys():
|
||||
ri_data.Raid(dname,'no',level,[],check_list)
|
||||
else:
|
||||
print 'get_next_name error in spare?'
|
||||
print dname
|
||||
ri_data.Raid.dict[dname].spare_components=check_list
|
||||
return s
|
||||
|
||||
def make_raid(self):
|
||||
fd_devices=self.raid_raw_init()
|
||||
|
||||
# from os
|
||||
raid_text=''
|
||||
for R in ri_data.Raid.dict.values():
|
||||
raid_text+='%s:\n active %s\n spare %s\n'%(R.device,R.active_components,R.spare_components)
|
||||
|
||||
# fd
|
||||
fd_devices_test='fd: '+','.join(fd_devices)
|
||||
|
||||
exit_info,raid=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=3,choices=[('Raid0',''),('Raid1',''),('Raid5','')],
|
||||
title='Make a raid',ok_label='edit',help_button=1,help_label='Next',clear=1)
|
||||
#choices=list,title='Mount',ok_label='edit',help_button=1,help_label='Next',clear=1)
|
||||
|
||||
if exit_info == 0:
|
||||
dname=ri_data.Raid.get_next_device()
|
||||
self.raid_raw_to_active(raid[-1],dname)
|
||||
self.raid_raw_to_spare(raid[-1],dname)
|
||||
else:
|
||||
return exit_info
|
||||
|
||||
def del_raid(self):
|
||||
pass
|
||||
|
||||
def set_data(self):
|
||||
list = [('make a raid?',''),('delect a raid?')]
|
||||
fd_devices=self.raid_raw_init()
|
||||
fd_devices_test=''
|
||||
raid_text=''
|
||||
|
||||
if len(fd_devices) < 3 and not ri_data.Raid.dict.keys():
|
||||
return 0
|
||||
|
||||
if len(fd_devices) < 3:
|
||||
del list[0]
|
||||
else:
|
||||
fd_devices_test='fd: '+','.join(fd_devices)
|
||||
|
||||
if not ri_data.Raid.dict.keys():
|
||||
del list[1]
|
||||
else:
|
||||
for R in ri_data.Raid.dict.values():
|
||||
raid_text+='%s:\n active %s\n spare %s\n'%(R.device,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')
|
||||
|
||||
if exit_info == 0 and string == list[0][0]:
|
||||
self.make_raid()
|
||||
elif exit_info == 0 and string == list[1][0]:
|
||||
pass
|
||||
|
||||
|
||||
class MountPoint(Dialog):
|
||||
@@ -111,33 +214,43 @@ class MountPoint(Dialog):
|
||||
return n
|
||||
|
||||
def set_data(self):
|
||||
ri_data.MountPoint.init_from_internal()
|
||||
while True:
|
||||
list=[]
|
||||
keys=ri_data.MountPoint.dict.keys()
|
||||
keys.sort()
|
||||
|
||||
for d in keys:
|
||||
list.append((ri_data.MountPoint.dict[d].device,ri_data.MountPoint.dict[d].directory.ljust(10)+ri_data.MountPoint.dict[d].filesystem.ljust(10)+ri_data.MountPoint.dict[d].format.ljust(5)+ri_data.Partition.dict[d].size+ri_data.Partition.unit))
|
||||
list.append((ri_data.MountPoint.dict[d].device,
|
||||
ri_data.MountPoint.dict[d].directory.ljust(10)+
|
||||
ri_data.MountPoint.dict[d].filesystem.ljust(10)+
|
||||
ri_data.MountPoint.dict[d].format.ljust(5)+
|
||||
ri_data.MountPoint.get_size(d)+
|
||||
ri_data.Partition.unit))
|
||||
|
||||
exit_info,string=Dialog.dialog.menu(text="There are five columns in the mount point display frame.\n \
|
||||
Device Directory Filesystem Format Size",
|
||||
exit_info,string=Dialog.dialog.menu(text="There are five columns in the mount point display frame.\n Device Directory Filesystem Format Size",
|
||||
height=self.height,width=self.width,menu_height=(len(list) > self.height and self.helght - 2 or len(list) ),
|
||||
choices=list,title='Mount',ok_label='edit',help_button=1,help_label='Next',clear=1)
|
||||
if exit_info == 0 :
|
||||
# edit mountpoint
|
||||
self.set_mountpoint(string)
|
||||
self.set_format(string)
|
||||
|
||||
if not ri_data.MountPoint.check_data(string, # device
|
||||
# check date
|
||||
if not ri_data.MountPoint.check_data(string, # device
|
||||
ri_data.MountPoint.dict[string].directory.rstrip('/'), # mountpoint
|
||||
ri_data.MountPoint.dict[string].filesystem): # filesystem
|
||||
|
||||
ri_data.MountPoint.dict[string].directory = ''
|
||||
Dialog.message("The mount point couldn't be mounted on because it has been used or it's particular.")
|
||||
|
||||
elif exit_info == 1 :
|
||||
# back
|
||||
break
|
||||
else:
|
||||
# next
|
||||
exit_info = 0
|
||||
break
|
||||
|
||||
return exit_info
|
||||
|
||||
class Network(Dialog):
|
||||
@@ -278,3 +391,8 @@ class Prepar_installation(Dialog):
|
||||
else:
|
||||
return s
|
||||
|
||||
ri_data.init()
|
||||
R=Raid(15,40)
|
||||
R.set_data()
|
||||
#M=MountPoint(20,40)
|
||||
#M.set_data()
|
||||
|
||||
Reference in New Issue
Block a user