diff --git a/lib/backend.py b/lib/backend.py index 2bae5a2aa273430e46e0b1da1e1a784a9893b4c9..0c311edf12914f094f8471dcd87fdccb0e9624ec 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -1492,7 +1492,7 @@ def _RecursiveAssembleBD(disk, owner, as_primary): return result -def BlockdevAssemble(disk, owner, as_primary): +def BlockdevAssemble(disk, owner, as_primary, idx): """Activate a block device for an instance. This is a wrapper over _RecursiveAssembleBD. @@ -1507,8 +1507,12 @@ def BlockdevAssemble(disk, owner, as_primary): if isinstance(result, bdev.BlockDev): # pylint: disable-msg=E1103 result = result.dev_path + if as_primary: + _SymlinkBlockDev(owner, result, idx) except errors.BlockDeviceError, err: _Fail("Error while assembling disk: %s", err, exc=True) + except OSError, err: + _Fail("Error while symlinking disk: %s", err, exc=True) return result diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 2e52a59868a9a6b1ac12b745a42d25baae3e6a4e..782768da04c0c3e375771c905cd0fc49a05c7508 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -4783,13 +4783,13 @@ def _AssembleInstanceDisks(lu, instance, disks=None, ignore_secondaries=False, # SyncSource, etc.) # 1st pass, assemble on all nodes in secondary mode - for inst_disk in disks: + for idx, inst_disk in enumerate(disks): for node, node_disk in inst_disk.ComputeNodeTree(instance.primary_node): if ignore_size: node_disk = node_disk.Copy() node_disk.UnsetSize() lu.cfg.SetDiskID(node_disk, node) - result = lu.rpc.call_blockdev_assemble(node, node_disk, iname, False) + result = lu.rpc.call_blockdev_assemble(node, node_disk, iname, False, idx) msg = result.fail_msg if msg: lu.proc.LogWarning("Could not prepare block device %s on node %s" @@ -4801,7 +4801,7 @@ def _AssembleInstanceDisks(lu, instance, disks=None, ignore_secondaries=False, # FIXME: race condition on drbd migration to primary # 2nd pass, do only the primary node - for inst_disk in disks: + for idx, inst_disk in enumerate(disks): dev_path = None for node, node_disk in inst_disk.ComputeNodeTree(instance.primary_node): @@ -4811,7 +4811,7 @@ def _AssembleInstanceDisks(lu, instance, disks=None, ignore_secondaries=False, node_disk = node_disk.Copy() node_disk.UnsetSize() lu.cfg.SetDiskID(node_disk, node) - result = lu.rpc.call_blockdev_assemble(node, node_disk, iname, True) + result = lu.rpc.call_blockdev_assemble(node, node_disk, iname, True, idx) msg = result.fail_msg if msg: lu.proc.LogWarning("Could not prepare block device %s on node %s" @@ -5949,7 +5949,7 @@ class LUInstanceMove(LogicalUnit): for idx, disk in enumerate(instance.disks): self.LogInfo("Copying data for disk %d", idx) result = self.rpc.call_blockdev_assemble(target_node, disk, - instance.name, True) + instance.name, True, idx) if result.fail_msg: self.LogWarning("Can't assemble newly created disk %d: %s", idx, result.fail_msg) diff --git a/lib/rpc.py b/lib/rpc.py index 633dc6a7aff1a8d3e424de86a1901dba793b71cf..bd625de98d9d8fe77de8642343118b232f6e546a 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -999,14 +999,14 @@ class RpcRunner(object): [[bdev.ToDict() for bdev in disks], pause]) @_RpcTimeout(_TMO_NORMAL) - def call_blockdev_assemble(self, node, disk, owner, on_primary): + def call_blockdev_assemble(self, node, disk, owner, on_primary, idx): """Request assembling of a given block device. This is a single-node call. """ return self._SingleNodeCall(node, "blockdev_assemble", - [disk.ToDict(), owner, on_primary]) + [disk.ToDict(), owner, on_primary, idx]) @_RpcTimeout(_TMO_NORMAL) def call_blockdev_shutdown(self, node, disk): diff --git a/lib/server/noded.py b/lib/server/noded.py index bf557bc17c348241d61796968b8dc7e71ed27a8d..decc874494f02d8e5850b7b4dbe4b3943b104946 100644 --- a/lib/server/noded.py +++ b/lib/server/noded.py @@ -1,7 +1,7 @@ # # -# Copyright (C) 2006, 2007, 2010 Google Inc. +# Copyright (C) 2006, 2007, 2010, 2011 Google Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -223,11 +223,11 @@ class NodeHttpServer(http.server.HttpServer): """Assemble a block device. """ - bdev_s, owner, on_primary = params + bdev_s, owner, on_primary, idx = params bdev = objects.Disk.FromDict(bdev_s) if bdev is None: raise ValueError("can't unserialize data!") - return backend.BlockdevAssemble(bdev, owner, on_primary) + return backend.BlockdevAssemble(bdev, owner, on_primary, idx) @staticmethod def perspective_blockdev_shutdown(params):