Example #1
0
def checkForSwapNoMatch(intf, diskset, partitions):
    """Check for any partitions of type 0x82 which don't have a swap fs."""
    for request in partitions.requests:
        if not request.device or not request.fstype:
            continue

        part = partedUtils.get_partition_by_name(diskset.disks, request.device)
        if (part and (not part.type & parted.PARTITION_FREESPACE)
                and (part.native_type == 0x82)
                and (request.fstype and request.fstype.getName() != "swap")
                and (not request.format)):
            rc = intf.messageWindow(_("Format as Swap?"),
                                    _("/dev/%s has a partition type of 0x82 "
                                      "(Linux swap) but does not appear to "
                                      "be formatted as a Linux swap "
                                      "partition.\n\n"
                                      "Would you like to format this "
                                      "partition as a swap partition?") %
                                    (request.device),
                                    type="yesno",
                                    custom_icon="question")
            if rc == 1:
                request.format = 1
                request.fstype = fsset.fileSystemTypeGet("swap")
                if request.fstype.getName() == "software RAID":
                    part.set_flag(parted.PARTITION_RAID, 1)
                else:
                    part.set_flag(parted.PARTITION_RAID, 0)

                partedUtils.set_partition_file_system_type(
                    part, request.fstype)
Example #2
0
def bootloaderSetupChoices(dispatch, bl, fsset, diskSet, dir):
    if dir == DISPATCH_BACK:
        return

    choices = fsset.bootloaderChoices(diskSet, bl)
    if not choices and iutil.getPPCMachine() != "iSeries":
	dispatch.skipStep("instbootloader")
    else:
	dispatch.skipStep("instbootloader", skip = 0)

    bl.images.setup(diskSet, fsset)

    if bl.defaultDevice != None and choices:
        keys = choices.keys()
        # there are only two possible things that can be in the keys
        # mbr and boot.  boot is ALWAYS present.  so if the dev isn't
        # listed, it was mbr and we should nicely fall back to boot
        if bl.defaultDevice not in keys:
            log("MBR not suitable as boot device; installing to partition")
            bl.defaultDevice = "boot"
        bl.setDevice(choices[bl.defaultDevice][0])
    elif choices and choices.has_key("mbr"):
        bl.setDevice(choices["mbr"][0])
    elif choices and choices.has_key("boot"):
        bl.setDevice(choices["boot"][0])
    

    bootDev = fsset.getEntryByMountPoint("/")
    if not bootDev:
        bootDev = fsset.getEntryByMountPoint("/boot")
    part = partedUtils.get_partition_by_name(diskSet.disks,
                                              bootDev.device.getDevice())
    if part and partedUtils.end_sector_to_cyl(part.geom.dev,
                                               part.geom.end) >= 1024:
        bl.above1024 = 1
Example #3
0
 def getActualSize(self, partitions, diskset):
     """Return the actual size allocated for the request in megabytes."""
     part = partedUtils.get_partition_by_name(diskset.disks, self.device)
     if not part:
         # XXX kickstart might still call this before allocating the partitions
         raise RuntimeError, "Checking the size of a partition which hasn't been allocated yet"
     return partedUtils.getPartSizeMB(part)
Example #4
0
 def getActualSize(self, partitions, diskset):
     """Return the actual size allocated for the request in megabytes."""
     part = partedUtils.get_partition_by_name(diskset.disks, self.device)
     if not part:
         # XXX kickstart might still call this before allocating the partitions
         raise RuntimeError, "Checking the size of a partition which hasn't been allocated yet"
     return partedUtils.getPartSizeMB(part)
def checkForSwapNoMatch(anaconda):
    """Check for any partitions of type 0x82 which don't have a swap fs."""
    for request in anaconda.id.partitions.requests:
        if not request.device or not request.fstype:
            continue
        
        part = partedUtils.get_partition_by_name(anaconda.id.diskset.disks,
                                                 request.device)
        if (part and (not part.type & parted.PARTITION_FREESPACE)
            and (part.native_type == 0x82)
            and (request.fstype and request.fstype.getName() != "swap")
            and (not request.format)):
            rc = anaconda.intf.messageWindow(_("Format as Swap?"),
                                    _("/dev/%s has a partition type of 0x82 "
                                      "(Linux swap) but does not appear to "
                                      "be formatted as a Linux swap "
                                      "partition.\n\n"
                                      "Would you like to format this "
                                      "partition as a swap partition?")
                                    % (request.device), type = "yesno",
				    custom_icon="question")
            if rc == 1:
                request.format = 1
                request.fstype = fsset.fileSystemTypeGet("swap")
                if request.fstype.getName() == "software RAID":
                    part.set_flag(parted.PARTITION_RAID, 1)
                else:
                    part.set_flag(parted.PARTITION_RAID, 0)
                    
                partedUtils.set_partition_file_system_type(part,
                                                           request.fstype)
Example #6
0
def doDeletePartitionsByDevice(intf,
                               requestlist,
                               diskset,
                               device,
                               confirm=1,
                               quiet=0):
    """ Remove all partitions currently on device """
    if confirm:
        rc = intf.messageWindow(_("Confirm Delete"),
                                _("You are about to delete all partitions on "
                                  "the device '/dev/%s'.") % (device, ),
                                type="custom",
                                custom_icon="warning",
                                custom_buttons=[_("Cancel"),
                                                _("_Delete")])

        if not rc:
            return

    requests = requestlist.getRequestsByDevice(diskset, device)
    if not requests:
        return

    # get list of unique IDs of these requests
    reqIDs = []
    for req in requests:
        part = partedUtils.get_partition_by_name(diskset.disks, req.device)
        if part.type & parted.PARTITION_FREESPACE or part.type & parted.PARTITION_METADATA or part.type & parted.PARTITION_PROTECTED:
            continue
        reqIDs.append(req.uniqueID)

    # now go thru and try to delete the unique IDs
    for id in reqIDs:
        try:
            req = requestlist.getRequestByID(id)
            if req is None:
                continue
            part = partedUtils.get_partition_by_name(diskset.disks, req.device)
            rc = doDeletePartitionByRequest(intf,
                                            requestlist,
                                            part,
                                            confirm=0,
                                            quiet=1)
            # not sure why it returns both '0' and '(None, None)' on failure
            if not rc or rc == (None, None):
                pass
        except:
            pass

    # see which partitions are left
    notdeleted = []
    left_requests = requestlist.getRequestsByDevice(diskset, device)
    if left_requests:
        # get list of unique IDs of these requests
        leftIDs = []
        for req in left_requests:
            part = partedUtils.get_partition_by_name(diskset.disks, req.device)
            if part.type & parted.PARTITION_FREESPACE or part.type & parted.PARTITION_METADATA or part.type & parted.PARTITION_PROTECTED:
                continue
            leftIDs.append(req.uniqueID)

        for id in leftIDs:
            req = requestlist.getRequestByID(id)
            notdeleted.append(req)

    # see if we need to report any failures - some were because we removed
    # an extended partition which contained other members of our delete list
    outlist = ""
    for req in notdeleted:
        newreq = requestlist.getRequestByID(req.uniqueID)
        if newreq:
            outlist = outlist + "\t/dev/%s\n" % (newreq.device, )

    if outlist != "" and not quiet:
        intf.messageWindow(_("Notice"),
                           _("The following partitions were not deleted "
                             "because they are in use:\n\n%s") % outlist,
                           custom_icon="warning")

    return 1
Example #7
0
def bootloaderSetupChoices(anaconda):
    if anaconda.dir == DISPATCH_BACK:
        return

    # FIXME: this is a hack...
    if flags.livecd:
        return 

    if anaconda.id.ksdata:
        anaconda.id.bootloader.updateDriveList(anaconda.id.ksdata.bootloader["driveorder"])
    else:
        anaconda.id.bootloader.updateDriveList()

# iSeries bootloader on upgrades
    if iutil.getPPCMachine() == "iSeries" and not anaconda.id.bootloader.device:        
        drives = anaconda.id.diskset.disks.keys()
        drives.sort()
        bootPart = None
        for drive in drives:
            disk = anaconda.id.diskset.disks[drive]
            part = disk.next_partition()
            while part:
                if part.is_active() and part.native_type == 0x41:
                    bootPart = partedUtils.get_partition_name(part)
                    break
                part = disk.next_partition(part)
            if bootPart:
                break
        if bootPart:
            anaconda.id.bootloader.setDevice(bootPart)
            dev = Device()
            dev.device = bootPart
            anaconda.id.fsset.add(FileSystemSetEntry(dev, None, fileSystemTypeGet("PPC PReP Boot")))

    choices = anaconda.id.fsset.bootloaderChoices(anaconda.id.diskset, anaconda.id.bootloader)
    if not choices and iutil.getPPCMachine() != "iSeries":
	anaconda.dispatch.skipStep("instbootloader")
    else:
	anaconda.dispatch.skipStep("instbootloader", skip = 0)

    anaconda.id.bootloader.images.setup(anaconda.id.diskset, anaconda.id.fsset)

    if anaconda.id.bootloader.defaultDevice != None and choices:
        keys = choices.keys()
        # there are only two possible things that can be in the keys
        # mbr and boot.  boot is ALWAYS present.  so if the dev isn't
        # listed, it was mbr and we should nicely fall back to boot
        if anaconda.id.bootloader.defaultDevice not in keys:
            log.warning("MBR not suitable as boot device; installing to partition")
            anaconda.id.bootloader.defaultDevice = "boot"
        anaconda.id.bootloader.setDevice(choices[anaconda.id.bootloader.defaultDevice][0])
    elif choices and iutil.isMactel() and choices.has_key("boot"): # haccckkkk
        anaconda.id.bootloader.setDevice(choices["boot"][0])        
    elif choices and choices.has_key("mbr") and not \
         (choices.has_key("boot") and choices["boot"][1] == N_("RAID Device")):
        anaconda.id.bootloader.setDevice(choices["mbr"][0])
    elif choices and choices.has_key("boot"):
        anaconda.id.bootloader.setDevice(choices["boot"][0])
    

    bootDev = anaconda.id.fsset.getEntryByMountPoint("/")
    if not bootDev:
        bootDev = anaconda.id.fsset.getEntryByMountPoint("/boot")
    part = partedUtils.get_partition_by_name(anaconda.id.diskset.disks,
                                              bootDev.device.getDevice())
    if part and partedUtils.end_sector_to_cyl(part.geom.dev,
                                               part.geom.end) >= 1024:
        anaconda.id.bootloader.above1024 = 1
Example #8
0
def bootloaderSetupChoices(anaconda):
    if anaconda.dir == DISPATCH_BACK:
        return

    # FIXME: this is a hack...
    if flags.livecd:
        return

    if anaconda.id.ksdata:
        anaconda.id.bootloader.updateDriveList(
            anaconda.id.ksdata.bootloader["driveorder"])
    else:
        anaconda.id.bootloader.updateDriveList()


# iSeries bootloader on upgrades
    if iutil.getPPCMachine(
    ) == "iSeries" and not anaconda.id.bootloader.device:
        drives = anaconda.id.diskset.disks.keys()
        drives.sort()
        bootPart = None
        for drive in drives:
            disk = anaconda.id.diskset.disks[drive]
            part = disk.next_partition()
            while part:
                if part.is_active() and part.native_type == 0x41:
                    bootPart = partedUtils.get_partition_name(part)
                    break
                part = disk.next_partition(part)
            if bootPart:
                break
        if bootPart:
            anaconda.id.bootloader.setDevice(bootPart)
            dev = Device()
            dev.device = bootPart
            anaconda.id.fsset.add(
                FileSystemSetEntry(dev, None,
                                   fileSystemTypeGet("PPC PReP Boot")))

    choices = anaconda.id.fsset.bootloaderChoices(anaconda.id.diskset,
                                                  anaconda.id.bootloader)
    if not choices and iutil.getPPCMachine() != "iSeries":
        anaconda.dispatch.skipStep("instbootloader")
    else:
        anaconda.dispatch.skipStep("instbootloader", skip=0)

    anaconda.id.bootloader.images.setup(anaconda.id.diskset, anaconda.id.fsset)

    if anaconda.id.bootloader.defaultDevice != None and choices:
        keys = choices.keys()
        # there are only two possible things that can be in the keys
        # mbr and boot.  boot is ALWAYS present.  so if the dev isn't
        # listed, it was mbr and we should nicely fall back to boot
        if anaconda.id.bootloader.defaultDevice not in keys:
            log.warning(
                "MBR not suitable as boot device; installing to partition")
            anaconda.id.bootloader.defaultDevice = "boot"
        anaconda.id.bootloader.setDevice(
            choices[anaconda.id.bootloader.defaultDevice][0])
    elif choices and iutil.isMactel() and choices.has_key("boot"):  # haccckkkk
        anaconda.id.bootloader.setDevice(choices["boot"][0])
    elif choices and choices.has_key("mbr") and not \
         (choices.has_key("boot") and choices["boot"][1] == N_("RAID Device")):
        anaconda.id.bootloader.setDevice(choices["mbr"][0])
    elif choices and choices.has_key("boot"):
        anaconda.id.bootloader.setDevice(choices["boot"][0])

    bootDev = anaconda.id.fsset.getEntryByMountPoint("/")
    if not bootDev:
        bootDev = anaconda.id.fsset.getEntryByMountPoint("/boot")
    part = partedUtils.get_partition_by_name(anaconda.id.diskset.disks,
                                             bootDev.device.getDevice())
    if part and partedUtils.end_sector_to_cyl(part.geom.dev,
                                              part.geom.end) >= 1024:
        anaconda.id.bootloader.above1024 = 1
def doDeletePartitionsByDevice(intf, requestlist, diskset, device,
			       confirm=1, quiet=0):
    """ Remove all partitions currently on device """
    if confirm:
	rc = intf.messageWindow(_("Confirm Delete"),
				_("You are about to delete all partitions on "
				  "the device '/dev/%s'.") % (device,),
				type="custom", custom_icon="warning",
				custom_buttons=[_("Cancel"), _("_Delete")])

	if not rc:
	    return

    requests = requestlist.getRequestsByDevice(diskset, device)
    if not requests:
        return

    # get list of unique IDs of these requests
    reqIDs = []
    for req in requests:
	part = partedUtils.get_partition_by_name(diskset.disks, req.device)
	if part.type & parted.PARTITION_FREESPACE or part.type & parted.PARTITION_METADATA or part.type & parted.PARTITION_PROTECTED:
	    continue
	reqIDs.append(req.uniqueID)

    # now go thru and try to delete the unique IDs
    for id in reqIDs:
        try:
	    req = requestlist.getRequestByID(id)
	    if req is None:
		continue
            part = partedUtils.get_partition_by_name(diskset.disks, req.device)
            rc = doDeletePartitionByRequest(intf, requestlist, part,
                                            confirm=0, quiet=1)
            # not sure why it returns both '0' and '(None, None)' on failure
            if not rc or rc == (None, None):
		pass
        except:
	    pass

    # see which partitions are left
    notdeleted = []
    left_requests = requestlist.getRequestsByDevice(diskset, device)
    if left_requests:
	# get list of unique IDs of these requests
	leftIDs = []
	for req in left_requests:
	    part = partedUtils.get_partition_by_name(diskset.disks, req.device)
	    if part.type & parted.PARTITION_FREESPACE or part.type & parted.PARTITION_METADATA or part.type & parted.PARTITION_PROTECTED:
		continue
	    leftIDs.append(req.uniqueID)

	for id in leftIDs:
	    req = requestlist.getRequestByID(id)
	    notdeleted.append(req)
	    

    # see if we need to report any failures - some were because we removed
    # an extended partition which contained other members of our delete list
    outlist = ""
    for req in notdeleted:
        newreq = requestlist.getRequestByID(req.uniqueID)
        if newreq:
            outlist = outlist + "\t/dev/%s\n" % (newreq.device,)

    if outlist != "" and not quiet:
        intf.messageWindow(_("Notice"),
                           _("The following partitions were not deleted "
                             "because they are in use:\n\n%s") % outlist,
			   custom_icon="warning")

    return 1