class documentation

Config object representing a block device.

Class Method FromDict Custom function for Disks
Static Method ComputeLDParams Computes Logical Disk parameters from Disk Template parameters.
Method __str__ Custom str() formatter for disks.
Method AssembleOnSecondary Test if this device needs to be assembled on a secondary node.
Method ChildrenNeeded Compute the needed number of children for activation.
Method ComputeGrowth Compute the per-VG growth requirements.
Method ComputeNodeTree Compute the node/disk tree for this disk and its children.
Method CreateOnSecondary Test if this device needs to be created on a secondary node.
Method GetNodes This function returns the nodes this device lives on.
Method GetPrimaryNode This function returns the primary node of the device.
Method IsBasedOnDiskType Check if the disk or its children are based on the given type.
Method OpenOnSecondary Test if this device needs to be opened on a secondary node.
Method RecordGrow Update the size of this disk after growth.
Method StaticDevPath Return the device path if this device type has a static one.
Method SupportsSnapshots Test if this device supports snapshots.
Method ToDict Disk-specific conversion to standard python types.
Method UnsetSize Sets recursively the size to zero for the disk and its children.
Method Update Apply changes to size, spindles and mode.
Method UpdateDynamicDiskParams Updates the dynamic disk params for the given node.
Method UpgradeConfig Fill defaults for missing configuration values.
Method Verify Checks that this disk is correctly configured.
Class Variable __slots__ Undocumented
Class Variable all_nodes Undocumented
Instance Variable ctime Undocumented
Instance Variable dev_type Undocumented
Instance Variable dynamic_params Undocumented
Instance Variable mode Undocumented
Instance Variable mtime Undocumented
Instance Variable params Undocumented
Instance Variable serial_no Undocumented
Instance Variable size Undocumented
Instance Variable spindles Undocumented
Method _ComputeAllNodes Compute the list of all nodes covered by a device and its children.

Inherited from ConfigObject:

Method __getattr__ Undocumented
Method __repr__ Implement __repr__ for ConfigObjects.
Method __setstate__ Undocumented
Method Copy Makes a deep copy of the current object and its children.
Method Validate Validates the slots.

Inherited from ValidatedSlots (via ConfigObject):

Class Method GetAllSlots Compute the list of all declared slots for a class.
Method __init__ Constructor for BaseOpCode.
@classmethod
def FromDict(cls, val):

Custom function for Disks

@staticmethod
def ComputeLDParams(disk_template, disk_params):

Computes Logical Disk parameters from Disk Template parameters.

Parameters
disk_template:stringdisk template, one of constants.DISK_TEMPLATES
disk_params:dictdisk 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.
def __str__(self):

Custom str() formatter for disks.

def AssembleOnSecondary(self):

Test if this device needs to be assembled on a secondary node.

def ChildrenNeeded(self):

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.

def ComputeGrowth(self, amount):

Compute the per-VG growth requirements.

This only works for VG-based disks.

Parameters
amount:integerthe desired increase in (user-visible) disk space
Returns
dicta dictionary of volume-groups and the required size
def ComputeNodeTree(self, parent_node_uuid):

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.

def CreateOnSecondary(self):

Test if this device needs to be created on a secondary node.

def GetNodes(self, node_uuid):

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.

def GetPrimaryNode(self, node_uuid):

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.

def IsBasedOnDiskType(self, dev_type):

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

Parameters
dev_type:constants.DTS_BLOCKthe type to look for
Returns
booleanboolean indicating if a device of the given type was found or not
def OpenOnSecondary(self):

Test if this device needs to be opened on a secondary node.

def RecordGrow(self, amount):

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.

def StaticDevPath(self):

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.

Unknown Field: warning
The path returned is not a normalized pathname; callers should check that it is a valid path.
def SupportsSnapshots(self):

Test if this device supports snapshots.

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

Disk-specific conversion to standard python types.

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

def UnsetSize(self):

Sets recursively the size to zero for the disk and its children.

def Update(self, size=None, mode=None, spindles=None):

Apply changes to size, spindles and mode.

def UpdateDynamicDiskParams(self, target_node_uuid, nodes_ip):

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.

def UpgradeConfig(self):

Fill defaults for missing configuration values.

def Verify(self):

Checks that this disk is correctly configured.

__slots__ =

Undocumented

all_nodes =

Undocumented

ctime =

Undocumented

dev_type =

Undocumented

dynamic_params =

Undocumented

mode =

Undocumented

mtime =

Undocumented

params: dict =

Undocumented

serial_no: int =

Undocumented

size: int =

Undocumented

spindles =

Undocumented

def _ComputeAllNodes(self):

Compute the list of all nodes covered by a device and its children.