The AssembleInstanceDisks function uses internally the call_blockdev_assemble RPC call. It does two passes with this function, the first in the secondary and the last in the primary node. The payloads from the latter operation can be useful to the caller for hotplugging reasons, so we return them in array format.
Signed-off-by: Alex Pyrgiotis <[email protected]> diff --git a/lib/cmdlib/instance.py b/lib/cmdlib/instance.py index a8403f6..54dd7e6 100644 --- a/lib/cmdlib/instance.py +++ b/lib/cmdlib/instance.py @@ -519,8 +519,8 @@ class LUInstanceMove(LogicalUnit): self.LogInfo("Starting instance %s on node %s", self.instance.name, target_node.name) - disks_ok, _ = AssembleInstanceDisks(self, self.instance, - ignore_secondaries=True) + disks_ok, _, _ = AssembleInstanceDisks(self, self.instance, + ignore_secondaries=True) if not disks_ok: ShutdownInstanceDisks(self, self.instance) raise errors.OpExecError("Can't activate the instance's disks") diff --git a/lib/cmdlib/instance_migration.py b/lib/cmdlib/instance_migration.py index 2ab82b8..9eb40d2 100644 --- a/lib/cmdlib/instance_migration.py +++ b/lib/cmdlib/instance_migration.py @@ -963,8 +963,8 @@ class TLMigrateInstance(Tasklet): logging.info("Starting instance %s on node %s", self.instance.name, self.cfg.GetNodeName(self.target_node_uuid)) - disks_ok, _ = AssembleInstanceDisks(self.lu, self.instance, - ignore_secondaries=True) + disks_ok, _, _ = AssembleInstanceDisks(self.lu, self.instance, + ignore_secondaries=True) if not disks_ok: ShutdownInstanceDisks(self.lu, self.instance) raise errors.OpExecError("Can't activate the instance's disks") diff --git a/lib/cmdlib/instance_storage.py b/lib/cmdlib/instance_storage.py index 9354fc1..380fb54 100644 --- a/lib/cmdlib/instance_storage.py +++ b/lib/cmdlib/instance_storage.py @@ -1548,11 +1548,13 @@ def AssembleInstanceDisks(lu, instance, disks=None, ignore_secondaries=False, when the size is wrong @return: False if the operation failed, otherwise a list of (host, instance_visible_name, node_visible_name) - with the mapping from node devices to instance devices + with the mapping from node devices to instance devices, as well as the + payloads of the RPC calls """ device_info = [] disks_ok = True + payloads = [] if disks is None: # only mark instance disks as active if all disks are affected @@ -1605,6 +1607,7 @@ def AssembleInstanceDisks(lu, instance, disks=None, ignore_secondaries=False, node_disk.UnsetSize() result = lu.rpc.call_blockdev_assemble(node_uuid, (node_disk, instance), instance, True, idx) + payloads.append(result.payload) msg = result.fail_msg if msg: lu.LogWarning("Could not prepare block device %s on node %s" @@ -1620,7 +1623,7 @@ def AssembleInstanceDisks(lu, instance, disks=None, ignore_secondaries=False, if not disks_ok: lu.cfg.MarkInstanceDisksInactive(instance.uuid) - return disks_ok, device_info + return disks_ok, device_info, payloads def StartInstanceDisks(lu, instance, force): @@ -1630,8 +1633,8 @@ def StartInstanceDisks(lu, instance, force): instance configuration, if needed. """ - disks_ok, _ = AssembleInstanceDisks(lu, instance, - ignore_secondaries=force) + disks_ok, _, _ = AssembleInstanceDisks(lu, instance, + ignore_secondaries=force) if not disks_ok: ShutdownInstanceDisks(lu, instance) if force is not None and not force: @@ -1774,7 +1777,8 @@ class LUInstanceGrowDisk(LogicalUnit): wipe_disks = self.cfg.GetClusterInfo().prealloc_wipe_disks - disks_ok, _ = AssembleInstanceDisks(self, self.instance, disks=[self.disk]) + disks_ok, _, _ = AssembleInstanceDisks(self, self.instance, + disks=[self.disk]) if not disks_ok: raise errors.OpExecError("Cannot activate block device to grow") @@ -2040,9 +2044,9 @@ class LUInstanceActivateDisks(NoHooksLU): """Activate the disks. """ - disks_ok, disks_info = \ - AssembleInstanceDisks(self, self.instance, - ignore_size=self.op.ignore_size) + disks_ok, disks_info, _ = AssembleInstanceDisks( + self, self.instance, ignore_size=self.op.ignore_size) + if not disks_ok: raise errors.OpExecError("Cannot activate block devices") -- 1.7.10.4
