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, ...@@ -3730,12 +3730,37 @@ def _CreateBlockDev(lu, node, instance, device, force_create,
if not force_create: if not force_create:
return return
_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) lu.cfg.SetDiskID(device, node)
new_id = lu.rpc.call_blockdev_create(node, device, device.size, new_id = lu.rpc.call_blockdev_create(node, device, device.size,
instance.name, force_open, info) instance.name, force_open, info)
if new_id.failed or not new_id.data: if new_id.failed or not new_id.data:
raise errors.OpExecError("Can't create block device %s on" raise errors.OpExecError("Can't create block device %s on"
" node %s" % (device, node)) " node %s for instance %s" %
(device, node, instance.name))
if device.physical_id is None: if device.physical_id is None:
device.physical_id = new_id device.physical_id = new_id
...@@ -5017,8 +5042,8 @@ class LUReplaceDisks(LogicalUnit): ...@@ -5017,8 +5042,8 @@ class LUReplaceDisks(LogicalUnit):
logical_id=new_alone_id, logical_id=new_alone_id,
children=dev.children) children=dev.children)
try: try:
_CreateBlockDev(self, new_node, instance, new_drbd, False, _CreateSingleBlockDev(self, new_node, instance, new_drbd,
_GetInstanceInfoText(instance), False) _GetInstanceInfoText(instance), False)
except error.BlockDeviceError: except error.BlockDeviceError:
self.cfg.ReleaseDRBDMinors(instance.name) self.cfg.ReleaseDRBDMinors(instance.name)
raise raise
......
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