blivet.devicelibs package

Submodules

blivet.devicelibs.btrfs module

blivet.devicelibs.btrfs.get_mountpoint_subvolumes(mountpoint)

Get list of subvolume names on given mounted btrfs filesystem

blivet.devicelibs.btrfs.is_btrfs_name_valid(name)

blivet.devicelibs.crypto module

blivet.devicelibs.crypto.calculate_integrity_metadata_size(device_size, algorithm='crc32c')
blivet.devicelibs.crypto.calculate_luks2_max_memory()

Calculates maximum RAM that will be used during LUKS format. The calculation is based on currently available (free) memory. This value will be used for the ‘max_memory_kb’ option for the ‘argon2’ key derivation function.

blivet.devicelibs.crypto.get_optimal_luks_sector_size(device)
blivet.devicelibs.crypto.is_fips_enabled()

blivet.devicelibs.disk module

blivet.devicelibs.disk.LSMInfo
class blivet.devicelibs.disk.LSMInfo
system (str): descriptive name of HBA unit
nodes (list[str]): list of device node paths for the volume
raid_type (:class:`~.devicelibs.raid.RAIDLevel` or None): RAID level
raid_stripe_size (:class:`~.size.Size` or None): stripe size
raid_disk_count (int or None): number of disks in the RAID set
blivet.devicelibs.disk.update_volume_info()

Build a dict of namedtuples containing basic HBA RAID info w/ device path keys.

blivet.devicelibs.edd module

class blivet.devicelibs.edd.EddEntry(sysfspath, root=None)

Bases: object

This object merely collects what the /sys/firmware/edd/* entries can provide.

ata_device

The device number from edd/int13_devXX/interface when self.type is ATA or SATA (because Linux treats these the same.)

ata_pmp

The ATA port multiplier ID from edd/int13_devXX/interface when self.type is SATA.

atapi_device

The device number of the ATAPI device from edd/int13_devXX/interface when self.type is ATAPI.

atapi_lun

The LUN of the ATAPI device from edd/int13_devXX/interface when self.type is ATAPI.

bios_device_number

The device number from the EDD path

channel

The host bus device’s channel number edd/int13_devXX/host_bus. The spec says:

Channel number. If more than one interface of the same type is accessed through a single Bus, Slot, Function, then the channel number shall identify each interface. If there is only one interface, the content of this field shall be cleared to zero. If there are two interfaces, such as an ATA Primary and Secondary interface, the primary interface shall be zero, and the secondary interface shall be one.

Values 00h through FEh shall represent a valid Channel Number.

Value FFh shall indicate that this field is not used.

If the device is connected to a SATA controller functioning in non-PATA emulation mode, this byte shall be FFh.

fibre_lun

The FibreChannel LUN from edd/int13_devXX/interface when self.type is FIBRE.

fibre_wwid

The FibreChannel WWID from edd/int13_devXX/interface when self.type is FIBRE.

host_bus

The ID string for the host bus type, from edd/int13_devXX/host_bus.

i2o_identity

The I2O Identity from edd/int13_devXX/interface when self.type is I2O.

ieee1394_eui64

The Firewire/IEEE-1394 EUI-64 ID from edd/int13_devXX/interface when self.type is 1394.

interface

interface is the actual contents of the interface file, preserved for logging later.

load()
mbr_sig

The MBR signature data from edd/int13_devXX/mbr_signature

pci_dev

The host bus bus:device.function, from edd/int13_devXX/host_bus.

sas_address

The SAS Address from edd/int13_devXX/interface when self.type is SAS.

sas_lun

The SAS LUN from edd/int13_devXX/interface when self.type is SAS.

scsi_id

The SCSI device ID from edd/int13_devXX/interface when self.type is SCSI

scsi_lun

The SCSI device LUN from edd/int13_devXX/interface when self.type is SCSI

sectors

The number of sectors on the device from edd/int13_devXX/sectors

The path /sys/block/BLAH is a symlink link to once we’ve resolved that this is a particular device. Used for logging later.

sysfspath

sysfspath is the path we’re probing

type

The device type from edd/int13_devXX/interface.

usb_serial

The USB storage device’s serial number from edd/int13_devXX/interface when self.type is USB.

version

The edd version this entry claims conformance with, from /sys/firmware/edd/int13_devXX/version

class blivet.devicelibs.edd.EddMatcher(edd_entry, root=None)

Bases: object

This object tries to match given entry to a disk device name.

Assuming, heuristic analysis and guessing happens here.

devname_from_ata_pci_dev()
devname_from_pci_dev()
devname_from_scsi_pci_dev()
devname_from_virt_pci_dev()
devname_from_virtio_scsi_pci_dev()
match_via_mbrsigs(mbr_dict)

Try to match the edd entry based on its mbr signature.

This will obviously fail for a fresh drive/image, but in extreme cases can also show false positives for randomly matching data.

blivet.devicelibs.edd.collect_edd_data(root=None)
blivet.devicelibs.edd.collect_mbrs(devices, root=None)

Read MBR signatures from devices.

Returns a dict mapping device names to their MBR signatures. It is not guaranteed this will succeed, with a new disk for instance.

blivet.devicelibs.edd.get_edd_dict(devices, root=None)

Generates the ‘device name’ -> ‘edd number’ mapping.

The EDD kernel module that exposes /sys/firmware/edd is thoroughly broken, the information there is incomplete and sometimes downright wrong. So after we mine out all useful information that the files under /sys/firmware/edd/int13_*/ can provide, we resort to heuristics and guessing. Our first attempt is, by looking at the device type int ‘interface’, attempting to map pci device number, channel number etc. to a sysfs path, check that the path really exists, then read the device name (e.g ‘sda’) from there. Should this fail we try to match contents of ‘mbr_signature’ to a real MBR signature found on the existing block devices.

blivet.devicelibs.gpt module

blivet.devicelibs.gpt.gpt_part_uuid_for_mountpoint(path, arch=None)
Parameters:
  • path (str) – the absolute path at which a filesystem is to be mounted

  • arch – the architecture of the target install, None to use host arch

Returns:

the GPT partition type UUID or None

Return type:

str

Given an absolute path at which a filesystem is to be mounted, determine if there is a well known GPT partition type UUID associated to allow the partition to be automatically mounted.

The architecture must be canonicalized in accordance with the blivet.arch logic. Usually it can be omitted, to request use of the host architecture detected by blivet.arch.get_arch.

blivet.devicelibs.gpt.gpt_part_uuid_for_volume(voltype, arch=None)
Parameters:
  • path (str) – the volume type as a GPT_VOL constant

  • arch – the architecture of the target install, None to use host arch

Returns:

the GPT partition type UUID or None

Return type:

str

Given a volume type defined by one of the GPT_VOL constants, determine if there is a well known GPT partition type UUID associated to allow the partition to be automatically mounted.

The architecture must be canonicalized in accordance with the blivet.arch logic. Usually it can be omitted, to request use of the host architecture detected by blivet.arch.get_arch.

blivet.devicelibs.lvm module

class blivet.devicelibs.lvm.ThPoolProfile(name, desc)

Bases: tuple

Create new instance of ThPoolProfile(name, desc)

desc

Alias for field number 1

name

Alias for field number 0

blivet.devicelibs.lvm.determine_parent_lv(internal_lv, lvs, lv_info)

Try to determine which of the lvs is the parent of the internal_lv

Parameters:
  • internal_lv (LMVInternalLogicalVolumeDevice) – the internal LV to determine parent LV from

  • lvs (LMVLogicalVolumeDevice) – LVs searched for a potential parent LV

  • lv_info (dict) – all available information about LVs

blivet.devicelibs.lvm.empty_lvm_devices()
blivet.devicelibs.lvm.ensure_lv_is_writable(vg_name, lv_name)
blivet.devicelibs.lvm.is_lvm_name_valid(name)
blivet.devicelibs.lvm.is_valid_cache_md_size(md_size)
blivet.devicelibs.lvm.lvm_devices_add(*args, **kwargs)
blivet.devicelibs.lvm.lvm_devices_copy()
blivet.devicelibs.lvm.lvm_devices_remove(*args, **kwargs)
blivet.devicelibs.lvm.lvm_devices_reset(*args, **kwargs)
blivet.devicelibs.lvm.lvm_devices_restore(*args, **kwargs)
blivet.devicelibs.lvm.lvmetad_socket_exists()
blivet.devicelibs.lvm.needs_config_refresh(fn)
blivet.devicelibs.lvm.recommend_thpool_chunk_size(thpool_size)

blivet.devicelibs.mdraid module

class blivet.devicelibs.mdraid.MDRaidLevels(levels=None)

Bases: RAIDLevels

Add the specified standard levels to the levels in this object.

Parameters:

levels (list of valid RAID level descriptors) – the levels to be added to this object

If levels is True, add all standard levels. Else, levels must be a list of valid level descriptors of standard levels. Duplicate descriptors are ignored.

classmethod is_raid_level(level)

Return False if level does not satisfy minimum requirements for a RAID level, otherwise return True.

Parameters:

level (object) – an object representing a RAID level

There must be at least one element in the names list, or the level will be impossible to look up by any string.

The name property must be defined; it should be one of the elements in the names list.

All RAID objects that extend RAIDlevel are guaranteed to pass these minimum requirements.

This method should not be overridden in any subclass so that it is so restrictive that a RAIDlevel object does not satisfy it.

blivet.devicelibs.raid module

class blivet.devicelibs.raid.ErsatzRAID

Bases: RAIDLevel

A superclass for a raid level which is not really a raid level at all, just a bunch of block devices of possibly differing sizes thrown together. This concept has different names depending on where it crops up. btrfs’s name is single, lvm’s is linear. Consequently, this abstract class implements all the functionality, but there are distinct subclasses which have different names.

get_max_spares(member_count)
get_size(member_sizes, num_members=None, chunk_size=None, superblock_size_func=None)
get_space(size, num_members, chunk_size=None, superblock_size_func=None)
has_redundancy()

Whether this RAID level incorporates inherent redundancy.

Note that for some RAID levels, the notion of redundancy is meaningless.

Return type:

boolean

Returns:

True if this RAID level has inherent redundancy

property is_uniform

Whether data is uniformly distributed across all devices.

min_members = 1
property nick
class blivet.devicelibs.raid.RAIDLevel

Bases: object

An abstract class which is the parent of all classes which represent a RAID level.

It ensures that RAIDLevel objects will really be singleton objects by overriding copy methods.

abstract has_redundancy()

Whether this RAID level incorporates inherent redundancy.

Note that for some RAID levels, the notion of redundancy is meaningless.

Return type:

boolean

Returns:

True if this RAID level has inherent redundancy

abstract property is_uniform

Whether data is uniformly distributed across all devices.

abstract property min_members

The minimum number of members required to make a fully functioning array.

abstract property name

The canonical name for this level

abstract property names

List of recognized names for this level.

class blivet.devicelibs.raid.RAIDLevels(levels=None)

Bases: object

A class which keeps track of registered RAID levels. This class may be extended, overriding the is_raid method to include any additional properties that a client of this package may require for its RAID levels.

Add the specified standard levels to the levels in this object.

Parameters:

levels (list of valid RAID level descriptors) – the levels to be added to this object

If levels is True, add all standard levels. Else, levels must be a list of valid level descriptors of standard levels. Duplicate descriptors are ignored.

add_raid_level(level)

Adds level to levels if it is not already there.

Parameters:

level (object) – an object representing a RAID level

Raises a RaidError if level is not valid.

Does not allow duplicate level objects.

classmethod is_raid_level(level)

Return False if level does not satisfy minimum requirements for a RAID level, otherwise return True.

Parameters:

level (object) – an object representing a RAID level

There must be at least one element in the names list, or the level will be impossible to look up by any string.

The name property must be defined; it should be one of the elements in the names list.

All RAID objects that extend RAIDlevel are guaranteed to pass these minimum requirements.

This method should not be overridden in any subclass so that it is so restrictive that a RAIDlevel object does not satisfy it.

raid_level(descriptor)

Return RAID object corresponding to descriptor.

Parameters:

descriptor (object) – a RAID level descriptor

Note that descriptor may be any object that identifies a RAID level, including the RAID object itself.

Raises a RaidError if no RAID object can be found for this descriptor.

class blivet.devicelibs.raid.RAIDn

Bases: RAIDLevel

An abstract class which is the parent of classes which represent a numeric RAID level. A better word would be classification, since ‘level’ implies an ordering, but level is the canonical word.

The abstract properties of the class are:

  • level: A string containing the number that designates this level

  • nick: A single nickname for this level, may be None

All methods in this class fall into these categories:

  1. May not be overridden in any subclass.

  2. Are private abstract methods.

  3. Are special Python methods, e.g., __str__

Note that each subclass in this file is instantiated immediately after it is defined and using the same name, effectively yielding a singleton object of the class.

property alt_synth_names

names that can be synthesized from level but are not name

get_base_member_size(size, member_count)

The required size for each member of the array for storing only data.

Parameters:
  • size (Size) – size of data to be stored

  • member_count (int) – number of members in this array

Return type:

Size

Raises a RaidError if member_count is fewer than the minimum number of members required for this array or if size is less than 0.

get_max_spares(member_count)

The maximum number of spares for this level.

Parameters:

member_count (int) – the number of members belonging to the array

Return type:

int

Raises a RaidError if member_count is fewer than the minimum number of members required for this level.

get_net_array_size(member_count, smallest_member_size)

Return the space, essentially the number of bits available for storage. This value is generally a function of the smallest member size. If the smallest member size represents the amount of data that can be stored on the smallest member, then the result will represent the amount of data that can be stored on the array. If the smallest member size represents both data and metadata, then the result will represent the available space in the array for both data and metadata.

Parameters:
  • member_count (int) – the number of members in the array

  • smallest_member_size (Size) – the size of the smallest member of this array

Returns:

the array size

Return type:

Size

Raises a RaidError if member_count is fewer than the minimum number of members required for this array or if size is less than 0.

Return a recommended stride size in blocks.

Returns None if there is no recommended size.

Parameters:

member_count (int) – the number of members in the array

Return type:

int or None

Raises a RaidError if member_count is fewer than the minimum number of members required for this level

get_size(member_sizes, num_members=None, chunk_size=None, superblock_size_func=None)

Estimate the amount of data that can be stored on this array.

Parameters:
  • member_size (list of Size) – a list of the sizes of members of this array

  • num_members (int) – the number of members in the array

  • chunk_size (Size) – the smallest unit of size read or written

  • superblock_size_func (a function from Size to Size) – a function that estimates the superblock size for this array

Returns:

an estimate of the amount of data that can be stored on this array

Return type:

Size

Note that the number of members in the array may not be the same as the length of member_sizes if the array is still under construction.

get_space(size, num_members, chunk_size=None, superblock_size_func=None)

Estimate the amount of memory required by this array, including memory allocated for metadata.

Parameters:
  • size (Size) – the amount of data on this array

  • num_members (int) – the number of members in the array

  • chunk_size (Size) – the smallest unit of size read or written

  • superblock_size_func (a function from Size to Size) – a function that estimates the superblock size for this array

Returns:

an estimate of the memory required, including metadata

Return type:

Size

property is_uniform

Whether data is uniformly distributed across all devices.

abstract property level

A code representing the level

property name

The canonical name for this level

property names

all valid names for this level

abstract property nick

A nickname for this level

property number

A numeric code for this level

blivet.devicelibs.raid.div_up(a, b)

Rounds up integer division. For example, div_up(3, 2) is 2.

Parameters:
  • a (int) – the dividend

  • b (int) – the divisor

blivet.devicelibs.raid.get_raid_level(descriptor)

Convenience function to return a RAID level for the descriptor.

Parameters:

descriptor (object) – a RAID level descriptor

Return type:

RAIDLevel

Returns:

The RAIDLevel object for this descriptor

Note that descriptor may be any object that identifies a RAID level, including the RAID object itself.

Raises a RaidError is there is no RAID object for the descriptor.

blivet.devicelibs.stratis module

blivet.devicelibs.stratis.add_device(pool_uuid, device)
blivet.devicelibs.stratis.create_filesystem(name, pool_uuid, fs_size=None)
blivet.devicelibs.stratis.create_pool(name, devices, encrypted, passphrase, key_file, clevis)
blivet.devicelibs.stratis.filesystem_md_size(fs_size)
blivet.devicelibs.stratis.pool_used(dev_sizes, encrypted=False)
blivet.devicelibs.stratis.remove_filesystem(pool_uuid, fs_uuid)
blivet.devicelibs.stratis.remove_pool(pool_uuid)
blivet.devicelibs.stratis.set_key(key_desc, passphrase, key_file)
blivet.devicelibs.stratis.unlock_pool(pool_uuid, method)

Module contents