blivet.devices package

Submodules

blivet.devices.btrfs module

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

Bases: blivet.devices.storage.StorageDevice

Base class for BTRFS volume and sub-volume devices.

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

current_size

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

direct

Is this device directly accessible?

fstab_spec

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

is_name_valid(name)
path

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

status

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

update_size(newsize=None)
update_sysfs_path()

Update this device’s sysfs path.

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

Bases: blivet.devices.btrfs.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)
source = None

the snapshot’s source subvolume

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

Bases: blivet.devices.btrfs.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)
container

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

populate_ksdata(data)
remove_hook(modparent=True)
setup_parents(orig=False)

Run setup method of all parent devices.

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: blivet.devices.btrfs.BTRFSDevice, blivet.devices.container.ContainerDevice, blivet.devices.raid.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

data_level

Return the RAID level for data.

Returns:raid level
Return type:an object that represents a raid level
default_subvolume

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

format_immutable

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

list_subvolumes(snapshots_only=False)
members

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

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.

backing_device_name

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

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

exists

Whether the cache (device) exists or not

mode

Mode of the cache (writeback/writethrough...) :rtype: str

size

Size of the cache

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

fast_devs

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

mode

Mode the cache should use

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.

block_size

block size of the cache

hits

number of hits

misses

number of misses

size

size of the cache

used

how much of the cache is used

blivet.devices.container module

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

Bases: blivet.devices.storage.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().

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)

blivet.devices.device module

class blivet.devices.device.Device(name, parents=None)

Bases: blivet.util.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.

ancestors

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

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.

dict

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

dracut_setup_args()
is_name_valid(name)

Is the device name valid for the device type?

isleaf

True if no other device depends on this one.

name

This device’s name

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
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
status

Is this device currently active and ready for use?

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
type

Device type.

type_description

String describing the device type.

blivet.devices.disk module

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

Bases: blivet.devices.disk.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
  • busid – bus ID
  • opts (dict with option name keys and option value values) – options
description

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

dracut_setup_args()
get_opts()
class blivet.devices.disk.DMRaidArrayDevice(name, fmt=None, size=None, parents=None, sysfs_path='')

Bases: blivet.devices.dm.DMDevice, blivet.devices.container.ContainerDevice

A dmraid (device-mapper RAID) 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

DMRaidArrayDevices always exist. Blivet cannot create or destroy them.

activate()

Activate the raid set.

deactivate()

Deactivate the raid set.

description

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

devices

Return a list of this array’s member device instances.

dracut_setup_args()
model

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

teardown(recursive=None)

Close, or tear down, a device.

class blivet.devices.disk.DiskDevice(name, fmt=None, size=None, major=None, minor=None, sysfs_path='', parents=None, serial=None, vendor='', model='', bus='', exists=True)

Bases: blivet.devices.storage.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

DiskDevices always exist.

description

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

media_present

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

class blivet.devices.disk.DiskFile(name, fmt=None, size=None, major=None, minor=None, sysfs_path='', parents=None, serial=None, vendor='', model='', bus='', exists=True)

Bases: blivet.devices.disk.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()
sysfs_path

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

update_sysfs_path()
class blivet.devices.disk.FcoeDiskDevice(device, **kwargs)

Bases: blivet.devices.disk.DiskDevice, blivet.devices.network.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
  • nic – name of NIC to use
  • identifier

    ???

dracut_setup_args()
class blivet.devices.disk.MultipathDevice(name, fmt=None, size=None, serial=None, parents=None, sysfs_path='')

Bases: blivet.devices.dm.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
  • serial (str) – the device’s serial number

MultipathDevices always exist. Blivet cannot create or destroy them.

add_parent(parent)

Add a parent device to the mpath.

description

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

model

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

vendor

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

wwid

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

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

Bases: blivet.devices.disk.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
  • hba_id

    ???

  • wwpn

    ???

  • fcp_lun

    ???

description

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

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

Bases: blivet.devices.disk.DiskDevice, blivet.devices.network.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
  • node (str) –

    ???

  • ibft (bool) – use iBFT
  • nic (str) – name of NIC to use
  • initiator (str) – initiator name
  • fw_name – qla4xxx partial offload
  • fw_address – qla4xxx partial offload
  • fw_port – qla4xxx partial offload
dracut_setup_args()

blivet.devices.dm module

class blivet.devices.dm.DMCryptDevice(name, fmt=None, size=None, uuid=None, exists=False, sysfs_path='', parents=None)

Bases: blivet.devices.dm.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(name, fmt=None, size=None, dm_uuid=None, uuid=None, target=None, exists=False, parents=None, sysfs_path='')

Bases: blivet.devices.storage.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.

dict

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

fstab_spec

Return the device specifier for use in /etc/fstab.

get_dm_node()

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

map_name

This device’s device-mapper map name

setup_partitions()
slave

This device’s backing device.

status

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

teardown_partitions()
class blivet.devices.dm.DMLinearDevice(name, fmt=None, size=None, dm_uuid=None, exists=False, parents=None, sysfs_path='')

Bases: blivet.devices.dm.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)
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(path, fmt=None, size=None, exists=False, parents=None)

Bases: blivet.devices.file.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(path, fmt=None, size=None, exists=False, parents=None)

Bases: blivet.devices.storage.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
fstab_spec

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

is_name_valid(name)
path

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

read_current_size()
class blivet.devices.file.SparseFileDevice(path, fmt=None, size=None, exists=False, parents=None)

Bases: blivet.devices.file.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 = None

a function to call before adding an item

remove(y)

Remove an item from the list after running a callback.

removefunc = None

a function to call before removing an item

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(name=None, fmt=None, size=None, sysfs_path=None, exists=False, parents=None)

Bases: blivet.devices.storage.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.

size

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

slave

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

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.LUKSDevice(name, fmt=None, size=None, uuid=None, exists=False, sysfs_path='', parents=None)

Bases: blivet.devices.dm.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
dracut_setup_args()
max_size

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

populate_ksdata(data)
raw_device

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

resizable

Can this device be resized?

resize()
size

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

blivet.devices.lvm module

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

Bases: blivet.devices.cache.Cache

Class providing the cache-related functionality of a cached LV

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`.

backing_device_name
cache_device_name
detach()
exists
fast_pvs
md_size
mode
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
size
stats
vg_space_used
class blivet.devices.lvm.LVMCacheRequest(size, pvs, mode=None)

Bases: blivet.devices.cache.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)
fast_devs
mode
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
size
class blivet.devices.lvm.LVMCacheStats(stats_data)

Bases: blivet.devices.cache.CacheStats

Parameters:stats_data (blockdev.LVMCacheStats) – cache stats data
block_size
hits
md_block_size
md_size
md_used
misses
read_hits
read_misses
size
used
write_hits
write_misses
class blivet.devices.lvm.LVMInternalLVtype

Bases: enum.Enum

An enumeration.

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

Bases: object

add_hook(new=True)
destroy()
direct
display_lvname

Name of the internal LV as displayed by the lvm utilities

growable
int_lv_type
is_internal_lv
is_name_valid(name)
max_size
name_suffix
parent_lv
readonly
remove_hook(modparent=True)
resizable
resize()
setup(orig=False)
takes_extra_space
teardown(recursive=None)
type
vg
class blivet.devices.lvm.LVMLogicalVolumeBase(name, parents=None, size=None, uuid=None, seg_type=None, fmt=None, exists=False, sysfs_path='', grow=None, maxsize=None, percent=None, cache_request=None, pvs=None)

Bases: blivet.devices.dm.DMDevice, blivet.devices.raid.RaidDevice

Abstract base class for LVM LVs

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

add_internal_lv(int_lv)
cache

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

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

complete

Test if vg exits and if it has all pvs.

container

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

data_vg_space_used

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

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.

is_raid_lv

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

isleaf

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

log_size

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

lvname

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

map_name

This device’s device-mapper map name

members

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

metadata_size

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

metadata_vg_space_used

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

mirrored

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

path

Device node representing this device.

populate_ksdata(data)
pv_space_used
Returns:space occupied by this LV on its VG’s PVs (if we have and idea)
Return type:list of LVPVSpec
remove_internal_lv(int_lv)
vg

This Logical Volume’s Volume Group.

vg_space_used

Space occupied by this LV, not including snapshots.

class blivet.devices.lvm.LVMLogicalVolumeDevice(name, parents=None, size=None, uuid=None, seg_type=None, fmt=None, exists=False, sysfs_path='', grow=None, maxsize=None, percent=None, cache_request=None, pvs=None, parent_lv=None, int_type=None, origin=None, vorigin=False, metadata_size=None, chunk_size=None, profile=None)

Bases: blivet.devices.lvm.LVMLogicalVolumeBase, blivet.devices.lvm.LVMInternalLogicalVolumeMixin, blivet.devices.lvm.LVMSnapshotMixin, blivet.devices.lvm.LVMThinPoolMixin, blivet.devices.lvm.LVMThinLogicalVolumeMixin

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)

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)
add_hook(new=True)
attach_cache(cache_pool_lv)
depends_on(dep)
destroy()
direct

Is this device directly accessible?

display_lv_name

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

dracut_setup_args()
format_immutable

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

growable

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

is_name_valid(name)
max_size

The maximum size this lv can be.

populate_ksdata(data)
read_current_size()
readonly

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

remove_hook(modparent=True)
resizable

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

resize()
setup(orig=False)
setup_parents(orig=False)
size

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

teardown(recursive=None)
type

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

type_specific(meth)
vg

This Logical Volume’s Volume Group.

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)
format_immutable
is_snapshot_lv
merge()

Merge the snapshot back into its origin volume.

old_snapshot_specific(meth)

Decorator for methods that are specific only to old snapshots

origin = None

the snapshot’s source volume

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

a boolean flag indicating a vorigin snapshot

class blivet.devices.lvm.LVMThinLogicalVolumeMixin

Bases: object

add_hook(new=True)
is_thin_lv
pool
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)
type
vg
vg_space_used
class blivet.devices.lvm.LVMThinPoolMixin(metadata_size=None, chunk_size=None, profile=None)

Bases: object

chunk_size
direct

Is this device directly accessible?

dracut_setup_args()
free_space
is_thin_pool
lvs

A list of this pool’s LVs

populate_ksdata(data)
profile
resizable
type
used_space
vg_space_used
class blivet.devices.lvm.LVMVolumeGroupDevice(name, parents=None, size=None, free=None, pe_size=None, pe_count=None, pe_free=None, pv_count=None, uuid=None, exists=False, sysfs_path='')

Bases: blivet.devices.container.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

align(size, roundup=False)

Align a size to a multiple of physical extent size.

cached_lvs

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

complete

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

dict

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

direct

Is this device directly accessible?

extents

Number of extents in this VG

free_extents

The number of free extents in this VG.

free_space

The amount of free space in this VG.

static get_supported_pe_sizes()
is_modified

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

is_name_valid(name)
lvm_metadata_space

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

lvs

A list of this VG’s LVs

map_name

This device’s device-mapper map name

path

Device node representing this device.

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)
pv_free_info
Returns:information about sizes and free space in this VG’s PVs
Return type:list of PVFreeInfo
pvs

A list of this VG’s PVs

reserved_space

Reserved space in this VG

size

The size of this VG

status

The device’s status (True means active).

thinlvs

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

thinpools

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

update_sysfs_path()

Update this device’s sysfs path.

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

blivet.devices.md module

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

Bases: blivet.devices.md.MDRaidArrayDevice

description

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

is_disk

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

mdadm_conf_entry

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

members

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

partitionable

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

size

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

teardown(recursive=None)
total_devices

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

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

Bases: blivet.devices.md.MDRaidArrayDevice

description

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

is_disk

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

mdadm_conf_entry

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

media_present

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

partitionable

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

teardown(recursive=None)
class blivet.devices.md.MDRaidArrayDevice(name, level=None, major=None, minor=None, size=None, member_devices=None, total_devices=None, uuid=None, fmt=None, exists=False, metadata_version=None, parents=None, sysfs_path='')

Bases: blivet.devices.container.ContainerDevice, blivet.devices.raid.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
  • 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.

complete

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

create_bitmap

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

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

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

degraded

Return True if the array is running in degraded mode.

description

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

dict

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

dracut_setup_args()
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
is_disk

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

level

Return the raid level

Returns:raid level value
Return type:an object that represents a RAID level
mdadm_conf_entry

This array’s mdadm.conf entry.

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
member_devices

number of member devices

member_status(member)
members

Returns this array’s members.

Return type:list of StorageDevice
model

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

partitionable

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

populate_ksdata(data)
pre_commit_fixup()

Determine create parameters for this set

size

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

spares

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

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.

total_devices

Total number of devices in the array, including spares.

update_size(newsize=None)

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(device, fmt=None, parents=None)

Bases: blivet.devices.storage.StorageDevice, blivet.devices.network.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)
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)

blivet.devices.nodev module

class blivet.devices.nodev.NoDevice(fmt=None)

Bases: blivet.devices.storage.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.

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)
class blivet.devices.nodev.TmpFSDevice(*args, **kwargs)

Bases: blivet.devices.nodev.NoDevice

A nodev device for a tmpfs filesystem.

Create a tmpfs device

fstab_spec

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

populate_ksdata(data)
size

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

blivet.devices.optical module

class blivet.devices.optical.OpticalDevice(name, major=None, minor=None, exists=False, fmt=None, parents=None, sysfs_path='', vendor='', model='')

Bases: blivet.devices.storage.StorageDevice

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

XXX Is this useful?

eject()

Eject the drawer.

media_present

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

blivet.devices.partition module

class blivet.devices.partition.PartitionDevice(name, fmt=None, uuid=None, size=None, grow=False, maxsize=None, start=None, end=None, major=None, minor=None, bootable=None, sysfs_path='', parents=None, exists=False, part_type=None, primary=False, weight=0)

Bases: blivet.devices.storage.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) – an initial sorting weight to assign

Note

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

add_hook(new=True)
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
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.

dict

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

direct

Is this device directly accessible?

disk

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

flag_available(flag)
fstab_spec

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

get_flag(flag)
is_extended

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

is_logical

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

is_magic

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

is_primary

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

is_protected

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

isleaf

True if no other device depends on this one.

max_size

The maximum size this partition can be.

min_size

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

part_type

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

parted_partition

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

path

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

populate_ksdata(data)
pre_commit_fixup()

Re-get self.parted_partition from the original disklabel.

probe()

Probe for any missing information about this device.

size, partition type, flags

read_current_size()
remove_hook(modparent=True)
resizable

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

resize()
set_flag(flag)
unset_flag(flag)
update_name()
weight

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

blivet.devices.raid module

class blivet.devices.raid.RaidDevice(name, fmt=None, uuid=None, size=None, major=None, minor=None, sysfs_path='', parents=None, exists=False, serial=None, vendor='', model='', bus='')

Bases: blivet.devices.storage.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
members

A decorator indicating abstract properties.

Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.

Usage:

class C(metaclass=ABCMeta):

@abstractproperty def my_abstract_property(self):

...

This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:

class C(metaclass=ABCMeta):
def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)

‘abstractproperty’ is deprecated. Use ‘property’ with ‘abstractmethod’ instead.

blivet.devices.storage module

class blivet.devices.storage.StorageDevice(name, fmt=None, uuid=None, size=None, major=None, minor=None, sysfs_path='', parents=None, exists=False, serial=None, vendor='', model='', bus='')

Bases: blivet.devices.device.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

create()

Create the device.

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.

dict

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

direct

Is this device directly accessible?

disks

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

encrypted

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

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
format

The device’s formatting.

format_args

Device-specific arguments to format creation program.

format_immutable

Is it possible to execute format actions on this device?

fstab_spec

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

growable

True if this device or its component devices are growable.

is_disk

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

is_name_valid(name)
max_size

The maximum size this device can be.

media_present

True if this device contains usable media.

min_size

The minimum size this device can be.

model

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

packages

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

partitionable

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

partitioned

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

path

Device node representing this device.

populate_ksdata(data)
pre_commit_fixup()

Do any necessary pre-commit fixups.

protected

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

raw_device

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

read_current_size()
readonly

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

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.

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.

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.

size

The device’s size, accounting for pending changes

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
target_size

Target size of this device

teardown(recursive=None)

Close, or tear down, a device.

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.

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
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
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.

vendor

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

Module contents