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

Module bdev

source code

Block device abstraction.

Classes [hide private]
  RbdShowmappedJsonError
`rbd showmmapped' JSON formatting error Exception class.
  LogicalVolume
Logical Volume block device.
  PersistentBlockDevice
A block device with persistent node
  RADOSBlockDevice
A RADOS Block Device (rbd).
  ExtStorageDevice
A block device provided by an ExtStorage Provider.
Functions [hide private]
 
_CheckResult(result)
Throws an error if the given result is a failed one.
source code
None or a block device path (during attach)
_ExtStorageAction(action, unique_id, ext_params, size=None, grow=None, metadata=None, name=None, uuid=None)
Take an External Storage action.
source code
tuple
ExtStorageFromDisk(name, base_dir=None)
Create an ExtStorage instance from disk.
source code
dict
_ExtStorageEnvironment(unique_id, ext_params, size=None, grow=None, metadata=None, name=None, uuid=None)
Calculate the environment for an External Storage script.
source code
 
_VolumeLogName(kind, es_name, volume)
Compute the ExtStorage log filename for a given Volume and operation.
source code
 
_VerifyDiskType(dev_type) source code
 
_VerifyDiskParams(disk)
Verifies if all disk parameters are set.
source code
 
FindDevice(disk, children)
Search for an existing, assembled device.
source code
 
Assemble(disk, children)
Try to attach or assemble an existing device.
source code
bdev.BlockDev
Create(disk, children, excl_stor)
Create a device.
source code
Variables [hide private]
  DEV_MAP = {constants.DT_PLAIN: LogicalVolume, constants.DT_DRB...
Map disk types to disk type classes.

Imports: re, stat, os, logging, math, utils, errors, constants, objects, compat, pathutils, serializer, base, drbd, FileStorage, GlusterStorage


Function Details [hide private]

_CheckResult(result)

source code 

Throws an error if the given result is a failed one.

Parameters:
  • result - result from RunCmd

_ExtStorageAction(action, unique_id, ext_params, size=None, grow=None, metadata=None, name=None, uuid=None)

source code 

Take an External Storage action.

Take an External Storage action concerning or affecting a specific Volume inside the External Storage.

Parameters:
  • action (string) - which action to perform. One of: create / remove / grow / attach / detach
  • unique_id (tuple (driver, vol_name)) - a tuple containing the type of ExtStorage (driver) and the Volume name
  • ext_params (dict) - ExtStorage parameters
  • size (integer) - the size of the Volume in mebibytes
  • grow (integer) - the new size in mebibytes (after grow)
  • metadata (string) - metadata info of the Volume, for use by the provider
  • name (string) - name of the Volume (objects.Disk.name)
  • uuid (string) - uuid of the Volume (objects.Disk.uuid)
Returns: None or a block device path (during attach)

ExtStorageFromDisk(name, base_dir=None)

source code 

Create an ExtStorage instance from disk.

This function will return an ExtStorage instance if the given name is a valid ExtStorage name.

Parameters:
  • base_dir (string) - Base directory containing ExtStorage installations. Defaults to a search in all the ES_SEARCH_PATH dirs.
Returns: tuple
True and the ExtStorage instance if we find a valid one, or False and the diagnose message on error

_ExtStorageEnvironment(unique_id, ext_params, size=None, grow=None, metadata=None, name=None, uuid=None)

source code 

Calculate the environment for an External Storage script.

Parameters:
  • unique_id (tuple (driver, vol_name)) - ExtStorage pool and name of the Volume
  • ext_params (dict) - the EXT parameters
  • size (string) - size of the Volume (in mebibytes)
  • grow (string) - new size of Volume after grow (in mebibytes)
  • metadata (string) - metadata info of the Volume
  • name (string) - name of the Volume (objects.Disk.name)
  • uuid (string) - uuid of the Volume (objects.Disk.uuid)
Returns: dict
dict of environment variables

_VolumeLogName(kind, es_name, volume)

source code 

Compute the ExtStorage log filename for a given Volume and operation.

Parameters:
  • kind (string) - the operation type (e.g. create, remove etc.)
  • es_name (string) - the ExtStorage name
  • volume (string) - the name of the Volume inside the External Storage

FindDevice(disk, children)

source code 

Search for an existing, assembled device.

This will succeed only if the device exists and is assembled, but it does not do any actions in order to activate the device.

Parameters:
  • disk (objects.Disk) - the disk object to find
  • children (list of bdev.BlockDev) - the list of block devices that are children of the device represented by the disk parameter

Assemble(disk, children)

source code 

Try to attach or assemble an existing device.

This will attach to assemble the device, as needed, to bring it fully up. It must be safe to run on already-assembled devices.

Parameters:
  • disk (objects.Disk) - the disk object to assemble
  • children (list of bdev.BlockDev) - the list of block devices that are children of the device represented by the disk parameter

Create(disk, children, excl_stor)

source code 

Create a device.

Parameters:
  • disk (objects.Disk) - the disk object to create
  • children (list of bdev.BlockDev) - the list of block devices that are children of the device represented by the disk parameter
  • excl_stor (boolean) - Whether exclusive_storage is active
Returns: bdev.BlockDev
the created device, or None in case of an error

Variables Details [hide private]

DEV_MAP

Map disk types to disk type classes.

See Also: Assemble, FindDevice, Create.

Value:
{constants.DT_PLAIN: LogicalVolume, constants.DT_DRBD8: drbd.DRBD8Dev,\
 constants.DT_BLOCK: PersistentBlockDevice, constants.DT_RBD: RADOSBlo\
ckDevice, constants.DT_EXT: ExtStorageDevice, constants.DT_FILE: FileS\
torage, constants.DT_SHARED_FILE: FileStorage, constants.DT_GLUSTER: G\
lusterStorage,}