cinder.brick.local_dev.lvm module

LVM class for performing LVM operations.

class LVM(vg_name: str, root_helper, create_vg: bool = False, physical_volumes: list | None = None, lvm_type: str = 'default', executor: Callable = <function execute>, lvm_conf: str | None = None, suppress_fd_warn: bool = False)

Bases: Executor

LVM object to enable various LVM related operations.

LVM_CMD_PREFIX = ['env', 'LC_ALL=C']
activate_lv(name: str, is_snapshot: bool = False, permanent: bool = False) None

Ensure that logical volume/snapshot logical volume is activated.

Parameters:
  • name – Name of LV to activate

  • is_snapshot – whether LV is a snapshot

  • permanent – whether we should drop skipactivation flag

Raises:

putils.ProcessExecutionError

create_lv_snapshot(name: str, source_lv_name: str, lv_type: str = 'default') None

Creates a snapshot of a logical volume.

Parameters:
  • name – Name to assign to new snapshot

  • source_lv_name – Name of Logical Volume to snapshot

  • lv_type – Type of LV (default or thin)

create_thin_pool(name: str | None = None, size_str: str | None = None) str | None

Creates a thin provisioning pool for this VG.

The syntax here is slightly different than the default lvcreate -T, so we’ll just write a custom cmd here and do it.

Parameters:
  • name – Name to use for pool, default is “<vg-name>-pool”

  • size_str – Size to allocate for pool, default is entire VG

Returns:

The size string passed to the lvcreate command

create_volume(name: str, size_str: str, lv_type: str = 'default', mirror_count: int = 0) None

Creates a logical volume on the object’s VG.

Parameters:
  • name – Name to use when creating Logical Volume

  • size_str – Size to use when creating Logical Volume

  • lv_type – Type of Volume (default or thin)

  • mirror_count – Use LVM mirroring with specified count

deactivate_lv(name: str) None
delete(name: str) None

Delete logical volume or snapshot.

Parameters:

name – Name of LV to delete

extend_volume(lv_name: str, new_size: str) None

Extend the size of an existing volume.

static get_all_physical_volumes(root_helper, vg_name: str | None = None) list

Static method to get all PVs on a system.

Parameters:
  • root_helper – root_helper to use for execute

  • vg_name – optional, gathers info for only the specified VG

Returns:

List of Dictionaries with PV info

static get_all_volume_groups(root_helper, vg_name: str | None = None) list

Static method to get all VGs on a system.

Parameters:
  • root_helper – root_helper to use for execute

  • vg_name – optional, gathers info for only the specified VG

Returns:

List of Dictionaries with VG info

static get_lv_info(root_helper, vg_name: str | None = None, lv_name: str | None = None) list

Retrieve info about LVs (all, in a VG, or a single LV).

Parameters:
  • root_helper – root_helper to use for execute

  • vg_name – optional, gathers info for only the specified VG

  • lv_name – optional, gathers info for only the specified LV

Returns:

List of Dictionaries with LV info

static get_lvm_version(root_helper) tuple

Static method to get LVM version from system.

Parameters:

root_helper – root_helper to use for execute

Returns:

version 3-tuple

get_volume(name: str) dict | None

Get reference object of volume specified by name.

Returns:

dict representation of Logical Volume if exists

get_volumes(lv_name: str | None = None) list

Get all LV’s associated with this instantiation (VG).

Returns:

List of Dictionaries with LV info

lv_get_origin(name: str) str | None

Return the origin of an LV that is a snapshot, None otherwise.

lv_has_snapshot(name: str) bool
lv_is_open(name: str) bool

Return True if LV is currently open, False otherwise.

lv_is_snapshot(name: str) bool

Return True if LV is a snapshot, False otherwise.

rename_volume(lv_name: str, new_name: str) None

Change the name of an existing volume.

revert(snapshot_name: str) None

Revert an LV to snapshot.

Parameters:

snapshot_name – Name of snapshot to revert

property supports_lvchange_ignoreskipactivation: bool

Property indicating whether lvchange can ignore skip activation.

Check for LVM version >= 2.02.99. (LVM2 git: ab789c1bc add –ignoreactivationskip to lvchange)

static supports_pvs_ignoreskippedcluster(root_helper) bool

Property indicating whether pvs supports –ignoreskippedcluster

Check for LVM version >= 2.02.103. (LVM2 git: baf95bbff cmdline: Add –ignoreskippedcluster.

property supports_snapshot_lv_activation: bool

Property indicating whether snap activation changes are supported.

Check for LVM version >= 2.02.91. (LVM2 git: e8a40f6 Allow to activate snapshot)

Returns:

True/False indicating support

static supports_thin_provisioning(root_helper) bool

Static method to check for thin LVM support on a system.

Parameters:

root_helper – root_helper to use for execute

Returns:

True if supported, False otherwise

update_volume_group_info() None

Update VG info for this instantiation.

Used to update member fields of object and provide a dict of info for caller.

Returns:

Dictionaries of VG info

vg_mirror_free_space(mirror_count: int) float
vg_mirror_size(mirror_count: int) float