From 2cc1da8b07305c1c322a5524a7e24ea07b071d72 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 8 Jun 2009 17:38:31 +0200
Subject: [PATCH] Convert call_blockdev_addchildren to new result

This patch converts the blockdev_addchildren rpc call to the new result
format.

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

diff --git a/lib/backend.py b/lib/backend.py
index 9586994a0..f941fbb9b 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -1326,15 +1326,16 @@ def BlockdevAddchildren(parent_cdev, new_cdevs):
   """
   parent_bdev = _RecursiveFindBD(parent_cdev)
   if parent_bdev is None:
-    logging.error("Can't find parent device")
-    return False
+    msg = "Can't find parent device %s" % str(parent_cdev)
+    logging.error("BlockdevAddchildren: %s", msg)
+    return (False, msg)
   new_bdevs = [_RecursiveFindBD(disk) for disk in new_cdevs]
   if new_bdevs.count(None) > 0:
-    logging.error("Can't find new device(s) to add: %s:%s",
-                  new_bdevs, new_cdevs)
-    return False
+    msg = "Can't find new device(s) to add: %s:%s" % (new_bdevs, new_cdevs)
+    logging.error(msg)
+    return (False, msg)
   parent_bdev.AddChildren(new_bdevs)
-  return True
+  return (True, None)
 
 
 def BlockdevRemovechildren(parent_cdev, new_cdevs):
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 4bd74b65d..fba9bb7d4 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -5275,13 +5275,14 @@ class LUReplaceDisks(LogicalUnit):
       # now that the new lvs have the old name, we can add them to the device
       info("adding new mirror component on %s" % tgt_node)
       result = self.rpc.call_blockdev_addchildren(tgt_node, dev, new_lvs)
-      if result.failed or not result.data:
+      msg = result.RemoteFailMsg()
+      if msg:
         for new_lv in new_lvs:
           msg = self.rpc.call_blockdev_remove(tgt_node, new_lv).RemoteFailMsg()
           if msg:
             warning("Can't rollback device %s: %s", dev, msg,
                     hint="cleanup manually the unused logical volumes")
-        raise errors.OpExecError("Can't add local storage to drbd")
+        raise errors.OpExecError("Can't add local storage to drbd: %s" % msg)
 
       dev.children = new_lvs
       cfg.Update(instance)
-- 
GitLab