From e480923b7b9be96ce4415ffe817d6c6158701958 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 9 Jun 2009 15:02:44 +0200
Subject: [PATCH] Convert vg_list rpc to new style result

This doesn't have known failure modes but converting will help later.

We also now call directly utils.ListVolumeGroups() instead of the
backend.ListVolumeGroups() so that we don't have to undo the (status,
value) result type.

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

diff --git a/lib/backend.py b/lib/backend.py
index 1d6572908..7dc62f5b2 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -451,7 +451,7 @@ def VerifyNode(what, cluster_name):
       what[constants.NV_INSTANCELIST])
 
   if constants.NV_VGLIST in what:
-    result[constants.NV_VGLIST] = ListVolumeGroups()
+    result[constants.NV_VGLIST] = utils.ListVolumeGroups()
 
   if constants.NV_VERSION in what:
     result[constants.NV_VERSION] = (constants.PROTOCOL_VERSION,
@@ -519,7 +519,7 @@ def ListVolumeGroups():
       size of the volume
 
   """
-  return utils.ListVolumeGroups()
+  return True, utils.ListVolumeGroups()
 
 
 def NodeVolumes():
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index c4a13b9ae..29b21ad36 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -1510,11 +1510,13 @@ class LUSetClusterParams(LogicalUnit):
     if self.op.vg_name:
       vglist = self.rpc.call_vg_list(node_list)
       for node in node_list:
-        if vglist[node].failed:
+        msg = vglist[node].RemoteFailMsg()
+        if msg:
           # ignoring down node
-          self.LogWarning("Node %s unreachable/error, ignoring" % node)
+          self.LogWarning("Error while gathering data on node %s"
+                          " (ignoring node): %s", node, msg)
           continue
-        vgstatus = utils.CheckVolumeGroupSize(vglist[node].data,
+        vgstatus = utils.CheckVolumeGroupSize(vglist[node].payload,
                                               self.op.vg_name,
                                               constants.MIN_VG_SIZE)
         if vgstatus:
@@ -5226,7 +5228,10 @@ class LUReplaceDisks(LogicalUnit):
       raise errors.OpExecError("Can't list volume groups on the nodes")
     for node in oth_node, tgt_node:
       res = results[node]
-      if res.failed or not res.data or my_vg not in res.data:
+      msg = res.RemoteFailMsg()
+      if msg:
+        raise errors.OpExecError("Error checking node %s: %s" % (node, msg))
+      if my_vg not in res.payload:
         raise errors.OpExecError("Volume group '%s' not found on %s" %
                                  (my_vg, node))
     for idx, dev in enumerate(instance.disks):
@@ -5422,7 +5427,10 @@ class LUReplaceDisks(LogicalUnit):
     results = self.rpc.call_vg_list([pri_node, new_node])
     for node in pri_node, new_node:
       res = results[node]
-      if res.failed or not res.data or my_vg not in res.data:
+      msg = res.RemoteFailMsg()
+      if msg:
+        raise errors.OpExecError("Error checking node %s: %s" % (node, msg))
+      if my_vg not in res.payload:
         raise errors.OpExecError("Volume group '%s' not found on %s" %
                                  (my_vg, node))
     for idx, dev in enumerate(instance.disks):
-- 
GitLab