class documentation

class DRBD8Dev(base.BlockDev):

View In Hierarchy

DRBD v8.x block device.

This implements the local host part of the DRBD device, i.e. it doesn't do anything to the supposed peer. If you need a fully connected DRBD pair, you need to use this class on both hosts.

The unique_id for the drbd device is a (pnode_uuid, snode_uuid, port, pnode_minor, lnode_minor, secret) tuple, and it must have two children: the data device and the meta_device. The meta device is checked for valid size and is zeroed on create.

Class Method Create Create a new DRBD8 device.
Method __init__ Undocumented
Method AddChildren Add a disk to the DRBD device.
Method Assemble Assemble the drbd.
Method Attach Check if our minor is configured.
Method AttachNet Reconnects the network.
Method Close Make the local state secondary.
Method DisconnectNet Removes network configuration.
Method GetProcStatus Return the current status data from /proc/drbd for this device.
Method GetSyncStatus Returns the sync status of the device.
Method Grow Resize the DRBD device and its backing storage.
Method Open Make the local state primary.
Method PauseResumeSync Pauses or resumes the sync of a DRBD device.
Method Remove Stub remove for DRBD devices.
Method RemoveChildren Detach the drbd device from local storage.
Method Rename Rename a device.
Method SetSyncParams Set the synchronization parameters of the DRBD syncer.
Method Shutdown Shutdown the DRBD device.
Instance Variable attached Undocumented
Instance Variable dev_path Undocumented
Instance Variable major Undocumented
Instance Variable minor Undocumented
Class Method _InitMeta Initialize a meta device.
Static Method _CheckMetaSize Check if the given meta device looks like a valid one.
Static Method _DevPath Return the path to a drbd device for a given minor.
Static Method _GetNetFamily Undocumented
Static Method _NeedsLocalSyncerParams Undocumented
Method _AssembleLocal Configure the local part of a DRBD device.
Method _AssembleNet Configure the network part of the device.
Method _FastAssemble Assemble the drbd device from zero.
Method _GetShowData Return the `drbdsetup show` data.
Method _GetShowInfo Return parsed information from `drbdsetup show`.
Method _MatchesLocal Test if our local config matches with an existing device.
Method _MatchesNet Test if our network config matches with an existing device.
Method _SetFromMinor Set our parameters based on the given minor.
Method _SetMinorSyncParams Set the parameters of the DRBD syncer.
Method _ShutdownLocal Detach from the local device.
Method _ShutdownNet Disconnect from the remote peer.
Method _SlowAssemble Assembles the DRBD device from a (partially) configured device.
Constant _DRBD_MAJOR Undocumented
Constant _NET_RECONFIG_TIMEOUT Undocumented
Instance Variable _aminor Undocumented
Instance Variable _children Undocumented
Instance Variable _cmd_gen Undocumented
Instance Variable _lhost Undocumented
Instance Variable _lport Undocumented
Instance Variable _rhost Undocumented
Instance Variable _rport Undocumented
Instance Variable _secret Undocumented
Instance Variable _show_info_cls Undocumented

Inherited from BlockDev:

Method __eq__ Undocumented
Method __repr__ Undocumented
Method CombinedSyncStatus Calculate the mirror status recursively for our children.
Method Export Builds the shell command for exporting data from device.
Method GetActualDimensions Return the actual disk size and number of spindles used.
Method GetActualSize Return the actual disk size.
Method GetActualSpindles Return the actual number of spindles used.
Method GetUserspaceAccessUri Return URIs hypervisors can use to access disks in userspace mode.
Method Import Builds the shell command for importing data to device.
Method SetInfo Update metadata with info text.
Method Snapshot Creates a snapshot of the block device.
Instance Variable dyn_params Undocumented
Instance Variable params Undocumented
Instance Variable size Undocumented
Instance Variable unique_id Undocumented
@classmethod
def Create(cls, unique_id, children, size, spindles, params, excl_stor, dyn_params, **kwargs):

Create a new DRBD8 device.

Since DRBD devices are not created per se, just assembled, this function only initializes the metadata.

def __init__(self, unique_id, children, size, params, dyn_params, **kwargs):

Undocumented

def AddChildren(self, devices):

Add a disk to the DRBD device.

Parameters
devices:list of BlockDeva list of exactly two BlockDev objects; the first denotes the data device, the second the meta device for this DRBD device
def Assemble(self):

Assemble the drbd.

Method:

  • if we have a configured device, we try to ensure that it matches our config
  • if not, we create it from zero
  • anyway, set the device parameters
def Attach(self, **kwargs):

Check if our minor is configured.

This doesn't do any device configurations - it only checks if the minor is in a state different from Unconfigured.

Note that this function will not change the state of the system in any way (except in case of side-effects caused by reading from /proc).

def AttachNet(self, multimaster):

Reconnects the network.

This method connects the network side of the device with a specified multi-master flag. The device needs to be 'Standalone' but have valid network configuration data.

Parameters
multimaster:booleaninit the network in dual-primary mode
def Close(self):

Make the local state secondary.

This will, of course, fail if the device is in use.

def DisconnectNet(self):

Removes network configuration.

This method shutdowns the network side of the device.

The method will wait up to a hardcoded timeout for the device to go into standalone after the 'disconnect' command before re-configuring it, as sometimes it takes a while for the disconnect to actually propagate and thus we might issue a 'net' command while the device is still connected. If the device will still be attached to the network and we time out, we raise an exception.

def GetProcStatus(self):

Return the current status data from /proc/drbd for this device.

Returns
DRBD8StatusUndocumented
def GetSyncStatus(self):

Returns the sync status of the device.

If sync_percent is None, it means all is ok If estimated_time is None, it means we can't estimate the time needed, otherwise it's the time left in seconds.

We set the is_degraded parameter to True on two conditions: network not connected or local disk missing.

We compute the ldisk parameter based on whether we have a local disk or not.

Returns
objects.BlockDevStatusUndocumented
def Grow(self, amount, dryrun, backingstore, excl_stor):

Resize the DRBD device and its backing storage.

See BlockDev.Grow for parameter description.

def Open(self, force=False, exclusive=True):

Make the local state primary.

If the 'force' parameter is given, DRBD is instructed to switch the device into primary mode. Since this is a potentially dangerous operation, the force flag should be only given after creation, when it actually is mandatory.

def PauseResumeSync(self, pause):

Pauses or resumes the sync of a DRBD device.

See BlockDev.PauseResumeSync for parameter description.

def Remove(self):

Stub remove for DRBD devices.

def RemoveChildren(self, devices):

Detach the drbd device from local storage.

Parameters
devices:list of BlockDeva list of exactly two BlockDev objects; the first denotes the data device, the second the meta device for this DRBD device
def Rename(self, new_id):

Rename a device.

This is not supported for drbd devices.

def SetSyncParams(self, params):

Set the synchronization parameters of the DRBD syncer.

See BlockDev.SetSyncParams for parameter description.

def Shutdown(self):

Shutdown the DRBD device.

attached: bool =

Undocumented

dev_path =

Undocumented

major =

Undocumented

minor =

Undocumented

@classmethod
def _InitMeta(cls, minor, dev_path):

Initialize a meta device.

This will not work if the given minor is in use.

Parameters
minor:intthe DRBD minor whose (future) meta device should be initialized
dev_path:stringpath to the meta device to initialize
@staticmethod
def _CheckMetaSize(meta_device):

Check if the given meta device looks like a valid one.

This currently only checks the size, which must be around 128MiB.

Parameters
meta_device:stringthe path to the device to check
@staticmethod
def _DevPath(minor):

Return the path to a drbd device for a given minor.

Parameters
minor:intUndocumented
Returns
stringUndocumented
@staticmethod
def _GetNetFamily(minor, lhost, rhost):

Undocumented

@staticmethod
def _NeedsLocalSyncerParams():

Undocumented

def _AssembleLocal(self, minor, backend, meta, size):

Configure the local part of a DRBD device.

Parameters
minor:intthe minor to assemble locally
backend:stringpath to the data device to use
meta:stringpath to the meta device to use
size:intsize in MiB
def _AssembleNet(self, minor, net_info, dual_pri=False, hmac=None, secret=None):

Configure the network part of the device.

Parameters
minor:intthe minor to assemble the network for
net_info:(string, int, string, int)tuple containing the local address, local port, remote address and remote port
dual_pri:booleanwhether two primaries should be allowed or not
hmac:stringthe HMAC algorithm to use
secret:stringthe shared secret to use
def _FastAssemble(self):

Assemble the drbd device from zero.

This is run when in Assemble we detect our minor is unused.

def _GetShowData(self, minor):

Return the `drbdsetup show` data.

Parameters
minor:intthe minor to collect show output for
Returns
stringUndocumented
def _GetShowInfo(self, minor):

Return parsed information from `drbdsetup show`.

Parameters
minor:intthe minor to return information for
Returns
dict as described in drbd_info.BaseShowInfo.GetDevInfoUndocumented
def _MatchesLocal(self, info):

Test if our local config matches with an existing device.

The parameter should be as returned from `_GetShowInfo()`. This method tests if our local backing device is the same as the one in the info parameter, in effect testing if we look like the given device.

Parameters
info:dict as described in drbd_info.BaseShowInfo.GetDevInfoUndocumented
Returns
booleanUndocumented
def _MatchesNet(self, info):

Test if our network config matches with an existing device.

The parameter should be as returned from `_GetShowInfo()`. This method tests if our network configuration is the same as the one in the info parameter, in effect testing if we look like the given device.

Parameters
info:dict as described in drbd_info.BaseShowInfo.GetDevInfoUndocumented
Returns
booleanUndocumented
def _SetFromMinor(self, minor):

Set our parameters based on the given minor.

This sets our minor variable and our dev_path.

Parameters
minor:intUndocumented
def _SetMinorSyncParams(self, minor, params):

Set the parameters of the DRBD syncer.

This is the low-level implementation.

Parameters
minor:intthe drbd minor whose settings we change
params:dictLD level disk parameters related to the synchronization
Returns
lista list of error messages
def _ShutdownLocal(self, minor):

Detach from the local device.

I/Os will continue to be served from the remote device. If we don't have a remote device, this operation will fail.

Parameters
minor:intthe device to detach from the local device
def _ShutdownNet(self, minor):

Disconnect from the remote peer.

This fails if we don't have a local device.

Parameters
minor:booleanthe device to disconnect from the remote peer
def _SlowAssemble(self):

Assembles the DRBD device from a (partially) configured device.

In case of partially attached (local device matches but no network setup), we perform the network attach. If successful, we re-test the attach if can return success.

_DRBD_MAJOR: int =

Undocumented

Value
147
_NET_RECONFIG_TIMEOUT: int =

Undocumented

Value
60
_aminor =

Undocumented

_children: list =
_cmd_gen =

Undocumented

_lhost =

Undocumented

_lport =

Undocumented

_rhost =

Undocumented

_rport =

Undocumented

_secret =

Undocumented

_show_info_cls =

Undocumented