From 96841384853d1b673a7bc004a20e8b39693c141a Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 20 Jan 2009 16:26:57 +0000 Subject: [PATCH] Convert RenameInstance to (status, data) This allows the rename failures to show the ouput of OS scripts. Reviewed-by: ultrotter --- lib/backend.py | 7 +++++-- lib/cmdlib.py | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index 389d4ed35..709f1c9fa 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -723,9 +723,12 @@ def RunRenameInstance(instance, old_name): if result.failed: logging.error("os create command '%s' returned error: %s output: %s", result.cmd, result.fail_reason, result.output) - return False + lines = [val.encode("string_escape") + for val in utils.TailFile(logfile, lines=20)] + return (False, "OS rename script failed (%s), last lines in the" + " log file:\n%s" % (result.fail_reason, "\n".join(lines))) - return True + return (True, "Rename successful") def _GetVGInfo(vg_name): diff --git a/lib/cmdlib.py b/lib/cmdlib.py index dc092a5ee..f1b4ab226 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2973,10 +2973,11 @@ class LURenameInstance(LogicalUnit): try: result = self.rpc.call_instance_run_rename(inst.primary_node, inst, old_name) - if result.failed or not result.data: + msg = result.RemoteFailMsg() + if msg: msg = ("Could not run OS rename script for instance %s on node %s" - " (but the instance has been renamed in Ganeti)" % - (inst.name, inst.primary_node)) + " (but the instance has been renamed in Ganeti): %s" % + (inst.name, inst.primary_node, msg)) self.proc.LogWarning(msg) finally: _ShutdownInstanceDisks(self, inst) -- GitLab