blivet.devices package

Submodules

blivet.devices.btrfs module

class blivet.devices.btrfs.BTRFSDevice(*args, **kwargs)

Bases: StorageDevice

Base class for BTRFS volume and sub-volume devices.

Passing None or no name means auto-generate one like btrfs.%d

property current_size

Return an attribute of instance, which is of type owner.

property direct

Is this device directly accessible?

property fstab_spec

Return an attribute of instance, which is of type owner.

is_name_valid(name)

Is the device name valid for the device type?

property path

Return an attribute of instance, which is of type owner.

property status

Return an attribute of instance, which is of type owner.

update_size(newsize=None)

Update size, current_size, and target_size to actual size.

:keyword Size newsize: new size for device

Note

Most callers will not pass a new size. It is for special cases like outside resize of inactive LVs, which precludes updating the size from /sys.

update_sysfs_path()

Update this device’s sysfs path.

class blivet.devices.btrfs.BTRFSSnapShotDevice(*args, **kwargs)

Bases: BTRFSSubVolumeDevice

A btrfs snapshot pseudo-device.

BTRFS snapshots are a specialized type of subvolume that contains a source attribute which identifies which subvolume the snapshot was taken from. They do not have to be removed when removing the source subvolume.

Parameters:
  • name (str) – the subvolume name

  • exists (bool) – does this device exist?

:keyword Size size: the device’s size :keyword ParentList parents: a list of parent devices :keyword fmt: this device’s formatting :type fmt: DeviceFormat :keyword str sysfs_path: sysfs device path :keyword BTRFSDevice source: the snapshot source :keyword bool read_only: create a read-only snapshot

Snapshot source can be either a subvolume or a top-level volume.

depends_on(dep)

Return True if this device depends on dep.

This device depends on another device if the other device is an ancestor of this device. For example, a PartitionDevice depends on the DiskDevice on which it resides.

Parameters:

dep (Device) – the other device

Returns:

whether this device depends on ‘dep’

Return type:

bool

source

the snapshot’s source subvolume

class blivet.devices.btrfs.BTRFSSubVolumeDevice(*args, **kwargs)

Bases: BTRFSDevice

A btrfs subvolume pseudo-device.

Parameters:
  • name (str) – the subvolume name

  • exists (bool) – does this device exist?

:keyword Size size: the device’s size :keyword ParentList parents: a list of parent devices :keyword fmt: this device’s formatting :type fmt: DeviceFormat :keyword str sysfs_path: sysfs device path

add_hook(new=True)

Perform actions related to adding a device to the devicetree.

Parameters:

new (bool) – whether this device is new to the devicetree

The only intended use case for new=False is when unhiding a device from the devicetree. Additional operations are performed when new is False that are normally performed as part of the device constructor.

property container

Return an attribute of instance, which is of type owner.

property device_id

Return an attribute of instance, which is of type owner.

populate_ksdata(data)
remove_hook(modparent=True)

Perform actions related to removing a device from the devicetree.

Parameters:

modparent (bool) – whether to account for removal in parents

Parents’ list of child devices is updated regardless of modparent. The intended use of modparent is to prevent doing things like removing a parted.Partition from the disk that contains it as part of msdos extended partition management. In general, you should not override the default value of modparent in new code.

setup_parents(orig=False)

Run setup method of all parent devices.

property volume

Return the first ancestor that is not a BTRFSSubVolumeDevice.

Note: Assumes that each ancestor in traversal has only one parent.

Raises a DeviceError if the ancestor found is not a BTRFSVolumeDevice.

class blivet.devices.btrfs.BTRFSVolumeDevice(*args, **kwargs)

Bases: BTRFSDevice, ContainerDevice, RaidDevice

Parameters:
  • name (str) – the volume name

  • exists (bool) – does this device exist?

:keyword Size size: the device’s size :keyword ParentList parents: a list of parent devices :keyword fmt: this device’s formatting :type fmt: DeviceFormat :keyword str uuid: UUID of top-level filesystem/volume :keyword str sysfs_path: sysfs device path :keyword data_level: RAID level for data :type data_level: any valid raid level descriptor :keyword metadata_level: RAID level for metadata :type metadata_level: any valid raid level descriptor

property data_level

Return the RAID level for data.

Returns:

raid level

Return type:

an object that represents a raid level

property default_subvolume

Return an attribute of instance, which is of type owner.

property device_id

Return an attribute of instance, which is of type owner.

property format_immutable

Return an attribute of instance, which is of type owner.

list_subvolumes(snapshots_only=False)
property members

Return an attribute of instance, which is of type owner.

property metadata_level

Return the RAID level for metadata.

Returns:

raid level

Return type:

an object that represents a raid level

populate_ksdata(data)
remove_subvolume(name)
vol_id = 5

blivet.devices.cache module

Module providing common helper classes, functions and other things related to cached devices (like bcache, LVM cache and whatever appears in the future).

class blivet.devices.cache.Cache

Bases: object

Abstract base class for cache objects providing the cache-related functionality on cached devices. Instances of this class are not expected to be devices (both in what they represent as well as not instances of the Device class) since they just provide the cache-related functionality of cached devices and are not devices on their own.

abstract property backing_device_name

Name of the backing (big/slow) device of the cache (if any)

abstract property cache_device_name

Name of the cache (small/fast) device of the cache (if any)

abstract detach()

Detach the cache :returns: identifier of the detached cache that can be later used for attaching it back

abstract property exists

Whether the cache (device) exists or not

abstract property size

Size of the cache

abstract property stats

Statistics for the cache :rtype: CacheStats

class blivet.devices.cache.CacheRequest

Bases: object

Abstract base class for cache requests specifying cache parameters for a cached device

abstract property fast_devs

Devices (type-specific) to allocate/create the cache on

abstract property mode

Mode the cache should use

abstract property size

Requested size

class blivet.devices.cache.CacheStats

Bases: object

Abstract base class for common statistics of caches (cached devices). Inheriting classes are expected to add (cache-)type-specific attributes on top of the common set.

abstract property block_size

block size of the cache

abstract property hits

number of hits

abstract property misses

number of misses

abstract property size

size of the cache

abstract property used

how much of the cache is used

blivet.devices.container module

class blivet.devices.container.ContainerDevice(*args, **kwargs)

Bases: StorageDevice

A device that aggregates a set of member devices.

The only interfaces provided by this class are for addition and removal of member devices – one set for modifying the member set of the python objects, and one for writing the changes to disk.

The member set of the instance can be manipulated using the methods append() and remove() of the instance’s parents attribute.

add() and remove() remove a member from the container’s on- disk representation. These methods should normally only be called from within deviceaction.ActionAddMember.execute() and deviceaction.ActionRemoveMember.execute().

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • uuid (str) – universally unique identifier (device – not fs)

  • sysfs_path (str) – sysfs device path

  • major (int) – the device major

  • minor (int) – the device minor

  • serial (str) – the ID_SERIAL_SHORT for this device

  • vendor (str) – the manufacturer of this Device

  • model (str) – manufacturer’s device model string

  • bus (str) – the interconnect this device uses

add(member)

Add a member to the container.

Parameters:

member (StorageDevice) – the member device to add

This method writes the member addition to disk.

remove(member)

Remove a member from the container.

Parameters:

member (StorageDevice) – the member device to remove

This method writes the member removal to disk.

update_size(newsize=None)

Update size, current_size, and target_size to actual size.

:keyword Size newsize: new size for device

Note

Most callers will not pass a new size. It is for special cases like outside resize of inactive LVs, which precludes updating the size from /sys.

blivet.devices.device module

class blivet.devices.device.Device(*args, **kwargs)

Bases: ObjectID

A generic device.

Device instances know which devices they depend upon (parents attribute). They do not know which devices depend upon them, but they do know whether or not they have any dependent devices (isleaf attribute).

A Device’s setup method should set up all parent devices as well as the device itself. It should not run the resident format’s setup method.

Which Device types rely on their parents’ formats being active?

DMCryptDevice

A Device’s teardown method should accept the keyword argument recursive, which takes a boolean value and indicates whether or not to recursively close parent devices.

A Device’s create method should create all parent devices as well as the device itself. It should also run the Device’s setup method after creating the device. The create method should not create a device’s resident format.

Which device type rely on their parents’ formats to be created before they can be created/assembled?

VolumeGroup DMCryptDevice

A Device’s destroy method should destroy any resident format before destroying the device itself.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • parents (list of Device instances) – a list of parent devices

add_child(child)

Increment the child counter for this device.

property ancestors

A list of all of this device’s ancestors, including itself.

property children

List of this device’s immediate descendants.

create()

Create the device.

depends_on(dep)

Return True if this device depends on dep.

This device depends on another device if the other device is an ancestor of this device. For example, a PartitionDevice depends on the DiskDevice on which it resides.

Parameters:

dep (Device) – the other device

Returns:

whether this device depends on ‘dep’

Return type:

bool

destroy()

Destroy the device.

property device_id

Unique ID for this device.

Note: This is an internal identifier in Blivet which is designed to be unique

even for devices with the same name or label. This ID is persistent between blivet.reset() calls for existing devices.

property dict

Return an attribute of instance, which is of type owner.

dracut_setup_args()
property external_dependencies

A list of external dependencies of this device and its parents.

Returns:

the external dependencies of this device and all parents.

Return type:

set of availability.ExternalResource

is_name_valid(name)

Is the device name valid for the device type?

property isleaf

True if no other device depends on this one.

property name

This device’s name

property packages

List of packages required to manage this device and all its ancestor devices. Does not contain duplicates.

Returns:

names of packages required by device and all ancestors

Return type:

list of str

property parents

Devices upon which this device is built

remove_child(child)

Decrement the child counter for this device.

setup(orig=False)

Open, or set up, a device.

setup_parents(orig=False)

Run setup method of all parent devices.

Parameters:

orig (bool) – set up original format instead of current format

property status

Is this device currently active and ready for use?

property tags

set of (str) tags describing this device.

teardown(recursive=None)

Close, or tear down, a device.

teardown_parents(recursive=None)

Run teardown method of all parent devices.

Parameters:

recursive (bool) – tear down all ancestor devices recursively

property type

Device type.

property type_description

String describing the device type.

classmethod type_external_dependencies()

A list of external dependencies of this device type.

Returns:

a set of external dependencies

Return type:

set of availability.ExternalResource

The external dependencies include the dependencies of this device type and of all superclass device types.

property unavailable_dependencies

Any unavailable external dependencies of this device or its parents.

Returns:

A list of unavailable external dependencies.

Return type:

set of availability.external_resource

property unavailable_direct_dependencies

Any unavailable external dependencies of this device.

Returns:

A list of unavailable external dependencies.

Return type:

set of availability.external_resource

classmethod unavailable_type_dependencies()

A set of unavailable dependencies for this type.

Returns:

the unavailable external dependencies for this type

Return type:

set of availability.ExternalResource

blivet.devices.disk module

class blivet.devices.disk.DASDDevice(*args, **kwargs)

Bases: DiskDevice

A mainframe DASD.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • format (DeviceFormat or a subclass of it) – this device’s formatting

  • wwn (str) – the disk’s WWN

  • busid – bus ID

  • opts (dict with option name keys and option value values) – options

property description

Return an attribute of instance, which is of type owner.

dracut_setup_args()
get_opts()
class blivet.devices.disk.DiskDevice(*args, **kwargs)

Bases: StorageDevice

A local/generic disk.

This is not the only kind of device that is treated as a disk. More useful than checking isinstance(device, DiskDevice) is checking device.is_disk.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • uuid (str) – universally unique identifier (device – not fs)

  • sysfs_path (str) – sysfs device path

  • removable (bool) – whether or not this is a removable device

  • serial (str) – the ID_SERIAL_RAW, ID_SERIAL or ID_SERIAL_SHORT for this device (which one is available)

  • vendor (str) – the manufacturer of this Device

  • model (str) – manufacturer’s device model string

  • bus (str) – the interconnect this device uses

  • wwn (str) – the disk’s WWN

DiskDevices always exist.

property description

Return an attribute of instance, which is of type owner.

property media_present

Return an attribute of instance, which is of type owner.

property raid_disk_count

Return an attribute of instance, which is of type owner.

property raid_level

Return an attribute of instance, which is of type owner.

property raid_stripe_size

Return an attribute of instance, which is of type owner.

property raid_system

Return an attribute of instance, which is of type owner.

class blivet.devices.disk.DiskFile(*args, **kwargs)

Bases: DiskDevice

This is a file that we will pretend is a disk.

This is intended only for testing purposes. The benefit of this class is that you can instantiate a disk-like device with a working disklabel class as a non-root user. It is not known how the system will behave if partitions are committed to one of these disks.

Parameters:

name (str) – the full path to the backing regular file

:keyword DeviceFormat fmt: the device’s format

read_current_size()
property sysfs_path

Return an attribute of instance, which is of type owner.

update_sysfs_path()

Update this device’s sysfs path.

class blivet.devices.disk.FcoeDiskDevice(*args, **kwargs)

Bases: DiskDevice, NetworkStorageDevice

An FCoE disk.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • format (DeviceFormat or a subclass of it) – this device’s formatting

  • wwn (str) – the disk’s WWN

  • nic – name of NIC to use

  • identifier

    ???

dracut_setup_args()
class blivet.devices.disk.MultipathDevice(*args, **kwargs)

Bases: DMDevice

A multipath device

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • sysfs_path (str) – sysfs device path

  • wwn (str) – the device’s WWN

MultipathDevices always exist. Blivet cannot create or destroy them.

add_parent(parent)

Add a parent device to the mpath.

property description

Return an attribute of instance, which is of type owner.

property model

Return an attribute of instance, which is of type owner.

property vendor

Return an attribute of instance, which is of type owner.

class blivet.devices.disk.NVMeController(name, serial, nvme_ver, id, subsysnqn, transport, transport_address)

Bases: tuple

Create new instance of NVMeController(name, serial, nvme_ver, id, subsysnqn, transport, transport_address)

id

Alias for field number 3

name

Alias for field number 0

nvme_ver

Alias for field number 2

serial

Alias for field number 1

subsysnqn

Alias for field number 4

transport

Alias for field number 5

transport_address

Alias for field number 6

class blivet.devices.disk.NVMeFabricsNamespaceDevice(*args, **kwargs)

Bases: NVMeNamespaceDevice, NetworkStorageDevice

NVMe fabrics namespace

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • format (DeviceFormat or a subclass of it) – this device’s formatting

class blivet.devices.disk.NVMeNamespaceDevice(*args, **kwargs)

Bases: DiskDevice

NVMe namespace

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • format (DeviceFormat or a subclass of it) – this device’s formatting

  • nsid (int) – namespace ID

property controllers

Return an attribute of instance, which is of type owner.

class blivet.devices.disk.ZFCPDiskDevice(*args, **kwargs)

Bases: DiskDevice

A mainframe ZFCP disk.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • format (DeviceFormat or a subclass of it) – this device’s formatting

  • wwn (str) – the disk’s WWN

  • hba_id

    ???

  • wwpn

    ???

  • fcp_lun

    ???

  • id_path – string from udev-builtin-path_id

property description

Return an attribute of instance, which is of type owner.

dracut_setup_args()
class blivet.devices.disk.iScsiDiskDevice(*args, **kwargs)

Bases: DiskDevice, NetworkStorageDevice

An iSCSI disk.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • format (DeviceFormat or a subclass of it) – this device’s formatting

  • wwn (str) – the disk’s WWN

  • target (str) – the name of the iscsi target

  • lun – lun of the target

  • iface (str) – name of network interface to use for operation

  • initiator (str) – initiator name

  • offload – a partial offload device (qla4xxx)

  • address – ip address of the target

  • port – port of the target

Type:

bool

Type:

str

Type:

str

dracut_setup_args()

blivet.devices.dm module

class blivet.devices.dm.DMCryptDevice(*args, **kwargs)

Bases: DMDevice

A dm-crypt device

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • sysfs_path (str) – sysfs device path

class blivet.devices.dm.DMDevice(*args, **kwargs)

Bases: StorageDevice

A device-mapper device

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • sysfs_path (str) – sysfs device path

  • dm_uuid (str) – device-mapper UUID (see note below)

  • target (str) – device mapper table/target name (eg: “linear”)

Note

The dm_uuid is not necessarily persistent, as it is based on map name in many cases. The uuid, however, is a persistent UUID stored in device metadata on disk.

property device_id

Return an attribute of instance, which is of type owner.

property dict

Return an attribute of instance, which is of type owner.

get_dm_node()

Return the dm-X (eg: dm-0) device node for this device.

property map_name

This device’s device-mapper map name

setup_partitions()
property status

Return an attribute of instance, which is of type owner.

teardown_partitions()
class blivet.devices.dm.DMIntegrityDevice(*args, **kwargs)

Bases: DMDevice

A dm-integrity device

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • sysfs_path (str) – sysfs device path

class blivet.devices.dm.DMLinearDevice(*args, **kwargs)

Bases: DMDevice

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • sysfs_path (str) – sysfs device path

  • dm_uuid (str) – device-mapper UUID

deactivate(recursive=False)
property description

Return an attribute of instance, which is of type owner.

teardown(recursive=None)

Close, or tear down, a device.

blivet.devices.file module

class blivet.devices.file.DirectoryDevice(*args, **kwargs)

Bases: FileDevice

A directory on a filesystem.

This exists because of bind mounts.

Parameters:
  • path (str) – full path to the file

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

class blivet.devices.file.FileDevice(*args, **kwargs)

Bases: StorageDevice

A file on a filesystem.

This exists because of swap files.

Parameters:
  • path (str) – full path to the file

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

property fstab_spec

Return an attribute of instance, which is of type owner.

is_name_valid(name)

Is the device name valid for the device type?

property path

Return an attribute of instance, which is of type owner.

read_current_size()
update_sysfs_path()

Update this device’s sysfs path.

class blivet.devices.file.SparseFileDevice(*args, **kwargs)

Bases: FileDevice

A sparse file on a filesystem. This exists for sparse disk images.

Parameters:
  • path (str) – full path to the file

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

blivet.devices.lib module

class blivet.devices.lib.ParentList(items=None, appendfunc=None, removefunc=None)

Bases: object

A list with auditing and side-effects for additions and removals.

The class provides an ordered list with guaranteed unique members and optional functions to run before adding or removing a member. It provides a subset of the functionality provided by list, making it easy to ensure that changes pass through the check functions.

The following operations are implemented:

ml.append(x)
ml.remove(x)
iter(ml)
len(ml)
x in ml
x = ml[i]   # not ml[i] = x
Parameters:
  • items (any iterable) – initial contents

  • appendfunc (callable) – a function to call before adding an item

  • removefunc (callable) – a function to call before removing an item

appendfunc and removefunc should take the item to be added or removed and perform any checks or other processing. The appropriate function will be called immediately before adding or removing the item. The function should raise an exception if the addition/removal should not take place. ParentList instance is not passed to the function. While this is not optimal for general-purpose use, it is ideal for the intended use as part of Device. The functions themselves should not modify the ParentList.

append(y)

Add an item to the list after running a callback.

appendfunc

a function to call before adding an item

remove(y)

Remove an item from the list after running a callback.

removefunc

a function to call before removing an item

class blivet.devices.lib.Tags(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: str, Enum

Tags that describe various classes of disk.

local = 'local'
nvme = 'nvme'
remote = 'remote'
removable = 'removable'
ssd = 'ssd'
usb = 'usb'
blivet.devices.lib.device_name_to_disk_by_path(device_name=None)

Return a /dev/disk/by-path/ symlink path for the given device name.

Parameters:

device_name (str) – the device name

Returns:

the full path to a /dev/disk/by-path/ symlink, or None

Return type:

str or NoneType

blivet.devices.lib.device_path_to_name(device_path)

Return a name based on the given path to a device node.

Parameters:

device_path (str) – the path to a device node

Returns:

the name

Return type:

str

blivet.devices.lib.get_device_type_by_major(major)

Return a device-type string for the given major number.

Parameters:

major (int) – major number

Return type:

str

Note

Type strings are taken directly from /proc/devices.

blivet.devices.lib.get_majors_by_device_type(device_type)

Return a list of major numbers for the given device type.

Parameters:

device_type (str) – device type string (eg: ‘device-mapper’, ‘md’)

Return type:

list of int

Note

Type strings are taken directly from /proc/devices.

blivet.devices.loop module

class blivet.devices.loop.LoopDevice(*args, **kwargs)

Bases: StorageDevice

A loop device.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

Loop devices always exist.

property size

Return an attribute of instance, which is of type owner.

property status

Return an attribute of instance, which is of type owner.

update_name()

Update this device’s name.

blivet.devices.luks module

class blivet.devices.luks.BITLKDevice(*args, **kwargs)

Bases: DMCryptDevice

A mapped BITLK device.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • sysfs_path (str) – sysfs device path

class blivet.devices.luks.IntegrityDevice(*args, **kwargs)

Bases: DMIntegrityDevice

A mapped integrity device.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • sysfs_path (str) – sysfs device path

  • uuid (str) – the device UUID

property controllable

Return an attribute of instance, which is of type owner.

property metadata_size

Return an attribute of instance, which is of type owner.

property raw_device

Return an attribute of instance, which is of type owner.

property size

Return an attribute of instance, which is of type owner.

class blivet.devices.luks.LUKSDevice(*args, **kwargs)

Bases: DMCryptDevice

A mapped LUKS device.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • sysfs_path (str) – sysfs device path

  • uuid (str) – the device UUID

property device_id

Return an attribute of instance, which is of type owner.

dracut_setup_args()
property max_size

The maximum size this luks device can be. Maximum is based on the maximum size of the backing device.

populate_ksdata(data)
property raw_device

Return an attribute of instance, which is of type owner.

property resizable

Can this device be resized?

resize()

Resize a device to self.target_size.

This method should only be invoked via the ActionResizeDevice.execute method. All the pre-conditions enforced by ActionResizeDevice.__init__ are assumed to hold.

Returns nothing.

property size

Return an attribute of instance, which is of type owner.

update_name()

blivet.devices.lvm module

class blivet.devices.lvm.LVMCache(cached_lv, size=None, md_size=None, exists=False, pvs=None, mode=None)

Bases: Cache

Parameters:
  • cached_lv (LVMLogicalVolumeDevice) – the LV the cache functionality of which to provide

  • size (Size) – size of the cache (useful mainly for non-existing caches that cannot determine their size dynamically)

  • md_size (Size or NoneType) – size of the metadata part (LV) of the cache (for non-existing caches that cannot determine their metadata size dynamically) or None to use the default (see note below)

  • exists (bool) – whether the cache exists or not

  • pvs (list of LVPVSpec) – PVs to allocate the cache on/from (ignored for existing)

  • mode (str) – desired mode for non-existing cache (ignored for existing)

Note

If :param:`md_size` is None for a an unexisting cache, the default is used and it is subtracted from the requested :param:`size` so that the whole cache (data+metadata) fits in the space of size :param:`size`.

property backing_device_name

Name of the backing (big/slow) device of the cache (if any)

property cache_device_name

Name of the cache (small/fast) device of the cache (if any)

detach()

Detach the cache :returns: identifier of the detached cache that can be later used for attaching it back

property exists

Whether the cache (device) exists or not

property fast_pvs
property md_size
property mode
property pv_space_used
Returns:

space to be occupied by the cache on its LV’s VG’s PVs (one has to love LVM)

Return type:

list of LVPVSpec

property size

Size of the cache

property stats

Statistics for the cache :rtype: CacheStats

type = 'cache'

Class providing the cache-related functionality of a cached LV

property vg_space_used
class blivet.devices.lvm.LVMCachePoolMixin(metadata_size, cache_mode=None, attach_to=None)

Bases: object

add_hook(new=True)
autoset_md_size(enforced=False)

If self._metadata_size not set already, it calculates the recommended value and sets it while subtracting the size from self.size.

property direct

Is this device directly accessible?

dracut_setup_args()
property format_immutable
property is_cache_pool
property profile
read_current_size()
remove_hook(modparent=True)
property resizable
property type
class blivet.devices.lvm.LVMCacheRequest(size, pvs, mode=None, cache_type=LVMCacheType.lvmcache)

Bases: CacheRequest

Class representing the LVM cache creation request

Parameters:
  • size (Size) – requested size of the cache

  • pvs (list of (StorageDevice or LVPVSpec)) – PVs to allocate the cache on/from

  • mode (str) – requested mode for the cache (None means the default is used)

  • cache_type (enum LVMCacheType) – type of the cache to use (writecache or “normal” cache)

property cache_type
property fast_devs

Devices (type-specific) to allocate/create the cache on

property mode

Mode the cache should use

property pv_space_requests
Returns:

space to be occupied by the cache on its LV’s VG’s PVs (one has to love LVM)

Return type:

list of LVPVSpec

property size

Requested size

class blivet.devices.lvm.LVMCacheStats(stats_data)

Bases: CacheStats

Parameters:

stats_data (blockdev.LVMCacheStats) – cache stats data

property block_size

block size of the cache

property hits

number of hits

property md_block_size
property md_size
property md_used
property misses

number of misses

property read_hits
property read_misses
property size

size of the cache

property used

how much of the cache is used

property write_hits
property write_misses
class blivet.devices.lvm.LVMCacheType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

lvmcache = 1
lvmwritecache = 2
class blivet.devices.lvm.LVMInternalLVtype(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

cache_pool = 6
data = 1
classmethod get_type(lv_attr, lv_name)
image = 4
log = 3
meta = 2
origin = 5
unknown = 99
class blivet.devices.lvm.LVMInternalLogicalVolumeMixin(vg, parent_lv, lv_type)

Bases: object

add_hook(new=True)
destroy()
property direct
property display_lvname

Name of the internal LV as displayed by the lvm utilities

property growable
property int_lv_type
property is_internal_lv
is_name_valid(name)
property max_size
property name_suffix
property parent_lv
property readonly
remove_hook(modparent=True)
property resizable
resize()
setup(orig=False)
property takes_extra_space
teardown(recursive=None)
property type
property vg
class blivet.devices.lvm.LVMLogicalVolumeBase(*args, **kwargs)

Bases: DMDevice, RaidDevice

Abstract base class for LVM LVs

Attributes, properties and methods defined in this class are common too all LVs.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • sysfs_path (str) – sysfs device path

  • dm_uuid (str) – device-mapper UUID (see note below)

  • target (str) – device mapper table/target name (eg: “linear”)

Note

The dm_uuid is not necessarily persistent, as it is based on map name in many cases. The uuid, however, is a persistent UUID stored in device metadata on disk.

add_internal_lv(int_lv)
property cache

Return an attribute of instance, which is of type owner.

property cached

Return an attribute of instance, which is of type owner.

check_size()

Check to make sure the size of the device is allowed by the format used.

Returns: 0 - ok 1 - Too large -1 - Too small

property complete

Test if vg exits and if it has all pvs.

config_actions_map = {'compression': '_set_compression', 'deduplication': '_set_deduplication', 'name': '_rename'}
property container

Return an attribute of instance, which is of type owner.

property data_vg_space_used

Space occupied by the data part of this LV, not including snapshots

property device_id

Return an attribute of instance, which is of type owner.

property dict

Return an attribute of instance, which is of type owner.

property from_lvs

Return an attribute of instance, which is of type owner.

get_dm_node()

Return the dm-X (eg: dm-0) device node for this device.

property is_raid_lv

Return an attribute of instance, which is of type owner.

property isleaf

Return an attribute of instance, which is of type owner.

property log_size

Return an attribute of instance, which is of type owner.

property lvname

The LV’s name (not including VG name).

property map_name

This device’s device-mapper map name

property members

Return an attribute of instance, which is of type owner.

property metadata_size

Size of the meta data space this LV has available (see also :property:`metadata_vg_space_used`)

property metadata_vg_space_used

Space occupied by the metadata part(s) of this LV, not including snapshots

property mirrored

Return an attribute of instance, which is of type owner.

property num_raid_pvs

Return an attribute of instance, which is of type owner.

property path

Device node representing this device.

populate_ksdata(data)
property pv_space_used
Returns:

space occupied by this LV on its VG’s PVs (if we have and idea)

Return type:

list of LVPVSpec

property raid_level

Return an attribute of instance, which is of type owner.

remove_internal_lv(int_lv)
set_rw()

Run lvchange as needed to ensure the lv is not read-only.

property vg

This Logical Volume’s Volume Group.

property vg_space_used

Space occupied by this LV, not including snapshots.

class blivet.devices.lvm.LVMLogicalVolumeDevice(*args, **kwargs)

Bases: LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin, LVMSnapshotMixin, LVMThinPoolMixin, LVMThinLogicalVolumeMixin, LVMVDOPoolMixin, LVMVDOLogicalVolumeMixin, LVMCachePoolMixin

An LVM Logical Volume

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • sysfs_path (str) – sysfs device path

  • uuid (str) – the device UUID

  • seg_type (str) – segment type (eg: “linear”, “raid1”, “thin-pool”, “thin”,…)

For non-existent LVs only:

Parameters:
  • grow (bool) – whether to grow this LV

  • maxsize (Size) – maximum size for growable LV

  • percent (int) – percent of VG space to take

  • cache_request (LVMCacheRequest) – parameters of requested cache (if any)

  • pvs (list of StorageDevice or LVPVSpec objects (tuples)) – list of PVs to allocate extents from (size could be specified for each PV)

  • shared (bool) – whether to activate the newly create LV in shared mode

For internal LVs only:

Parameters:

For snapshots only:

Parameters:
  • origin (StorageDevice) – origin of this snapshot

  • vorigin (bool) – is this a vorigin snapshot?

For thin pools (seg_type=”thin-pool”) only:

Parameters:
  • metadata_size (Size) – the size of the metadata LV

  • chunk_size (Size) – chunk size for the pool

  • profile (ThPoolProfile or NoneType) – (allocation) profile for the pool or None (unspecified)

For new LVs created from other LVs:

Parameters:

from_lvs (tuple of LVMLogicalVolumeDevice) – LVs to create the new LV from (in the (data_lv, metadata_lv) order)

For VDO pools only:

Parameters:
  • compression (bool) – whether to enable compression on the VDO pool

  • dudplication (bool) – whether to enable dudplication on the VDO pool

  • index_memory (int) – amount of index memory (in bytes) or 0 for default

  • write_policy (str) – write policy for the volume or None for default

For cache pools only:

Parameters:
  • metadata_size (Size) – the size of the metadata LV

  • cache_mode (str) – mode for the cache or None for default (writethrough)

  • attach_to (LVMLogicalVolumeDevice) – for non-existing cache pools a logical volume the pool should be attached to when created

For RAID LVs only:

Parameters:

stripe_size (Size) – size of the RAID stripe

add_hook(new=True)

Perform actions related to adding a device to the devicetree.

Parameters:

new (bool) – whether this device is new to the devicetree

The only intended use case for new=False is when unhiding a device from the devicetree. Additional operations are performed when new is False that are normally performed as part of the device constructor.

attach_cache(cache_pool_lv)
attach_writecache(writecache_lv)
autoset_md_size(enforced=False)

If self._metadata_size not set already, it calculates the recommended value and sets it while subtracting the size from self.size.

depends_on(dep)

Return True if this device depends on dep.

This device depends on another device if the other device is an ancestor of this device. For example, a PartitionDevice depends on the DiskDevice on which it resides.

Parameters:

dep (Device) – the other device

Returns:

whether this device depends on ‘dep’

Return type:

bool

destroy()

Destroy the device.

property direct

Is this device directly accessible?

property display_lv_name

Return an attribute of instance, which is of type owner.

dracut_setup_args()
property external_dependencies

Return an attribute of instance, which is of type owner.

property format_immutable

Return an attribute of instance, which is of type owner.

property growable

Return an attribute of instance, which is of type owner.

is_name_valid(name)

Is the device name valid for the device type?

property lvs

Return an attribute of instance, which is of type owner.

property max_size

The maximum size this lv can be.

property min_size

Return an attribute of instance, which is of type owner.

property pool

Return an attribute of instance, which is of type owner.

populate_ksdata(data)
read_current_size()
property readonly

Return an attribute of instance, which is of type owner.

remove_hook(modparent=True)

Perform actions related to removing a device from the devicetree.

Parameters:

modparent (bool) – whether to account for removal in parents

Parents’ list of child devices is updated regardless of modparent. The intended use of modparent is to prevent doing things like removing a parted.Partition from the disk that contains it as part of msdos extended partition management. In general, you should not override the default value of modparent in new code.

property resizable

Return an attribute of instance, which is of type owner.

resize()

Resize a device to self.target_size.

This method should only be invoked via the ActionResizeDevice.execute method. All the pre-conditions enforced by ActionResizeDevice.__init__ are assumed to hold.

Returns nothing.

setup(orig=False)

Open, or set up, a device.

setup_parents(orig=False)

Run setup method of all parent devices.

property size

Get the device’s size, accounting for pending changes.

teardown(recursive=None)

Close, or tear down, a device.

property type

Return an attribute of instance, which is of type owner.

type_specific()
property unavailable_direct_dependencies

Return an attribute of instance, which is of type owner.

property vg

This Logical Volume’s Volume Group.

property vg_space_used

Space occupied by this LV, not including snapshots.

class blivet.devices.lvm.LVMSnapshotMixin(origin=None, vorigin=False)

Bases: object

depends_on(dep)
property format_immutable
property is_snapshot_lv
merge()

Merge the snapshot back into its origin volume.

old_snapshot_specific()

Decorator for methods that are specific only to old snapshots

origin

the snapshot’s source volume

read_current_size()
property resizable
setup(orig=False)
teardown(recursive=False)
property type
vorigin

a boolean flag indicating a vorigin snapshot

class blivet.devices.lvm.LVMThinLogicalVolumeMixin

Bases: object

add_hook(new=True)
property is_thin_lv
property pool
property pool_space_used

The total space used within the thin pool by this volume.

This should probably align to the greater of vg extent size and pool chunk size. If it ends up causing overcommit in the amount of less than one chunk per thin lv, so be it.

populate_ksdata(data)
remove_hook(modparent=True)
property type
property vg
property vg_space_used
class blivet.devices.lvm.LVMThinPoolMixin(metadata_size=None, chunk_size=None, profile=None)

Bases: object

autoset_md_size(enforced=False)

If self._metadata_size not set already, it calculates the recommended value and sets it while subtracting the size from self.size.

property chunk_size
property direct

Is this device directly accessible?

dracut_setup_args()
property free_space
property is_thin_pool
property lvs

A list of this pool’s LVs

populate_ksdata(data)
property profile
property resizable
property type
property used_space
class blivet.devices.lvm.LVMVDOLogicalVolumeMixin

Bases: object

add_hook(new=True)
property is_vdo_lv
property pool
remove_hook(modparent=True)
property resizable
property type
classmethod type_external_dependencies()
classmethod unavailable_type_dependencies()
property vg
property vg_space_used
class blivet.devices.lvm.LVMVDOPoolMixin(compression=True, deduplication=True, index_memory=0, write_policy=None)

Bases: object

property direct

Is this device directly accessible?

property is_vdo_pool
property lvs

A list of this VDO pool’s LVs

property min_size
read_current_size()
property resizable
property type
classmethod type_external_dependencies()
classmethod unavailable_type_dependencies()
property vdo_lv
class blivet.devices.lvm.LVMVolumeGroupDevice(*args, **kwargs)

Bases: ContainerDevice

An LVM Volume Group

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • parents (list of StorageDevice) – a list of parent devices

  • sysfs_path (str) – sysfs device path

  • pe_size (Size) – physical extent size

For existing VG’s only:

Parameters:

size (Size) – the VG’s size

:keyword free – amount of free space in the VG :type free: Size :keyword pe_free: number of free extents :type pe_free: int :keyword pe_count – total number of extents :type pe_count: int :keyword pv_count: number of PVs in this VG :type pv_count: int :keyword uuid: the VG UUID :type uuid: str

For non-existing VGs only:

Parameters:

shared (bool) – whether to create this VG as shared

add_hook(new=True)

Perform actions related to adding a device to the devicetree.

Parameters:

new (bool) – whether this device is new to the devicetree

The only intended use case for new=False is when unhiding a device from the devicetree. Additional operations are performed when new is False that are normally performed as part of the device constructor.

align(size, roundup=False)

Align a size to a multiple of physical extent size.

property cached_lvs

Return an attribute of instance, which is of type owner.

property complete

Check if the vg has all its pvs in the system Return True if complete.

property device_id

Return an attribute of instance, which is of type owner.

property dict

Return an attribute of instance, which is of type owner.

property direct

Is this device directly accessible?

property extents

Number of extents in this VG

property free_extents

The number of free extents in this VG.

property free_space

The amount of free space in this VG.

static get_supported_pe_sizes()
property is_empty

Return an attribute of instance, which is of type owner.

property is_modified

Return True if the VG has changes queued that LVM is unaware of.

is_name_valid(name)

Is the device name valid for the device type?

property lvm_metadata_space

The amount of the space LVM metadata cost us in this VG’s PVs

property lvs

A list of this VG’s LVs

property map_name

This device’s device-mapper map name

property path

Device node representing this device.

property pmspare_size

Size of the pmspare LV LVM creates in every VG that contains some metadata (even internal) LV. The size of such LV is equal to the size of the biggest metadata LV in the VG.

populate_ksdata(data)
property protected

Return an attribute of instance, which is of type owner.

property pv_free_info
Returns:

information about sizes and free space in this VG’s PVs

Return type:

list of PVFreeInfo

property pvs

A list of this VG’s PVs

remove_hook(modparent=True)

Perform actions related to removing a device from the devicetree.

Parameters:

modparent (bool) – whether to account for removal in parents

Parents’ list of child devices is updated regardless of modparent. The intended use of modparent is to prevent doing things like removing a parted.Partition from the disk that contains it as part of msdos extended partition management. In general, you should not override the default value of modparent in new code.

property reserved_percent

Reserved space in this VG in percent

property reserved_space

Reserved space in this VG

property size

The size of this VG

property status

The device’s status (True means active).

property thinlvs

Return an attribute of instance, which is of type owner.

property thinpools

Return an attribute of instance, which is of type owner.

property thpool_reserve

Return an attribute of instance, which is of type owner.

update_sysfs_path()

Update this device’s sysfs path.

class blivet.devices.lvm.LVMWriteCache(cached_lv, size, exists=False, pvs=None)

Bases: Cache

property backing_device_name

Name of the backing (big/slow) device of the cache (if any)

property cache_device_name

Name of the cache (small/fast) device of the cache (if any)

detach()

Detach the cache :returns: identifier of the detached cache that can be later used for attaching it back

property exists

Whether the cache (device) exists or not

property fast_pvs
property md_size
property pv_space_used
Returns:

space to be occupied by the cache on its LV’s VG’s PVs (one has to love LVM)

Return type:

list of LVPVSpec

property size

Size of the cache

property stats

Statistics for the cache :rtype: CacheStats

type = 'writecache'
property vg_space_used
class blivet.devices.lvm.LVPVSpec(pv, size)

Bases: object

Class for specifying how much space on a PV should be allocated for some LV

exception blivet.devices.lvm.NotTypeSpecific

Bases: Exception

Exception class for invalid type-specific calls

class blivet.devices.lvm.PVFreeInfo(pv, size, free)

Bases: tuple

A namedtuple class holding the information about PV’s (usable) size and free space

free

Alias for field number 2

pv

Alias for field number 0

size

Alias for field number 1

class blivet.devices.lvm.ThPoolReserveSpec(percent, min, max)

Bases: tuple

A namedtuple class for specifying restrictions of space reserved for a thin pool to grow

max

Alias for field number 2

min

Alias for field number 1

percent

Alias for field number 0

blivet.devices.md module

class blivet.devices.md.MDBiosRaidArrayDevice(*args, **kwargs)

Bases: MDRaidArrayDevice

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • sysfs_path (str) – sysfs device path

  • chunk_size (Size) – chunk size for the device

  • uuid (str) – the device UUID

  • level (any valid RAID level descriptor) – the device’s RAID level

  • member_devices (int) – the number of active member devices

  • total_devices (int) – the total number of member devices

  • metadata_version (str (eg: "0.90")) – the version of the device’s md metadata

  • minor (int) – the device minor (obsolete?)

Note

An instance of this class whose exists attribute is True and whose parent/member devices are all partitionable is also considered to be partitionable.

Note

An instance of this class whose exists attribute is True and whose parent/member devices are all disks is also treated like a disk.

property description

Return an attribute of instance, which is of type owner.

property is_disk

Return an attribute of instance, which is of type owner.

property mdadm_conf_entry

Return an attribute of instance, which is of type owner.

property members

Return an attribute of instance, which is of type owner.

property partitionable

Return an attribute of instance, which is of type owner.

property size

Return an attribute of instance, which is of type owner.

teardown(recursive=None)

Close, or tear down, a device.

property total_devices

Return an attribute of instance, which is of type owner.

class blivet.devices.md.MDContainerDevice(*args, **kwargs)

Bases: MDRaidArrayDevice

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • sysfs_path (str) – sysfs device path

  • chunk_size (Size) – chunk size for the device

  • uuid (str) – the device UUID

  • level (any valid RAID level descriptor) – the device’s RAID level

  • member_devices (int) – the number of active member devices

  • total_devices (int) – the total number of member devices

  • metadata_version (str (eg: "0.90")) – the version of the device’s md metadata

  • minor (int) – the device minor (obsolete?)

Note

An instance of this class whose exists attribute is True and whose parent/member devices are all partitionable is also considered to be partitionable.

Note

An instance of this class whose exists attribute is True and whose parent/member devices are all disks is also treated like a disk.

property description

Return an attribute of instance, which is of type owner.

property is_disk

Return an attribute of instance, which is of type owner.

property mdadm_conf_entry

Return an attribute of instance, which is of type owner.

property media_present

Return an attribute of instance, which is of type owner.

property partitionable

Return an attribute of instance, which is of type owner.

teardown(recursive=None)

Close, or tear down, a device.

class blivet.devices.md.MDRaidArrayDevice(*args, **kwargs)

Bases: ContainerDevice, RaidDevice

An mdraid (Linux RAID) device.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • sysfs_path (str) – sysfs device path

  • chunk_size (Size) – chunk size for the device

  • uuid (str) – the device UUID

  • level (any valid RAID level descriptor) – the device’s RAID level

  • member_devices (int) – the number of active member devices

  • total_devices (int) – the total number of member devices

  • metadata_version (str (eg: "0.90")) – the version of the device’s md metadata

  • minor (int) – the device minor (obsolete?)

Note

An instance of this class whose exists attribute is True and whose parent/member devices are all partitionable is also considered to be partitionable.

Note

An instance of this class whose exists attribute is True and whose parent/member devices are all disks is also treated like a disk.

property bootable

Return an attribute of instance, which is of type owner.

property chunk_size

Return an attribute of instance, which is of type owner.

property complete

An MDRaidArrayDevice is complete if it has at least as many component devices as its count of active devices.

property create_bitmap

Whether or not a bitmap should be created on the array.

If the array is sufficiently small, a bitmap yields no benefit.

If the array has no redundancy, a bitmap is just pointless.

property degraded

Return True if the array is running in degraded mode.

property description

Return an attribute of instance, which is of type owner.

property device_id

Return an attribute of instance, which is of type owner.

property dict

Return an attribute of instance, which is of type owner.

dracut_setup_args()
property format_args

Return an attribute of instance, which is of type owner.

get_superblock_size(raw_array_size)

Estimate the superblock size for a member of an array, given the total available memory for this array and raid level.

Parameters:

raw_array_size (Size) – total available for this array and level

Returns:

estimated superblock size

Return type:

Size

property is_disk

Return an attribute of instance, which is of type owner.

property level

Return the raid level

Returns:

raid level value

Return type:

an object that represents a RAID level

property mdadm_conf_entry

This array’s mdadm.conf entry.

property mdadm_format_uuid

This array’s UUID, formatted for external use.

Returns:

the array’s UUID in mdadm format, if available

Return type:

str or NoneType

property member_devices

number of member devices

member_status(member)
property members

Returns this array’s members.

Return type:

list of StorageDevice

property model

Return an attribute of instance, which is of type owner.

property partitionable

Return an attribute of instance, which is of type owner.

populate_ksdata(data)
pre_commit_fixup(current_fmt=False)

Determine create parameters for this set

read_chunk_size()
property sector_size

Return an attribute of instance, which is of type owner.

property size

Returns the actual or estimated size depending on whether or not the array exists.

property spares

Return an attribute of instance, which is of type owner.

property status

This device’s status.

For now, this should return a boolean:

True the device is open and ready for use False the device is not open

teardown(recursive=None)

Close, or tear down, a device.

property total_devices

Total number of devices in the array, including spares.

update_size(newsize=None)

Update size, current_size, and target_size to actual size.

:keyword Size newsize: new size for device

Note

Most callers will not pass a new size. It is for special cases like outside resize of inactive LVs, which precludes updating the size from /sys.

blivet.devices.network module

class blivet.devices.network.NetworkStorageDevice(host_address=None, nic=None)

Bases: object

Virtual base class for network backed storage devices

Note this class is only to be used as a baseclass and then only with multiple inheritance. The only correct use is: class MyStorageDevice(StorageDevice, NetworkStorageDevice):

The sole purpose of this class is to: 1) Be able to check if a StorageDevice is network backed

(using isinstance).

  1. To be able to get the host address of the host (server) backing the storage or the NIC through which the storage is connected

Parameters:
  • host_address (str) – host address of the backing server

  • nic (str) – NIC to which the block device is bound

blivet.devices.nfs module

class blivet.devices.nfs.NFSDevice(*args, **kwargs)

Bases: StorageDevice, NetworkStorageDevice

An NFS device

Parameters:
  • device (str) – the device name (generally a device node’s basename)

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

create()

Create the device.

destroy()

Destroy the device.

is_name_valid(name)

Is the device name valid for the device type?

property path

Device node representing this device.

setup(orig=False)

Open, or set up, a device.

teardown(recursive=None)

Close, or tear down, a device.

update_size(newsize=None)

Update size, current_size, and target_size to actual size.

:keyword Size newsize: new size for device

Note

Most callers will not pass a new size. It is for special cases like outside resize of inactive LVs, which precludes updating the size from /sys.

update_sysfs_path()

Update this device’s sysfs path.

blivet.devices.nodev module

class blivet.devices.nodev.NoDevice(*args, **kwargs)

Bases: StorageDevice

A nodev device for nodev filesystems like tmpfs.

Parameters:

fmt (DeviceFormat or a subclass of it) – the device’s formatting

create()

Create the device.

destroy()

Destroy the device.

property path

Device node representing this device.

setup(orig=False)

Open, or set up, a device.

teardown(recursive=False)

Close, or tear down, a device.

update_size(newsize=None)

Update size, current_size, and target_size to actual size.

:keyword Size newsize: new size for device

Note

Most callers will not pass a new size. It is for special cases like outside resize of inactive LVs, which precludes updating the size from /sys.

update_sysfs_path()

Update this device’s sysfs path.

class blivet.devices.nodev.TmpFSDevice(*args, **kwargs)

Bases: NoDevice

A nodev device for a tmpfs filesystem.

Create a tmpfs device

property fstab_spec

Return an attribute of instance, which is of type owner.

populate_ksdata(data)
property size

Return an attribute of instance, which is of type owner.

blivet.devices.optical module

class blivet.devices.optical.OpticalDevice(*args, **kwargs)

Bases: StorageDevice

An optical drive, eg: cdrom, dvd+r, &c.

XXX Is this useful?

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • uuid (str) – universally unique identifier (device – not fs)

  • sysfs_path (str) – sysfs device path

  • major (int) – the device major

  • minor (int) – the device minor

  • serial (str) – the ID_SERIAL_SHORT for this device

  • vendor (str) – the manufacturer of this Device

  • model (str) – manufacturer’s device model string

  • bus (str) – the interconnect this device uses

eject()

Eject the drawer.

property media_present

Return a boolean indicating whether or not the device contains media.

blivet.devices.partition module

class blivet.devices.partition.PartitionDevice(*args, **kwargs)

Bases: StorageDevice

A disk partition.

On types and flags…

We don’t need to deal with numerical partition types at all. The only type we are concerned with is primary/logical/extended. Usage specification is accomplished through the use of flags, which we will set according to the partition’s format.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (:class:Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

For existing partitions only:

Parameters:
  • uuid (str) – partition UUID (not filesystem UUID)

  • major (long) – the device major

  • minor (long) – the device minor

  • sysfs_path (str) – sysfs device path

For non-existent partitions only:

Parameters:
  • part_type (parted partition type constant) – parted type constant, eg: parted.PARTITION_NORMAL

  • grow (bool) – whether or not to grow the partition

  • maxsize (Size) – max size for growable partitions

  • start (long) – start sector (see note, below)

  • end (long) – end sector (see note, below)

  • bootable (bool) – whether the partition is bootable

  • weight (int or NoneType) – an initial sorting weight to assign

  • disk_tags (iterable) – (str) tags defining candidate disk set

  • part_type_uuid (uuid.UUID or NoneType) – GPT partition type UUID or None

  • mountpoint (str or NoneType) – where the partition’s format will be mounted

Note

If a start sector is specified the partition will not be adjusted for optimal alignment. That is up to the caller.

Note

You can only pass one of parents or disk_tags when instantiating a non-existent partition. If both disk set and disk tags are specified, the explicit disk set will be used.

Note

Multiple disk tags will be combined using the logical “or” operation.

add_hook(new=True)

Perform actions related to adding a device to the devicetree.

Parameters:

new (bool) – whether this device is new to the devicetree

The only intended use case for new=False is when unhiding a device from the devicetree. Additional operations are performed when new is False that are normally performed as part of the device constructor.

align_target_size(newsize)

Return newsize adjusted to allow for an end-aligned partition.

:param Size newsize: proposed/unaligned target size :raises _ped.CreateException: if the size extends beyond the end of

the disk

Returns:

newsize modified to yield an end-aligned partition

Return type:

Size

property bootable

Return an attribute of instance, which is of type owner.

check_size()

Check to make sure the size of the device is allowed by the format used.

Returns: 0 - ok 1 - Too large -1 - Too small

default_size = Size (500 MiB)
depends_on(dep)

Return True if this device depends on dep.

property dict

Return an attribute of instance, which is of type owner.

property direct

Is this device directly accessible?

property disk

Return an attribute of instance, which is of type owner.

flag_available(flag)
property fstab_spec

Return an attribute of instance, which is of type owner.

get_flag(flag)
property is_extended

Return an attribute of instance, which is of type owner.

property is_logical

Return an attribute of instance, which is of type owner.

property is_magic

Return an attribute of instance, which is of type owner.

property is_primary

Return an attribute of instance, which is of type owner.

property is_protected

Return an attribute of instance, which is of type owner.

property isleaf

True if no other device depends on this one.

property max_size

The maximum size this partition can be.

property min_size

Return an attribute of instance, which is of type owner.

property part_type

Get the partition’s type (as parted constant).

property part_type_uuid

Get the partition’s type (as a UUID object).

property part_type_uuid_req

Return an attribute of instance, which is of type owner.

property parted_partition

Return an attribute of instance, which is of type owner.

property path

Return an attribute of instance, which is of type owner.

populate_ksdata(data)
pre_commit_fixup(current_fmt=False)

Re-get self.parted_partition from the original disklabel.

probe()

Probe for any missing information about this device.

size, partition type, flags

property protected

Return an attribute of instance, which is of type owner.

read_current_size()
remove_hook(modparent=True)

Perform actions related to removing a device from the devicetree.

Parameters:

modparent (bool) – whether to account for removal in parents

Parents’ list of child devices is updated regardless of modparent. The intended use of modparent is to prevent doing things like removing a parted.Partition from the disk that contains it as part of msdos extended partition management. In general, you should not override the default value of modparent in new code.

property resizable

Return an attribute of instance, which is of type owner.

resize()

Resize a device to self.target_size.

This method should only be invoked via the ActionResizeDevice.execute method. All the pre-conditions enforced by ActionResizeDevice.__init__ are assumed to hold.

Returns nothing.

property sector_size

Return an attribute of instance, which is of type owner.

set_flag(flag)
unset_flag(flag)
update_name()
property weight

Return an attribute of instance, which is of type owner.

blivet.devices.raid module

class blivet.devices.raid.RaidDevice(*args, **kwargs)

Bases: StorageDevice

Metaclass for devices that support RAID in some form.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • uuid (str) – universally unique identifier (device – not fs)

  • sysfs_path (str) – sysfs device path

  • major (int) – the device major

  • minor (int) – the device minor

  • serial (str) – the ID_SERIAL_SHORT for this device

  • vendor (str) – the manufacturer of this Device

  • model (str) – manufacturer’s device model string

  • bus (str) – the interconnect this device uses

property members

A list of the member device instances

blivet.devices.storage module

class blivet.devices.storage.StorageDevice(*args, **kwargs)

Bases: Device

A generic storage device.

A fully qualified path to the device node can be obtained via the path attribute, although it is not guaranteed to be useful, or even present, unless the StorageDevice’s setup method has been run.

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • uuid (str) – universally unique identifier (device – not fs)

  • sysfs_path (str) – sysfs device path

  • major (int) – the device major

  • minor (int) – the device minor

  • serial (str) – the ID_SERIAL_SHORT for this device

  • vendor (str) – the manufacturer of this Device

  • model (str) – manufacturer’s device model string

  • bus (str) – the interconnect this device uses

add_hook(new=True)

Perform actions related to adding a device to the devicetree.

Parameters:

new (bool) – whether this device is new to the devicetree

The only intended use case for new=False is when unhiding a device from the devicetree. Additional operations are performed when new is False that are normally performed as part of the device constructor.

align_target_size(newsize)

Return a proposed target size adjusted for device specifics.

:param Size newsize: the proposed/unaligned target size :returns: newsize modified to yield an aligned device :rtype: Size

check_size()

Check to make sure the size of the device is allowed by the format used.

Returns: 0 - ok 1 - Too large -1 - Too small

config_actions_map = {'name': '_rename'}
property controllable

Return an attribute of instance, which is of type owner.

create()

Create the device.

property current_size

The device’s actual size, generally the size discovered by using system tools. May use a cached value if the information is currently unavailable.

If the device does not exist, then the actual size is 0.

destroy()

Destroy the device.

property dict

Return an attribute of instance, which is of type owner.

property direct

Is this device directly accessible?

property disks

A list of all disks this device depends on, including itself.

property encrypted

True if this device, or any it requires, is encrypted.

property format

The device’s formatting.

property format_args

Device-specific arguments to format creation program.

property format_immutable

Is it possible to execute format actions on this device?

property fstab_spec

Return an attribute of instance, which is of type owner.

property growable

True if this device or its component devices are growable.

property is_disk

Return an attribute of instance, which is of type owner.

property is_empty

Return an attribute of instance, which is of type owner.

is_name_valid(name)

Is the device name valid for the device type?

property logical_block_size

Logical sector (block) size of this device

property max_size

The maximum size this device can be.

property media_present

True if this device contains usable media.

property min_size

The minimum size this device can be.

property model

Return an attribute of instance, which is of type owner.

property packages

Return an attribute of instance, which is of type owner.

property partitionable

Return an attribute of instance, which is of type owner.

property partitioned

Return an attribute of instance, which is of type owner.

property path

Device node representing this device.

property physical_block_size

Physical sector (block) size of this device

populate_ksdata(data)
pre_commit_fixup(current_fmt=False)

Do any necessary pre-commit fixups.

property protected

Return an attribute of instance, which is of type owner.

property raw_device

The device itself, or when encrypted, the backing device.

read_current_size()
property readonly

Return an attribute of instance, which is of type owner.

property removable

Return an attribute of instance, which is of type owner.

remove_hook(modparent=True)

Perform actions related to removing a device from the devicetree.

Parameters:

modparent (bool) – whether to account for removal in parents

Parents’ list of child devices is updated regardless of modparent. The intended use of modparent is to prevent doing things like removing a parted.Partition from the disk that contains it as part of msdos extended partition management. In general, you should not override the default value of modparent in new code.

property resizable

Can this device be resized?

resize()

Resize a device to self.target_size.

This method should only be invoked via the ActionResizeDevice.execute method. All the pre-conditions enforced by ActionResizeDevice.__init__ are assumed to hold.

Returns nothing.

property sector_size

Logical sector (block) size of this device

property serial

Return an attribute of instance, which is of type owner.

setup(orig=False)

Open, or set up, a device.

setup_parents(orig=False)

Run setup method of all parent devices.

property size

The device’s size, accounting for pending changes

property status

This device’s status.

For now, this should return a boolean:

True the device is open and ready for use False the device is not open

property target_size

Target size of this device

teardown(recursive=None)

Close, or tear down, a device.

update_size(newsize=None)

Update size, current_size, and target_size to actual size.

:keyword Size newsize: new size for device

Note

Most callers will not pass a new size. It is for special cases like outside resize of inactive LVs, which precludes updating the size from /sys.

update_sysfs_path()

Update this device’s sysfs path.

property vendor

Return an attribute of instance, which is of type owner.

blivet.devices.stratis module

class blivet.devices.stratis.StratisFilesystemDevice(*args, **kwargs)

Bases: StorageDevice

A stratis pool device

Parameters:
  • name (str) – the device name (generally a device node’s basename)

  • exists (bool) – does this device exist?

  • size (Size) – the device’s size

  • parents (list of StorageDevice) – a list of parent devices

  • fmt (DeviceFormat or a subclass of it) – this device’s formatting

  • uuid (str) – universally unique identifier (device – not fs)

  • sysfs_path (str) – sysfs device path

  • major (int) – the device major

  • minor (int) – the device minor

  • serial (str) – the ID_SERIAL_SHORT for this device

  • vendor (str) – the manufacturer of this Device

  • model (str) – manufacturer’s device model string

  • bus (str) – the interconnect this device uses

property device_id

Return an attribute of instance, which is of type owner.

dracut_setup_args()
property fsname

The Stratis filesystem name (not including pool name).

property pool

Return an attribute of instance, which is of type owner.

property used_size

Size used by this filesystem in the pool

class blivet.devices.stratis.StratisPoolDevice(*args, **kwargs)

Bases: ContainerDevice

A stratis pool device

Encrypted:

whether this pool is encrypted or not

Parameters:
  • passphrase (str) – device passphrase

  • key_file (str) – path to a file containing a key

  • clevis – clevis configuration

Type:

StratisClevisConfig

add_hook(new=True)

Perform actions related to adding a device to the devicetree.

Parameters:

new (bool) – whether this device is new to the devicetree

The only intended use case for new=False is when unhiding a device from the devicetree. Additional operations are performed when new is False that are normally performed as part of the device constructor.

property blockdevs

A list of this pool block devices

property device_id

Return an attribute of instance, which is of type owner.

dracut_setup_args()
property encrypted

True if this device is encrypted.

property filesystems

A list of this pool block filesystems

property free_space

Free space in the pool usable for new filesystems

property has_key

Return an attribute of instance, which is of type owner.

property key_file

Path to key file to be used in /etc/crypttab

property passphrase

Return an attribute of instance, which is of type owner.

remove_hook(modparent=True)

Perform actions related to removing a device from the devicetree.

Parameters:

modparent (bool) – whether to account for removal in parents

Parents’ list of child devices is updated regardless of modparent. The intended use of modparent is to prevent doing things like removing a parted.Partition from the disk that contains it as part of msdos extended partition management. In general, you should not override the default value of modparent in new code.

property size

The size of this pool

Module contents