From 4e679f11a47e6cc5d5b1f3ffef6ca36fe47b9def Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Mon, 5 Nov 2007 00:43:34 +0000 Subject: [PATCH] Simplify diagnose mangling/unmangling functions The functions in ganeti-noded and rpc.py still deal with the fact that an InvalidOS error could be returned by DiagnoseOS. As this is not the case anymore simplify their code for the current behavior. Reviewed-By: iustinp --- daemons/ganeti-noded | 18 +----------------- lib/rpc.py | 13 +++---------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index 92825bb42..e11e27c27 100755 --- a/daemons/ganeti-noded +++ b/daemons/ganeti-noded @@ -451,23 +451,7 @@ class ServerObject(pb.Avatar): """Query detailed information about existing OSes. """ - os_list = backend.DiagnoseOS() - if not os_list: - # this catches also return values of 'False', - # for which we can't iterate over - return os_list - result = [] - for data in os_list: - if isinstance(data, objects.OS): - result.append(data.ToDict()) - elif isinstance(data, errors.InvalidOS): - result.append(data.args) - else: - raise errors.ProgrammerError("Invalid result from backend.DiagnoseOS" - " (class %s, %s)" % - (str(data.__class__), data)) - - return result + return [os.ToDict() for os in backend.DiagnoseOS()] @staticmethod def perspective_os_get(params): diff --git a/lib/rpc.py b/lib/rpc.py index 82a78ebfc..c0a1eca53 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -638,17 +638,10 @@ def call_os_diagnose(node_list): result = c.getresult() new_result = {} for node_name in result: - nr = [] if result[node_name]: - for data in result[node_name]: - if data: - if isinstance(data, dict): - nr.append(objects.OS.FromDict(data)) - elif isinstance(data, tuple) and len(data) == 3: - nr.append(errors.InvalidOS(data[0], data[1], data[2])) - else: - raise errors.ProgrammerError("Invalid data from" - " xcserver.os_diagnose") + nr = [objects.OS.FromDict(oss) for oss in result[node_name]] + else: + nr = [] new_result[node_name] = nr return new_result -- GitLab