From ed6ba90bea01081fe172daa5281e1715f35bba65 Mon Sep 17 00:00:00 2001 From: fling Date: Thu, 4 Nov 2010 18:46:50 +0800 Subject: [PATCH] modified: ri_data.py modified: ri_main.py fix Partition/Raid/MountPoint must be from os when installation system every time. fix the data of raid.level is a number, not a string. Eg: "raid0"-->"0" --- interface/ri_data.py | 28 ++++++++++++++++++++++++---- interface/ri_main.py | 2 +- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/interface/ri_data.py b/interface/ri_data.py index 6b72693..fd03653 100644 --- a/interface/ri_data.py +++ b/interface/ri_data.py @@ -84,8 +84,9 @@ class Partition: or re.search(r'([a-zA-Z]+)', i).group(1) not in l]: st,o=commands.getstatusoutput('LANG=c parted /dev/%s unit %s print'%(d,Partition.unit)) if st: - print "Error parted execute error" - return + # if a raid device wasn't formated, exec "parted it unit GB print" + # command will return a error info. + continue # an example of o's content # Model: ATA Hitachi HDS72105 (scsi) # Disk /dev/sda: 500GB @@ -210,8 +211,9 @@ class Raid: dev_res = dev_p.split(s) if len(dev_res)>1: # matched # dev_res[0] is '' + # dev_res[2] is 'raidX' raid_dev = dev_res[1] - raid_level = dev_res[2] + raid_level = dev_res[2][4:] act_cmpts =[] spr_cmpts =[] for ss in dev_res[3].split(): @@ -654,7 +656,7 @@ def init(): Service.init_from_config_xml(root_cfg) def init_from_xml(): - ''' init all classes in this module based input file (install xml) ''' + ''' get data in file (install.xml)''' xmldoc = minidom.parse(install_xml) root = xmldoc.firstChild for n in root.childNodes: @@ -674,6 +676,24 @@ def init_from_xml(): elif n.nodeName == 'services': Service.init_from_xml(n) +def init_from_xml_and_os(): + ''' init all classes in this module from file and os ''' + xmldoc = minidom.parse(install_xml) + root = xmldoc.firstChild + for n in root.childNodes: + if n.nodeType == n.ELEMENT_NODE: + if n.nodeName == 'serial-number': + SerialNumber.init_from_xml(n) + elif n.nodeName == 'network': + Network.init_from_xml(n) + elif n.nodeName == 'groups': + Group.init_from_xml(n) + elif n.nodeName == 'services': + Service.init_from_xml(n) + Partition.init_from_os() + Raid.init_from_os() + MountPoint.init_from_internal() + def to_xml(): ''' write internal data into xml file ''' f = file(install_xml, 'w') diff --git a/interface/ri_main.py b/interface/ri_main.py index 932181d..d5e87ec 100644 --- a/interface/ri_main.py +++ b/interface/ri_main.py @@ -39,7 +39,7 @@ else: sys.exit(1) if os.path.isfile(ri_data.install_xml): - ri_data.init_from_xml() + ri_data.init_from_xml_and_os() else: ri_data.init()