Package ganeti :: Package cmdlib :: Module instance_storage
[hide private]
[frames] | no frames]

Module instance_storage

source code

Logical units dealing with storage of instances.

Classes [hide private]
  LUInstanceRecreateDisks
Recreate an instance's missing disks.
  LUInstanceGrowDisk
Grow a disk of an instance.
  LUInstanceReplaceDisks
Replace the disks of an instance.
  LUInstanceActivateDisks
Bring up an instance's disks.
  LUInstanceDeactivateDisks
Shutdown an instance's disks.
  TLReplaceDisks
Replaces disks for an instance.
Functions [hide private]
 
CreateSingleBlockDev(lu, node_uuid, instance, device, info, force_open, excl_stor)
Create a single block device on a given node.
source code
 
_CreateBlockDevInner(lu, node_uuid, instance, device, force_create, info, force_open, excl_stor)
Create a tree of block devices on a given node.
source code
bool
IsExclusiveStorageEnabledNodeUuid(cfg, node_uuid)
Whether exclusive_storage is in effect for the given node.
source code
 
_CreateBlockDev(lu, node_uuid, instance, device, force_create, info, force_open)
Wrapper around _CreateBlockDevInner.
source code
 
_UndoCreateDisks(lu, disks_created, instance)
Undo the work performed by CreateDisks.
source code
 
CreateDisks(lu, instance, to_skip=None, target_node_uuid=None, disks=None)
Create all disks for an instance.
source code
 
ComputeDiskSizePerVG(disk_template, disks)
Compute disk size requirements in the volume group
source code
 
ComputeDisks(op, default_vg)
Computes the instance disks.
source code
 
CheckRADOSFreeSpace()
Compute disk size requirements inside the RADOS cluster.
source code
 
_GenerateDRBD8Branch(lu, primary_uuid, secondary_uuid, size, vgnames, names, iv_name, p_minor, s_minor)
Generate a drbd8 device complete with its children.
source code
 
GenerateDiskTemplate(lu, template_name, instance_uuid, primary_node_uuid, secondary_node_uuids, disk_info, file_storage_dir, file_driver, base_index, feedback_fn, full_disk_params)
Generate the entire disk layout for a given template type.
source code
 
CheckSpindlesExclusiveStorage(diskdict, es_flag, required)
Check the presence of the spindle options with exclusive_storage.
source code
 
_PerformNodeInfoCall(lu, node_uuids, vg)
Prepares the input and performs a node info call.
source code
 
_CheckVgCapacityForNode(node_name, node_info, vg, requested)
Checks the vg capacity for a given node.
source code
 
_CheckNodesFreeDiskOnVG(lu, node_uuids, vg, requested)
Checks if nodes have enough free disk space in the specified VG.
source code
 
CheckNodesFreeDiskPerVG(lu, node_uuids, req_sizes)
Checks if nodes have enough free disk space in all the VGs.
source code
 
_DiskSizeInBytesToMebibytes(lu, size)
Converts a disk size in bytes to mebibytes.
source code
 
_CalcEta(time_taken, written, total_size)
Calculates the ETA based on size written and total size.
source code
 
WipeDisks(lu, instance, disks=None)
Wipes instance disks.
source code
 
WipeOrCleanupDisks(lu, instance, disks=None, cleanup=None)
Wrapper for WipeDisks that handles errors.
source code
list of objects.Disk
ExpandCheckDisks(instance, disks)
Return the instance disks selected by the disks list
source code
 
WaitForSync(lu, instance, disks=None, oneshot=False)
Sleep and poll for an instance's disk to sync.
source code
 
ShutdownInstanceDisks(lu, instance, disks=None, ignore_primary=False)
Shutdown block devices of an instance.
source code
 
_SafeShutdownInstanceDisks(lu, instance, disks=None)
Shutdown block devices of an instance.
source code
 
AssembleInstanceDisks(lu, instance, disks=None, ignore_secondaries=False, ignore_size=False)
Prepare the block devices for an instance.
source code
 
StartInstanceDisks(lu, instance, force)
Start the disks of an instance.
source code
 
_CheckDiskConsistencyInner(lu, instance, dev, node_uuid, on_primary, ldisk=False)
Check that mirrors are not degraded.
source code
 
CheckDiskConsistency(lu, instance, dev, node_uuid, on_primary, ldisk=False)
Wrapper around _CheckDiskConsistencyInner.
source code
 
_BlockdevFind(lu, node_uuid, dev, instance)
Wrapper around call_blockdev_find to annotate diskparams.
source code
 
_GenerateUniqueNames(lu, exts)
Generate a suitable LV name.
source code
Variables [hide private]
  _DISK_TEMPLATE_NAME_PREFIX = {constants.DT_PLAIN: "", constant...

Imports: itertools, logging, os, time, compat, constants, errors, ht, locking, iallocator, objects, utils, rpc, LogicalUnit, NoHooksLU, Tasklet, INSTANCE_DOWN, INSTANCE_NOT_RUNNING, AnnotateDiskParams, CheckIAllocatorOrNode, ExpandNodeUuidAndName, CheckNodeOnline, CheckInstanceNodeGroups, CheckInstanceState, IsExclusiveStorageEnabledNode, FindFaultyInstanceDisks, GetWantedNodes, CheckDiskTemplateEnabled, GetInstanceInfoText, CopyLockList, ReleaseLocks, CheckNodeVmCapable, BuildInstanceHookEnvByObject, CheckNodeNotDrained, CheckTargetNodeIPolicy, ganeti


Function Details [hide private]

CreateSingleBlockDev(lu, node_uuid, instance, device, info, force_open, excl_stor)

source code 

Create a single block device on a given node.

This will not recurse over children of the device, so they must be created in advance.

Parameters:
  • lu - the lu on whose behalf we execute
  • node_uuid - the node on which to create the device
  • instance (objects.Instance) - the instance which owns the device
  • device (objects.Disk) - the device to create
  • info - the extra 'metadata' we should attach to the device (this will be represented as a LVM tag)
  • force_open (boolean) - this parameter will be passes to the backend.BlockdevCreate function where it specifies whether we run on primary or not, and it affects both the child assembly and the device own Open() execution
  • excl_stor (boolean) - Whether exclusive_storage is active for the node

_CreateBlockDevInner(lu, node_uuid, instance, device, force_create, info, force_open, excl_stor)

source code 

Create a tree of block devices on a given node.

If this device type has to be created on secondaries, create it and all its children.

If not, just recurse to children keeping the same 'force' value.

Parameters:
  • lu - the lu on whose behalf we execute
  • node_uuid - the node on which to create the device
  • instance (objects.Instance) - the instance which owns the device
  • device (objects.Disk) - the device to create
  • force_create (boolean) - whether to force creation of this device; this will be change to True whenever we find a device which has CreateOnSecondary() attribute
  • info - the extra 'metadata' we should attach to the device (this will be represented as a LVM tag)
  • force_open (boolean) - this parameter will be passes to the backend.BlockdevCreate function where it specifies whether we run on primary or not, and it affects both the child assembly and the device own Open() execution
  • excl_stor (boolean) - Whether exclusive_storage is active for the node
Returns:
list of created devices

Attention: The device has to be annotated already.

IsExclusiveStorageEnabledNodeUuid(cfg, node_uuid)

source code 

Whether exclusive_storage is in effect for the given node.

Parameters:
Returns: bool
The effective value of exclusive_storage
Raises:

_CreateBlockDev(lu, node_uuid, instance, device, force_create, info, force_open)

source code 

Wrapper around _CreateBlockDevInner.

This method annotates the root device first.

_UndoCreateDisks(lu, disks_created, instance)

source code 

Undo the work performed by CreateDisks.

This function is called in case of an error to undo the work of CreateDisks.

Parameters:

CreateDisks(lu, instance, to_skip=None, target_node_uuid=None, disks=None)

source code 

Create all disks for an instance.

This abstracts away some work from AddInstance.

Parameters:
  • lu (LogicalUnit) - the logical unit on whose behalf we execute
  • instance (objects.Instance) - the instance whose disks we should create
  • to_skip (list) - list of indices to skip
  • target_node_uuid (string) - if passed, overrides the target node for creation
  • disks (list of {objects.Disk}) - the disks to create; if not specified, all the disks of the instance are created
Returns:
information about the created disks, to be used to call _UndoCreateDisks
Raises:

ComputeDisks(op, default_vg)

source code 

Computes the instance disks.

Parameters:
  • op - The instance opcode
  • default_vg - The default_vg to assume
Returns:
The computed disks

CheckSpindlesExclusiveStorage(diskdict, es_flag, required)

source code 

Check the presence of the spindle options with exclusive_storage.

Parameters:
  • diskdict (dict) - disk parameters
  • es_flag (bool) - the effective value of the exlusive_storage flag
  • required (bool) - whether spindles are required or just optional @raise errors.OpPrereqError when spindles are given and they should not

_PerformNodeInfoCall(lu, node_uuids, vg)

source code 

Prepares the input and performs a node info call.

Parameters:
  • lu (LogicalUnit) - a logical unit from which we get configuration data
  • node_uuids (list of string) - list of node UUIDs to perform the call for
  • vg (string) - the volume group's name

_CheckVgCapacityForNode(node_name, node_info, vg, requested)

source code 

Checks the vg capacity for a given node.

Parameters:
  • node_info (tuple (_, list of dicts, _)) - the result of the node info call for one node
  • node_name (string) - the name of the node
  • vg (string) - volume group name
  • requested (int) - the amount of disk in MiB to check for
Raises:

_CheckNodesFreeDiskOnVG(lu, node_uuids, vg, requested)

source code 

Checks if nodes have enough free disk space in the specified VG.

This function checks if all given nodes have the needed amount of free disk. In case any node has less disk or we cannot get the information from the node, this function raises an OpPrereqError exception.

Parameters:
  • lu (LogicalUnit) - a logical unit from which we get configuration data
  • node_uuids (list) - the list of node UUIDs to check
  • vg (str) - the volume group to check
  • requested (int) - the amount of disk in MiB to check for
Raises:

CheckNodesFreeDiskPerVG(lu, node_uuids, req_sizes)

source code 

Checks if nodes have enough free disk space in all the VGs.

This function checks if all given nodes have the needed amount of free disk. In case any node has less disk or we cannot get the information from the node, this function raises an OpPrereqError exception.

Parameters:
  • lu (LogicalUnit) - a logical unit from which we get configuration data
  • node_uuids (list) - the list of node UUIDs to check
  • req_sizes (dict) - the hash of vg and corresponding amount of disk in MiB to check for
Raises:

_DiskSizeInBytesToMebibytes(lu, size)

source code 

Converts a disk size in bytes to mebibytes.

Warns and rounds up if the size isn't an even multiple of 1 MiB.

_CalcEta(time_taken, written, total_size)

source code 

Calculates the ETA based on size written and total size.

Parameters:
  • time_taken - The time taken so far
  • written - amount written so far
  • total_size - The total size of data to be written
Returns:
The remaining time in seconds

WipeDisks(lu, instance, disks=None)

source code 

Wipes instance disks.

Parameters:
  • lu (LogicalUnit) - the logical unit on whose behalf we execute
  • instance (objects.Instance) - the instance whose disks we should create
  • disks (None or list of tuple of (number, objects.Disk, number)) - Disk details; tuple contains disk index, disk object and the start offset

WipeOrCleanupDisks(lu, instance, disks=None, cleanup=None)

source code 

Wrapper for WipeDisks that handles errors.

Parameters:
  • lu (LogicalUnit) - the logical unit on whose behalf we execute
  • instance (objects.Instance) - the instance whose disks we should wipe
  • disks - see WipeDisks
  • cleanup - the result returned by CreateDisks, used for cleanup in case of error
Raises:

ExpandCheckDisks(instance, disks)

source code 

Return the instance disks selected by the disks list

Parameters:
Returns: list of objects.Disk
selected instance disks to act on

ShutdownInstanceDisks(lu, instance, disks=None, ignore_primary=False)

source code 

Shutdown block devices of an instance.

This does the shutdown on all nodes of the instance.

If the ignore_primary is false, errors on the primary node are ignored.

_SafeShutdownInstanceDisks(lu, instance, disks=None)

source code 

Shutdown block devices of an instance.

This function checks if an instance is running, before calling _ShutdownInstanceDisks.

AssembleInstanceDisks(lu, instance, disks=None, ignore_secondaries=False, ignore_size=False)

source code 

Prepare the block devices for an instance.

This sets up the block devices on all nodes.

Parameters:
  • lu (LogicalUnit) - the logical unit on whose behalf we execute
  • instance (objects.Instance) - the instance for whose disks we assemble
  • disks (list of objects.Disk or None) - which disks to assemble (or all, if None)
  • ignore_secondaries (boolean) - if true, errors on secondary nodes won't result in an error return from the function
  • ignore_size (boolean) - if true, the current known size of the disk will not be used during the disk activation, useful for cases when the size is wrong
Returns:
False if the operation failed, otherwise a list of (host, instance_visible_name, node_visible_name) with the mapping from node devices to instance devices

_CheckDiskConsistencyInner(lu, instance, dev, node_uuid, on_primary, ldisk=False)

source code 

Check that mirrors are not degraded.

Attention: The device has to be annotated already.

The ldisk parameter, if True, will change the test from the is_degraded attribute (which represents overall non-ok status for the device(s)) to the ldisk (representing the local storage status).

_BlockdevFind(lu, node_uuid, dev, instance)

source code 

Wrapper around call_blockdev_find to annotate diskparams.

Parameters:
  • lu - A reference to the lu object
  • node_uuid - The node to call out
  • dev - The device to find
  • instance - The instance object the device belongs to @returns The result of the rpc call

_GenerateUniqueNames(lu, exts)

source code 

Generate a suitable LV name.

This will generate a logical volume name for the given instance.


Variables Details [hide private]

_DISK_TEMPLATE_NAME_PREFIX

Value:
{constants.DT_PLAIN: "", constants.DT_RBD: ".rbd", constants.DT_EXT: "\
.ext", constants.DT_FILE: ".file", constants.DT_SHARED_FILE: ".sharedf\
ile",}