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

Module storage

source code

Utility functions for storage.

Functions [hide private]
 
GetDiskTemplatesOfStorageTypes(*storage_types)
Given the storage type, returns a list of disk templates based on that storage type.
source code
 
IsDiskTemplateEnabled(disk_template, enabled_disk_templates)
Checks if a particular disk template is enabled.
source code
 
IsFileStorageEnabled(enabled_disk_templates)
Checks if file storage is enabled.
source code
 
IsSharedFileStorageEnabled(enabled_disk_templates)
Checks if shared file storage is enabled.
source code
 
IsLvmEnabled(enabled_disk_templates)
Check whether or not any lvm-based disk templates are enabled.
source code
 
LvmGetsEnabled(enabled_disk_templates, new_enabled_disk_templates)
Checks whether lvm was not enabled before, but will be enabled after the operation.
source code
string
_GetDefaultStorageUnitForDiskTemplate(cfg, disk_template)
Retrieves the identifier of the default storage entity for the given storage type.
source code
 
DiskTemplateSupportsSpaceReporting(disk_template)
Check whether the disk template supports storage space reporting.
source code
list of tuples (string, string)
GetStorageUnits(cfg, disk_templates)
Get the cluster's storage units for the given disk templates.
source code
tuple
LookupSpaceInfoByDiskTemplate(storage_space_info, disk_template)
Looks up the storage space info for a given disk template.
source code
tuple
LookupSpaceInfoByStorageType(storage_space_info, storage_type)
Looks up the storage space info for a given storage type.
source code
generator
GetDiskLabels(prefix, num_disks, start=0)
Generate disk labels for a number of disks
source code
tuple(string, list(string)) or NoneType
CreateBdevPartitionMapping(image_path)
Create dm device for each partition of disk image.
source code
 
ReleaseBdevPartitionMapping(loop_dev_path)
Release allocated dm devices and loopback devices.
source code
 
osminor(dev)
Return the device minor number from a raw device number.
source code

Imports: logging, constants, errors, utils_io, utils_process


Function Details [hide private]

_GetDefaultStorageUnitForDiskTemplate(cfg, disk_template)

source code 

Retrieves the identifier of the default storage entity for the given storage type.

Parameters:
  • cfg (objects.ConfigData) - the configuration data
  • disk_template (string) - a disk template, for example 'drbd'
Returns: string
identifier for a storage unit, for example the vg_name for lvm storage

GetStorageUnits(cfg, disk_templates)

source code 

Get the cluster's storage units for the given disk templates.

If any lvm-based disk template is requested, spindle information is added to the request.

Parameters:
  • cfg (config.ConfigWriter) - Cluster configuration
  • disk_templates (list of string) - list of disk templates for which the storage units will be computed
Returns: list of tuples (string, string)
list of storage units, each storage unit being a tuple of (storage_type, storage_key); storage_type is in constants.STORAGE_TYPES and the storage_key a string to identify an entity of that storage type, for example a volume group name for LVM storage or a file for file storage.

LookupSpaceInfoByDiskTemplate(storage_space_info, disk_template)

source code 

Looks up the storage space info for a given disk template.

Parameters:
  • storage_space_info (list of dicts) - result of GetNodeInfo
  • disk_template (string) - disk template to get storage space info
Returns: tuple
returns the element of storage_space_info that matches the given disk template

LookupSpaceInfoByStorageType(storage_space_info, storage_type)

source code 

Looks up the storage space info for a given storage type.

Note that this lookup can be ambiguous if storage space reporting for several units of the same storage type was requested. This function is only supposed to be used for legacy code in situations where it actually is unambiguous.

Parameters:
  • storage_space_info (list of dicts) - result of GetNodeInfo
  • storage_type (string) - a storage type, which is included in the storage_units list
Returns: tuple
returns the element of storage_space_info that matches the given storage type

GetDiskLabels(prefix, num_disks, start=0)

source code 

Generate disk labels for a number of disks

Note that disk labels are generated in the range [start..num_disks[ (e.g., as in range(start, num_disks))

Parameters:
  • prefix (string) - disk label prefix (e.g., "/dev/sd")
  • num_disks (int) - number of disks (i.e., disk labels)
  • start (int) - optional start index
Returns: generator
generator for the disk labels

CreateBdevPartitionMapping(image_path)

source code 

Create dm device for each partition of disk image.

This operation will allocate a loopback and a device-mapper device to map partitions. You must call ReleaseBdevPartitionMapping to clean up resources allocated by this function call.

Parameters:
  • image_path (string) - path of multi-partition disk image
Returns: tuple(string, list(string)) or NoneType
returns the tuple(loopback_device, list(device_mapper_files)) if image_path is a multi-partition disk image. otherwise, returns None.

ReleaseBdevPartitionMapping(loop_dev_path)

source code 

Release allocated dm devices and loopback devices.

Parameters:

osminor(dev)

source code 

Return the device minor number from a raw device number.

This is a replacement for os.minor working around the issue that Python's os.minor still has the old definition. See Ganeti issue 1058 for more details.