Package ganeti :: Module bdev :: Class DRBD8
[hide private]
[frames] | no frames]

Class DRBD8

source code


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 the (local_ip, local_port, remote_ip, remote_port) 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.

Instance Methods [hide private]
 
__init__(self, unique_id, children, size)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
_MatchesLocal(self, info)
Test if our local config matches with an existing device.
source code
 
_MatchesNet(self, info)
Test if our network config matches with an existing device.
source code
 
AddChildren(self, devices)
Add a disk to the DRBD device.
source code
 
RemoveChildren(self, devices)
Detach the drbd device from local storage.
source code
boolean
SetSyncSpeed(self, kbytes)
Set the speed of the DRBD syncer.
source code
 
GetProcStatus(self)
Return device data from /proc.
source code
objects.BlockDevStatus
GetSyncStatus(self)
Returns the sync status of the device.
source code
 
Open(self, force=False)
Make the local state primary.
source code
 
Close(self)
Make the local state secondary.
source code
 
DisconnectNet(self)
Removes network configuration.
source code
 
AttachNet(self, multimaster)
Reconnects the network.
source code
 
Attach(self)
Check if our minor is configured.
source code
 
Assemble(self)
Assemble the drbd.
source code
 
_SlowAssemble(self)
Assembles the DRBD device from a (partially) configured device.
source code
 
_FastAssemble(self)
Assemble the drbd device from zero.
source code
 
Shutdown(self)
Shutdown the DRBD device.
source code
 
Remove(self)
Stub remove for DRBD devices.
source code
 
Grow(self, amount)
Resize the DRBD device and its backing storage.
source code

Inherited from BaseDRBD: Rename

Inherited from BaseDRBD (private): _SetFromMinor

Inherited from BlockDev: CombinedSyncStatus, GetActualSize, SetInfo, __repr__

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

Class Methods [hide private]
 
_InitMeta(cls, minor, dev_path)
Initialize a meta device.
source code
 
_FindUnusedMinor(cls)
Find an unused DRBD device.
source code
 
_GetShowParser(cls)
Return a parser for `drbd show` output.
source code
 
_GetShowData(cls, minor)
Return the `drbdsetup show` data for a minor.
source code
 
_GetDevInfo(cls, out)
Parse details about a given DRBD minor.
source code
 
_AssembleLocal(cls, minor, backend, meta, size)
Configure the local part of a DRBD device.
source code
 
_AssembleNet(cls, minor, net_info, protocol, dual_pri=False, hmac=None, secret=None)
Configure the network part of the device.
source code
boolean
_SetMinorSyncSpeed(cls, minor, kbytes)
Set the speed of the DRBD syncer.
source code
 
_ShutdownLocal(cls, minor)
Detach from the local device.
source code
 
_ShutdownNet(cls, minor)
Disconnect from the remote peer.
source code
 
_ShutdownAll(cls, minor)
Deactivate the device.
source code
 
Create(cls, unique_id, children, size)
Create a new DRBD8 device.
source code

Inherited from BaseDRBD: GetUsedDevs

Inherited from BaseDRBD (private): _GetVersion, _MassageProcData

Static Methods [hide private]

Inherited from BaseDRBD: GetUsermodeHelper

Inherited from BaseDRBD (private): _CheckMetaSize, _DevPath, _GetProcData

Class Variables [hide private]
  _MAX_MINORS = 255
  _PARSE_SHOW = None
  _NET_RECONFIG_TIMEOUT = 60
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, unique_id, children, size)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

_InitMeta(cls, minor, dev_path)
Class Method

source code 

Initialize a meta device.

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

_FindUnusedMinor(cls)
Class Method

source code 

Find an unused DRBD device.

This is specific to 8.x as the minors are allocated dynamically, so non-existing numbers up to a max minor count are actually free.

_GetShowParser(cls)
Class Method

source code 

Return a parser for `drbd show` output.

This will either create or return an already-create parser for the output of the command `drbd show`.

_GetDevInfo(cls, out)
Class Method

source code 

Parse details about a given DRBD minor.

This return, if available, the local backing device (as a path) and the local and remote (ip, port) information from a string containing the output of the `drbdsetup show` command as returned by _GetShowData.

_MatchesLocal(self, info)

source code 

Test if our local config matches with an existing device.

The parameter should be as returned from `_GetDevInfo()`. 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.

_MatchesNet(self, info)

source code 

Test if our network config matches with an existing device.

The parameter should be as returned from `_GetDevInfo()`. 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.

_SetMinorSyncSpeed(cls, minor, kbytes)
Class Method

source code 

Set the speed of the DRBD syncer.

This is the low-level implementation.

Parameters:
  • minor (int) - the drbd minor whose settings we change
  • kbytes (int) - the speed in kbytes/second
Returns: boolean
the success of the operation

SetSyncSpeed(self, kbytes)

source code 

Set the speed of the DRBD syncer.

Parameters:
  • kbytes (int) - the speed in kbytes/second
Returns: boolean
the success of the operation
Overrides: BlockDev.SetSyncSpeed

GetSyncStatus(self)

source code 

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.BlockDevStatus
Overrides: BlockDev.GetSyncStatus

Open(self, force=False)

source code 

Make the local state primary.

If the 'force' parameter is given, the '-o' option is passed to drbdsetup. Since this is a potentially dangerous operation, the force flag should be only given after creation, when it actually is mandatory.

Overrides: BlockDev.Open

Close(self)

source code 

Make the local state secondary.

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

Overrides: BlockDev.Close

DisconnectNet(self)

source code 

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.

AttachNet(self, multimaster)

source code 

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.

Args:

  • multimaster: init the network in dual-primary mode

Attach(self)

source code 

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).

Overrides: BlockDev.Attach

Assemble(self)

source code 

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
Overrides: BlockDev.Assemble

_SlowAssemble(self)

source code 

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.

_FastAssemble(self)

source code 

Assemble the drbd device from zero.

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

_ShutdownLocal(cls, minor)
Class Method

source code 

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.

_ShutdownNet(cls, minor)
Class Method

source code 

Disconnect from the remote peer.

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

_ShutdownAll(cls, minor)
Class Method

source code 

Deactivate the device.

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

Shutdown(self)

source code 

Shutdown the DRBD device.

Overrides: BlockDev.Shutdown

Remove(self)

source code 

Stub remove for DRBD devices.

Overrides: BlockDev.Remove

Create(cls, unique_id, children, size)
Class Method

source code 

Create a new DRBD8 device.

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

Overrides: BlockDev.Create

Grow(self, amount)

source code 

Resize the DRBD device and its backing storage.

Parameters:
  • amount - the amount (in mebibytes) to grow with
Overrides: BlockDev.Grow