Support making raid and Fix problems of partition-tool
Merge the button 'Next' to 'OK' on the network configure interface modified: dialog/di_main.py modified: dialog/di_newt.py modified: interface/ri_data.py modified: interface/ri_oper.py modified: new_partition/interface_partition.py modified: new_partition/partition_data.py
This commit is contained in:
@@ -6,6 +6,7 @@ from xml.dom import minidom
|
||||
from xml.dom.ext import PrettyPrint
|
||||
sys.path.append('../new_partition/')
|
||||
import partition_data as p_d
|
||||
import interface_partition
|
||||
|
||||
|
||||
|
||||
@@ -197,11 +198,14 @@ p_node - xml node (parent node)'''
|
||||
class Raid:
|
||||
''' raid information '''
|
||||
dict = {}
|
||||
def __init__(self, dev, from_os, level, a_devs, s_devs=[]):
|
||||
def __init__(self, dev, from_os, level, mp, fmt, filesystem,a_devs, s_devs=[]):
|
||||
''' Raid init function '''
|
||||
self.device = dev
|
||||
self.from_os = from_os
|
||||
self.level = level
|
||||
self.mp = mp
|
||||
self.fmt = fmt
|
||||
self.filesystem = filesystem
|
||||
self.active_components = a_devs
|
||||
self.spare_components = s_devs
|
||||
Raid.dict[dev] = self
|
||||
@@ -232,7 +236,7 @@ class Raid:
|
||||
else:
|
||||
act_cmpts.append(ss[:ss.index('[')])
|
||||
|
||||
Raid(raid_dev, "yes", raid_level, act_cmpts, spr_cmpts)
|
||||
Raid(raid_dev, "yes", raid_level, '', 'no', '', act_cmpts, spr_cmpts)
|
||||
|
||||
@staticmethod
|
||||
def add_component(node, l):
|
||||
@@ -252,6 +256,9 @@ l - list
|
||||
raid_dev = e.attributes['device'].value
|
||||
raid_from = e.attributes['from_os'].value
|
||||
raid_level = e.attributes['level'].value
|
||||
raid_mp = e.attributes['mp'].value
|
||||
raid_fmt = e.attributes['fmt'].value
|
||||
raid_fs = e.attributes['filesystem'].value
|
||||
act_cmpts = []
|
||||
spr_cmpts = []
|
||||
for sub_e in e.childNodes:
|
||||
@@ -261,7 +268,7 @@ l - list
|
||||
elif sub_e.nodeName == 'spare':
|
||||
Raid.add_component(sub_e, spr_cmpts)
|
||||
|
||||
Raid(raid_dev, raid_from, raid_level, act_cmpts, spr_cmpts)
|
||||
Raid(raid_dev, raid_from, raid_level, raid_mp, raid_fmt, raid_fs, act_cmpts, spr_cmpts)
|
||||
|
||||
@staticmethod
|
||||
def to_xml(doc, p_node):
|
||||
@@ -287,6 +294,18 @@ p_node - xml node (parent node) '''
|
||||
rd_level_attr.value = r.level
|
||||
rd.setAttributeNode(rd_level_attr)
|
||||
|
||||
rd_mp_attr = doc.createAttribute('mp')
|
||||
rd_mp_attr.value = r.mp
|
||||
rd.setAttributeNode(rd_mp_attr)
|
||||
|
||||
rd_fmt_attr = doc.createAttribute('fmt')
|
||||
rd_fmt_attr.value = r.fmt
|
||||
rd.setAttributeNode(rd_fmt_attr)
|
||||
|
||||
rd_fs_attr = doc.createAttribute('filesystem')
|
||||
rd_fs_attr.value = r.filesystem
|
||||
rd.setAttributeNode(rd_fs_attr)
|
||||
|
||||
rd_act_elem = doc.createElement('active')
|
||||
for act_c in r.active_components:
|
||||
act_c_e = doc.createElement('component')
|
||||
@@ -311,10 +330,11 @@ p_node - xml node (parent node) '''
|
||||
def get_size(dev):
|
||||
''' calculate raid device size '''
|
||||
rd = Raid.dict[dev]
|
||||
sz = min([ float(Partition.dict[d].size) for d in rd.active_components])
|
||||
if rd.level == '0': return str(sz*len(rd.active_components))
|
||||
elif rd.level == '1': return str(sz*len(rd.active_components)/2)
|
||||
elif rd.level == '5': return str(sz*(len(rd.active_components)-1))
|
||||
sz = 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)))
|
||||
|
||||
@staticmethod
|
||||
def get_next_device():
|
||||
@@ -335,6 +355,13 @@ p_node - xml node (parent node) '''
|
||||
devices_in_raid.update(r.spare_components)
|
||||
return devices_in_raid
|
||||
|
||||
@staticmethod
|
||||
def get_raid_from_partition(partition):
|
||||
for raid in Raid.dict.keys():
|
||||
for p in Raid.dict[raid].active_components + Raid.dict[Raid].spare.components:
|
||||
if p == partition:
|
||||
return raid
|
||||
|
||||
class MountPoint:
|
||||
''' mount-points '''
|
||||
dict={}
|
||||
@@ -677,7 +704,7 @@ def prepar_installation():
|
||||
def init():
|
||||
''' initialize '''
|
||||
Partition.init_from_os()
|
||||
Raid.init_from_os()
|
||||
#Raid.init_from_os()
|
||||
MountPoint.init_from_internal()
|
||||
xmldoc_cfg = minidom.parse(config_xml)
|
||||
root_cfg = xmldoc_cfg.firstChild
|
||||
|
||||
@@ -87,6 +87,7 @@ class Operation:
|
||||
process.stdin.close()
|
||||
while True:
|
||||
line = process.stdout.readline()
|
||||
print line
|
||||
if not line:
|
||||
break
|
||||
if line[0] == '@' and self.current_step < self.steps:
|
||||
@@ -167,6 +168,9 @@ class Format(Operation):
|
||||
n = 0
|
||||
disks = p_d.Partition.dict.keys()
|
||||
disks.sort()
|
||||
mds = ri_data.Raid.dict.keys()
|
||||
mds.sort()
|
||||
|
||||
for d in disks:
|
||||
partitions = p_d.sort_partitions(p_d.Partition.dict, d, 'partition')
|
||||
for p in partitions:
|
||||
@@ -175,6 +179,13 @@ class Format(Operation):
|
||||
if fmt.strip() == 'yes' and fs_type.strip():
|
||||
format += "%s %s\n" %(p, fs_type)
|
||||
n += 1
|
||||
for m in mds:
|
||||
R = ri_data.Raid.dict[m]
|
||||
fs_type = R.filesystem
|
||||
fmt = R.fmt
|
||||
if fmt.strip() == 'yes' and fs_type.strip():
|
||||
format += "/dev/%s %s\n" %(m, fs_type)
|
||||
n += 1
|
||||
|
||||
self.steps += n
|
||||
return format
|
||||
@@ -231,6 +242,8 @@ class Mount(Operation):
|
||||
n = 0
|
||||
disks = p_d.Partition.dict.keys()
|
||||
disks.sort()
|
||||
mds = ri_data.Raid.dict.keys()
|
||||
mds.sort()
|
||||
for d in disks:
|
||||
partitions = p_d.sort_partitions(p_d.Partition.dict, d, 'partition')
|
||||
for p in partitions:
|
||||
@@ -239,6 +252,14 @@ class Mount(Operation):
|
||||
if mp.strip() and fs.strip():
|
||||
mount += "%s %s %s\n" %(p, mp, fs)
|
||||
n += 1
|
||||
for m in mds:
|
||||
R = ri_data.Raid.dict[m]
|
||||
mp = R.mp
|
||||
fs = R.filesystem
|
||||
if mp.strip() and fs.strip():
|
||||
mount += "/dev/%s %s %s\n" %(m, mp, fs)
|
||||
n += 1
|
||||
|
||||
self.steps += n
|
||||
return mount
|
||||
|
||||
@@ -271,6 +292,9 @@ class ConfigureFstab(Mount):
|
||||
fstab=''
|
||||
disks = p_d.Partition.dict.keys()
|
||||
disks.sort()
|
||||
mds = ri_data.Raid.dict.keys()
|
||||
mds.sort()
|
||||
|
||||
for d in disks:
|
||||
partitions = p_d.sort_partitions(p_d.Partition.dict, d, 'partition')
|
||||
for p in partitions:
|
||||
@@ -281,6 +305,15 @@ class ConfigureFstab(Mount):
|
||||
mp = 'swap'
|
||||
if mp.strip() and fs.strip():
|
||||
fstab += "%s %s %s\n" %(p, mp, fs)
|
||||
for m in mds:
|
||||
R = ri_data.Raid.dict[m]
|
||||
mp = R.mp
|
||||
fs = R.filesystem
|
||||
if fs.strip() == 'linux-swap':
|
||||
fs = 'swap'
|
||||
mp = 'swap'
|
||||
if mp.strip() and fs.strip():
|
||||
fstab += "/dev/%s %s %s\n" %(m, mp, fs)
|
||||
|
||||
# process fstab to sort
|
||||
fstab_new = ''
|
||||
|
||||
Reference in New Issue
Block a user