Commit dfa96ded authored by Guido Trotter's avatar Guido Trotter
Browse files

Convert os_get to use OS rather than InvalidOS

In order to do this for simplicity we leave the OSFromDisk function as-is and
we convert the eventual exception to an OS object in ganeti-noded. The
unmangling gets simplified and so does the code for checking whether the OS is
valid.

Reviewed-By: iustinp
parent 4e679f11
......@@ -460,10 +460,10 @@ class ServerObject(pb.Avatar):
"""
name = params[0]
try:
os_obj = backend.OSFromDisk(name).ToDict()
os_obj = backend.OSFromDisk(name)
except errors.InvalidOS, err:
os_obj = err.args
return os_obj
os_obj = objects.OS.FromInvalidOS(err)
return os_obj.ToDict()
# hooks -----------------------
......
......@@ -2159,7 +2159,7 @@ class LUReinstallInstance(LogicalUnit):
raise errors.OpPrereqError("Primary node '%s' is unknown" %
self.op.pnode)
os_obj = rpc.call_os_get(pnode.name, self.op.os_type)
if not isinstance(os_obj, objects.OS):
if not os_obj:
raise errors.OpPrereqError("OS '%s' not in supported OS list for"
" primary node" % self.op.os_type)
......@@ -2950,7 +2950,7 @@ class LUCreateInstance(LogicalUnit):
# os verification
os_obj = rpc.call_os_get(pnode.name, self.op.os_type)
if not isinstance(os_obj, objects.OS):
if not os_obj:
raise errors.OpPrereqError("OS '%s' not in supported os list for"
" primary node" % self.op.os_type)
......
......@@ -656,15 +656,10 @@ def call_os_get(node, name):
c.connect(node)
c.run()
result = c.getresult().get(node, False)
if isinstance(result, dict):
new_result = objects.OS.FromDict(result)
elif isinstance(result, tuple) and len(data) == 3:
new_result = errors.InvalidOS(result[0], result[1], result[2])
return objects.OS.FromDict(result)
else:
new_result = result
return new_result
return result
def call_hooks_runner(node_list, hpath, phase, env):
......
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