Package ganeti :: Module objects :: Class Disk
[hide private]
[frames] | no frames]

Class Disk

source code


Config object representing a block device.

Instance Methods [hide private]
 
_ComputeAllNodes(self)
Compute the list of all nodes covered by a device and its children.
source code
 
CreateOnSecondary(self)
Test if this device needs to be created on a secondary node.
source code
 
AssembleOnSecondary(self)
Test if this device needs to be assembled on a secondary node.
source code
 
OpenOnSecondary(self)
Test if this device needs to be opened on a secondary node.
source code
 
SupportsSnapshots(self)
Test if this device supports snapshots.
source code
 
StaticDevPath(self)
Return the device path if this device type has a static one.
source code
 
ChildrenNeeded(self)
Compute the needed number of children for activation.
source code
boolean
IsBasedOnDiskType(self, dev_type)
Check if the disk or its children are based on the given type.
source code
 
GetNodes(self, node_uuid)
This function returns the nodes this device lives on.
source code
 
GetPrimaryNode(self, node_uuid)
This function returns the primary node of the device.
source code
 
ComputeNodeTree(self, parent_node_uuid)
Compute the node/disk tree for this disk and its children.
source code
dict
ComputeGrowth(self, amount)
Compute the per-VG growth requirements.
source code
 
RecordGrow(self, amount)
Update the size of this disk after growth.
source code
 
Update(self, size=None, mode=None, spindles=None)
Apply changes to size, spindles and mode.
source code
 
UnsetSize(self)
Sets recursively the size to zero for the disk and its children.
source code
 
UpdateDynamicDiskParams(self, target_node_uuid, nodes_ip)
Updates the dynamic disk params for the given node.
source code
 
ToDict(self, include_dynamic_params=False, _with_private=False)
Disk-specific conversion to standard python types.
source code
 
__str__(self)
Custom str() formatter for disks.
source code
 
Verify(self)
Checks that this disk is correctly configured.
source code
 
UpgradeConfig(self)
Fill defaults for missing configuration values.
source code

Inherited from ConfigObject: Copy, Validate, __eq__, __getattr__, __getstate__, __repr__, __setstate__

Inherited from outils.ValidatedSlots: __init__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]
 
FromDict(cls, val)
Custom function for Disks
source code

Inherited from outils.ValidatedSlots: GetAllSlots

Static Methods [hide private]
list(dict)
ComputeLDParams(disk_template, disk_params)
Computes Logical Disk parameters from Disk Template parameters.
source code
Class Variables [hide private]
  all_nodes = property(_ComputeAllNodes, None, None, "List of na...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

StaticDevPath(self)

source code 

Return the device path if this device type has a static one.

Some devices (LVM for example) live always at the same /dev/ path, irrespective of their status. For such devices, we return this path, for others we return None.

Warning: The path returned is not a normalized pathname; callers should check that it is a valid path.

ChildrenNeeded(self)

source code 

Compute the needed number of children for activation.

This method will return either -1 (all children) or a positive number denoting the minimum number of children needed for activation (only mirrored devices will usually return >=0).

Currently, only DRBD8 supports diskless activation (therefore we return 0), for all other we keep the previous semantics and return -1.

IsBasedOnDiskType(self, dev_type)

source code 

Check if the disk or its children are based on the given type.

Parameters:
  • dev_type (constants.DTS_BLOCK) - the type to look for
Returns: boolean
boolean indicating if a device of the given type was found or not

GetNodes(self, node_uuid)

source code 

This function returns the nodes this device lives on.

Given the node on which the parent of the device lives on (or, in case of a top-level device, the primary node of the devices' instance), this function will return a list of nodes on which this devices needs to (or can) be assembled.

GetPrimaryNode(self, node_uuid)

source code 

This function returns the primary node of the device.

If the device is not a DRBD device, we still return the node the device lives on.

ComputeNodeTree(self, parent_node_uuid)

source code 

Compute the node/disk tree for this disk and its children.

This method, given the node on which the parent disk lives, will return the list of all (node UUID, disk) pairs which describe the disk tree in the most compact way. For example, a drbd/lvm stack will be returned as (primary_node, drbd) and (secondary_node, drbd) which represents all the top-level devices on the nodes.

ComputeGrowth(self, amount)

source code 

Compute the per-VG growth requirements.

This only works for VG-based disks.

Parameters:
  • amount (integer) - the desired increase in (user-visible) disk space
Returns: dict
a dictionary of volume-groups and the required size

RecordGrow(self, amount)

source code 

Update the size of this disk after growth.

This method recurses over the disks's children and updates their size correspondigly. The method needs to be kept in sync with the actual algorithms from bdev.

UpdateDynamicDiskParams(self, target_node_uuid, nodes_ip)

source code 

Updates the dynamic disk params for the given node.

This is mainly used for drbd, which needs ip/port configuration.

Arguments:

  • target_node_uuid: the node UUID we wish to configure for
  • nodes_ip: a mapping of node name to ip

The target_node must exist in nodes_ip, and should be one of the nodes in the logical ID if this device is a DRBD device.

ToDict(self, include_dynamic_params=False, _with_private=False)

source code 

Disk-specific conversion to standard python types.

This replaces the children lists of objects with lists of standard python types.

Parameters:
  • _with_private - if True, the object will leak its private fields in the dictionary representation. If False, the values will be replaced with None.
Overrides: ConfigObject.ToDict

FromDict(cls, val)
Class Method

source code 

Custom function for Disks

Overrides: ConfigObject.FromDict

__str__(self)
(Informal representation operator)

source code 

Custom str() formatter for disks.

Overrides: object.__str__

UpgradeConfig(self)

source code 

Fill defaults for missing configuration values.

Overrides: ConfigObject.UpgradeConfig

ComputeLDParams(disk_template, disk_params)
Static Method

source code 

Computes Logical Disk parameters from Disk Template parameters.

Parameters:
  • disk_template (string) - disk template, one of constants.DISK_TEMPLATES
  • disk_params (dict) - disk template parameters; dict(template_name -> parameters
Returns: list(dict)
a list of dicts, one for each node of the disk hierarchy. Each dict contains the LD parameters of the node. The tree is flattened in-order.

Class Variable Details [hide private]

all_nodes

Value:
property(_ComputeAllNodes, None, None, "List of names of all the nodes\
 of a disk")