class documentation

class LogicalVolume(base.BlockDev):

View In Hierarchy

Logical Volume block device.

Class Method Create Create a new logical volume.
Class Method GetPVInfo Get the free space info for PVs in a volume group.
Class Method GetVGInfo Get the free space info for specific VGs.
Class Method GetVgSpindlesInfo Get the free space info for specific VGs.
Static Method GetLvGlobalInfo Obtain the current state of the existing LV disks.
Method __init__ Attaches to a LV device.
Method Assemble Assemble the device.
Method Attach Attach to an existing LV.
Method Close Notifies that the device will no longer be used for I/O.
Method GetActualSpindles Return the number of spindles used.
Method GetSyncStatus Returns the sync status of the device.
Method Grow Grow the logical volume.
Method Open Make the device ready for I/O.
Method Remove Remove this logical volume.
Method Rename Rename this logical volume.
Method SetInfo Update metadata with info text.
Method Shutdown Shutdown the device.
Method Snapshot Create a snapshot copy of an lvm block device.
Instance Variable attached Undocumented
Instance Variable dev_path Undocumented
Instance Variable major Undocumented
Instance Variable minor Undocumented
Instance Variable pe_size Undocumented
Instance Variable pv_names Undocumented
Instance Variable stripe_count Undocumented
Class Method _GetExclusiveStorageVgFree Return the free disk space in the given VG, in exclusive storage mode.
Class Method _GetRawFreePvInfo Return info (size/free) about PVs.
Class Method _ValidateName Validates that a given name is valid as VG or LV name.
Static Method _ComputeNumPvs Compute the number of PVs needed for an LV (with exclusive storage).
Static Method _GetEmptyPvNames Return a list of empty PVs, by name.
Static Method _GetStdPvSize Return the the standard PV size (used with exclusive storage).
Static Method _GetVolumeInfo Returns LVM Volume infos using lvm_cmd
Static Method _ParseLvInfoLine Parse one line of the lvs output used in GetLvGlobalInfo.
Method _GetGrowthAvaliabilityExclStor Return how much the disk can grow with exclusive storage.
Method _RemoveOldInfo Try to remove old tags from the lv.
Constant _INVALID_NAMES Undocumented
Constant _INVALID_SUBSTRINGS Undocumented
Constant _PARSE_PV_DEV_RE Undocumented
Constant _VALID_NAME_RE Undocumented
Instance Variable _degraded Undocumented
Instance Variable _lv_name Undocumented
Instance Variable _vg_name Undocumented

Inherited from BlockDev:

Method __eq__ Undocumented
Method __repr__ Undocumented
Method CombinedSyncStatus Calculate the mirror status recursively for our children.
Method Export Builds the shell command for exporting data from device.
Method GetActualDimensions Return the actual disk size and number of spindles used.
Method GetActualSize Return the actual disk size.
Method GetUserspaceAccessUri Return URIs hypervisors can use to access disks in userspace mode.
Method Import Builds the shell command for importing data to device.
Method PauseResumeSync Pause/Resume the sync of the mirror.
Method SetSyncParams Adjust the synchronization parameters of the mirror.
Instance Variable dyn_params Undocumented
Instance Variable params Undocumented
Instance Variable size Undocumented
Instance Variable unique_id Undocumented
Instance Variable _children Undocumented
@classmethod
def Create(cls, unique_id, children, size, spindles, params, excl_stor, dyn_params, **kwargs):

Create a new logical volume.

@classmethod
def GetPVInfo(cls, vg_names, filter_allocatable=True, include_lvs=False):

Get the free space info for PVs in a volume group.

Parameters
vg_nameslist of volume group names, if empty all will be returned
filter_allocatablewhether to skip over unallocatable PVs
include_lvswhether to include a list of LVs hosted on each PV
Returns
listlist of objects.LvmPvInfo objects
@classmethod
def GetVGInfo(cls, vg_names, excl_stor, filter_readonly=True):

Get the free space info for specific VGs.

Parameters
vg_nameslist of volume group names, if empty all will be returned
excl_storwhether exclusive_storage is enabled
filter_readonlywhether to skip over readonly VGs
Returns
listlist of tuples (free_space, total_size, name) with free_space in MiB
@classmethod
def GetVgSpindlesInfo(cls, vg_name):

Get the free space info for specific VGs.

Parameters
vg_namevolume group name
Returns
tuple(free_spindles, total_spindles)
@staticmethod
def GetLvGlobalInfo(_run_cmd=utils.RunCmd):

Obtain the current state of the existing LV disks.

Returns
a dict containing the state of each disk with the disk path as key
def __init__(self, unique_id, children, size, params, dyn_params, **kwargs):

Attaches to a LV device.

The unique_id is a tuple (vg_name, lv_name)

def Assemble(self):

Assemble the device.

We always run `lvchange -ay` on the LV to ensure it's active before use, as there were cases when xenvg was not active after boot (also possibly after disk issues).

def Attach(self, lv_info=None, **kwargs):

Attach to an existing LV.

This method will try to see if an existing and active LV exists which matches our name. If so, its major/minor will be recorded.

def Close(self):

Notifies that the device will no longer be used for I/O.

This is a no-op for the LV device type.

def GetActualSpindles(self):

Return the number of spindles used.

def GetSyncStatus(self):

Returns the sync status of the device.

If this device is a mirroring device, this function returns the status of the mirror.

For logical volumes, sync_percent and estimated_time are always None (no recovery in progress, as we don't handle the mirrored LV case). The is_degraded parameter is the inverse of the ldisk parameter.

For the ldisk parameter, we check if the logical volume has the 'virtual' type, which means it's not backed by existing storage anymore (read from it return I/O error). This happens after a physical disk failure and subsequent 'vgreduce --removemissing' on the volume group.

The status was already read in Attach, so we just return it.

Returns
objects.BlockDevStatusUndocumented
def Grow(self, amount, dryrun, backingstore, excl_stor):

Grow the logical volume.

def Open(self, force=False, exclusive=True):

Make the device ready for I/O.

This is a no-op for the LV device type.

def Remove(self):

Remove this logical volume.

def Rename(self, new_id):

Rename this logical volume.

def SetInfo(self, text):

Update metadata with info text.

def Shutdown(self):

Shutdown the device.

This is a no-op for the LV device type, as we don't deactivate the volumes on shutdown.

def Snapshot(self, snap_name=None, snap_size=None):

Create a snapshot copy of an lvm block device.

Returns
tuple (vg, lv)
attached: bool =

Undocumented

dev_path =

Undocumented

major =

Undocumented

minor =

Undocumented

pe_size =

Undocumented

pv_names =

Undocumented

stripe_count =

Undocumented

@classmethod
def _GetExclusiveStorageVgFree(cls, vg_name):

Return the free disk space in the given VG, in exclusive storage mode.

Parameters
vg_name:stringVG name
Returns
floatfree space in MiB
@classmethod
def _GetRawFreePvInfo(cls, vg_name):

Return info (size/free) about PVs.

Parameters
vg_name:stringVG name
Returns
tuple(standard_pv_size_in_MiB, number_of_free_pvs, total_number_of_pvs)
@classmethod
def _ValidateName(cls, name):

Validates that a given name is valid as VG or LV name.

The list of valid characters and restricted names is taken out of the lvm(8) manpage, with the simplification that we enforce both VG and LV restrictions on the names.

@staticmethod
def _ComputeNumPvs(size, pvs_info):

Compute the number of PVs needed for an LV (with exclusive storage).

Parameters
size:floatLV size in MiB
pvs_infolist of objects.LvmPvInfo, cannot be empty
Returns
integernumber of PVs needed
@staticmethod
def _GetEmptyPvNames(pvs_info, max_pvs=None):

Return a list of empty PVs, by name.

@staticmethod
def _GetStdPvSize(pvs_info):

Return the the standard PV size (used with exclusive storage).

Parameters
pvs_infolist of objects.LvmPvInfo, cannot be empty
Returns
floatsize in MiB
@staticmethod
def _GetVolumeInfo(lvm_cmd, fields):

Returns LVM Volume infos using lvm_cmd

Parameters
lvm_cmdShould be one of "pvs", "vgs" or "lvs"
fieldsFields to return
Returns
A list of dicts each with the parsed fields
@staticmethod
def _ParseLvInfoLine(line, sep):

Parse one line of the lvs output used in GetLvGlobalInfo.

def _GetGrowthAvaliabilityExclStor(self):

Return how much the disk can grow with exclusive storage.

Returns
floatavailable space in Mib
def _RemoveOldInfo(self):

Try to remove old tags from the lv.

_INVALID_NAMES =

Undocumented

Value
compat.UniqueFrozenset(['.', '..', 'snapshot', 'pvmove'])
_INVALID_SUBSTRINGS =

Undocumented

Value
compat.UniqueFrozenset(['_mlog', '_mimage'])
_PARSE_PV_DEV_RE =

Undocumented

Value
re.compile(r'^([^ \(\)]+)\([0-9]+\)$')
_VALID_NAME_RE =

Undocumented

Value
re.compile(r'^[a-zA-Z0-9\+_\.-]*$')
_degraded =

Undocumented

_lv_name =

Undocumented

_vg_name =

Undocumented