Пример #1
0
    def sanityCheckRaid(self, partitions):
        if not self.raidmembers or not self.raidlevel:
            return _("No members in RAID request, or not RAID "
                     "level specified.")
        # XXX fix this code to look to see if there is a bootable partition
        bootreq = partitions.getBootableRequest()
        if not bootreq and self.mountpoint:
            # XXX 390 can't have boot on raid
            if (self.mountpoint in partitions.getBootableMountpoints()
                    and not raid.isRaid1(self.raidlevel)):
                return _("Bootable partitions can only be on RAID1 devices.")

        minmembers = raid.get_raid_min_members(self.raidlevel)
        if len(self.raidmembers) < minmembers:
            return _(
                "A RAID device of type %s "
                "requires at least %s members.") % (self.raidlevel, minmembers)

        if len(self.raidmembers) > 27:
            return "RAID devices are limited to 27 members."

        if self.raidspares:
            if (len(self.raidmembers) - self.raidspares) < minmembers:
                return _(
                    "This RAID device can have a maximum of %s spares. "
                    "To have more spares you will need to add members to "
                    "the RAID device.") % (len(self.raidmembers) - minmembers)
        return None
Пример #2
0
    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"
Пример #3
0
    def sanityCheckRaid(self, partitions):
        if not self.raidmembers or not self.raidlevel:
            return _("No members in RAID request, or not RAID "
                     "level specified.")
        # XXX fix this code to look to see if there is a bootable partition
        bootreq = partitions.getBootableRequest()
        if not bootreq and self.mountpoint:
            # XXX 390 can't have boot on raid
            if (self.mountpoint in partitions.getBootableMountpoints()
                 and not raid.isRaid1(self.raidlevel)):
                return _("Bootable partitions can only be on RAID1 devices.")

        minmembers = raid.get_raid_min_members(self.raidlevel)
        if len(self.raidmembers) < minmembers:
            return _("A RAID device of type %s "
                     "requires at least %s members.") % (self.raidlevel,
                                                         minmembers)

        if len(self.raidmembers) > 27:
            return "RAID devices are limited to 27 members."

        if self.raidspares:
            if (len(self.raidmembers) - self.raidspares) < minmembers:
                return _("This RAID device can have a maximum of %s spares. "
                         "To have more spares you will need to add members to "
                         "the RAID device.") % (len(self.raidmembers)
                                                - minmembers )
        return None
Пример #4
0
    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"
Пример #5
0
def isRaid1(raidlevel):
    """Return whether raidlevel is a valid descriptor of RAID1."""
    return raid.isRaid1(raidlevel)
Пример #6
0
    def sanityCheckAllRequests(self, diskset, baseChecks=0):
        """Do a sanity check of all of the requests.

        This function is called at the end of partitioning so that we
        can make sure you don't have anything silly (like no /, a really
        small /, etc).  Returns (errors, warnings) where each is a list
        of strings or None if there are none.
        If baseChecks is set, the basic sanity tests which the UI runs prior to
        accepting a partition will be run on the requests as well.
        """
        checkSizes = [('/usr', 250), ('/tmp', 50), ('/var', 384),
                      ('/home', 100), ('/boot', 75)]
        warnings = []
        errors = []

        slash = self.getRequestByMountPoint('/')
        if not slash:
            errors.append(
                _("You have not defined a root partition (/), "
                  "which is required for installation of %s "
                  "to continue.") % (productName, ))

        if slash and slash.getActualSize(self, diskset) < 250:
            warnings.append(
                _("Your root partition is less than 250 "
                  "megabytes which is usually too small to "
                  "install %s.") % (productName, ))

        if iutil.getArch() == "ia64":
            bootreq = self.getRequestByMountPoint("/boot/efi")
            if not bootreq or bootreq.getActualSize(self, diskset) < 50:
                errors.append(
                    _("You must create a /boot/efi partition of "
                      "type FAT and a size of 50 megabytes."))

        if (iutil.getPPCMachine() == "pSeries"
                or iutil.getPPCMachine() == "iSeries"):
            reqs = self.getBootableRequest()
            found = 0

            bestreq = None
            if reqs:
                for req in reqs:
                    if req.fstype == fsset.fileSystemTypeGet("PPC PReP Boot"):
                        found = 1
                        # the best one is either the first or the first
                        # newly formatted one
                        if ((bestreq is None) or ((bestreq.format == 0) and
                                                  (req.format == 1))):
                            bestreq = req
                        break
            if iutil.getPPCMachine() == "iSeries" and iutil.hasIbmSis():
                found = 1

            if not found:
                errors.append(_("You must create a PPC PReP Boot partition."))

            if bestreq is not None:
                if (iutil.getPPCMachine() == "pSeries"):
                    minsize = 4
                else:
                    minsize = 16
                if bestreq.getActualSize(self, diskset) < minsize:
                    warnings.append(
                        _("Your %s partition is less than %s "
                          "megabytes which is lower than "
                          "recommended for a normal %s install.") %
                        (_("PPC PReP Boot"), minsize, productName))

        for (mount, size) in checkSizes:
            req = self.getRequestByMountPoint(mount)
            if not req:
                continue
            if req.getActualSize(self, diskset) < size:
                warnings.append(
                    _("Your %s partition is less than %s "
                      "megabytes which is lower than recommended "
                      "for a normal %s install.") % (mount, size, productName))

        foundSwap = 0
        swapSize = 0
        for request in self.requests:
            if request.fstype and request.fstype.getName() == "swap":
                foundSwap = foundSwap + 1
                swapSize = swapSize + request.getActualSize(self, diskset)
            if baseChecks:
                rc = request.doSizeSanityCheck()
                if rc:
                    warnings.append(rc)
                rc = request.doMountPointLinuxFSChecks()
                if rc:
                    errors.append(rc)
                if isinstance(request, partRequests.RaidRequestSpec):
                    rc = request.sanityCheckRaid(self)
                    if rc:
                        errors.append(rc)

        bootreqs = self.getBootableRequest()
        if bootreqs:
            for bootreq in bootreqs:
                if (bootreq
                        and (isinstance(bootreq, partRequests.RaidRequestSpec))
                        and (not raid.isRaid1(bootreq.raidlevel))):
                    errors.append(
                        _("Bootable partitions can only be on RAID1 "
                          "devices."))

                # can't have bootable partition on LV
                if (bootreq and (isinstance(
                        bootreq, partRequests.LogicalVolumeRequestSpec))):
                    errors.append(
                        _("Bootable partitions cannot be on a "
                          "logical volume."))

                # most arches can't have boot on RAID
                if (bootreq
                        and (isinstance(bootreq, partRequests.RaidRequestSpec))
                        and (iutil.getArch() not in raid.raidBootArches)):
                    errors.append("Bootable partitions cannot be on a RAID "
                                  "device.")

        if foundSwap == 0:
            warnings.append(
                _("You have not specified a swap partition.  "
                  "Although not strictly required in all cases, "
                  "it will significantly improve performance for "
                  "most installations."))

        # XXX number of swaps not exported from kernel and could change
        if foundSwap >= 32:
            warnings.append(
                _("You have specified more than 32 swap devices.  "
                  "The kernel for %s only supports 32 "
                  "swap devices.") % (productName, ))

        mem = iutil.memInstalled()
        rem = mem % 16384
        if rem:
            mem = mem + (16384 - rem)
        mem = mem / 1024

        if foundSwap and (swapSize < (mem - 8)) and (mem < 1024):
            warnings.append(
                _("You have allocated less swap space (%dM) than "
                  "available RAM (%dM) on your system.  This "
                  "could negatively impact performance.") % (swapSize, mem))

        if warnings == []:
            warnings = None
        if errors == []:
            errors = None

        return (errors, warnings)