blivet package

Subpackages

Submodules

blivet.actionlist module

class blivet.actionlist.ActionList(addfunc=None, removefunc=None)

Bases: object

add(action)
find(device=None, action_type=None, object_type=None, path=None, devid=None)

Find all actions that match all specified parameters.

A value of None for any of the keyword arguments indicates that any value is acceptable for that field.

Parameters:
  • device (StorageDevice or None) – device to match
  • action_type (str or None) – action type to match (eg: “create”, “destroy”)
  • object_type (str or None) – operand type to match (eg: “device” or “format”)
  • path (str or None) – device path to match
  • devid (int or None) – device id to match
Returns:

a list of matching actions

Return type:

list of DeviceAction

process(callbacks=None, devices=None, dry_run=None)

Execute all registered actions.

Parameters:
  • callbacks (DoItCallbacks) – callbacks to be invoked when actions are executed
  • devices – a list of all devices current in the devicetree
prune()

Remove redundant/obsolete actions from the action list.

remove(action)
sort()

Sort actions based on dependencies.

blivet.actionlist.with_flag(flag_attr)

Decorator to set a flag attribute while running a method.

blivet.arch module

blivet.arch.get_arch()
Returns:The hardware architecture
Return type:string
blivet.arch.get_arm_machine()
Returns:The ARM processor variety type, or None if not ARM.
Return type:string
blivet.arch.get_ppc_mac_book()
Returns:True if the hardware is an i_book or PowerBook, False otherwise.
Return type:string
blivet.arch.get_ppc_mac_gen()
Returns:The PPC generation, or None if not PPC or a powermac.
Return type:string
blivet.arch.get_ppc_mac_id()
Returns:The powermac machine type, or None if not PPC or a powermac.
Return type:string
blivet.arch.get_ppc_machine()
Returns:The PPC machine type, or None if not PPC.
Return type:string
blivet.arch.is_aarch64()
Returns:True if the hardware supports Aarch64, False otherwise.
Return type:boolean
blivet.arch.is_alpha()
Returns:True if the hardware supports Alpha, False otherwise.
Return type:boolean
blivet.arch.is_arm()
Returns:True if the hardware supports ARM, False otherwise.
Return type:boolean
blivet.arch.is_cell()
Returns:True if the hardware is the Cell platform, False otherwise.
Return type:boolean
blivet.arch.is_efi()
Returns:True if the hardware supports EFI, False otherwise.
Return type:boolean
blivet.arch.is_ia64()
Returns:True if the hardware supports IA64, False otherwise.
Return type:boolean
blivet.arch.is_mactel()
Returns:True if the hardware is an Intel-based Apple Mac, False otherwise.
Return type:boolean
blivet.arch.is_ppc(bits=None)
Returns:True if the hardware supports PPC, False otherwise.
Return type:boolean
Parameters:bits (int) – The number of bits used to define a memory address.
blivet.arch.is_s390()
Returns:True if the hardware supports PPC, False otherwise.
Return type:boolean
blivet.arch.is_x86(bits=None)
Returns:True if the hardware supports X86, False otherwise.
Return type:boolean
Parameters:bits (int) – The number of bits used to define a memory address.
blivet.arch.num_bits()

Return an integer representing the length of the “word” used by the current architecture -> it is usually either 32 or 64

Returns:number of bits for the current architecture

or None if the number could not be determined :rtype: integer or None

blivet.autopart module

This module provides functions related to automatic partitioning.

blivet.autopart.do_autopart(storage, data, min_luks_entropy=0)

Perform automatic partitioning.

Parameters:
  • storage (Blivet) – a Blivet instance
  • data (pykickstart.BaseHandler) – kickstart data
  • min_luks_entropy (int) – minimum entropy in bits required for luks format creation

Blivet.do_autopart controls whether this method creates the automatic partitioning layout. Blivet.autopart_type controls which variant of autopart used. It uses one of the pykickstart AUTOPART_TYPE_* constants. The set of eligible disks is defined in StorageDiscoveryConfig.clear_part_disks.

Note

Clearing of partitions is handled separately, in clear_partitions().

blivet.autopart.do_reqpart(storage, requests)

Perform automatic partitioning of just required platform-specific partitions. This is incompatible with do_autopart.

Parameters:
  • storage (Blivet) – a Blivet instance
  • requests (list of PartSpec instances) – list of partitioning requests to operate on, or ~.storage.autopart_requests by default
blivet.autopart.swap_suggestion(quiet=False, hibernation=False, disk_space=None)

Suggest the size of the swap partition that will be created.

Parameters:
  • quiet (bool) – whether to log size information or not
  • hibernation (bool) – calculate swap size big enough for hibernation
  • disk_space (Size) – how much disk space is available
Returns:

calculated swap size

blivet.blivet module

class blivet.blivet.Blivet(ksdata=None)

Bases: object

Top-level class for managing storage configuration.

Parameters:ksdata (pykickstart.Handler) – kickstart data store
add_fstab_swap(device)

Add swap device to the list of swaps that should appear in the fstab.

Parameters:device (blivet.devices.StorageDevice instance holding a swap format) – swap device that should be added to the list
boot_device

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

boot_disk

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

boot_fstypes

A list of all valid filesystem types for the boot partition.

boot_loader_device

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

bootloader

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

btrfs_volumes

A list of the BTRFS volumes in the device tree.

This is based on the current state of the device tree and does not necessarily reflect the actual on-disk state of the system’s disks.

clear_partitions()

Clear partitions and dependent devices from disks.

This is also where zerombr is handled.

compare_disks(first, second)
compare_disks_key

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

copy()
create_device(device)

Schedule creation of a device.

Parameters:device (StorageDevice) – the device to schedule creation of
Return type:None
create_free_space_snapshot()
create_swap_file(device, size)
default_boot_fstype

The default filesystem type for the boot partition.

default_fstype

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

destroy_device(device)

Schedule destruction of a device.

Parameters:device (StorageDevice) – the device to schedule destruction of
Return type:None
device_deps(device)

Return a list of the devices that depend on the specified device.

Parameters:device (StorageDevice) – the subtree root device
Returns:list of dependent devices
Return type:list
devices

A list of all the devices in the device tree.

disks

A list of the disks in the device tree.

Ignored disks are excluded, as are disks with no media present.

This is based on the current state of the device tree and does not necessarily reflect the actual on-disk state of the system’s disks.

do_it(callbacks=None)

Commit queued changes to disk.

Parameters:callbacks (return value of the create_new_callbacks_register()) – callbacks to be invoked when actions are executed
dump_state(suffix)

Dump the current device list to the storage shelf.

factory_device(device_type, size, **kwargs)

Schedule creation of a device based on a top-down specification.

Parameters:
  • device_type (int (DEVICE_TYPE_*)) – device type constant
  • size (Size) – requested size
Returns:

the newly configured device

Return type:

StorageDevice

See DeviceFactory for possible kwargs.

file_system_free_space

Combined free space in / and /usr as Size.

format_by_default(device)

Return whether the device should be reformatted by default.

format_device(device, fmt)

Schedule formatting of a device.

Parameters:
  • device (StorageDevice) – the device to create the formatting on
  • fmt – the format to create on the device
Return type:

None

A format destroy action will be scheduled first, so it is not necessary to create and schedule an ActionDestroyFormat prior to calling this method.

free_space_snapshot

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

get_free_space(disks=None, clear_part_type=None)

Return a dict with free space info for each disk.

The dict values are 2-tuples: (disk_free, fs_free). fs_free is space available by shrinking filesystems. disk_free is space not allocated to any partition.

disks and clear_part_type allow specifying a set of disks other than self.disks and a clear_part_type value other than self.config.clear_part_type.

Parameters:
  • disks (list) – overrides disks
  • clear_part_type (int) – overrides self.config.clear_part_type
Returns:

dict with disk name keys and tuple (disk, fs) free values

Return type:

dict

Note

The free space values are Size instances.

get_fstype(mountpoint=None)

Return the default filesystem type based on mountpoint.

initialize_disk(disk)

(Re)initialize a disk by creating a disklabel on it.

The disk should not contain any partitions except perhaps for a magic partitions on mac and sun disklabels. If the disk does contain partitions other than the disklabel-type-specific “magic” partitions ValueError will be raised.

Parameters:disk (StorageDevice) – the disk to initialize
Returns None:
Raises:ValueError
lvs

A list of the LVM Logical Volumes in the device tree.

This is based on the current state of the device tree and does not necessarily reflect the actual on-disk state of the system’s disks.

make_mtab()
mdarrays

A list of the MD arrays in the device tree.

This is based on the current state of the device tree and does not necessarily reflect the actual on-disk state of the system’s disks.

mdcontainers

A list of the MD containers in the device tree.

mdmembers

A list of the MD member devices in the device tree.

This is based on the current state of the device tree and does not necessarily reflect the actual on-disk state of the system’s disks.

mk_dev_root()
mount_filesystems(read_only=None, skip_root=False)
mountpoints

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

must_format(device)

Return a string explaining why the device must be reformatted.

Return None if the device need not be reformatted.

names

A list of all of the known in-use device names.

new_btrfs(*args, **kwargs)

Return a new BTRFSVolumeDevice or BRFSSubVolumeDevice.

Parameters:
  • fmt_args (dict) – arguments for format constructor
  • mountpoint (str) – mountpoint for format (filesystem)
  • subvol (bool) – whether this is a subvol (as opposed to a volume)
Returns:

the new device

Return type:

BTRFSDevice

All other arguments are passed on to the appropriate BTRFSDevice constructor.

For volumes, the label is the same as the name. If a name/label is not specified, one will be generated based on the hostname and/or product name.

Note

If you are creating a subvolume, the parents kwarg should contain the volume you want to contain the subvolume.

new_btrfs_sub_volume(*args, **kwargs)

Return a new BRFSSubVolumeDevice.

Parameters:
  • fmt_args (dict) – arguments for format constructor
  • mountpoint (str) – mountpoint for format (filesystem)
Returns:

the new device

Return type:

BTRFSSubVolumeDevice

All other arguments are passed on to the BTRFSSubVolumeDevice constructor.

Note

Since you are creating a subvolume, the parents kwarg should contain the volume you want to contain the subvolume.

new_lv(*args, **kwargs)

Return a new LVMLogicalVolumeDevice instance.

Parameters:
  • fmt_type (str) – format type
  • fmt_args (dict) – arguments for format constructor
  • mountpoint (str) – mountpoint for format (filesystem)
  • thin_pool (bool) – whether to create a thin pool
  • thin_volume (bool) – whether to create a thin volume
Returns:

the new device

Return type:

LVMLogicalVolumeDevice

All other arguments are passed on to the appropriate LVMLogicalVolumeDevice constructor.

If a name is not specified, one will be generated based on the format type and/or mountpoint.

Note

If you are creating a thin volume, the parents kwarg should contain the pool – not the vg.

new_mdarray(*args, **kwargs)

Return a new MDRaidArrayDevice instance.

Parameters:
  • fmt_type (str) – format type
  • fmt_args (dict) – arguments for format constructor
  • mountpoint (str) – mountpoint for format (filesystem)
Returns:

the new md array device

Return type:

MDRaidArrayDevice

All other arguments are passed on to the MDRaidArrayDevice constructor.

If a name is not specified, one will be generated based on the format type, mountpoint, hostname, and/or product name.

new_partition(*args, **kwargs)

Return a new (unallocated) PartitionDevice instance.

Parameters:
  • fmt_type (str) – format type
  • fmt_args (dict) – arguments for format constructor
  • mountpoint (str) – mountpoint for format (filesystem)

All other arguments are passed on to the PartitionDevice constructor.

new_tmp_fs(*args, **kwargs)

Return a new TmpFSDevice.

new_vg(*args, **kwargs)

Return a new LVMVolumeGroupDevice instance.

Returns:the new volume group device
Return type:LVMVolumeGroupDevice

All arguments are passed on to the LVMVolumeGroupDevice constructor.

If a name is not specified, one will be generated based on the hostname, and/or product name.

next_id

Used for creating unique placeholder names.

packages

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

parse_fstab(chroot=None)
partitioned

A list of the partitioned devices in the device tree.

Ignored devices are not included, nor disks with no media present.

Devices of types for which partitioning is not supported are also not included.

This is based on the current state of the device tree and does not necessarily reflect the actual on-disk state of the system’s disks.

partitions

A list of the partitions in the device tree.

This is based on the current state of the device tree and does not necessarily reflect the actual on-disk state of the system’s disks.

pvs

A list of the LVM Physical Volumes in the device tree.

This is based on the current state of the device tree and does not necessarily reflect the actual on-disk state of the system’s disks.

recursive_remove(device)

Remove a device after removing its dependent devices.

If the device is not a leaf, all of its dependents are removed recursively until it is a leaf device. At that point the device is removed, unless it is a disk. If the device is a disk, its formatting is removed by no attempt is made to actually remove the disk device.

remove_empty_extended_partitions()
remove_fstab_swap(device)

Remove swap device from the list of swaps that should appear in the fstab.

Parameters:device (blivet.devices.StorageDevice instance holding a swap format) – swap device that should be removed from the list
reset(cleanup_only=False)

Reset storage configuration to reflect actual system state.

This will cancel any queued actions and rescan from scratch but not clobber user-obtained information like passphrases, iscsi config, &c

Parameters:cleanup_only (bool) – prepare the tree only to deactivate devices

See devicetree.Devicetree.populate() for more information about the cleanup_only keyword argument.

reset_device(device)

Cancel all scheduled actions and reset formatting.

Parameters:device (StorageDevice) – the device to reset
Return type:None
resize_device(device, new_size)

Schedule a resize of a device and its formatting, if any.

Parameters:
  • device (StorageDevice) – the device to resize
  • new_size (Size) – the new target size for the device
Return type:

None

If the device has formatting that is recognized as being resizable an action will be scheduled to resize it as well.

root_device

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

safe_device_name(name)

Convert a device name to something safe and return that.

LVM limits lv names to 128 characters. I don’t know the limits for the other various device types, so I’m going to pick a number so that we don’t have to have an entire fucking library to determine device name limits.

save_passphrase(device)

Save a device’s LUKS passphrase in case of reset.

set_default_boot_fstype(newtype)

Set the default /boot fstype for this instance.

Raise ValueError on invalid input.

set_default_fstype(newtype)

Set the default fstype for this instance.

Raise ValueError on invalid input.

set_fstab_swaps(devices)

Set swap devices that should appear in the fstab.

Parameters:devices (iterable providing blivet.devices.StorageDevice instances holding a swap format) – iterable providing devices that should appear in the fstab
set_up_boot_loader(early=False)

Propagate ksdata into BootLoader.

Parameters:early (bool) – Set to True to skip stage1_device setup
Raises BootloaderError:
 if stage1 setup fails

If this needs to be run early, eg. to setup stage1_disk but not stage1_device ‘early’ should be set True to prevent it from raising BootloaderError

setup_disk_images()
should_clear(device, **kwargs)

Return True if a clearpart settings say a device should be cleared.

Parameters:
  • device (StorageDevice) – the device (required)
  • clear_part_type (int) – overrides self.config.clear_part_type
  • clear_part_disks (list) – overrides self.config.clear_part_disks
  • clear_part_devices (list) – overrides self.config.clear_part_devices
Returns:

whether or not clear_partitions should remove this device

Return type:

bool

shutdown()

Deactivate all devices (installer_mode only).

suggest_container_name(hostname=None, prefix='')

Return a reasonable, unused device name.

Parameters:
  • hostname – the system’s hostname
  • prefix – a prefix for the container name
Returns:

the suggested name

Return type:

str

suggest_device_name(parent=None, swap=None, mountpoint=None, prefix='')

Return a suitable, unused name for a new device.

Parameters:
  • parent (StorageDevice) – the parent device
  • swap (bool) – will this be a swap device
  • mountpoint (str) – the device’s mountpoint
  • prefix (str) – device name prefix
Returns:

the suggested name

Return type:

str

swaps

A list of the swap devices in the device tree.

This is based on the current state of the device tree and does not necessarily reflect the actual on-disk state of the system’s disks.

thinlvs

A list of the LVM Thin Logical Volumes in the device tree.

This is based on the current state of the device tree and does not necessarily reflect the actual on-disk state of the system’s disks.

thinpools

A list of the LVM Thin Pool Logical Volumes in the device tree.

This is based on the current state of the device tree and does not necessarily reflect the actual on-disk state of the system’s disks.

turn_on_swap()
umount_filesystems(swapoff=True)
unused_devices

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

update_boot_loader_disk_list()
update_ksdata()

Update ksdata to reflect the settings of this Blivet instance.

vgs

A list of the LVM Volume Groups in the device tree.

This is based on the current state of the device tree and does not necessarily reflect the actual on-disk state of the system’s disks.

write()

Write out all storage-related configuration files.

write_dasd_conf(root)

Write /etc/dasd.conf to target system for all DASD devices configured during installation.

class blivet.blivet.StorageDiscoveryConfig

Bases: object

Class to encapsulate various detection/initialization parameters.

update(ksdata)

Update configuration from ksdata source.

Parameters:ksdata (pykickstart.Handler) – kickstart data used as data source
blivet.blivet.empty_device(device)

blivet.callbacks module

Module providing classes defining the callbacks used by Blivet and their arguments.

class blivet.callbacks.CreateFormatPostData(msg)

Bases: tuple

msg

Alias for field number 0

class blivet.callbacks.CreateFormatPreData(msg)

Bases: tuple

msg

Alias for field number 0

class blivet.callbacks.ReportProgressData(msg)

Bases: tuple

msg

Alias for field number 0

class blivet.callbacks.ResizeFormatPostData(msg)

Bases: tuple

msg

Alias for field number 0

class blivet.callbacks.ResizeFormatPreData(msg)

Bases: tuple

msg

Alias for field number 0

class blivet.callbacks.WaitForEntropyData(msg, min_entropy)

Bases: tuple

min_entropy

Alias for field number 1

msg

Alias for field number 0

blivet.callbacks.create_new_callbacks_register(create_format_pre=None, create_format_post=None, resize_format_pre=None, resize_format_post=None, wait_for_entropy=None, report_progress=None)

A function for creating a new opaque object holding the references to callbacks. The point of this function is to hide the implementation of such object and to provide default values for non-specified fields (e.g. newly added callbacks).

Parameters:wait_for_entropy (WaitForEntropyData -> bool) – callback for waiting for enough entropy whose return value indicates whether continuing regardless of available entropy should be forced (True) or not (False)

blivet.deviceaction module

class blivet.deviceaction.ActionAddMember(container, device)

Bases: blivet.deviceaction.DeviceAction

An action representing addition of a member device to a container.

apply()
cancel()
execute(callbacks=None)
obj = 3
obsoletes(action)
  • remove same member from same container
    • add same member to same container w/ higher id
obsoleted by
  • destroy the container
  • destroy the device
  • remove same member from same container
requires(action)
  • create/resize the same device
required by
  • any create/grow action on a device in the same container
type = 50
type_desc_str = 'add container member'
class blivet.deviceaction.ActionCreateDevice(device)

Bases: blivet.deviceaction.DeviceAction

Action representing the creation of a new device.

execute(callbacks=None)
obj = 2
requires(action)

Return True if self requires action.

Device create actions require other actions when either of the following is true:

  • this action’s device depends on the other action’s device
  • both actions are partition create actions on the same disk and this partition has a higher number
  • the other action adds a member to this device’s container
type = 100
type_desc_str = 'create device'
class blivet.deviceaction.ActionCreateFormat(device, fmt=None)

Bases: blivet.deviceaction.DeviceAction

An action representing creation of a new filesystem.

Parameters:
  • device (StorageDevice) – the device on which the format will be created
  • fmt (:class:~.formats.DeviceFormat`) – the format to put on the device

If no format is specified, it is assumed that the format is already associated with the device.

apply()

apply changes related to the action to the device(s)

cancel()
execute(callbacks=None)
obj = 1
obsoletes(action)

Return True if this action obsoletes action.

Format create actions obsolete the following actions:

  • format actions w/ lower id on this action’s device, other than those that destroy existing formats
requires(action)

Return True if self requires action.

Format create action can require another action if:

  • this action’s device depends on the other action’s device and the other action is not a device destroy action or a container action
  • the other action is a create or resize of this action’s device
type = 100
type_desc_str = 'create format'
class blivet.deviceaction.ActionDestroyDevice(device)

Bases: blivet.deviceaction.DeviceAction

An action representing the deletion of an existing device.

execute(callbacks=None)
obj = 2
obsoletes(action)

Return True if self obsoletes action.

  • obsoletes all actions w/ lower id that act on the same device, including self, if device does not exist
  • obsoletes all but ActionDestroyFormat actions w/ lower id on the same device if device exists
  • obsoletes all actions that add a member to this action’s (container) device
requires(action)

Return True if self requires action.

Device destroy actions require other actions when either of the following is true:

  • the other action’s device depends on this action’s device
  • both actions are partition create actions on the same disk and this partition has a lower number
  • the other action removes this action’s device from a container
type = 1000
type_desc_str = 'destroy device'
class blivet.deviceaction.ActionDestroyFormat(device)

Bases: blivet.deviceaction.DeviceAction

An action representing the removal of an existing filesystem.

apply()
cancel()
execute(callbacks=None)

wipe the filesystem signature from the device

format

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

obj = 1
obsoletes(action)

Return True if this action obsoletes action.

Format destroy actions obsolete the following actions:

  • non-destroy format actions w/ lower id on same device, including self if format does not exist
  • destroy format action w/ higher id on same device
  • format destroy action on a non-existent format shouldn’t obsolete a format destroy action on an existing one
requires(action)

Return True if self requires action.

Format destroy actions require other actions when:

  • the other action’s device depends on this action’s device and the other action is a destroy action
  • the other action removes this action’s device from a container
type = 1000
type_desc_str = 'destroy format'
class blivet.deviceaction.ActionRemoveMember(container, device)

Bases: blivet.deviceaction.DeviceAction

An action representing removal of a member device from a container.

apply()
cancel()
execute(callbacks=None)
obj = 3
obsoletes(action)
  • add same member to same container
    • remove same member from same container w/ higher id
obsoleted by
  • add same member to same container
requires(action)
  • any destroy/shrink action on a device in the same container
    • any add action on this container
required by
  • any destroy/resize action on the device
type = 10
type_desc_str = 'remove container member'
class blivet.deviceaction.ActionResizeDevice(device, newsize)

Bases: blivet.deviceaction.DeviceAction

An action representing the resizing of an existing device.

apply()

apply changes related to the action to the device(s)

cancel()
execute(callbacks=None)
obj = 2
requires(action)

Return True if self requires action.

A device resize action requires another action if:

  • the other action is a format resize on the same device and both are shrink operations
  • the other action grows a device (or format it contains) that this action’s device depends on
  • the other action shrinks a device (or format it contains) that depends on this action’s device
  • the other action removes this action’s device from a container
  • the other action adds a member to this device’s container
type = 500
type_desc_str = 'resize device'
class blivet.deviceaction.ActionResizeFormat(device, newsize)

Bases: blivet.deviceaction.DeviceAction

An action representing the resizing of an existing filesystem.

XXX Do we even want to support resizing of a filesystem without
also resizing the device it resides on?
apply()
cancel()
execute(callbacks=None)
obj = 1
requires(action)

Return True if self requires action.

A format resize action requires another action if:

  • the other action is a device resize on the same device and both are grow operations
  • the other action shrinks a device (or format it contains) that depends on this action’s device
  • the other action grows a device (or format) that this action’s device depends on
  • the other action removes this action’s device from a container
type = 500
type_desc_str = 'resize format'
class blivet.deviceaction.DeviceAction(device)

Bases: blivet.util.ObjectID

An action that will be carried out in the future on a Device.

These classes represent actions to be performed on devices or filesystems.

The operand Device instance will be modified according to the action, but no changes will be made to the underlying device or filesystem until the DeviceAction instance’s execute method is called. The DeviceAction instance’s cancel method should reverse any modifications made to the Device instance’s attributes.

If the Device instance represents a pre-existing device, the constructor should call any methods or set any attributes that the action will eventually change. Device/DeviceFormat classes should verify that the requested modifications are reasonable and raise an exception if not.

Only one action of any given type/object pair can exist for any given device at any given time. This is enforced by the DeviceTree.

Basic usage:

a = DeviceAction(dev) a.execute()

OR

a = DeviceAction(dev) a.cancel()

XXX should we back up the device with a deep copy for forcibly

cancelling actions?

The downside is that we lose any checking or verification that would get done when resetting the Device instance’s attributes to their original values.

The upside is that we would be guaranteed to achieve a total reversal. No chance of, eg: resizes ending up altering Device size due to rounding or other miscalculation.

apply()

apply changes related to the action to the device(s)

cancel()

cancel the action

execute(callbacks=None)

Perform the action.

Parameters:callbacks – callbacks to be run when matching actions are executed (see do_it())
format

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

is_add

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

is_container

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

is_create

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

is_destroy

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

is_device

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

is_format

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

is_grow

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

is_remove

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

is_resize

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

is_shrink

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

obj = 0
object_string

String indicating if this action’s operand is device or format.

object_type_string

String representing the type of the operand device or format.

obsoletes(action)

Return True is self obsoletes action.

DeviceAction instances obsolete other DeviceAction instances with lower id and same device.

requires(action)

Return True if self requires action.

resize_string

String representing the direction of a resize action.

type = 0
type_desc

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

type_desc_str = ''
type_string

String indicating if this action is a create, destroy or resize.

blivet.deviceaction.action_object_from_string(type_string)
blivet.deviceaction.action_type_from_string(type_string)
blivet.deviceaction.resize_type_from_string(type_string)

blivet.devicefactory module

class blivet.devicefactory.BTRFSFactory(storage, size, disks, **kwargs)

Bases: blivet.devicefactory.DeviceFactory

BTRFS subvolume

child_factory_class

alias of PartitionSetFactory

child_factory_fstype = 'btrfs'
container_list
class blivet.devicefactory.DeviceFactory(storage, size, disks, fstype=None, mountpoint=None, label=None, raid_level=None, encrypted=False, container_encrypted=False, container_name=None, container_raid_level=None, container_size=0, name=None, device=None, min_luks_entropy=0)

Bases: object

Class for creation of devices based on a top-down specification

DeviceFactory instances can be combined/stacked to create more complex device stacks like lvm with md pvs.

Simplified call trace for creation of a new LV in a new VG with partition PVs:

LVMFactory.configure
    PartitionSetFactory.configure   # set up PVs on partitions
    LVMFactory._create_container    # create container device (VG)
    LVMFactory._create_device       # create leaf device (LV)

Simplified call trace for creation of a new LV in a new VG with a single MD PV with member partitions on multiple disks:

LVMOnMDFactory.configure
    MDFactory.configure
        PartitionSetFactory.configure   # create md partitions
        MDFactory._create_device        # create PV on MD array
    LVMFactory._create_container        # create VG
    LVMFactory._create_device           # create LV

The code below will create a volume group with the name “data” just large enough to contain a new logical volume named “music” with a size of 10000 MB. It will make one physical volume partition on each disk in “disks” that has space. If the resulting volume group is not large enough to contain a logical volume of the specified size, the logical volume will be created with a size that is as close as possible to the requested size. If there is already a non-existent volume group named “data” in the Blivet instance’s device tree, that volume group will be used instead of creating a new one. If the already-defined “data” volume group exists on disk its size will not be changed, but if it has not been written to disk it will be adjusted to hold the new logical volume:

import blivet

_blivet = blivet.Blivet()
_blivet.reset()
disks = _blivet.partitioned

# Create a new LV "music" to a VG named "data", which may or may not
# exist. If the VG exists, the LV will be allocated from free space
# in the VG. If the VG does not exist, one will be created using new
# PVs on each of the specified disks. No free space is maintained in
# new VGs by default.
factory = blivet.devicefactory.LVMFactory(_blivet,
                                          Size("10000 MB"),
                                          disks,
                                          fstype="xfs",
                                          label="music",
                                          name="music",
                                          container_name="data")
factory.configure()
music_lv = factory.device


# Now add another LV to the "data" VG, adjusting the size of a non-
# existent "data" VG so that it can contain the new LV.
factory = blivet.devicefactory.LVMFactory(_blivet,
                                          Size("20000 MB"),
                                          disks,
                                          fstype="xfs",
                                          label="videos",
                                          name="videos",
                                          container_name="data")
factory.configure()

# Now change the size of the "music" LV and adjust the size of the
# "data" VG accordingly.
factory = blivet.devicefactory.LVMFactory(_blivet,
                                          Size("15000 MB"),
                                          disks,
                                          device=music_lv)
factory.configure()

# Write the new devices to disk and create the filesystems they
# contain.
_blivet.do_it()

Some operations (on non-existent devices) these classes do support:

  • create a device and a container to hold it
  • create a device within a defined container
  • create a device within an existing (on disk) container
  • change the set of disks from which partitions used by a factory can be allocated
  • change the size of a defined (but non-existent) device
  • toggle encryption of a leaf device or container member devices

Some operations these classes do not support:

  • any modification to an existing leaf device
  • change an existing container’s member device set
  • resize or rename an existing container
  • move a device from one container to another
  • change the type of a defined device
  • change the container member device type of a defined device
Parameters:
  • storage (Blivet) – a Blivet instance
  • size (Size) – the desired size for the device
  • disks (list of StorageDevice) – the set of disks to use
  • fstype (str) – filesystem type
  • mountpoint (str) – filesystem mount point
  • label (str) – filesystem label text
  • raid_level (any valid RAID level descriptor) – raid level descriptor
  • encrypted (bool) – whether to encrypt (boolean)
  • name (str) – name of requested device
  • device (StorageDevice) – an already-defined but non-existent device to adjust instead of creating a new device

Note

any device passed must be of the appropriate type for the factory class it is passed to

Parameters:
  • container_name (str) – name of requested container
  • container_raid_level (any valid RAID level descriptor) – raid level for container
  • container_encrypted (bool) – whether to encrypt the container
  • container_size (Size) – requested container size
  • min_luks_entropy (int) – minimum entropy in bits required for LUKS format creation
child_factory_class = None
child_factory_fstype = None
configure()

Configure the factory’s device(s).

Keyword arguments:

An example of the parent_factory is the LVMOnMDFactory creating and then using an MDFactory to manage the volume group’s single MD PV.

Another example is the MDFactory creating and then using a PartitionSetFactory to manage the set of member partitions.

container_list

List of containers of the appropriate type for this class.

container_raid_level
devices

A list of this factory’s product devices.

get_container(device=None, name=None, allow_existing=False)

Return the best choice of container for this factory.

Keyword arguments:

device – a defined factory device name – a specific container name to look for allow_existing – whether to allow selection of preexisting

containers
raid_level
raw_device

If self.device is encrypted, this is its backing device.

size_set_class

alias of TotalSizeSet

class blivet.devicefactory.LVMFactory(*args, **kwargs)

Bases: blivet.devicefactory.DeviceFactory

Factory for creating LVM logical volumes with partition PVs.

child_factory_class

alias of PartitionSetFactory

child_factory_fstype = 'lvmpv'
container_list
size_set_class

alias of TotalSizeSet

class blivet.devicefactory.LVMThinPFactory(*args, **kwargs)

Bases: blivet.devicefactory.LVMFactory

Factory for creating LVM using thin provisioning.

This class will be very similar to LVMFactory except that there are two layers of container: vg and thin pool (lv). We could make a separate factory class for creating and managing the thin pool, but we haven’t used a separate factory for any of the other classes’ containers.

pv(s)
vg
pool
thinlv(s)

This is problematic in that there are two containers in this stack: the vg and thin pool.

The thin pool does not need to be large enough to contain all of the thin lvs, so that check/adjust piece must be overridden/skipped here.

XXX We aren’t going to allow overcommitting initially, so that’ll
simplify things somewhat. That means we can manage the thin pool size automatically. We will need to handle overcommit in existing thinp setups in anaconda’s UI.

Because of the argument-passing madness that would ensue from being able to pass specs for two separate containers, the initial version of this class will only support auto-sized pools.

Also, the initial version will only support one thin pool per vg.

In summary:

  • one thin pool per vg
  • pools are auto-sized by anaconda/blivet
  • thinp setups created by the installer will not overcommit

Where to manage the pool:

  • the pool will need to be adjusted on device removal, which means pool management must not be hidden in device management routines
get_pool()
pool_list
class blivet.devicefactory.MDFactory(storage, size, disks, **kwargs)

Bases: blivet.devicefactory.DeviceFactory

Factory for creating MD RAID devices.

child_factory_class

alias of PartitionSetFactory

child_factory_fstype = 'mdmember'
container_list
get_container(device=None, name=None, allow_existing=False)
size_set_class

alias of SameSizeSet

class blivet.devicefactory.PartitionFactory(storage, size, disks, fstype=None, mountpoint=None, label=None, raid_level=None, encrypted=False, container_encrypted=False, container_name=None, container_raid_level=None, container_size=0, name=None, device=None, min_luks_entropy=0)

Bases: blivet.devicefactory.DeviceFactory

Factory class for creating a partition.

Parameters:
  • storage (Blivet) – a Blivet instance
  • size (Size) – the desired size for the device
  • disks (list of StorageDevice) – the set of disks to use
  • fstype (str) – filesystem type
  • mountpoint (str) – filesystem mount point
  • label (str) – filesystem label text
  • raid_level (any valid RAID level descriptor) – raid level descriptor
  • encrypted (bool) – whether to encrypt (boolean)
  • name (str) – name of requested device
  • device (StorageDevice) – an already-defined but non-existent device to adjust instead of creating a new device

Note

any device passed must be of the appropriate type for the factory class it is passed to

Parameters:
  • container_name (str) – name of requested container
  • container_raid_level (any valid RAID level descriptor) – raid level for container
  • container_encrypted (bool) – whether to encrypt the container
  • container_size (Size) – requested container size
  • min_luks_entropy (int) – minimum entropy in bits required for LUKS format creation
get_container(device=None, name=None, allow_existing=False)
class blivet.devicefactory.PartitionSetFactory(storage, size, disks, fstype=None, encrypted=False, devices=None)

Bases: blivet.devicefactory.PartitionFactory

Factory for creating a set of related partitions.

Create a new DeviceFactory instance.

Arguments:

storage a Blivet instance size the desired size for the device disks the set of disks to use

Keyword args:

fstype filesystem type encrypted whether to encrypt (boolean)

devices an initial set of devices

configure()

Configure the factory’s device set.

This factory class will always have a parent factory.

devices
blivet.devicefactory.get_device_factory(blivet, device_type, size, **kwargs)

Return a suitable DeviceFactory instance for device_type.

blivet.devicefactory.get_device_type(device)
blivet.devicefactory.get_supported_raid_levels(device_type)

Return the supported raid levels for this device type.

Parameters:device_type (int) – an enumeration indicating the device type
Returns:a set of supported raid levels for this device type
Return type:set of RAIDLevel
blivet.devicefactory.is_supported_device_type(device_type)

Return True if blivet supports this device type.

Parameters:device_type (int) – an enumeration indicating the device type
Returns:True if this device type is supported
Return type:bool

blivet.devicetree module

class blivet.devicetree.DeviceTree(conf=None, passphrase=None, luks_dict=None)

Bases: blivet.devicetree.DeviceTreeBase, blivet.populator.populator.PopulatorMixin, blivet.events.handler.EventHandlerMixin

reset(conf=None, passphrase=None, luks_dict=None)
class blivet.devicetree.DeviceTreeBase(conf=None)

Bases: object

A quasi-tree that represents the devices in the system.

The tree contains a list of StorageDevice instances, which does not necessarily reflect the actual state of the system’s devices. DeviceAction is used to perform modifications to the tree, except when initially populating the tree.

DeviceAction instances are registered, possibly causing the addition or removal of StorageDevice instances to/from the tree. A DeviceAction is reversible up to the time its ‘execute’ method is called.

Only one action of any given type/object pair should exist for any given device at any given time.

DeviceAction instances can only be registered for leaf devices, except for resize actions.

Parameters:conf (StorageDiscoveryConfig) – storage discovery configuration
actions

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

cancel_disk_actions(disks)

Cancel all actions related to the specified disk.

Parameters:disks – list of disks

This includes actions related directly and indirectly (via container membership, for example).

devices

List of devices currently in the tree

filesystems

List of filesystems.

get_dependent_devices(dep, hidden=False)

Return a list of devices that depend on dep.

The list includes both direct and indirect dependents.

Parameters:
  • dep (StorageDevice) – the device whose dependents we are looking for
  • hidden (bool) – include hidden devices in search
get_device_by_id(id_num, incomplete=False, hidden=False)

Return a device with specified device id.

Parameters:
  • id_num (int) – the id to look for
  • incomplete (bool) – include incomplete devices in search
  • hidden (bool) – include hidden devices in search
Returns:

the first matching device found

Return type:

Device

get_device_by_label(label, incomplete=False, hidden=False)

Return a device with a matching filesystem label.

Parameters:
  • label (str) – the filesystem label to match
  • incomplete (bool) – include incomplete devices in search
  • hidden (bool) – include hidden devices in search
Returns:

the first matching device found

Return type:

Device

get_device_by_name(name, incomplete=False, hidden=False)

Return a device with a matching name.

Parameters:
  • name (str) – the name to look for
  • incomplete (bool) – include incomplete devices in search
  • hidden (bool) – include hidden devices in search
Returns:

the first matching device found

Return type:

Device

get_device_by_path(path, incomplete=False, hidden=False)

Return a device with a matching path.

If there is more than one device with a matching path, prefer a leaf device to a non-leaf device.

Parameters:
  • path (str) – the path to match
  • incomplete (bool) – include incomplete devices in search
  • hidden (bool) – include hidden devices in search
Returns:

the first matching device found

Return type:

Device

get_device_by_sysfs_path(path, incomplete=False, hidden=False)

Return a list of devices with a matching sysfs path.

Parameters:
  • path (str) – the sysfs path to match
  • incomplete (bool) – include incomplete devices in search
  • hidden (bool) – include hidden devices in search
Returns:

the first matching device found

Return type:

Device

get_device_by_uuid(uuid, incomplete=False, hidden=False)

Return a list of devices with a matching UUID.

Parameters:
  • uuid (str) – the UUID to match
  • incomplete (bool) – include incomplete devices in search
  • hidden (bool) – include hidden devices in search
Returns:

the first matching device found

Return type:

Device

get_disk_actions(disks)

Return a list of actions related to the specified disk.

Parameters:disks – list of disks
Returns:list of related actions
Return type:list of DeviceAction

This includes all actions on the specified disks, plus all actions on disks that are in any way connected to the specified disk via container devices.

Return disks related to disk by container membership.

:param StorageDevice disk: the disk :returns: related disks :rtype: set of StorageDevice

Note

The disk may be hidden.

hide(device)

Hide the specified device.

Parameters:device (StorageDevice) – the device to hide

Hiding a device will cancel all actions that involve the device and will remove the device from the device list.

If the device is not a leaf device, all devices that depend on it will be hidden leaves-first until the device is a leaf device.

If a device exists, performs some special actions and places it on a list of hidden devices.

Mixes recursion and side effects, most significantly in the code that removes all the actions. However, this code is a null op in every case except the first base case that is reached, where all actions are removed. This means that when a device is removed explicitly in this function by means of a direct call to _remove_devices it is guaranteed that all actions have already been canceled.

If a device does not exist then it must have been removed by the cancelation of all the actions, so it does not need to be removed explicitly.

Most devices are considered leaf devices if they have no children, however, some devices must satisfy more stringent requirements. _remove_device() will raise an exception if the device it is removing is not a leaf device. hide() guarantees that any device that it removes will have no children, but it does not guarantee that the more stringent requirements will be enforced. Therefore, _remove_device() is invoked with the force parameter set to True, to skip the isleaf check.

labels

Dict with label keys and Device values.

FIXME: duplicate labels are a possibility

leaves

List of all devices upon which no other devices exist.

recursive_remove(device, actions=True, remove_device=True, modparent=True)

Remove a device after removing its dependent devices.

:param StorageDevice device: the device to remove :keyword bool actions: whether to schedule actions for the removal :keyword bool modparent: whether to update parent device upon removal :keyword bool remove_device: whether to remove the root device

If the device is not a leaf, all of its dependents are removed recursively until it is a leaf device. At that point the device is removed, unless it is a disk. If the device is a disk, its formatting is removed but no attempt is made to actually remove the disk device.

reset(conf=None)

Reset the instance to its initial state.

resolve_device(devspec, blkid_tab=None, crypt_tab=None, options=None)

Return the device matching the provided device specification.

The spec can be anything from a device name (eg: ‘sda3’) to a device node path (eg: ‘/dev/mapper/fedora-root’ or ‘/dev/dm-2’) to something like ‘UUID=xyz-tuv-qrs’ or ‘LABEL=rootfs’.

Parameters:
  • devspec (str) – a string describing a block device
  • blkid_tab (BlkidTab) – blkid info
  • crypt_tab (CryptTab) – crypto info
  • options (str) – mount options
Returns:

the device

Return type:

StorageDevice or None

setup_all()

Run setup methods on all devices.

teardown_all()

Run teardown methods on all devices.

unhide(device)

Restore a device’s visibility.

Parameters:device (StorageDevice) – the device to restore/unhide

Note

Actions canceled while hiding the device are not rescheduled automatically.

uuids

Dict with uuid keys and Device values.

blivet.errors module

exception blivet.errors.AlignmentError(*args, **kwargs)

Bases: blivet.errors.DiskLabelError

exception blivet.errors.AvailabilityError(*args, **kwargs)

Bases: blivet.errors.StorageError

Raised if problem determining availability of external resource.

exception blivet.errors.BTRFSError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.BTRFSValueError(*args, **kwargs)

Bases: blivet.errors.BTRFSError, ValueError

exception blivet.errors.CorruptGPTError(*args, **kwargs)

Bases: blivet.errors.UnusableConfigurationError

suggestion = 'Either restore the disklabel to a completely working state or remove it completely.\nHint: parted can restore it or wipefs can remove it.'
exception blivet.errors.DMError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.DMRaidMemberError(*args, **kwargs)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.DependencyError(*args, **kwargs)

Bases: blivet.errors.StorageError

Raised when an external dependency is missing or not available

exception blivet.errors.DeviceActionError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.DeviceCreateError(*args, **kwargs)

Bases: blivet.errors.DeviceError

exception blivet.errors.DeviceDestroyError(*args, **kwargs)

Bases: blivet.errors.DeviceError

exception blivet.errors.DeviceError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.DeviceFactoryError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.DeviceFormatError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.DeviceNotFoundError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.DeviceResizeError(*args, **kwargs)

Bases: blivet.errors.DeviceError

exception blivet.errors.DeviceSetupError(*args, **kwargs)

Bases: blivet.errors.DeviceError

exception blivet.errors.DeviceTeardownError(*args, **kwargs)

Bases: blivet.errors.DeviceError

exception blivet.errors.DeviceTreeError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.DeviceUserDeniedFormatError(*args, **kwargs)

Bases: blivet.errors.DeviceError

exception blivet.errors.DiskLabelCommitError(*args, **kwargs)

Bases: blivet.errors.DiskLabelError

exception blivet.errors.DiskLabelError(*args, **kwargs)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.DiskLabelScanError(*args, **kwargs)

Bases: blivet.errors.UnusableConfigurationError

suggestion = 'For some reason we were unable to locate a disklabel on a disk that the kernel is reporting partitions on. It is unclear what the exact problem is. Please file a bug at http://bugzilla.redhat.com'
exception blivet.errors.DuplicateVGError(*args, **kwargs)

Bases: blivet.errors.UnusableConfigurationError

suggestion = "Rename one of the volume groups so the names are distinct.\nHint 1: vgrename accepts UUID in place of the old name.\nHint 2: You can get the VG UUIDs by running 'pvs -o +vg_uuid'."
exception blivet.errors.EventHandlingError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.EventManagerError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.EventParamError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.FSError(*args, **kwargs)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.FSReadLabelError(*args, **kwargs)

Bases: blivet.errors.FSError

exception blivet.errors.FSResizeError(message, details)

Bases: blivet.errors.FSError

exception blivet.errors.FSTabTypeMismatchError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.FSWriteLabelError(*args, **kwargs)

Bases: blivet.errors.FSError

exception blivet.errors.FormatCreateError(*args, **kwargs)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.FormatDestroyError(*args, **kwargs)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.FormatResizeError(message, details)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.FormatSetupError(*args, **kwargs)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.FormatTeardownError(*args, **kwargs)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.InvalidDiskLabelError(*args, **kwargs)

Bases: blivet.errors.DiskLabelError

exception blivet.errors.LUKSError(*args, **kwargs)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.MDMemberError(*args, **kwargs)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.MPathError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.MultipathMemberError(*args, **kwargs)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.NoDisksError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.NotEnoughFreeSpaceError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.PartitioningError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.PhysicalVolumeError(*args, **kwargs)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.RaidError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.SinglePhysicalVolumeError(*args, **kwargs)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.SizePlacesError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.StorageError(*args, **kwargs)

Bases: Exception

exception blivet.errors.SwapSpaceError(*args, **kwargs)

Bases: blivet.errors.DeviceFormatError

exception blivet.errors.ThreadError(*args, **kwargs)

Bases: blivet.errors.StorageError

An error occurred in a non-main thread.

exception blivet.errors.UdevError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.UnknownSourceDeviceError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.UnrecognizedFSTabEntryError(*args, **kwargs)

Bases: blivet.errors.StorageError

exception blivet.errors.UnusableConfigurationError(*args, **kwargs)

Bases: blivet.errors.StorageError

User has an unusable initial storage configuration.

suggestion = ''

blivet.fcoe module

class blivet.fcoe.FCoE

Bases: object

FCoE utility class.

This class will automatically discover and connect to EDD configured FCoE SAN’s when the startup() method gets called. It can also be used to manually configure FCoE SAN’s through the add_san() method.

As this class needs to make sure certain things like starting fcoe daemons and connecting to firmware discovered SAN’s only happens once and as it keeps a global list of all FCoE devices it is implemented as a Singleton.

Warning

Since this is a singleton class, calling deepcopy() on the instance just returns self with no copy being created.

add_san(nic, dcb=False, auto_vlan=True)

Activates FCoE SANs attached to interface specified by nic.

Returns error message, or empty string if succeeded.

startup()
write(root)
blivet.fcoe.has_fcoe()

blivet.flags module

class blivet.flags.Flags

Bases: object

get_boot_cmdline()
update_from_anaconda_flags(anaconda_flags)
update_from_boot_cmdline()

blivet.i18n module

blivet.i18n.N_(x)
blivet.i18n.P_(x, y, z)

blivet.iscsi module

class blivet.iscsi.LoginInfo(node, logged_in)

Bases: object

class blivet.iscsi.NodeInfo(name, tpgt, address, port, iface)

Bases: tuple

address

Alias for field number 2

iface

Alias for field number 4

name

Alias for field number 0

port

Alias for field number 3

tpgt

Alias for field number 1

class blivet.iscsi.TargetInfo(ipaddr, port)

Bases: tuple

ipaddr

Alias for field number 0

port

Alias for field number 1

blivet.iscsi.has_iscsi()
class blivet.iscsi.iSCSI

Bases: object

iSCSI utility class.

This class will automatically discover and login to iBFT (or other firmware) configured iscsi devices when the startup() method gets called. It can also be used to manually configure iscsi devices through the add_target() method.

As this class needs to make sure certain things like starting iscsid and logging in to firmware discovered disks only happens once and as it keeps a global list of all iSCSI devices it is implemented as a Singleton.

Warning

Since this is a singleton class, calling deepcopy() on the instance just returns self with no copy being created.

active_nodes(target=None)

Nodes logged in to

add_target(ipaddr, port='3260', user=None, pw=None, user_in=None, pw_in=None, target=None, iface=None, discover_user=None, discover_pw=None, discover_user_in=None, discover_pw_in=None)

Connect to iSCSI server specified by IP address and port and add all targets found on the server and authenticate if necessary. If the target parameter is set, connect only to this target.

NOTE: the iSCSI target can have two sets of different authentication
credentials - one for discovery and one for logging into nodes
Parameters:
  • ipaddr (str) – target IP address
  • port (str) – target port
  • user (str or NoneType) – CHAP username for node login
  • pw (str or NoneType) – CHAP password for node login
  • user_in – reverse CHAP username for node login
  • pw_in (str or NoneType) – reverse CHAP password for node login
  • target (str or NoneType) – only add this target (if present)
  • iface (str or NoneType) – interface to use
  • discover_user (str or NoneType) – CHAP username for discovery
  • discover_pw (str or NoneType) – CHAP password for discovery
  • discover_user_in – reverse CHAP username for discovery
  • discover_pw_in (str or NoneType) – reverse CHAP password for discovery
available
create_interfaces(ifaces)
delete_interfaces()
discover(ipaddr, port='3260', username=None, password=None, r_username=None, r_password=None)

Discover iSCSI nodes on the target available for login.

If we are logged in a node discovered for specified target do not do the discovery again as it can corrupt credentials stored for the node (set_auth and get_auth are using database in /var/lib/iscsi/nodes which is filled by discovery). Just return nodes obtained and stored in the first discovery instead.

Returns list of nodes user can log in.

get_node(name, address, port, iface)
get_node_disks(node, storage)
initiator
log_into_node(node, username=None, password=None, r_username=None, r_password=None)
Parameters:
  • node (NodeInfo) – node to log into
  • username (str) – username to use when logging in
  • password (str) – password to use when logging in
  • r_username (str) – r_username to use when logging in
  • r_password (str) – r_password to use when logging in
mode
stabilize()
startup()
write(root, storage)
class blivet.iscsi.iSCSIDependencyGuard(exn_cls=<class 'blivet.errors.DependencyError'>)

Bases: blivet.util.DependencyGuard

error_msg = 'storaged iSCSI functionality not available'
blivet.iscsi.iscsi = <blivet.iscsi.iSCSI object>

An instance of iSCSI

blivet.mounts module

class blivet.mounts.MountsCache

Bases: object

Cache object for system mountpoints; checks /proc/mounts and /proc/self/mountinfo for up-to-date information.

get_mountpoints(devspec, subvolspec=None)

Get mountpoints for selected device

Parameters:
  • devscpec – device specification, eg. “/dev/vda1”
  • subvolspec (object (may be NoneType)) – btrfs subvolume specification, eg. ID or name
Returns:

list of mountpoints (path)

Return type:

list of str or empty list

Note

Devices can be mounted on multiple paths, and paths can have multiple devices mounted to them (hiding previous mounts). Callers should take this into account.

is_mountpoint(path)

Check to see if a path is already mounted

Parameters:path (str) – Path to check

blivet.osinstall module

This module provides functions related to OS installation.

class blivet.osinstall.BlkidTab(chroot='')

Bases: object

Dictionary-like interface to blkid.tab with device path keys

get(key, default=None)
parse()
class blivet.osinstall.CryptTab(devicetree, blkid_tab=None, chroot='')

Bases: object

Dictionary-like interface to crypttab entries with map name keys

crypttab()

Write out /etc/crypttab

get(key, default=None)
parse(chroot='')

Parse /etc/crypttab from an existing installation.

populate()

Populate the instance based on the device tree’s contents.

class blivet.osinstall.FSSet(devicetree)

Bases: object

A class to represent a set of filesystems.

add_fstab_swap(device)

Add swap device to the list of swaps that should appear in the fstab.

Parameters:device (blivet.devices.StorageDevice instance holding a swap format) – swap device that should be added to the list
create_swap_file(device, size)

Create and activate a swap file under storage root.

crypttab()
dev
devices
devpts
devshm
efivars
fstab()
mdadm_conf()

Return the contents of mdadm.conf.

mk_dev_root()
mount_filesystems(root_path='', read_only=None, skip_root=False)

Mount the system’s filesystems.

Parameters:
  • root_path (str) – the root directory for this filesystem
  • read_only (str or None) – read only option str for this filesystem
  • skip_root (bool) – whether to skip mounting the root filesystem
mountpoints
parse_fstab(chroot=None)

parse /etc/fstab

preconditions:
all storage devices have been scanned, including filesystems

postconditions:

FIXME: control which exceptions we raise

XXX do we care about bind mounts?
how about nodev mounts? loop mounts?
proc
remove_fstab_swap(device)

Remove swap device from the list of swaps that should appear in the fstab.

Parameters:device (blivet.devices.StorageDevice instance holding a swap format) – swap device that should be removed from the list
root_device
run
selinux
set_fstab_swaps(devices)

Set swap devices that should appear in the fstab.

Parameters:devices (iterable providing blivet.devices.StorageDevice instances holding a swap format) – iterable providing devices that should appear in the fstab
swap_devices
sysfs
turn_on_swap(root_path='')

Activate the system’s swap space.

umount_filesystems(swapoff=True)

unmount filesystems, except swap if swapoff == False

usb
write()

write out all config files based on the set of filesystems

class blivet.osinstall.Root(mounts=None, swaps=None, name=None)

Bases: object

A Root represents an existing OS installation.

Parameters:
  • mounts (dict (mountpoint keys and StorageDevice values)) – mountpoint dict
  • swaps (list of StorageDevice) – swap device list
  • name (str) – name for this installed OS
device
blivet.osinstall.find_existing_installations(devicetree, teardown_all=True)

Find existing GNU/Linux installations on devices from the devicetree. :param devicetree: devicetree to find existing installations in :type devicetree: DeviceTree :param bool teardown_all: whether to tear down all devices in the

devicetree in the end
Returns:roots of all found installations
Return type:list of Root
blivet.osinstall.get_containing_device(path, devicetree)

Return the device that a path resides on.

blivet.osinstall.get_release_string()

Attempt to identify the installation of a Linux distribution by checking a previously mounted filesystem for several files. The filesystem must be mounted under the target physical root.

Returns:The machine’s arch, distribution name, and distribution version

or None for any parts that cannot be determined :rtype: (string, string, string)

blivet.osinstall.mount_existing_system(fsset, root_device, read_only=None)

Mount filesystems specified in root_device’s /etc/fstab file.

blivet.osinstall.parse_fstab(devicetree, chroot=None)

parse /etc/fstab and return a tuple of a mount dict and swap list

blivet.osinstall.release_from_os_release(fn)

Attempt to identify the installation of a Linux distribution via /etc/os-release. This file must already have been verified to exist and be readable.

Parameters:fn (filehandle) – an open filehandle on /etc/os-release
Returns:The distribution’s name and version, or None for either or both

if they cannot be determined :rtype: (string, string)

blivet.osinstall.release_from_redhat_release(fn)

Attempt to identify the installation of a Linux distribution via /etc/redhat-release. This file must already have been verified to exist and be readable.

Parameters:fn (filehandle) – an open filehandle on /etc/redhat-release
Returns:The distribution’s name and version, or None for either or both

if they cannot be determined :rtype: (string, string)

blivet.osinstall.storage_initialize(storage, ksdata, protected)

Perform installer-specific storage initialization.

blivet.osinstall.turn_on_filesystems(storage, mount_only=False, callbacks=None)

Perform installer-specific activation of storage configuration.

Parameters:callbacks (return value of the create_new_callbacks_register()) – callbacks to be invoked when actions are executed
blivet.osinstall.write_escrow_packets(storage)

blivet.partitioning module

class blivet.partitioning.Chunk(length, requests=None)

Bases: object

A free region from which devices will be allocated

Parameters:
  • length (int) – the length of the chunk (units vary with subclass)
  • requests (list of Request) – list of requests to add
add_request(req)

Add a request to this chunk.

Parameters:req (Request) – the request to add
done

True if we are finished growing all requests in this chunk.

grow_requests(uniform=False)

Calculate growth amounts for requests in this chunk.

Parameters:uniform (bool) – grow requests uniformly instead of proportionally

The default mode of growth is as follows: given a total number of available units, requests receive an allotment proportional to their base sizes. That means a request with base size 1000 will grow four times as fast as a request with base size 250.

Under uniform growth, all requests receive an equal portion of the free units.

growth

Sum of growth for all requests in this chunk.

has_growable

True if this chunk contains at least one growable request.

length_to_size(length)
max_growth(req)
reclaim(request, amount)

Reclaim units from a request and return them to the pool.

Parameters:
  • request (Request) – the request to reclaim units from
  • amount (int) – number of units to reclaim from the request
Raises:

ValueError

Returns:

None

remaining

Number of requests still being grown in this chunk.

size_to_length(size)
sort_requests()
trim_over_grown_request(req, base=None)

Enforce max growth and return extra units to the pool.

Parameters:
  • req (Request) – the request to trim
  • base (int) – base unit count to adjust if req is done growing
Returns:

the new base or None if no base was given

Return type:

int or None

class blivet.partitioning.DiskChunk(geometry, requests=None)

Bases: blivet.partitioning.Chunk

A free region on disk from which partitions will be allocated

Parameters:
  • geometry (parted.Geometry) – the free region this chunk represents
  • requests (list of PartitionRequest) – list of requests to add initially

Note

We will limit partition growth based on disklabel limitations for partition end sector, so a 10TB disk with an msdos disklabel will be treated like a 2TiB disk.

Note

If you plan to allocate aligned partitions you should pass in an aligned geometry instance.

add_request(req)

Add a request to this chunk.

Parameters:req (PartitionRequest) – the request to add
length_to_size(length)
max_growth(req)

Return the maximum possible growth for a request.

Parameters:req (PartitionRequest) – the request
size_to_length(size)
sort_requests()
class blivet.partitioning.LVRequest(lv)

Bases: blivet.partitioning.Request

Parameters:lv (LVMLogicalVolumeDevice) – the logical volume being requested
reserve_request
class blivet.partitioning.PartitionRequest(partition)

Bases: blivet.partitioning.Request

Parameters:partition (PartitionDevice) – the partition being requested
class blivet.partitioning.Request(device)

Bases: object

A partition request.

Request instances are used for calculating how much to grow partitions.

Parameters:device (StorageDevice) – the device being requested
growable

True if this request is growable.

id

The id of the Device instance this request corresponds to.

reserve_request

Requested reserved fixed extra space for the request (in sectors)

class blivet.partitioning.SameSizeSet(devices, size, grow=False, max_size=None)

Bases: object

Set of device requests with a common target size.

Parameters:
  • devices (list of PartitionDevice) – the set of devices
  • size (Size) – target size for each device/request
  • grow (bool) – whether the devices can be grown
  • max_size (Size) – the maximum size for growable devices
class blivet.partitioning.ThinPoolChunk(pool, requests=None)

Bases: blivet.partitioning.VGChunk

A free region in an LVM thin pool from which LVs will be allocated

Parameters:
  • pool (LVMLogicalVolumeDevice) – the thin pool whose free space this chunk represents
  • requests (list of LVRequest) – list of requests to add initially
class blivet.partitioning.TotalSizeSet(devices, size)

Bases: object

Set of device requests with a target combined size.

This will be handled by growing the requests until the desired combined size has been achieved.

Parameters:
  • devices (list of PartitionDevice) – the set of devices
  • size (Size) – the target combined size
allocate(amount)
deallocate(amount)
needed
class blivet.partitioning.VGChunk(vg, requests=None)

Bases: blivet.partitioning.Chunk

A free region in an LVM VG from which LVs will be allocated

Parameters:
  • vg (LVMVolumeGroupDevice) – the volume group whose free space this chunk represents
  • requests (list of LVRequest) – list of requests to add initially
add_request(req)

Add a request to this chunk.

Parameters:req (LVRequest) – the request to add
length_to_size(length)
size_to_length(size)
sort_requests()
blivet.partitioning.add_partition(disklabel, free, part_type, size, start=None, end=None)

Add a new partition to a disk.

Parameters:
  • disklabel (DiskLabel) – the disklabel to add the partition to
  • free (parted.Geometry) – the free region in which to place the new partition
  • part_type (a parted.PARTITION_* constant) – the partition type
  • size (Size) – size of the new partition
  • start (int) – starting sector for the partition
  • end (int) – ending sector for the partition
Raises:

PartitioningError

Returns:

the newly added partitions

Return type:

parted.Partition

Note

The new partition will be aligned using the kernel-provided optimal alignment unless a start sector is provided.

blivet.partitioning.align_size_for_disklabel(size, disklabel)
blivet.partitioning.allocate_partitions(storage, disks, partitions, freespace)

Allocate partitions based on requested features.

Parameters:
  • storage (Blivet) – a Blivet instance
  • disks (list of StorageDevice) – list of usable disks
  • partitions (list of PartitionDevice) – list of partitions
  • freespace (list of parted.Geometry) – list of free regions on disks
Raises:

PartitioningError

Returns:

None

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

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

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

blivet.partitioning.do_partitioning(storage)

Allocate and grow partitions.

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

Parameters:storage (Blivet) – Blivet instance
Raises:PartitioningError
Returns:None
blivet.partitioning.get_best_free_space_region(disk, part_type, req_size, start=None, boot=None, best_free=None, grow=None, alignment=None)

Return the “best” free region on the specified disk.

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

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

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

Parameters:
  • disk (parted.Disk) – the disk
  • part_type (one of parted’s PARTITION_* constants) – the type of partition we want to allocate
  • req_size (Size) – the requested size of the partition in MiB
  • start (int) – requested start sector for the partition
  • boot (bool) – whether this will be a bootable partition
  • best_free (parted.Geometry) – current best free region for this partition
  • grow (bool) – indicates whether this is a growable request
  • alignment (parted.Alignment) – disk alignment requirements
blivet.partitioning.get_disk_chunks(disk, partitions, free)

Return a list of Chunk instances representing a disk.

Parameters:
  • disk (StorageDevice) – the disk
  • partitions (list of PartitionDevice) – list of partitions
  • free (list of parted.Geometry) – list of free regions
Returns:

list of chunks representing the disk

Return type:

list of DiskChunk

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

Chunks contain an aligned version of the free region’s geometry.

blivet.partitioning.get_free_regions(disks, align=False)

Return a list of free regions on the specified disks.

Parameters:
  • disks (list of Disk) – list of disks
  • align (bool) – align the region length to disk grain_size
Returns:

list of free regions

Return type:

list of parted.Geometry

Only free regions guaranteed to contain at least one aligned sector for both the start and end alignments in the DiskLabel are returned.

blivet.partitioning.get_next_partition_type(disk, no_primary=None)

Return the type of partition to create next on a disk.

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

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

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

Parameters:
  • disk (parted.Disk) – the disk from which a partition may be allocated
  • no_primary – refuse to return parted.PARTITION_NORMAL
Returns:

the chosen partition type

Return type:

a parted PARTITION_* constant

blivet.partitioning.grow_lvm(storage)

Grow LVs according to the sizes of the PVs.

Strategy for growth involving thin pools:
  • Applies to device factory class as well.
  • Overcommit is not allowed.
  • Pool lv’s base size includes sizes of thin lvs within it.
  • Pool is grown along with other non-thin lvs.
  • Thin lvs within each pool are grown separately using the ThinPoolChunk class.
blivet.partitioning.grow_partitions(disks, partitions, free, size_sets=None)

Grow all growable partition requests.

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

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

Parameters:
  • disks (list of StorageDevice) – all usable disks
  • partitions (list of PartitionDevice) – all partitions
  • free (list of parted.Geometry) – all free regions on disks
  • size_sets (list of TotalSizeSet or SameSizeSet) – list of size-related partition sets
Returns:

None

blivet.partitioning.lv_compare(lv1, lv2)

More specifically defined lvs come first.

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

> 1 => x > y

blivet.partitioning.manage_size_sets(size_sets, chunks)
blivet.partitioning.partition_compare(part1, part2)

More specifically defined partitions come first.

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

> 1 => x > y

Parameters:
  • part1 (devices.PartitionDevice) – the first partition
  • part2 (devices.PartitionDevice) – the other partition
Returns:

see above

Return type:

int

blivet.partitioning.remove_new_partitions(disks, remove, all_partitions)

Remove newly added partitions from disks.

Remove all non-existent partitions from the disks in blivet’s model.

Param:

disks: list of partitioned disks

Parameters:
  • remove (list of PartitionDevice) – list of partitions to remove
  • all_partitions (list of PartitionDevice) – list of all partitions on the disks
Returns:

None

Return type:

NoneType

blivet.partitioning.sectors_to_size(sectors, sector_size)

Convert length in sectors to size.

Parameters:
  • sectors (int) – sector count
  • sector_size (Size) – sector size
Returns:

the size

Return type:

Size

blivet.partitioning.size_to_sectors(size, sector_size)

Convert size to length in sectors.

Parameters:
  • size (Size) – size
  • sector_size (Size) – sector size in bytes
Returns:

sector count

Return type:

int

blivet.partitioning.update_extended_partitions(storage, disks)

Reconcile extended partition changes with the DeviceTree.

Parameters:
  • storage (Blivet) – the Blivet instance
  • disks (list of StorageDevice) – list of disks
Returns:

None

Return type:

NoneType

blivet.partspec module

class blivet.partspec.PartSpec(mountpoint=None, fstype=None, size=None, max_size=None, grow=False, btr=False, lv=False, thin=False, weight=0, required_space=0, encrypted=False)

Bases: object

Create a new storage specification. These are used to specify the default partitioning layout as an object before we have the storage system up and running. The attributes are obvious except for the following:

btr – Should this be allocated as a btrfs subvolume? If not,
it will be allocated as a partition.
lv – Should this be allocated as a logical volume? If not,
it will be allocated as a partition.
thin – Should this be allocated as a thin logical volume if it is
being allocated as a logical volume?
weight – An integer that modifies the sort algorithm for partition
requests. A larger value means the partition will end up closer to the front of the disk. This is mainly used to make sure /boot ends up in front, and any special (PReP, appleboot, etc.) partitions end up in front of /boot. This value means nothing unless lv and btr are both False.
required_space – This value is only taken into account if
lv=True, and specifies the size in MiB that the containing VG must be for this PartSpec to even get used. The VG’s size is calculated before any other LVs are created inside it. If not enough space exists, this PartSpec will never get turned into an LV.
encrypted – Should this request be encrypted? For logical volume
requests, this is satisfied if the PVs are encrypted as in the case of encrypted LVM autopart.

blivet.platform module

class blivet.platform.ARM

Bases: blivet.platform.Platform

Creates a new Platform object. This is basically an abstract class. You should instead use one of the platform-specific classes as returned by get_platform below. Not all subclasses need to provide all the methods in this class.

arm_machine
weight(fstype=None, mountpoint=None)

Return the ARM platform-specific weight for the / partition. On ARM images ‘/’ must be the last partition, so we try to weight it accordingly.

class blivet.platform.Aarch64EFI

Bases: blivet.platform.EFI

Creates a new Platform object. This is basically an abstract class. You should instead use one of the platform-specific classes as returned by get_platform below. Not all subclasses need to provide all the methods in this class.

class blivet.platform.EFI

Bases: blivet.platform.Platform

Creates a new Platform object. This is basically an abstract class. You should instead use one of the platform-specific classes as returned by get_platform below. Not all subclasses need to provide all the methods in this class.

set_platform_bootloader_reqs()
weight(fstype=None, mountpoint=None)
class blivet.platform.IPSeriesPPC

Bases: blivet.platform.PPC

Creates a new Platform object. This is basically an abstract class. You should instead use one of the platform-specific classes as returned by get_platform below. Not all subclasses need to provide all the methods in this class.

set_platform_bootloader_reqs()
weight(fstype=None, mountpoint=None)
class blivet.platform.MacEFI

Bases: blivet.platform.EFI

Creates a new Platform object. This is basically an abstract class. You should instead use one of the platform-specific classes as returned by get_platform below. Not all subclasses need to provide all the methods in this class.

set_platform_bootloader_reqs()
class blivet.platform.NewWorldPPC

Bases: blivet.platform.PPC

Creates a new Platform object. This is basically an abstract class. You should instead use one of the platform-specific classes as returned by get_platform below. Not all subclasses need to provide all the methods in this class.

set_platform_bootloader_reqs()
weight(fstype=None, mountpoint=None)
class blivet.platform.PPC

Bases: blivet.platform.Platform

Creates a new Platform object. This is basically an abstract class. You should instead use one of the platform-specific classes as returned by get_platform below. Not all subclasses need to provide all the methods in this class.

ppc_machine
class blivet.platform.PS3

Bases: blivet.platform.PPC

Creates a new Platform object. This is basically an abstract class. You should instead use one of the platform-specific classes as returned by get_platform below. Not all subclasses need to provide all the methods in this class.

class blivet.platform.Platform

Bases: object

A class containing platform-specific information and methods for use during installation. The intent is to eventually encapsulate all the architecture quirks in one place to avoid lots of platform checks throughout anaconda.

Creates a new Platform object. This is basically an abstract class. You should instead use one of the platform-specific classes as returned by get_platform below. Not all subclasses need to provide all the methods in this class.

best_disklabel_type(device)

The best disklabel type for the specified device.

boot_stage1_constraint_dict
default_disklabel_type

The default disklabel type for this architecture.

disklabel_types

A list of valid disklabel types for this architecture.

packages
required_disklabel_type(device_type)
set_default_disklabel_type(disklabel)

Make the disklabel the default

Parameters:disklabel (str) – The disklabel type to set as default
Returns:True if successful False if disklabel not supported

If the disklabel is not supported on the platform it will return False and make no change to the disklabel list.

If it is supported it will move it to the start of the list, making it the default.

set_default_partitioning()

Return the default platform-specific partitioning information.

set_platform_boot_partition()

Return the default /boot partition for this platform.

set_platform_bootloader_reqs()

Return the required platform-specific bootloader partition information. These are typically partitions that do not get mounted, like biosboot or prepboot, but may also include the /boot/efi partition.

stage1MissingError

A platform-specific error message to be shown if stage1 target selection fails.

update_from_flags()
weight(fstype=None, mountpoint=None)

Given an fstype (as a string) or a mountpoint, return an integer for the base sorting weight. This is used to modify the sort algorithm for partition requests, mainly to make sure bootable partitions and /boot are placed where they need to be.

class blivet.platform.S390

Bases: blivet.platform.Platform

required_disklabel_type(device_type)

The required disklabel type for the specified device type.

set_platform_boot_partition()

Return the default platform-specific partitioning information.

class blivet.platform.X86

Bases: blivet.platform.Platform

set_platform_bootloader_reqs()

Return the default platform-specific partitioning information.

weight(fstype=None, mountpoint=None)
blivet.platform.get_platform()

Check the architecture of the system and return an instance of a Platform subclass to match. If the architecture could not be determined, raise an exception.

class blivet.platform.omapARM

Bases: blivet.platform.ARM

Creates a new Platform object. This is basically an abstract class. You should instead use one of the platform-specific classes as returned by get_platform below. Not all subclasses need to provide all the methods in this class.

set_default_partitioning()
set_platform_bootloader_reqs()

Return the ARM-OMAP platform-specific partitioning information.

weight(fstype=None, mountpoint=None)

Return the ARM-OMAP platform-specific weights for the uboot and / partitions. On OMAP, uboot must be the first partition, and ‘/’ must be the last partition, so we try to weight them accordingly.

blivet.safe_dbus module

Module providing thread-safe and mainloop-safe DBus operations.

exception blivet.safe_dbus.DBusCallError

Bases: blivet.safe_dbus.SafeDBusError

Class for the errors related to calling methods over DBus.

exception blivet.safe_dbus.DBusPropertyError

Bases: blivet.safe_dbus.DBusCallError

Class for the errors related to getting property values over DBus.

exception blivet.safe_dbus.SafeDBusError

Bases: Exception

Class for exceptions defined in this module.

blivet.safe_dbus.call_sync(service, obj_path, iface, method, args, connection=None)

Safely call a given method on a given object of a given service over DBus passing given arguments. If a connection is given, it is used, otherwise a new connection is established. Safely means that it is a synchronous, thread-safe call not using any main loop.

Parameters:
  • service (str) – DBus service to use
  • obj_path (str) – object path of the object to call method on
  • iface (str) – interface to use
  • method (str) – name of the method to call
  • args (GVariant) – arguments to pass to the method
  • connection (Gio.DBusConnection) – connection to use (if None, a new connection is established)
Returns:

unpacked value returned by the method

Return type:

tuple with elements that depend on the method

Raises DBusCallError:
 

if some DBus related error appears

blivet.safe_dbus.check_object_available(service, obj_path, iface=None)
blivet.safe_dbus.get_new_session_connection()

Get a connection handle for the per-user-login-session message bus.

!!! RUN THIS EARLY !!! like, before any other threads start. Connections to the session bus must be made with the effective UID of the login user, which in live installs is not the UID of anaconda. This means we need to call seteuid in this method, and doing that after threads have started will probably do something weird.

Live installs use consolehelper to run as root, which sets the original UID in $USERHELPER_UID.

Returns:

the session connection handle

Return type:

Gio.DBusConnection

Raises:
  • DBusCallError – if some DBus related error appears
  • OSError – if unable to set the effective UID
blivet.safe_dbus.get_new_system_connection()

Return a new connection to the system bus.

blivet.safe_dbus.get_property_sync(service, obj_path, iface, prop_name, connection=None)

Get value of a given property of a given object provided by a given service.

Parameters:
  • service (str) – DBus service to use
  • obj_path (str) – object path
  • iface (str) – interface to use
  • prop_name (str) – name of the property
  • connection (Gio.DBusConnection) – connection to use (if None, a new connection is established)
Returns:

unpacked value of the property

Return type:

tuple with elements that depend on the type of the property

Raises:
  • DBusCallError – when the internal dbus_call_safe_sync invocation raises an exception
  • DBusPropertyError – when the given object doesn’t have the given property

blivet.size module

class blivet.size.Size

Bases: decimal.Decimal

Common class to represent storage device and filesystem sizes. Can handle parsing strings such as 45MB or 6.7GB to initialize itself, or can be initialized with a numerical size in bytes. Also generates human readable strings to a specified number of decimal places.

convert_to(spec=None)

Return the size in the units indicated by the specifier.

Parameters:spec (a units specifier or Size) – a units specifier
Returns:a numeric value in the units indicated by the specifier
Return type:Decimal
Raises ValueError:
 if Size unit specifier is non-positive

New in version 1.6: spec parameter may be Size as well as units specifier.

human_readable(max_places=2, strip=True, min_value=1, xlate=True)

Return a string representation of this size with appropriate size specifier and in the specified number of decimal places. Values are always represented using binary not decimal units. For example, if the number of bytes represented by this size is 65531, expect the representation to be something like 64.00 KiB, not 65.53 KB.

Parameters:
  • max_places (an integer type or NoneType) – number of decimal places to use, default is 2
  • strip (bool) – True if trailing zeros are to be stripped.
  • min_value (A precise numeric type: int, long, or Decimal) – Lower bound for value, default is 1.
  • xlate (bool) – If True, translate for current locale
Returns:

a representation of the size

Return type:

str

If max_places is set to None, all non-zero digits will be shown. Otherwise, max_places digits will be shown.

If strip is True and there is a fractional quantity, trailing zeros are removed up to the decimal point.

min_value sets the smallest value allowed. If min_value is 10, then single digits on the lhs of the decimal will be avoided if possible. In that case, 9216 KiB is preferred to 9 MiB. However, 1 B has no alternative. If min_value is 1, however, 9 MiB is preferred. If min_value is 0.1, then 0.75 GiB is preferred to 768 MiB, but 0.05 GiB is still displayed as 51.2 MiB.

human_readable() is a function that evaluates to a number which represents a range of values. For a constant choice of max_places, all ranges are of equal size, and are bisected by the result. So, if n.human_readable() == x U and b is the number of bytes in 1 U, and e = 1/2 * 1/(10^max_places) * b, then x - e < n < x + e.

round_to_nearest(unit, rounding='ROUND_HALF_UP')

Rounds to nearest unit specified as a named constant or a Size.

Parameters:
  • unit (a named constant like KiB, or any non-negative Size) – a unit specifier
  • rounding (one of ROUND_UP, ROUND_DOWN, or ROUND_DEFAULT) – which direction to round
Returns:

Size rounded to nearest whole specified unit

Return type:

Size

If unit is Size(0), returns Size(0).

blivet.size.parse_spec(spec)

Parse string representation of size.

Parameters:spec (any type of string like object) – the specification of a size with, optionally, units
Returns:numeric value of the specification in bytes
Return type:Decimal
Raises ValueError:
 if spec is unparseable

Tries to parse the spec first as English, if that fails, as a locale specific string.

blivet.size.parse_units(spec, xlate)

Parse a unit specification and return corresponding factor.

Parameters:
  • spec (any type of string like object) – a units specifier
  • xlate (bool) – if True, assume locale specific
Returns:

a named constant corresponding to spec, if found

Return type:

_Prefix or NoneType

Looks first for exact matches for a specifier, but, failing that, searches for partial matches for abbreviations.

Normalizes units to lowercase, e.g., MiB and mib are treated the same.

blivet.size.unit_str(unit, xlate=False)

Return a string representation of unit.

Parameters:
  • unit – a named unit, e.g., KiB
  • xlate (bool) – if True, translate to current locale
Return type:

some kind of string type

Returns:

string representation of unit

blivet.storage_log module

blivet.storage_log.function_name_and_depth()
blivet.storage_log.log_exception_info(log_func=<bound method Logger.debug of <logging.Logger object at 0x7fab2e278ac8>>, fmt_str=None, fmt_args=None, ignored=True)

Log detailed exception information.

Parameters:
  • log_func – the desired logging function
  • fmt_str (str) – a format string for any additional message
  • fmt_args (a list of str) – arguments for the format string
  • ignored (bool) – True if no action is taken regarding the exception

Note: the logging function indicates the severity level of this exception according to the calling function. log.debug, the default, is the lowest level.

Note: If the ignored flag is set, each line of the exception information is prepended with an ‘IGNORED’ prefix.

blivet.storage_log.log_method_call(d, *args, **kwargs)
blivet.storage_log.log_method_return(d, retval)

blivet.threads module

class blivet.threads.SynchronizedABCMeta

Bases: blivet.threads.SynchronizedMeta, abc.ABCMeta

class blivet.threads.SynchronizedMeta

Bases: type

Metaclass that wraps all methods with the exclusive decorator.

To prevent specific methods from being wrapped, add the method name(s) to a class attribute called _unsynchronized_methods (list of str).

blivet.threads.clear_thread_exception()
blivet.threads.exclusive(m)

Run a callable while holding the global lock.

blivet.threads.get_thread_exception()
blivet.threads.save_thread_exception(thread, exc_info)

blivet.tsort module

exception blivet.tsort.CyclicGraphError

Bases: Exception

blivet.tsort.create_graph(items, edges)

Create a graph based on a list of items and a list of edges.

Arguments:

items - an iterable containing (hashable) items to sort edges - an iterable containing (parent, child) edge pair tuples

Return Value:

The return value is a dictionary representing the directed graph. It has three keys:

items is the same as the input argument of the same name edges is the same as the input argument of the same name incoming is a dict of incoming edge count hashed by item
blivet.tsort.main()
blivet.tsort.tsort(graph)

blivet.udev module

blivet.udev.INSTALLER_BLACKLIST = ('^mtd', '^mmcblk.+boot', '^mmcblk.+rpmb', '^zram')

device name regexes to ignore when flags.installer_mode is True

blivet.udev.device_dm_subsystem_match(info, subsystem)

Return True if the device matches a given device-mapper subsystem.

blivet.udev.device_get_bus(udev_info)

Get the bus a device is connected to the system by.

blivet.udev.device_get_by_path(info)
blivet.udev.device_get_dasd_bus_id(info)

Return the CCW bus ID of the dasd device.

blivet.udev.device_get_dasd_flag(info, flag=None)

Return the specified flag for the dasd device.

blivet.udev.device_get_devname(info)
blivet.udev.device_get_disklabel_type(info)

Return the type of disklabel on the device or None.

blivet.udev.device_get_disklabel_uuid(info)
blivet.udev.device_get_fcoe_identifier(info)
blivet.udev.device_get_fcoe_nic(info)
blivet.udev.device_get_format(udev_info)

Return a device’s format type as reported by udev.

blivet.udev.device_get_iscsi_address(info)
blivet.udev.device_get_iscsi_initiator(info)
blivet.udev.device_get_iscsi_name(info)
blivet.udev.device_get_iscsi_nic(info)
blivet.udev.device_get_iscsi_port(info)
blivet.udev.device_get_iscsi_session(info)
blivet.udev.device_get_label(udev_info)

Get the label from the device’s format as reported by udev.

blivet.udev.device_get_lv_attr(info)
blivet.udev.device_get_lv_name(info)
blivet.udev.device_get_lv_size(info)
blivet.udev.device_get_lv_type(info)
blivet.udev.device_get_lv_uuid(info)
blivet.udev.device_get_lv_vg_name(info)
blivet.udev.device_get_major(info)
blivet.udev.device_get_md_container(info)
Parameters:info (dict) – dictionary of name-value pairs as strings
Return type:str or NoneType
blivet.udev.device_get_md_device_uuid(info)

Returns the uuid of a device which is a member of an md array.

Parameters:info (dict) – dictionary of name-value pairs as strings
Returns:the uuid of this device (which is a member of an md array)
Return type:str or NoneType
blivet.udev.device_get_md_devices(info)

Returns the number of active devices in this device’s array.

Active devices are devices that are not spares or failed.

Parameters:info (dict) – dictionary of name-value pairs as strings
Returns:the number of devices belonging to this device’s md array
Return type:int
Raises:KeyError, ValueError
blivet.udev.device_get_md_level(info)

Returns the RAID level of the array of which this device is a member.

Parameters:info (dict) – dictionary of name-value pairs as strings
Returns:the RAID level of this device’s md array
Return type:str or NoneType
blivet.udev.device_get_md_metadata(info)

Return the metadata version number.

Parameters:info (dict) – dictionary of name-value pairs as strings
Returns:the metadata version number of the md array
Return type:str or NoneType
blivet.udev.device_get_md_name(info)

Returns the name of the array of which this device is a member.

Parameters:info (dict) – dictionary of name-value pairs as strings
Returns:the name of this device’s md array
Return type:str or NoneType
blivet.udev.device_get_md_uuid(info)

Returns the uuid of the array of which this device is a member.

Parameters:info (dict) – dictionary of name-value pairs as strings
Returns:the UUID of this device’s md array
Return type:str
Raises:KeyError
blivet.udev.device_get_minor(info)
blivet.udev.device_get_model(udev_info)

Get the model of the device as reported by udev.

blivet.udev.device_get_name(udev_info)

Return the best name for a device based on the udev db data.

blivet.udev.device_get_part_size(udev_info)

Get size for specified partition as reported by udev.

blivet.udev.device_get_partition_disk(info)
blivet.udev.device_get_partition_uuid(info)
blivet.udev.device_get_path(info)
blivet.udev.device_get_pv_pe_start(info)
blivet.udev.device_get_serial(udev_info)

Get the serial number/UUID from the device as reported by udev.

Get an array of symbolic links for a device.

Parameters:info – a pyudev.Device instance
Returns:list of symbolic links
Return type:list of str
blivet.udev.device_get_sysfs_path(info)
blivet.udev.device_get_uuid(udev_info)

Get the UUID from the device’s format as reported by udev.

Parameters:udev_info (dict) – dictionary of name-value pairs as strings
Returns:a UUID or None
Return type:str or NoneType
blivet.udev.device_get_vendor(udev_info)

Get the vendor of the device as reported by udev.

blivet.udev.device_get_vg_extent_count(info)
blivet.udev.device_get_vg_extent_size(info)
blivet.udev.device_get_vg_free(info)
blivet.udev.device_get_vg_free_extents(info)
blivet.udev.device_get_vg_name(info)
blivet.udev.device_get_vg_pv_count(info)
blivet.udev.device_get_vg_size(info)
blivet.udev.device_get_vg_uuid(info)
blivet.udev.device_get_wwid(udev_info)

The WWID of a device is typically just its serial number, but with colons in the name to make it more readable.

blivet.udev.device_get_zfcp_attribute(info, attr=None)

Return the value of the specified attribute of the zfcp device.

blivet.udev.device_is_biosraid_member(info)
blivet.udev.device_is_cciss(info)

Return True if the device is a CCISS device.

blivet.udev.device_is_cdrom(info)

Return True if the device is an optical drive.

blivet.udev.device_is_dasd(info)

Return True if the device is a dasd device.

blivet.udev.device_is_disk(info)

Return True is the device is a disk.

blivet.udev.device_is_dm(info)

Return True if the device is a device-mapper device.

blivet.udev.device_is_dm_anaconda(info)

Return True if the device is an anaconda disk image.

blivet.udev.device_is_dm_crypt(info)

Return True if the device is a mapped dm-crypt device.

blivet.udev.device_is_dm_livecd(info)

Return True if the device is a livecd OS image.

blivet.udev.device_is_dm_luks(info)

Return True if the device is a mapped LUKS device.

blivet.udev.device_is_dm_lvm(info)

Return True if the device is an LVM logical volume.

blivet.udev.device_is_dm_mpath(info)

Return True if the device is a multipath device.

blivet.udev.device_is_dm_partition(info)
blivet.udev.device_is_dm_raid(info)

Return True if the device is a dmraid array device.

blivet.udev.device_is_fcoe(info)
blivet.udev.device_is_iscsi(info)
blivet.udev.device_is_loop(info)

Return True if the device is a configured loop device.

blivet.udev.device_is_md(info)

Return True if the device is a mdraid array device.

blivet.udev.device_is_partition(info)
blivet.udev.device_is_partoff_iscsi(info)
blivet.udev.device_is_sw_iscsi(info)
blivet.udev.device_is_zfcp(info)

Return True if the device is a zfcp device.

blivet.udev.get_device(sysfs_path)
blivet.udev.get_devices(subsystem='block')
blivet.udev.resolve_devspec(devspec, sysname=False)
blivet.udev.resolve_glob(glob)
blivet.udev.settle(quiet=False)

Wait for the udev queue to settle.

Parameters:quiet (bool) – bypass blivet.util.run_program()
blivet.udev.trigger(subsystem=None, action='add', name=None)

blivet.util module

class blivet.util.DependencyGuard(exn_cls=<class 'blivet.errors.DependencyError'>)

Bases: object

check_avail(onetime=False)
error_msg

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.

class blivet.util.EvalMode

Bases: enum.Enum

An enumeration.

always = <EvalMode.always: 2>
onetime = <EvalMode.onetime: 1>
class blivet.util.ObjectID

Bases: object

This class is meant to be extended by other classes which require an ID which is preserved when an object copy is made. The value returned by the builtin function id() is not adequate: that value represents object identity so it is not in general preserved when the object is copied.

The name of the identifier property is id, its type is int.

The id is set during creation of the class instance to a new value which is unique for the object type. Subclasses can use self.id during __init__.

class blivet.util.Path

Bases: str

Path(path, root=None) provides a filesystem path object, which automatically normalizes slashes, assumes appends are what you always hoped os.path.join() was (but with out the weird slash games), and can easily handle paths with a root directory other than /

glob()

Similar to glob.glob(), except it takes the Path’s root into account when globbing and returns path objects with the same root, so you don’t have to think about that part.

newroot(newroot=None)

Change the root directory of this Path

normpath
ondisk

Path.ondisk evaluates as the real filesystem path of the path, including the path’s root in the data.

path
realpath
root
startswith(other)
blivet.util.canonicalize_UUID(a_uuid)

Converts uuids to canonical form.

Parameters:a_uuid (str) – the UUID
Returns:a canonicalized UUID
Return type:str

mdadm’s UUIDs are actual 128 bit uuids, but it formats them strangely. This converts the uuids to canonical form. Example:

mdadm UUID: ‘3386ff85:f5012621:4a435f06:1eb47236’

canonical UUID: ‘3386ff85-f501-2621-4a43-5f061eb47236’

If the UUID is already in canonical form, the conversion is equivalent to the identity.

blivet.util.capture_output(*args, **kwargs)
blivet.util.capture_output_binary(*args, **kwargs)
blivet.util.compare(first, second)

Compare two objects.

Parameters:
  • first – first object to compare
  • second – second object to compare
Returns:

0 if first == second, 1 if first > second, -1 if first < second

Return type:

int

This method replaces Python 2 cmp() built-in-function.

blivet.util.copy_to_system(source)
blivet.util.create_sparse_file(path, size)

Create a sparse file.

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

:param Size size: the size of the file :returns: None

blivet.util.create_sparse_tempfile(name, size)

Create a temporary sparse file.

Parameters:name (str) – suffix for filename

:param Size size: the file size :returns: the path to the newly created file

blivet.util.dedup_list(alist)

Deduplicates the given list by removing duplicates while preserving the order

blivet.util.default_namedtuple(name, fields, doc='')

Create a namedtuple class

The difference between a namedtuple class and this class is that default values may be specified for fields and fields with missing values on initialization being initialized to None.

Parameters:
  • name (str) – name of the new class
  • fields (list of str or (str, object) objects) – field descriptions - an iterable of either “name” or (“name”, default_value)
  • doc (str) – the docstring for the new class (should at least describe the meanings and types of fields)
Returns:

a new default namedtuple class

Return type:

type

blivet.util.deprecated(version, message)

Decorator to deprecate a function or method via warning and docstring.

Parameters:
  • version (str) – version in which the deprecation is effective
  • message (str) – message suggesting a preferred alternative

Note

At the point this decorator gets applied to a method in a class the method is just a function. It becomes a method later.

The docstring manipulation is performed only once for each decorated function/method, but the warning is issued every time the decorated function is called.

blivet.util.find_program_in_path(prog, raise_on_error=False)
blivet.util.get_cow_sysfs_path(dev_path, dev_sysfsPath)

Return sysfs path of cow device for a given device.

blivet.util.get_current_entropy()
blivet.util.get_mount_device(mountpoint)

Given a mountpoint, return the device node path mounted there.

blivet.util.get_mount_paths(dev)

Given a device node path, return a list of all active mountpoints.

Parameters:dev (str) – Device path
Returns:A list of mountpoints or []
Return type:list
blivet.util.get_option_value(opt_name, options)

Return the value of a named option in the specified options string.

blivet.util.get_sysfs_attr(path, attr, root=None)
blivet.util.get_sysfs_path_by_name(dev_node, class_name='block')

Return sysfs path for a given device.

For a device node (e.g. /dev/vda2) get the respective sysfs path (e.g. /sys/class/block/vda2). This also has to work for device nodes that are in a subdirectory of /dev like ‘/dev/cciss/c0d0p1’.

blivet.util.indent(text, spaces=4)

Indent text by a specified number of spaces.

Parameters:
  • text (str) – the text to indent
  • spaces (int) – the number of spaces to indent text

It would be nice if we could use textwrap.indent for this but, since it does not exist in python2, I prefer to just use this.

blivet.util.insert_colons(a_string)

Insert colon between every second character.

E.g. creates ‘al:go:ri:th:ms’ from ‘algoritms’. Useful for formatting MAC addresses and wwids for output.

blivet.util.join_paths(*paths)

Joins filesystem paths without any consiration of slashes or whatnot and then normalizes repeated slashes.

blivet.util.lsmod()

Returns list of names of all loaded modules.

blivet.util.makedirs(path)
blivet.util.match_path_context(path)

Return the default SELinux context for the given path.

blivet.util.md5_file(filename)
blivet.util.mount(device, mountpoint, fstype, options=None)
blivet.util.normalize_path_slashes(path)

Normalize the slashes in a filesystem path. Does not actually examine the filesystme in any way.

blivet.util.numeric_type(num)

Verify that a value is given as a numeric data type.

Return the number if the type is sensible or raise ValueError if not.

blivet.util.power_of_two(value)

Checks whether value is a power of 2 greater than 1.

Parameters:value (any) – a value
Returns:True if the value is a power of 2
Return type:bool
blivet.util.requires_property(prop_name, val=True)

Function returning a decorator that can be used to guard methods and properties with evaluation of the given property.

Parameters:
  • prop_name (str) – property to evaluate
  • val (Object (anything)) – guard value of the :param:`prop_name`
blivet.util.reset_file_context(path, root=None)

Restore the SELinux context of a file to its default value.

Arguments:

path filename string

Keyword Arguments:

root an optional chroot string

Return Value:

If successful, returns the file’s new/default context.
blivet.util.run_program(*args, **kwargs)
blivet.util.run_program_and_capture_output(*args, **kwargs)
blivet.util.run_program_and_capture_output_binary(*args, **kwargs)
blivet.util.set_file_context(path, context, root=None)

Set the SELinux file context of a file.

Arguments:

path filename string context context string

Keyword Arguments:

root an optional chroot string

Return Value:

True if successful, False if not.
blivet.util.set_up_console_log(log_names=None)
blivet.util.set_up_logging(log_dir='/tmp', log_prefix='blivet', console_logs=None)

Configure the blivet logger to write out a log file.

Parameters:
  • log_dir (str) – path to directory where log files are
  • log_prefix (str) – prefix for log file names
  • console_logs (list) – list of log names to output on the console
blivet.util.sparsetmpfile(name, size)

Context manager that creates a sparse tempfile and then unlinks it.

Parameters:name (str) – suffix for filename

:param Size size: the file size

Yields the path to the newly created file on __enter__.

blivet.util.stringize(inputstr)

Convert strings to a format compatible with Python 2’s str.

Parameters:inputstr (str) – the string to convert
Returns:a string with the correct type
Return type:str

This method is for use in __str__ calls to ensure that they always return a str. In Python 3, this method simply inputstr as a string. In Python 2, it converts unicode into str. The returned str in python 2 is encoded using utf-8.

blivet.util.total_memory()

Return the amount of system RAM.

Return type:Size
blivet.util.umount(mountpoint)
blivet.util.unicodeize(inputstr)

Convert strings to a format compatible with Python 2’s unicode.

Parameters:inputstr (str) – the string to convert
Returns:a string with the correct type
Return type:unicode

This method is for use in __unicode__ calls to ensure that they always return a unicode. This method does not handle non-ASCII characters in str parameters, but non-ASCII characters in unicode parameters will be correctly passed through.

blivet.util.variable_copy(obj, memo, omit=None, shallow=None, duplicate=None)

A configurable copy function. Any attributes not specified in omit, shallow, or duplicate are copied using copy.deepcopy().

Parameters:
  • obj (object) – a python object to be copied.
  • memo (dict) – a dictionary of already copied items
  • omit (iterable of str) – a list of names of attributes not to copy
  • shallow (iterable of str) – a list of names of attributes to shallow copy
  • duplicate (iterable of str) – a list of names of attributes to duplicate

Note that all atrributes in duplicate must implement a duplicate() method that does what is expected of it. Attributes with type pyparted.Disk are known to do so.

A shallow copy is implemented by calling copy.copy().

blivet.zfcp module

class blivet.zfcp.ZFCPDevice(devnum, wwpn, fcplun)

Bases: object

Warning

Since this is a singleton class, calling deepcopy() on the instance just returns self with no copy being created.

offline_device()
offline_scsi_device()
online_device()
blivet.zfcp.logged_write_line_to_file(fn, value)
class blivet.zfcp.zFCP

Bases: object

ZFCP utility class.

This class will automatically online to ZFCP drives configured in /tmp/fcpconfig when the startup() method gets called. It can also be used to manually configure ZFCP devices through the add_fcp() method.

As this class needs to make sure that /tmp/fcpconfig configured drives are only onlined once and as it keeps a global list of all ZFCP devices it is implemented as a Singleton.

add_fcp(devnum, wwpn, fcplun)
read_config()
shutdown()
startup()
write(root)

Module contents

class blivet.ErrorHandler

Bases: object

cb(exn)
blivet.enable_installer_mode()

Configure the module for use by anaconda (OS installer).

blivet.get_bootloader()
blivet.get_sysroot()

Returns the path to the target OS installation.

For traditional installations, this is the same as the physical storage root.

blivet.get_target_physical_root()

Returns the path to the “physical” storage root.

This may be distinct from the sysroot, which could be a chroot-type subdirectory of the physical root. This is used for example by all OSTree-based installations.

blivet.log_bd_message(level, msg)
blivet.set_sysroot(storage_root, sysroot=None)

Change the OS root path. :param storage_root: The root of physical storage :param sysroot: An optional chroot subdirectory of storage_root