From 6b5e3f705e15b4c6132f1b627cbd4daea95e014e Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 8 Jun 2009 17:30:44 +0200
Subject: [PATCH] Convert rpc call_blockdev_rename to (status, data)

This small patch converts the call_blockdev_rename to the new result
type.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/backend.py |  6 +++++-
 lib/cmdlib.py  | 14 ++++++++------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/lib/backend.py b/lib/backend.py
index 6e83798a4..9586994a0 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -2013,10 +2013,12 @@ def BlockdevRename(devlist):
   @return: True if all renames succeeded, False otherwise
 
   """
+  msgs = []
   result = True
   for disk, unique_id in devlist:
     dev = _RecursiveFindBD(disk)
     if dev is None:
+      msgs.append("Can't find device %s in rename" % str(disk))
       result = False
       continue
     try:
@@ -2031,9 +2033,11 @@ def BlockdevRename(devlist):
         # cache? for now, we only lose lvm data when we rename, which
         # is less critical than DRBD or MD
     except errors.BlockDeviceError, err:
+      msgs.append("Can't rename device '%s' to '%s': %s" %
+                  (dev, unique_id, err))
       logging.exception("Can't rename device '%s' to '%s'", dev, unique_id)
       result = False
-  return result
+  return (result, "; ".join(msgs))
 
 
 def _TransformFileStorageDir(file_storage_dir):
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 1136f31d9..4bd74b65d 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -5251,16 +5251,18 @@ class LUReplaceDisks(LogicalUnit):
 
       info("renaming the old LVs on the target node")
       result = self.rpc.call_blockdev_rename(tgt_node, rlist)
-      result.Raise()
-      if not result.data:
-        raise errors.OpExecError("Can't rename old LVs on node %s" % tgt_node)
+      msg = result.RemoteFailMsg()
+      if msg:
+        raise errors.OpExecError("Can't rename old LVs on node %s: %s" %
+                                 (tgt_node, msg))
       # now we rename the new LVs to the old LVs
       info("renaming the new LVs on the target node")
       rlist = [(new, old.physical_id) for old, new in zip(old_lvs, new_lvs)]
       result = self.rpc.call_blockdev_rename(tgt_node, rlist)
-      result.Raise()
-      if not result.data:
-        raise errors.OpExecError("Can't rename new LVs on node %s" % tgt_node)
+      msg = result.RemoteFailMsg()
+      if msg:
+        raise errors.OpExecError("Can't rename new LVs on node %s: %s" %
+                                 (tgt_node, msg))
 
       for old, new in zip(old_lvs, new_lvs):
         new.logical_id = old.logical_id
-- 
GitLab