From edb4b374651ca0d971498e36c2516e45439961db Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Wed, 16 Sep 2009 15:15:22 +0200
Subject: [PATCH] Remove RpcResult.failed attribute

It's redundant with RpcResult.fail_msg. This change survived QA, burnin and
unittests.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/cmdlib.py |  4 ++--
 lib/rpc.py    | 14 +++-----------
 2 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index e99d2dec3..8d743fcda 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -1601,7 +1601,7 @@ class LURepairDiskSizes(NoHooksLU):
     changed = []
     for node, dskl in per_node_disks.items():
       result = self.rpc.call_blockdev_getsizes(node, [v[2] for v in dskl])
-      if result.failed or result.fail_msg:
+      if result.RemoteFailMsg():
         self.LogWarning("Failure in blockdev_getsizes call to node"
                         " %s, ignoring", node)
         continue
@@ -4037,7 +4037,7 @@ class LUQueryInstances(NoHooksLU):
         if result.offline:
           # offline nodes will be in both lists
           off_nodes.append(name)
-        if result.failed or result.fail_msg:
+        if result.RemoteFailMsg():
           bad_nodes.append(name)
         else:
           if result.payload:
diff --git a/lib/rpc.py b/lib/rpc.py
index abcec8115..6e12bd2a1 100644
--- a/lib/rpc.py
+++ b/lib/rpc.py
@@ -83,9 +83,6 @@ class RpcResult(object):
   failed, and therefore we use this class to encapsulate the result.
 
   @ivar data: the data payload, for successful results, or None
-  @type failed: boolean
-  @ivar failed: whether the operation failed at transport level (not
-      application level on the remote node)
   @ivar call: the name of the RPC call
   @ivar node: the name of the node to which we made the call
   @ivar offline: whether the operation failed because the node was
@@ -97,12 +94,10 @@ class RpcResult(object):
   """
   def __init__(self, data=None, failed=False, offline=False,
                call=None, node=None):
-    self.failed = failed
     self.offline = offline
     self.call = call
     self.node = node
     if offline:
-      self.failed = True
       self.fail_msg = "Node is marked offline"
       self.data = self.payload = None
     elif failed:
@@ -111,15 +106,12 @@ class RpcResult(object):
     else:
       self.data = data
       if not isinstance(self.data, (tuple, list)):
-        self.failed = True
         self.fail_msg = ("RPC layer error: invalid result type (%s)" %
                          type(self.data))
       elif len(data) != 2:
-        self.failed = True
         self.fail_msg = ("RPC layer error: invalid result length (%d), "
                          "expected 2" % len(self.data))
       elif not self.data[0]:
-        self.failed = True
         self.fail_msg = self._EnsureErr(self.data[1])
       else:
         # finally success
@@ -813,7 +805,7 @@ class RpcRunner(object):
     """
     result = self._SingleNodeCall(node, "blockdev_getmirrorstatus",
                                   [dsk.ToDict() for dsk in disks])
-    if not (result.failed or result.fail_msg):
+    if not result.fail_msg:
       result.payload = [objects.BlockDevStatus.FromDict(i)
                         for i in result.payload]
     return result
@@ -825,7 +817,7 @@ class RpcRunner(object):
 
     """
     result = self._SingleNodeCall(node, "blockdev_find", [disk.ToDict()])
-    if not result.failed and result.payload is not None:
+    if not result.fail_msg and result.payload is not None:
       result.payload = objects.BlockDevStatus.FromDict(result.payload)
     return result
 
@@ -926,7 +918,7 @@ class RpcRunner(object):
 
     """
     result = self._SingleNodeCall(node, "os_get", [name])
-    if not result.failed and isinstance(result.data, dict):
+    if not result.fail_msg and isinstance(result.data, dict):
       result.data = objects.OS.FromDict(result.data)
     return result
 
-- 
GitLab