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"
This commit is contained in:
fling
2010-11-04 18:46:50 +08:00
parent b55e66a836
commit ed6ba90bea
2 changed files with 25 additions and 5 deletions

View File

@@ -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')

View File

@@ -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()