Package pyanaconda :: Package storage :: Module partitioning
[hide private]
[frames] | no frames]

Module partitioning

source code

Classes [hide private]
  Request
A partition request.
  PartitionRequest
  LVRequest
  Chunk
A free region from which devices will be allocated
  DiskChunk
A free region on disk from which partitions will be allocated
  VGChunk
A free region in an LVM VG from which LVs will be allocated
Functions [hide private]
 
_getCandidateDisks(storage)
Return a list of disks with space for a default-sized partition.
source code
 
_scheduleImplicitPartitions(storage, disks)
Schedule creation of a lvm/btrfs partition on each disk in disks.
source code
 
_schedulePartitions(storage, disks)
Schedule creation of autopart partitions.
source code
 
_scheduleVolumes(storage, devs)
Schedule creation of autopart lvm/btrfs volumes.
source code
 
scheduleShrinkActions(storage)
Schedule actions to shrink partitions as per autopart selection.
source code
 
doAutoPartition(anaconda) source code
 
shouldClear(device, clearPartType, clearPartDisks=None) source code
 
clearPartitions(storage, bootloader=None)
Clear partitions and dependent devices from disks.
source code
 
removeEmptyExtendedPartitions(storage) source code
 
partitionCompare(part1, part2)
More specifically defined partitions come first.
source code
 
getNextPartitionType(disk, no_primary=None)
Find the type of partition to create next on a disk.
source code
 
getBestFreeSpaceRegion(disk, part_type, req_size, boot=None, best_free=None, grow=None)
Return the "best" free region on the specified disk.
source code
 
sectorsToSize(sectors, sectorSize)
Convert length in sectors to size in MB.
source code
 
sizeToSectors(size, sectorSize)
Convert size in MB to length in sectors.
source code
 
removeNewPartitions(disks, partitions)
Remove newly added input partitions from input disks.
source code
 
addPartition(disklabel, free, part_type, size)
Return new partition after adding it to the specified disk.
source code
 
getFreeRegions(disks)
Return a list of free regions on the specified disks.
source code
 
updateExtendedPartitions(storage, disks) source code
 
doPartitioning(storage, bootloader=None)
Allocate and grow partitions.
source code
 
allocatePartitions(storage, disks, partitions, freespace, bootloader=None)
Allocate partitions based on requested features.
source code
 
getDiskChunks(disk, partitions, free)
Return a list of Chunk instances representing a disk.
source code
 
growPartitions(disks, partitions, free)
Grow all growable partition requests.
source code
 
lvCompare(lv1, lv2)
More specifically defined lvs come first.
source code
 
growLVM(storage)
Grow LVs according to the sizes of the PVs.
source code
Variables [hide private]
  _ = lambda x:
  log = logging.getLogger("storage")
Function Details [hide private]

clearPartitions(storage, bootloader=None)

source code 
Clear partitions and dependent devices from disks.

Arguments:

    storage -- a storage.Storage instance

Keyword arguments:

    bootloader -- a BootLoader instance

NOTES:

    - Needs some error handling, especially for the parted bits.

partitionCompare(part1, part2)

source code 
More specifically defined partitions come first.

< 1 => x < y
  0 => x == y
> 1 => x > y

getNextPartitionType(disk, no_primary=None)

source code 
Find the type of partition to create next on a disk.

Return a parted partition type value representing the type of the
next partition we will create on this disk.

If there is only one free primary partition and we can create an
extended partition, we do that.

If there are free primary slots and an extended partition we will
recommend creating a primary partition. This can be overridden
with the keyword argument no_primary.

Arguments:

    disk -- a parted.Disk instance representing the disk

Keyword arguments:

    no_primary -- given a choice between primary and logical
                  partitions, prefer logical

getBestFreeSpaceRegion(disk, part_type, req_size, boot=None, best_free=None, grow=None)

source code 
Return the "best" free region on the specified disk.

For non-boot partitions, we return the largest free region on the
disk. For boot partitions, we return the first region that is
large enough to hold the partition.

Partition type (parted's PARTITION_NORMAL, PARTITION_LOGICAL) is
taken into account when locating a suitable free region.

For locating the best region from among several disks, the keyword
argument best_free allows the specification of a current "best"
free region with which to compare the best from this disk. The
overall best region is returned.

Arguments:

    disk -- the disk (a parted.Disk instance)
    part_type -- the type of partition we want to allocate
                 (one of parted's partition type constants)
    req_size -- the requested size of the partition (in MB)

Keyword arguments:

    boot -- indicates whether this will be a bootable partition
            (boolean)
    best_free -- current best free region for this partition
    grow -- indicates whether this is a growable request

sectorsToSize(sectors, sectorSize)

source code 
Convert length in sectors to size in MB.

Arguments:

    sectors     -   sector count
    sectorSize  -   sector size for the device, in bytes

sizeToSectors(size, sectorSize)

source code 
Convert size in MB to length in sectors.

Arguments:

    size        -   size in MB
    sectorSize  -   sector size for the device, in bytes

removeNewPartitions(disks, partitions)

source code 
Remove newly added input partitions from input disks.

Arguments:

    disks -- list of StorageDevice instances with DiskLabel format
    partitions -- list of PartitionDevice instances

addPartition(disklabel, free, part_type, size)

source code 
Return new partition after adding it to the specified disk.

Arguments:

    disklabel -- disklabel instance to add partition to
    free -- where to add the partition (parted.Geometry instance)
    part_type -- partition type (parted.PARTITION_* constant)
    size -- size (in MB) of the new partition

The new partition will be aligned.

Return value is a parted.Partition instance.

getFreeRegions(disks)

source code 
Return a list of free regions on the specified disks.

Arguments:

    disks -- list of parted.Disk instances

Return value is a list of unaligned parted.Geometry instances.

doPartitioning(storage, bootloader=None)

source code 
Allocate and grow partitions.

When this function returns without error, all PartitionDevice
instances must have their parents set to the disk they are
allocated on, and their partedPartition attribute set to the
appropriate parted.Partition instance from their containing
disk. All req_xxxx attributes must be unchanged.

Arguments:

    storage - Main anaconda Storage instance

Keyword/Optional Arguments:

    bootloader - BootLoader instance

allocatePartitions(storage, disks, partitions, freespace, bootloader=None)

source code 

Allocate partitions based on requested features.

Non-existing partitions are sorted according to their requested attributes, and then allocated.

The basic approach to sorting is that the more specifically- defined a request is, the earlier it will be allocated. See the function partitionCompare for details on the sorting criteria.

The PartitionDevice instances will have their name and parents attributes set once they have been allocated.

getDiskChunks(disk, partitions, free)

source code 
Return a list of Chunk instances representing a disk.

Arguments:

    disk -- a StorageDevice with a DiskLabel format
    partitions -- list of PartitionDevice instances
    free -- list of parted.Geometry instances representing free space

Partitions and free regions not on the specified disk are ignored.

growPartitions(disks, partitions, free)

source code 
Grow all growable partition requests.

Partitions have already been allocated from chunks of free space on
the disks. This function does not modify the ordering of partitions
or the free chunks from which they are allocated.

Free space within a given chunk is allocated to each growable
partition allocated from that chunk in an amount corresponding to
the ratio of that partition's base size to the sum of the base sizes
of all growable partitions allocated from the chunk.

Arguments:

    disks -- a list of all usable disks (DiskDevice instances)
    partitions -- a list of all partitions (PartitionDevice instances)
    free -- a list of all free regions (parted.Geometry instances)

lvCompare(lv1, lv2)

source code 
More specifically defined lvs come first.

< 1 => x < y
  0 => x == y
> 1 => x > y