def getActualSize(self, partitions, diskset): """Return the actual size allocated for the request in megabytes.""" # this seems like a check which should never fail... if not self.raidmembers or not self.raidlevel: return 0 nummembers = len(self.raidmembers) - self.raidspares smallest = None sum = 0 for member in self.raidmembers: req = partitions.getRequestByID(member) partsize = req.getActualSize(partitions, diskset) if raid.isRaid0(self.raidlevel): sum = sum + partsize else: if not smallest: smallest = partsize elif partsize < smallest: smallest = partsize if raid.isRaid0(self.raidlevel): return sum elif raid.isRaid1(self.raidlevel): return smallest elif raid.isRaid5(self.raidlevel): return (nummembers - 1) * smallest elif raid.isRaid6(self.raidlevel): return (nummembers - 2) * smallest elif raid.isRaid10(self.raidlevel): return (nummembers / 2) * smallest else: raise ValueError, "Invalid raidlevel in RaidRequest.getActualSize"
def getActualSize(self, partitions, diskset): """Return the actual size allocated for the request in megabytes.""" # this seems like a check which should never fail... if not self.raidmembers or not self.raidlevel: return 0 nummembers = len(self.raidmembers) - self.raidspares smallest = None sum = 0 for member in self.raidmembers: req = partitions.getRequestByID(member) partsize = req.getActualSize(partitions, diskset) if raid.isRaid0(self.raidlevel): sum = sum + partsize else: if not smallest: smallest = partsize elif partsize < smallest: smallest = partsize if raid.isRaid0(self.raidlevel): return sum elif raid.isRaid1(self.raidlevel): return smallest elif raid.isRaid5(self.raidlevel): return (nummembers-1) * smallest elif raid.isRaid6(self.raidlevel): return (nummembers-2) * smallest elif raid.isRaid10(self.raidlevel): return (nummembers/2) * smallest else: raise ValueError, "Invalid raidlevel in RaidRequest.getActualSize"
def isRaid0(raidlevel): """Return whether raidlevel is a valid descriptor of RAID1.""" return raid.isRaid0(raidlevel)