Package ganeti :: Module cmdlib :: Class TLReplaceDisks
[hide private]
[frames] | no frames]

Class TLReplaceDisks

source code


Replaces disks for an instance.

Note: Locking is not within the scope of this class.

Instance Methods [hide private]
 
__init__(self, lu, instance_name, mode, iallocator_name, remote_node, disks, delay_iallocator, early_release)
Initializes this class.
source code
 
_FindFaultyDisks(self, node_name) source code
 
CheckPrereq(self)
Check prerequisites.
source code
 
_CheckPrereq2(self)
Check prerequisites, second part.
source code
 
Exec(self, feedback_fn)
Execute disk replacement.
source code
 
_CheckVolumeGroup(self, nodes) source code
 
_CheckDisksExistence(self, nodes) source code
 
_CheckDisksConsistency(self, node_name, on_primary, ldisk) source code
 
_CreateNewStorage(self, node_name)
Create new storage on the primary or secondary node.
source code
 
_CheckDevices(self, node_name, iv_names) source code
 
_RemoveOldStorage(self, node_name, iv_names) source code
 
_ReleaseNodeLock(self, node_name)
Releases the lock for a given node.
source code
 
_ExecDrbd8DiskOnly(self, feedback_fn)
Replace a disk on the primary or secondary for DRBD 8.
source code
 
_ExecDrbd8Secondary(self, feedback_fn)
Replace the secondary node for DRBD 8.
source code
Static Methods [hide private]
 
CheckArguments(mode, remote_node, iallocator)
Helper function for users of this class.
source code
 
_RunAllocator(lu, iallocator_name, instance_name, relocate_from)
Compute a new secondary node using an IAllocator.
source code
Method Details [hide private]

__init__(self, lu, instance_name, mode, iallocator_name, remote_node, disks, delay_iallocator, early_release)
(Constructor)

source code 

Initializes this class.

Overrides: Tasklet.__init__

CheckPrereq(self)

source code 

Check prerequisites.

This checks that the instance is in the cluster.

Overrides: Tasklet.CheckPrereq

_CheckPrereq2(self)

source code 

Check prerequisites, second part.

This function should always be part of CheckPrereq. It was separated and is now called from Exec because during node evacuation iallocator was only called with an unmodified cluster model, not taking planned changes into account.

Exec(self, feedback_fn)

source code 

Execute disk replacement.

This dispatches the disk replacement to the appropriate handler.

Overrides: Tasklet.Exec

_CreateNewStorage(self, node_name)

source code 

Create new storage on the primary or secondary node.

This is only used for same-node replaces, not for changing the secondary node, hence we don't want to modify the existing disk.

_ExecDrbd8DiskOnly(self, feedback_fn)

source code 

Replace a disk on the primary or secondary for DRBD 8.

The algorithm for replace is quite complicated:

  1. for each disk to be replaced:
    1. create new LVs on the target node with unique names
    1. detach old LVs from the drbd device
    1. rename old LVs to name_replaced.<time_t>
    1. rename new LVs to old LVs
    1. attach the new LVs (with the old names now) to the drbd device
  1. wait for sync across all devices
  1. for each modified disk:
    1. remove old LVs (which have the name name_replaces.<time_t>)

Failures are not very well handled.

_ExecDrbd8Secondary(self, feedback_fn)

source code 

Replace the secondary node for DRBD 8.

The algorithm for replace is quite complicated:

  • for all disks of the instance:
    • create new LVs on the new node with same names
    • shutdown the drbd device on the old secondary
    • disconnect the drbd network on the primary
    • create the drbd device on the new secondary
    • network attach the drbd on the primary, using an artifice: the drbd code for Attach() will connect to the network if it finds a device which is connected to the good local disks but not network enabled
  • wait for sync across all devices
  • remove all disks from the old secondary

Failures are not very well handled.