Commit 20e01edd authored by Iustin Pop's avatar Iustin Pop
Browse files

Convert AddOSToInstance to (status, data)

This allows the install and reinstall instance to return (hopefully)
relevant log files from the OS create scripts.

Reviewed-by: ultrotter
parent dd279568
......@@ -681,9 +681,12 @@ def AddOSToInstance(instance):
logging.error("os create command '%s' returned error: %s, logfile: %s,"
" output: %s", result.cmd, result.fail_reason, logfile,
result.output)
return False
lines = [val.encode("string_escape")
for val in utils.TailFile(logfile, lines=20)]
return (False, "OS create script failed (%s), last lines in the"
" log file:\n%s" % (result.fail_reason, "\n".join(lines)))
return True
return (True, "Successfully installed")
def RunRenameInstance(instance, old_name):
......
......@@ -2837,11 +2837,11 @@ class LUReinstallInstance(LogicalUnit):
try:
feedback_fn("Running the instance OS create scripts...")
result = self.rpc.call_instance_os_add(inst.primary_node, inst)
result.Raise()
if not result.data:
msg = result.RemoteFailMsg()
if msg:
raise errors.OpExecError("Could not install OS for instance %s"
" on node %s" %
(inst.name, inst.primary_node))
" on node %s: %s" %
(inst.name, inst.primary_node, msg))
finally:
_ShutdownInstanceDisks(self, inst)
......@@ -4512,11 +4512,11 @@ class LUCreateInstance(LogicalUnit):
if self.op.mode == constants.INSTANCE_CREATE:
feedback_fn("* running the instance OS create scripts...")
result = self.rpc.call_instance_os_add(pnode_name, iobj)
result.Raise()
if not result.data:
msg = result.RemoteFailMsg()
if msg:
raise errors.OpExecError("Could not add os for instance %s"
" on node %s" %
(instance, pnode_name))
" on node %s: %s" %
(instance, pnode_name, msg))
elif self.op.mode == constants.INSTANCE_IMPORT:
feedback_fn("* running the instance OS import scripts...")
......
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