Convert RenameInstance to (status, data)
authorIustin Pop <iustin@google.com>
Tue, 20 Jan 2009 16:26:57 +0000 (16:26 +0000)
committerIustin Pop <iustin@google.com>
Tue, 20 Jan 2009 16:26:57 +0000 (16:26 +0000)
This allows the rename failures to show the ouput of OS scripts.

Reviewed-by: ultrotter

lib/backend.py
lib/cmdlib.py

index 389d4ed..709f1c9 100644 (file)
@@ -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):
index dc092a5..f1b4ab2 100644 (file)
@@ -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)