Commit 1268d6fd authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix handling OS errors in AddOSToInstance

This patch fixes the error handling in the add OS to instance function
with regard to invalid OSes. Previously, we didn't handle any such
errors, with the end result that the user would have to look in the node
daemon log.

The patch also renames the name of the function to match the RPC call
name.

Reviewed-by: ultrotter
parent d3da87b8
......@@ -364,7 +364,7 @@ class NodeHttpServer(http.server.HttpServer):
"""
inst_s = params[0]
inst = objects.Instance.FromDict(inst_s)
return backend.AddOSToInstance(inst)
return backend.InstanceOsAdd(inst)
@staticmethod
def perspective_instance_run_rename(params):
......
......@@ -669,7 +669,7 @@ def GetAllInstancesInfo(hypervisor_list):
return output
def AddOSToInstance(instance):
def InstanceOsAdd(instance):
"""Add an OS to an instance.
@type instance: L{objects.Instance}
......@@ -678,7 +678,15 @@ def AddOSToInstance(instance):
@return: the success of the operation
"""
inst_os = OSFromDisk(instance.os)
try:
inst_os = OSFromDisk(instance.os)
except errors.InvalidOS, err:
os_name, os_dir, os_err = err.args
if os_dir is None:
return (False, "Can't find OS '%s': %s" % (os_name, os_err))
else:
return (False, "Error parsing OS '%s' in directory %s: %s" %
(os_name, os_dir, os_err))
create_env = OSEnvironment(instance)
......
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