From de12473a7fa22b7351a058df34fa4da3bc076853 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 19 Jan 2009 11:10:42 +0000 Subject: [PATCH] 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 --- lib/cmdlib.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 4140623f9..30387f209 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -3730,12 +3730,37 @@ def _CreateBlockDev(lu, node, instance, device, force_create, if not force_create: 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) new_id = lu.rpc.call_blockdev_create(node, device, device.size, instance.name, force_open, info) if new_id.failed or not new_id.data: 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: device.physical_id = new_id @@ -5017,8 +5042,8 @@ class LUReplaceDisks(LogicalUnit): logical_id=new_alone_id, children=dev.children) try: - _CreateBlockDev(self, new_node, instance, new_drbd, False, - _GetInstanceInfoText(instance), False) + _CreateSingleBlockDev(self, new_node, instance, new_drbd, + _GetInstanceInfoText(instance), False) except error.BlockDeviceError: self.cfg.ReleaseDRBDMinors(instance.name) raise -- GitLab