modified: ri_data.py

fix:
    add a raid device , must be del partition on MountPoint.dict
This commit is contained in:
fling
2010-10-17 09:49:48 +08:00
parent 9322af8a4f
commit 6df3e0f7ba

View File

@@ -175,9 +175,10 @@ p_node - xml node (parent node)'''
pt.setAttributeNode(from_attr)
pts.appendChild(pt)
p_node.appendChild(pts)
# ri_tk_cmd.py use
@staticmethod
def get_size(dev):
# maybe add raid not in Partition.dict
if Partition.dict.has_key(dev):
return Partition.dict[dev].size
return
@@ -290,12 +291,12 @@ p_node - xml node (parent node) '''
raids.appendChild(rd)
p_node.appendChild(raids)
#ri_tk_cmd.py use
@staticmethod
def get_size(dev):
sz=sys.maxint
level=Raid.dict[dev].level
active=Raid.dict[dev].active_components
sz = sys.maxint
level = Raid.dict[dev].level
active = Raid.dict[dev].active_components
for d in active:
if float(Partition.dict[d].size) < float(sz):
sz=float(Partition.dict[d].size)
@@ -303,6 +304,7 @@ p_node - xml node (parent node) '''
sz=sz*len(active)
return str(sz)
elif level == '1':
sz=(len(active) * sz) / 2
return str(sz)
elif level == '5':
sz=sz*(len(active)-1)
@@ -358,15 +360,18 @@ class MountPoint:
if MountPoint.dict.has_key(dev):
continue
MountPoint(dev)
# adding a raid device, the partition which is raid.active or raid.spare must be deleted
for d in Raid.dict[dev].active_components + Raid.dict[dev].spare_components:
if not MountPoint.dict.has_key(d):continue
del MountPoint.dict[d]
# now process whether a partition or raid was removed
# process has been tested. result's only remove raid device
s1 = set(MountPoint.dict.keys())
s2 = set(Partition.dict.keys() + Raid.dict.keys())
for dev in s1-s2:
del MountPoint.dict[dev]
#MountPoint.dict.keys().sort()
#print "keys=",MountPoint.dict.keys()
if MountPoint.dict.has_key(dev):
del MountPoint.dict[dev]
@staticmethod
def init_from_xml(node):