From 83d92ad8a5c653b599fec0f9cb550875012aef25 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 10 Jun 2009 17:17:24 +0200 Subject: [PATCH] Convert os_diagnose rpc to new style result This also removes custom post-processing from rpc.py; since this call has only one user, it was simple to move it back to the caller. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- daemons/ganeti-noded | 2 +- lib/cmdlib.py | 13 ++++++------- lib/rpc.py | 8 +------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index d70fe8e7d..3e53f2b66 100755 --- a/daemons/ganeti-noded +++ b/daemons/ganeti-noded @@ -608,7 +608,7 @@ class NodeHttpServer(http.server.HttpServer): """Query detailed information about existing OSes. """ - return [os_obj.ToDict() for os_obj in backend.DiagnoseOS()] + return True, [os_obj.ToDict() for os_obj in backend.DiagnoseOS()] @staticmethod def perspective_os_get(params): diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 7c540b8d8..ea3632797 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -1811,11 +1811,12 @@ class LUDiagnoseOS(NoHooksLU): # level), so that nodes with a non-responding node daemon don't # make all OSes invalid good_nodes = [node_name for node_name in rlist - if not rlist[node_name].failed] - for node_name, nr in rlist.iteritems(): - if nr.failed or not nr.data: + if not rlist[node_name].RemoteFailMsg()] + for node_name, nr in rlist.items(): + if nr.RemoteFailMsg() or not nr.payload: continue - for os_obj in nr.data: + for os_serialized in nr.payload: + os_obj = objects.OS.FromDict(os_serialized) if os_obj.name not in all_os: # build a list of nodes for this os containing empty lists # for each node in node_list @@ -1831,11 +1832,9 @@ class LUDiagnoseOS(NoHooksLU): """ valid_nodes = [node for node in self.cfg.GetOnlineNodeList()] node_data = self.rpc.call_os_diagnose(valid_nodes) - if node_data == False: - raise errors.OpExecError("Can't gather the list of OSes") pol = self._DiagnoseByOS(valid_nodes, node_data) output = [] - for os_name, os_data in pol.iteritems(): + for os_name, os_data in pol.items(): row = [] for field in self.op.output_fields: if field == "name": diff --git a/lib/rpc.py b/lib/rpc.py index 2e5d638ec..e7560a147 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -864,13 +864,7 @@ class RpcRunner(object): This is a multi-node call. """ - result = self._MultiNodeCall(node_list, "os_diagnose", []) - - for node_result in result.values(): - if not node_result.failed and node_result.data: - node_result.data = [objects.OS.FromDict(oss) - for oss in node_result.data] - return result + return self._MultiNodeCall(node_list, "os_diagnose", []) def call_os_get(self, node, name): """Returns an OS definition. -- GitLab