From 53c14ef1d9debcebf82861dcdb1659a72246f473 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 10 Feb 2009 14:43:57 +0000 Subject: [PATCH] Convert blockdev_assemble rpc to (status, data) This converts the RPC call blockdev_assemble to the new-style result format. Note that we won't usually have error information, but it's the first step toward it. Reviewed-by: ultrotter --- lib/backend.py | 16 ++++++++++++---- lib/cmdlib.py | 14 ++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index 6e1d0396e..2c601dbb6 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -1216,10 +1216,18 @@ def BlockdevAssemble(disk, owner, as_primary): C{True} for secondary nodes """ - result = _RecursiveAssembleBD(disk, owner, as_primary) - if isinstance(result, bdev.BlockDev): - result = result.dev_path - return result + status = False + result = "no error information" + try: + result = _RecursiveAssembleBD(disk, owner, as_primary) + if isinstance(result, bdev.BlockDev): + result = result.dev_path + status = True + if result == True: + status = True + except errors.BlockDeviceError, err: + result = "Error while assembling disk: %s" % str(err) + return (status, result) def BlockdevShutdown(disk): diff --git a/lib/cmdlib.py b/lib/cmdlib.py index a939749ff..3171c18fd 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2459,10 +2459,11 @@ def _AssembleInstanceDisks(lu, instance, ignore_secondaries=False): for node, node_disk in inst_disk.ComputeNodeTree(instance.primary_node): lu.cfg.SetDiskID(node_disk, node) result = lu.rpc.call_blockdev_assemble(node, node_disk, iname, False) - if result.failed or not result: + msg = result.RemoteFailMsg() + if msg: lu.proc.LogWarning("Could not prepare block device %s on node %s" - " (is_primary=False, pass=1)", - inst_disk.iv_name, node) + " (is_primary=False, pass=1): %s", + inst_disk.iv_name, node, msg) if not ignore_secondaries: disks_ok = False @@ -2475,10 +2476,11 @@ def _AssembleInstanceDisks(lu, instance, ignore_secondaries=False): continue lu.cfg.SetDiskID(node_disk, node) result = lu.rpc.call_blockdev_assemble(node, node_disk, iname, True) - if result.failed or not result: + msg = result.RemoteFailMsg() + if msg: lu.proc.LogWarning("Could not prepare block device %s on node %s" - " (is_primary=True, pass=2)", - inst_disk.iv_name, node) + " (is_primary=True, pass=2): %s", + inst_disk.iv_name, node, msg) disks_ok = False device_info.append((instance.primary_node, inst_disk.iv_name, result.data)) -- GitLab