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

Class BlockDev

source code


Block device abstract class.

A block device can be in the following states:

A device can also be online but read-only, however we are not using the readonly state (LV has it, if needed in the future) and we are usually looking at this like at a stack, so it's easier to conceptualise the transition from not-existing to online and back like a linear one.

The many different states of the device are due to the fact that we need to cover many device types:

A block device is identified by three items:

Not all devices implement both the first two as distinct items. LVM logical volumes have their unique ID (the pair volume group, logical volume name) in a 1-to-1 relation to the dev path. For DRBD devices, the /dev path is again dynamic and the unique id is the pair (host1, dev1), (host2, dev2).

You can get to a device in two ways:

The second point, the attachement to a device, is different depending on whether the device is assembled or not. At init() time, we search for a device with the same unique_id as us. If found, good. It also means that the device is already assembled. If not, after assembly we'll have our correct major/minor.

Instance Methods [hide private]
 
__init__(self, unique_id, children, size)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
Assemble(self)
Assemble the device from its components.
source code
 
Attach(self)
Find a device which matches our config and attach to it.
source code
 
Close(self)
Notifies that the device will no longer be used for I/O.
source code
 
Remove(self)
Remove this device.
source code
 
Rename(self, new_id)
Rename this device.
source code
 
Open(self, force=False)
Make the device ready for use.
source code
 
Shutdown(self)
Shut down the device, freeing its children.
source code
 
SetSyncSpeed(self, speed)
Adjust the sync speed of the mirror.
source code
objects.BlockDevStatus
GetSyncStatus(self)
Returns the sync status of the device.
source code
objects.BlockDevStatus
CombinedSyncStatus(self)
Calculate the mirror status recursively for our children.
source code
 
SetInfo(self, text)
Update metadata with info text.
source code
 
Grow(self, amount)
Grow the block device.
source code
 
GetActualSize(self)
Return the actual disk size.
source code
 
__repr__(self)
repr(x)
source code

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

Class Methods [hide private]
 
Create(cls, unique_id, children, size)
Create the device.
source code
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)

Assemble(self)

source code 

Assemble the device from its components.

Implementations of this method by child classes must ensure that:

  • after the device has been assembled, it knows its major/minor numbers; this allows other devices (usually parents) to probe correctly for their children
  • calling this method on an existing, in-use device is safe
  • if the device is already configured (and in an OK state), this method is idempotent

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

source code 

Create the device.

If the device cannot be created, it will return None instead. Error messages go to the logging system.

Note that for some devices, the unique_id is used, and for other, the children. The idea is that these two, taken together, are enough for both creation and assembly (later).

Remove(self)

source code 

Remove this device.

This makes sense only for some of the device types: LV and file storage. Also note that if the device can't attach, the removal can't be completed.

Rename(self, new_id)

source code 

Rename this device.

This may or may not make sense for a given device type.

Open(self, force=False)

source code 

Make the device ready for use.

This makes the device ready for I/O. For now, just the DRBD devices need this.

The force parameter signifies that if the device has any kind of --force thing, it should be used, we know what we are doing.

Shutdown(self)

source code 

Shut down the device, freeing its children.

This undoes the `Assemble()` work, except for the child assembling; as such, the children on the device are still assembled after this call.

SetSyncSpeed(self, speed)

source code 

Adjust the sync speed of the mirror.

In case this is not a mirroring device, this is no-op.

GetSyncStatus(self)

source code 

Returns the sync status of the device.

If this device is a mirroring device, this function returns the status of the mirror.

If sync_percent is None, it means the device is not syncing.

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

If is_degraded is True, it means the device is missing redundancy. This is usually a sign that something went wrong in the device setup, if sync_percent is None.

The ldisk parameter represents the degradation of the local data. This is only valid for some devices, the rest will always return False (not degraded).

Returns: objects.BlockDevStatus

CombinedSyncStatus(self)

source code 

Calculate the mirror status recursively for our children.

The return value is the same as for `GetSyncStatus()` except the minimum percent and maximum time are calculated across our children.

Returns: objects.BlockDevStatus

SetInfo(self, text)

source code 

Update metadata with info text.

Only supported for some device types.

Grow(self, amount)

source code 

Grow the block device.

Parameters:
  • amount - the amount (in mebibytes) to grow with

GetActualSize(self)

source code 

Return the actual disk size.

Note: the device needs to be active when this is called

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)