Commit de12473a authored by Iustin Pop's avatar Iustin Pop
Browse files

Split the block device creation in two parts

Some callers of _CreateBlockDev need recursive behaviour, but not all.
The replace secondary first creates (manually) new LVs to ensure storage
is there, and then it creates the new DRBD. At this point, we need a
non-recursive call so that the LVs are not needlessly re-created.

This patch splits the single device creation into a separate function,
so that LUReplaceDisks can use it.

Reviewed-by: ultrotter
parent 428958aa
......@@ -3730,12 +3730,37 @@ def _CreateBlockDev(lu, node, instance, device, force_create,
if not force_create:
_CreateSingleBlockDev(lu, node, instance, device, info, force_open)
def _CreateSingleBlockDev(lu, node, instance, device, info, force_open):
"""Create a single block device on a given node.
This will not recurse over children of the device, so they must be
created in advance.
@param lu: the lu on whose behalf we execute
@param node: the node on which to create the device
@type instance: L{objects.Instance}
@param instance: the instance which owns the device
@type device: L{objects.Disk}
@param device: the device to create
@param info: the extra 'metadata' we should attach to the device
(this will be represented as a LVM tag)
@type force_open: boolean
@param force_open: this parameter will be passes to the
L{backend.CreateBlockDevice} function where it specifies
whether we run on primary or not, and it affects both
the child assembly and the device own Open() execution
lu.cfg.SetDiskID(device, node)
new_id = lu.rpc.call_blockdev_create(node, device, device.size,, force_open, info)
if new_id.failed or not
raise errors.OpExecError("Can't create block device %s on"
" node %s" % (device, node))
" node %s for instance %s" %
(device, node,
if device.physical_id is None:
device.physical_id = new_id
......@@ -5017,8 +5042,8 @@ class LUReplaceDisks(LogicalUnit):
_CreateBlockDev(self, new_node, instance, new_drbd, False,
_GetInstanceInfoText(instance), False)
_CreateSingleBlockDev(self, new_node, instance, new_drbd,
_GetInstanceInfoText(instance), False)
except error.BlockDeviceError:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment