modified: ri_oper.py
updata check mount point
This commit is contained in:
@@ -37,21 +37,6 @@ class Rate:
|
||||
def set(n):
|
||||
Rate.value = n
|
||||
|
||||
def check_mount_point(dev,dir):
|
||||
'''check mount point be used or not. dev is a device of MountPoint.dict,
|
||||
dir is a directory of MountPoint.dict'''
|
||||
if dir:
|
||||
keys = ri_data.MountPoint.dict.keys()
|
||||
keys.sort()
|
||||
index = keys.index(dev)
|
||||
if index < 1:
|
||||
return False
|
||||
else:
|
||||
for k in keys[:index-1]:
|
||||
if ri_data.MountPoint.dict[k].directory == dir:
|
||||
return True
|
||||
return False
|
||||
|
||||
class Operation:
|
||||
''' This is a common base class for all install operations.
|
||||
The instances of its derived class should have the following
|
||||
@@ -152,6 +137,7 @@ class MakeRaidConfigure(Operation):
|
||||
"""class for make raid configure"""
|
||||
def __init__(self,scr):
|
||||
Operation.__init__(self,"Generate /etc/mdadm.conf",u"生成raid配置文件","mkraidconf.sh",scr)
|
||||
|
||||
def install(self):
|
||||
if ri_data.Raid.dict.values():
|
||||
return Operation.install(self)
|
||||
@@ -165,20 +151,21 @@ class MakeRaidConfigure(Operation):
|
||||
|
||||
class Mount(Operation):
|
||||
"""class for mount partition"""
|
||||
dict={}
|
||||
def __init__(self,scr):
|
||||
Operation.__init__(self, 'Mount partition', u'挂载分区', 'mount_partition.sh',scr)
|
||||
|
||||
def get_stdin(self):
|
||||
mount=''
|
||||
n = 0
|
||||
M_keys = ri_data.MountPoint.dict.keys()
|
||||
M_keys.sort()
|
||||
for k in M_keys :
|
||||
instance = ri_data.MountPoint.dict[k]
|
||||
if check_mount_point(instance.device, instance.directory): continue
|
||||
if instance.directory != '' and instance.filesystem !='':
|
||||
mount+="/dev/%s %s %s\n"%(instance.device,instance.directory,instance.filesystem)
|
||||
n += 1
|
||||
for dir in set([ m.directory for m in ri_data.MountPoint.dict.values() if m.directory ]):
|
||||
for k in ri_data.MountPoint.dict.keys():
|
||||
if ri_data.MountPoint.dict[k] == dir and ri_data.MountPoint.dict[k].filesystem:
|
||||
# during configure fstab, use dict of Mount
|
||||
Mount.dict[k]=dir
|
||||
mount+='/dev/%s %s %s\n' %(k,dir,ri_data.MountPoint.dict[k].filesystem)
|
||||
n+=1
|
||||
break
|
||||
self.steps += n
|
||||
return mount
|
||||
|
||||
@@ -206,16 +193,14 @@ class ConfigureFstab(Mount):
|
||||
def get_stdin(self):
|
||||
fstab=''
|
||||
flag=True
|
||||
M_keys = ri_data.MountPoint.dict.keys()
|
||||
M_keys.sort()
|
||||
for k in M_keys:
|
||||
instance = ri_data.MountPoint.dict[k]
|
||||
if check_mount_point(instance.device, instance.directory): continue
|
||||
if instance.filesystem != '' and instance.directory !='':
|
||||
fstab += "/dev/%s %s %s\n" %(instance.device, instance.directory, instance.filesystem)
|
||||
elif instance.filesystem == 'swap' and flag:
|
||||
fstab += "/dev/%s swap swap\n" %instance.device
|
||||
flag=False
|
||||
for k in Mount.dict.keys():
|
||||
if ri_data.MountPoint.dict[k] != 'swap':
|
||||
fstab += "/dev/%s %s %s\n" %(k,Mount.dict[k],ri_data.MountPoint.dict[k].filesystem)
|
||||
|
||||
for k in ri_data.MountPoint.dict.keys():
|
||||
if ri_data.MountPoint.dict[k].filesystem == 'swap':
|
||||
fstab += '/dev/%s swap swap\n' %k
|
||||
break
|
||||
return fstab
|
||||
|
||||
class GenerateIssue(Operation):
|
||||
@@ -294,6 +279,7 @@ class ExecFinishInstall(Operation):
|
||||
"""class for exec finish install"""
|
||||
def __init__(self,scr):
|
||||
Operation.__init__(self,"Exec finish_install script",u"安装完成执行的脚本","exec_finish_install.sh",scr)
|
||||
|
||||
def get_stdin(self):
|
||||
return "99finish_install.sh\n"
|
||||
|
||||
@@ -320,7 +306,6 @@ class ConfigureBootloader(Operation):
|
||||
def get_arguments(self):
|
||||
list=[]
|
||||
tp="grub"
|
||||
isboot=False
|
||||
# FIXME if tag file format is error?
|
||||
if os.path.isfile("/tag"):
|
||||
fd = open("/tag","r")
|
||||
@@ -329,19 +314,12 @@ class ConfigureBootloader(Operation):
|
||||
fd.close()
|
||||
|
||||
bootloader=['-t',tp,'-o',list[0][5:].split('.')[0]+'.'+list[0][5:].split('.')[1]]
|
||||
M_keys = ri_data.MountPoint.dict.keys()
|
||||
M_keys.sort()
|
||||
for k in M_keys:
|
||||
instance = ri_data.MountPoint.dict[k]
|
||||
if check_mount_point(instance.device,instance.directory): continue
|
||||
if instance.directory == '/':
|
||||
bootloader +=['-r',instance.device]
|
||||
isboot=True
|
||||
continue
|
||||
for k in Mount.dict.keys():
|
||||
if '/' == Mount.dict[k]:
|
||||
bootloader += ['-r',k]
|
||||
if '/boot' == Mount.dict[k]:
|
||||
bootloader += ['-b',k]
|
||||
|
||||
if isboot and instance.directory == '/boot':
|
||||
bootloader += ['-b',instance.device]
|
||||
|
||||
if ri_data.SerialNumber.value:
|
||||
bootloader+=['-k',"linx_serial=%s" %ri_data.SerialNumber.value]
|
||||
return bootloader
|
||||
|
||||
Reference in New Issue
Block a user