Package ganeti :: 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)
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)
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
 
Snapshot(self, size)
Create a snapshot copy of an lvm block device.
source code
 
SetInfo(self, text)
Update metadata with info text.
source code
 
Grow(self, amount)
Grow the logical volume.
source code

Inherited from BlockDev: CombinedSyncStatus, GetActualSize, SetSyncSpeed, __repr__

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

Class Methods [hide private]
 
Create(cls, unique_id, children, size)
Create a new logical volume.
source code
list
GetPVInfo(cls, vg_names, filter_allocatable=True)
Get the free space info for PVs in a volume group.
source code
list
GetVGInfo(cls, vg_names, 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
Static Methods [hide private]
 
_GetVolumeInfo(lvm_cmd, fields)
Returns LVM Volumen infos using lvm_cmd
source code
Class Variables [hide private]
  _VALID_NAME_RE = re.compile("^[a-zA-Z0-9+_.-]*$")
  _INVALID_NAMES = frozenset([".", "..", "snapshot", "pvmove"])
  _INVALID_SUBSTRINGS = frozenset(["_mlog", "_mimage"])
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, unique_id, children, size)
(Constructor)

source code 

Attaches to a LV device.

The unique_id is a tuple (vg_name, lv_name)

Overrides: object.__init__

Create(cls, unique_id, children, size)
Class Method

source code 

Create a new logical volume.

Overrides: BlockDev.Create

_GetVolumeInfo(lvm_cmd, fields)
Static Method

source code 

Returns LVM Volumen 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)
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
Returns: list
list of tuples (free_space, name) with free_space in mebibytes

GetVGInfo(cls, vg_names, 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
  • 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: BlockDev.Remove

Rename(self, new_id)

source code 

Rename this logical volume.

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

Open(self, force=False)

source code 

Make the device ready for I/O.

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

Overrides: 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: BlockDev.Close

SetInfo(self, text)

source code 

Update metadata with info text.

Overrides: BlockDev.SetInfo

Grow(self, amount)

source code 

Grow the logical volume.

Parameters:
  • amount - the amount (in mebibytes) to grow with
Overrides: BlockDev.Grow