Utility functions for storage.
Function |
|
Create dm device for each partition of disk image. |
Function |
|
Check whether the disk template supports storage space reporting. |
Function |
|
Generate disk labels for a number of disks |
Function |
|
Given the storage type, returns a list of disk templates based on that storage type. |
Function |
|
Get the cluster's storage units for the given disk templates. |
Function |
|
Checks if a particular disk template is enabled. |
Function |
|
Checks if file storage is enabled. |
Function |
|
Check whether or not any lvm-based disk templates are enabled. |
Function |
|
Checks if shared file storage is enabled. |
Function |
|
Looks up the storage space info for a given disk template. |
Function |
|
Looks up the storage space info for a given storage type. |
Function |
|
Checks whether lvm was not enabled before, but will be enabled after the operation. |
Function | osminor |
Return the device minor number from a raw device number. |
Function |
|
Release allocated dm devices and loopback devices. |
Function | _ |
Retrieves the identifier of the default storage entity for the given storage type. |
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 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. |
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 | number of disks (i.e., disk labels) |
start:int | optional start index |
Returns | |
generator | generator for the disk labels |
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 | 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. |
Looks up the storage space info for a given disk template.
Parameters | |
storage | result of GetNodeInfo |
disk | disk template to get storage space info |
Returns | |
tuple | returns the element of storage_space_info that matches the given disk template |
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 | result of GetNodeInfo |
storage | 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 |
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.
Release allocated dm devices and loopback devices.
Parameters | |
loop | path of loopback device returned by CreateBdevPartitionMapping |