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
|
||||
|
||||
Reference in New Issue
Block a user