Commit 4e679f11 authored by Guido Trotter's avatar Guido Trotter
Browse files

Simplify diagnose mangling/unmangling functions

The functions in ganeti-noded and 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
parent 8fa42c7c
......@@ -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):
elif isinstance(data, errors.InvalidOS):
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()]
def perspective_os_get(params):
......@@ -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):
elif isinstance(data, tuple) and len(data) == 3:
nr.append(errors.InvalidOS(data[0], data[1], data[2]))
raise errors.ProgrammerError("Invalid data from"
" xcserver.os_diagnose")
nr = [objects.OS.FromDict(oss) for oss in result[node_name]]
nr = []
new_result[node_name] = nr
return new_result
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment