Package ganeti :: Package storage :: Module bdev :: Class LogicalVolume
[hide private]
[frames] | no frames]

Class LogicalVolume

source code


Logical Volume block device.

Instance Methods [hide private]
 
__init__(self, unique_id, children, size, params, dyn_params, *args)
Attaches to a LV device.
source code
 
Remove(self)
Remove this logical volume.
source code
 
Rename(self, new_id)
Rename this logical volume.
source code
 
Attach(self)
Attach to an existing LV.
source code
 
Assemble(self)
Assemble the device.
source code
 
Shutdown(self)
Shutdown the device.
source code
objects.BlockDevStatus
GetSyncStatus(self)
Returns the sync status of the device.
source code
 
Open(self, force=False, exclusive=True)
Make the device ready for I/O.
source code
 
Close(self)
Notifies that the device will no longer be used for I/O.
source code
tuple
Snapshot(self, snap_name=None, snap_size=None)
Create a snapshot copy of an lvm block device.
source code
 
_RemoveOldInfo(self)
Try to remove old tags from the lv.
source code
 
SetInfo(self, text)
Update metadata with info text.
source code
float
_GetGrowthAvaliabilityExclStor(self)
Return how much the disk can grow with exclusive storage.
source code
 
Grow(self, amount, dryrun, backingstore, excl_stor)
Grow the logical volume.
source code
 
GetActualSpindles(self)
Return the number of spindles used.
source code

Inherited from base.BlockDev: CombinedSyncStatus, Export, GetActualDimensions, GetActualSize, GetUserspaceAccessUri, Import, PauseResumeSync, SetSyncParams, __repr__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
BlockDev
Create(cls, unique_id, children, size, spindles, params, excl_stor, dyn_params, *args)
Create a new logical volume.
source code
list
GetPVInfo(cls, vg_names, filter_allocatable=True, include_lvs=False)
Get the free space info for PVs in a volume group.
source code
tuple
_GetRawFreePvInfo(cls, vg_name)
Return info (size/free) about PVs.
source code
float
_GetExclusiveStorageVgFree(cls, vg_name)
Return the free disk space in the given VG, in exclusive storage mode.
source code
tuple
GetVgSpindlesInfo(cls, vg_name)
Get the free space info for specific VGs.
source code
list
GetVGInfo(cls, vg_names, excl_stor, filter_readonly=True)
Get the free space info for specific VGs.
source code
 
_ValidateName(cls, name)
Validates that a given name is valid as VG or LV name.
source code
 
_ParseLvInfoLine(cls, line, sep)
Parse one line of the lvs output used in _GetLvInfo.
source code
 
_GetLvInfo(cls, dev_path, _run_cmd=utils.RunCmd)
Get info about the given existing LV to be used.
source code
Static Methods [hide private]
float
_GetStdPvSize(pvs_info)
Return the the standard PV size (used with exclusive storage).
source code
integer
_ComputeNumPvs(size, pvs_info)
Compute the number of PVs needed for an LV (with exclusive storage).
source code
 
_GetEmptyPvNames(pvs_info, max_pvs=None)
Return a list of empty PVs, by name.
source code
 
_GetVolumeInfo(lvm_cmd, fields)
Returns LVM Volume infos using lvm_cmd
source code
Class Variables [hide private]
  _VALID_NAME_RE = re.compile("^[a-zA-Z0-9+_.-]*$")
  _PARSE_PV_DEV_RE = re.compile(r"^([^ ()]+)\([0-9]+\)$")
  _INVALID_NAMES = compat.UniqueFrozenset([".", "..", "snapshot"...
  _INVALID_SUBSTRINGS = compat.UniqueFrozenset(["_mlog", "_mimag...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, unique_id, children, size, params, dyn_params, *args)
(Constructor)

source code 

Attaches to a LV device.

The unique_id is a tuple (vg_name, lv_name)

Overrides: object.__init__

_GetStdPvSize(pvs_info)
Static Method

source code 

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

Parameters:
  • pvs_info - list of objects.LvmPvInfo, cannot be empty
Returns: float
size in MiB

_ComputeNumPvs(size, pvs_info)
Static Method

source code 

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

Parameters:
  • size (float) - LV size in MiB
  • pvs_info - list of objects.LvmPvInfo, cannot be empty
Returns: integer
number of PVs needed

Create(cls, unique_id, children, size, spindles, params, excl_stor, dyn_params, *args)
Class Method

source code 

Create a new logical volume.

Parameters:
  • unique_id - unique identifier; the details depend on the actual device type
  • children - for hierarchical devices, the child devices
  • size - size in MiB
  • spindles - number of physical disk to dedicate to the device
  • params - device-specific options/parameters
  • excl_stor - whether exclusive_storage is active
  • dyn_params - dynamic parameters of the disk only valid for this node. As set by objects.Disk.UpdateDynamicDiskParams.
Returns: BlockDev
the created device, or None in case of an error
Overrides: base.BlockDev.Create

_GetVolumeInfo(lvm_cmd, fields)
Static Method

source code 

Returns LVM Volume infos using lvm_cmd

Parameters:
  • lvm_cmd - Should be one of "pvs", "vgs" or "lvs"
  • fields - Fields to return
Returns:
A list of dicts each with the parsed fields

GetPVInfo(cls, vg_names, filter_allocatable=True, include_lvs=False)
Class Method

source code 

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

Parameters:
  • vg_names - list of volume group names, if empty all will be returned
  • filter_allocatable - whether to skip over unallocatable PVs
  • include_lvs - whether to include a list of LVs hosted on each PV
Returns: list
list of objects.LvmPvInfo objects

_GetRawFreePvInfo(cls, vg_name)
Class Method

source code 

Return info (size/free) about PVs.

Parameters:
  • vg_name (string) - VG name
Returns: tuple
(standard_pv_size_in_MiB, number_of_free_pvs, total_number_of_pvs)

_GetExclusiveStorageVgFree(cls, vg_name)
Class Method

source code 

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

Parameters:
  • vg_name (string) - VG name
Returns: float
free space in MiB

GetVgSpindlesInfo(cls, vg_name)
Class Method

source code 

Get the free space info for specific VGs.

Parameters:
  • vg_name - volume group name
Returns: tuple
(free_spindles, total_spindles)

GetVGInfo(cls, vg_names, excl_stor, filter_readonly=True)
Class Method

source code 

Get the free space info for specific VGs.

Parameters:
  • vg_names - list of volume group names, if empty all will be returned
  • excl_stor - whether exclusive_storage is enabled
  • filter_readonly - whether to skip over readonly VGs
Returns: list
list of tuples (free_space, total_size, name) with free_space in MiB

_ValidateName(cls, name)
Class Method

source code 

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.

Remove(self)

source code 

Remove this logical volume.

Overrides: base.BlockDev.Remove

Rename(self, new_id)

source code 

Rename this logical volume.

Overrides: base.BlockDev.Rename

Attach(self)

source code 

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.

Overrides: base.BlockDev.Attach

Assemble(self)

source code 

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

Overrides: base.BlockDev.Assemble

Shutdown(self)

source code 

Shutdown the device.

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

Overrides: base.BlockDev.Shutdown

GetSyncStatus(self)

source code 

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.BlockDevStatus
Overrides: base.BlockDev.GetSyncStatus

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

source code 

Make the device ready for I/O.

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

Overrides: base.BlockDev.Open

Close(self)

source code 

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

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

Overrides: base.BlockDev.Close

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

source code 

Create a snapshot copy of an lvm block device.

Parameters:
  • snap_name - The name of the snapshot.
  • snap_size - The size of the snapshot.
Returns: tuple
tuple (vg, lv)
Overrides: base.BlockDev.Snapshot

SetInfo(self, text)

source code 

Update metadata with info text.

Overrides: base.BlockDev.SetInfo

_GetGrowthAvaliabilityExclStor(self)

source code 

Return how much the disk can grow with exclusive storage.

Returns: float
available space in Mib

Grow(self, amount, dryrun, backingstore, excl_stor)

source code 

Grow the logical volume.

Parameters:
  • amount - the amount (in mebibytes) to grow with
  • dryrun - whether to execute the operation in simulation mode only, without actually increasing the size
  • backingstore - whether to execute the operation on backing storage only, or on "logical" storage only; e.g. DRBD is logical storage, whereas LVM, file, RBD are backing storage
  • excl_stor - Whether exclusive_storage is active
Overrides: base.BlockDev.Grow

GetActualSpindles(self)

source code 

Return the number of spindles used.

Overrides: base.BlockDev.GetActualSpindles

Class Variable Details [hide private]

_INVALID_NAMES

Value:
compat.UniqueFrozenset([".", "..", "snapshot", "pvmove"])

_INVALID_SUBSTRINGS

Value:
compat.UniqueFrozenset(["_mlog", "_mimage"])