Package ganeti :: 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.
  BlockDev
Block device abstract class.
  LogicalVolume
Logical Volume block device.
  DRBD8Status
A DRBD status representation class.
  BaseDRBD
Base DRBD class.
  DRBD8
DRBD v8.x block device.
  FileStorage
File 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]
boolean
_IgnoreError(fn, *args, **kwargs)
Executes the given function, ignoring BlockDeviceErrors.
source code
 
_ThrowError(msg, *args)
Log an error to the node daemon and the raise an exception.
source code
 
_CheckResult(result)
Throws an error if the given result is a failed one.
source code
 
_CanReadDevice(path)
Check if we can read from the given device.
source code
frozenset
_GetForbiddenFileStoragePaths()
Builds a list of path prefixes which shouldn't be used for file storage.
source code
list
_ComputeWrongFileStoragePaths(paths, _forbidden=_GetForbiddenFileStoragePaths())
Cross-checks a list of paths for prefixes considered bad.
source code
 
ComputeWrongFileStoragePaths(_filename=pathutils.FILE_STORAGE_PATHS_FILE)
Returns a list of file storage paths whose prefix is considered bad.
source code
 
_CheckFileStoragePath(path, allowed)
Checks if a path is in a list of allowed paths for file storage.
source code
list
_LoadAllowedFileStoragePaths(filename)
Loads file containing allowed file storage paths.
source code
 
CheckFileStoragePath(path, _filename=pathutils.FILE_STORAGE_PATHS_FILE)
Checks if a path is allowed for file storage.
source code
None or a block device path (during attach)
_ExtStorageAction(action, unique_id, ext_params, size=None, grow=None, metadata=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)
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
 
Create(disk, children, excl_stor)
Create a device.
source code
Variables [hide private]
  _DEVICE_READ_SIZE = 128* 1024
  DEV_MAP = {constants.LD_LV: LogicalVolume, constants.LD_DRBD8:...

Imports: re, time, errno, shlex, stat, pyp, os, logging, math, utils, errors, constants, objects, compat, netutils, pathutils, serializer


Function Details [hide private]

_IgnoreError(fn, *args, **kwargs)

source code 

Executes the given function, ignoring BlockDeviceErrors.

This is used in order to simplify the execution of cleanup or rollback functions.

Returns: boolean
True when fn didn't raise an exception, False otherwise

_ThrowError(msg, *args)

source code 

Log an error to the node daemon and the raise an exception.

Parameters:
  • msg (string) - the text of the exception @raise errors.BlockDeviceError

_CheckResult(result)

source code 

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

Parameters:
  • result - result from RunCmd

_CanReadDevice(path)

source code 

Check if we can read from the given device.

This tries to read the first 128k of the device.

_ComputeWrongFileStoragePaths(paths, _forbidden=_GetForbiddenFileStoragePaths())

source code 

Cross-checks a list of paths for prefixes considered bad.

Some paths, e.g. "/bin", should not be used for file storage.

Parameters:
  • paths (list) - List of paths to be checked
Returns: list
Sorted list of paths for which the user should be warned

ComputeWrongFileStoragePaths(_filename=pathutils.FILE_STORAGE_PATHS_FILE)

source code 

Returns a list of file storage paths whose prefix is considered bad.

See _ComputeWrongFileStoragePaths.

_CheckFileStoragePath(path, allowed)

source code 

Checks if a path is in a list of allowed paths for file storage.

Parameters:
  • path (string) - Path to check
  • allowed (list) - List of allowed paths
Raises:

_LoadAllowedFileStoragePaths(filename)

source code 

Loads file containing allowed file storage paths.

Returns: list
List of allowed paths (can be an empty list)

CheckFileStoragePath(path, _filename=pathutils.FILE_STORAGE_PATHS_FILE)

source code 

Checks if a path is allowed for file storage.

Parameters:
  • path (string) - Path to check
Raises:

_ExtStorageAction(action, unique_id, ext_params, size=None, grow=None, metadata=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
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)

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

Variables Details [hide private]

DEV_MAP

Value:
{constants.LD_LV: LogicalVolume, constants.LD_DRBD8: DRBD8, constants.\
LD_BLOCKDEV: PersistentBlockDevice, constants.LD_RBD: RADOSBlockDevice\
, constants.LD_EXT: ExtStorageDevice,}