Convert instance_os_import rpc to new style result
authorIustin Pop <iustin@google.com>
Tue, 9 Jun 2009 13:32:53 +0000 (15:32 +0200)
committerIustin Pop <iustin@google.com>
Mon, 15 Jun 2009 17:08:19 +0000 (19:08 +0200)
This changes from a list of booleans to «status, error messages». This
means that instead knowing which disk has failed (position based), we
get a list of all failures (with details how they failed).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

lib/backend.py
lib/cmdlib.py

index 9c64625..1f571fd 100644 (file)
@@ -1948,13 +1948,12 @@ def ImportOSIntoInstance(instance, src_node, src_images, cluster_name):
         logging.error("Disk import command '%s' returned error: %s"
                       " output: %s", command, result.fail_reason,
                       result.output)
-        final_result.append(False)
-      else:
-        final_result.append(True)
-    else:
-      final_result.append(True)
+        final_result.append("error importing disk %d: %s, %s" %
+                            (idx, result.fail_reason, result.output[-100]))
 
-  return final_result
+  if final_result:
+    return False, "; ".join(final_result)
+  return True, None
 
 
 def ListExports():
index 1ebd6d3..9de2a13 100644 (file)
@@ -4947,12 +4947,10 @@ class LUCreateInstance(LogicalUnit):
         import_result = self.rpc.call_instance_os_import(pnode_name, iobj,
                                                          src_node, src_images,
                                                          cluster_name)
-        import_result.Raise()
-        for idx, result in enumerate(import_result.data):
-          if not result:
-            self.LogWarning("Could not import the image %s for instance"
-                            " %s, disk %d, on node %s" %
-                            (src_images[idx], instance, idx, pnode_name))
+        msg = import_result.RemoteFailMsg()
+        if msg:
+          self.LogWarning("Error while importing the disk images for instance"
+                          " %s on node %s: %s" % (instance, pnode_name, msg))
       else:
         # also checked in the prereq part
         raise errors.ProgrammerError("Unknown OS initialization mode '%s'"