From f9af35c870db6c062d177d6e29eb76d430772f01 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Sun, 15 Jun 2008 10:55:09 +0000
Subject: [PATCH] Burnin: Use iallocator in import/export

Currently the iallocator option is ignored by burnin at import/export
time even if passed in. With this patch it becomes used. The log message
used by the importer is also changed to reflect this.

This patch also improves import/export on the non-iallocator case:
  - The secondary node is not passed anymore on non-mirrored templates
  - On mirrored templates the secondary node is logged

Reviewed-by: imsnah
---
 tools/burnin | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/tools/burnin b/tools/burnin
index 5d3976694..c35a8c275 100755
--- a/tools/burnin
+++ b/tools/burnin
@@ -288,6 +288,19 @@ class Burner(object):
                  self.instances)
 
     for pnode, snode, enode, instance in mytor:
+
+      if self.opts.iallocator:
+        pnode = snode = None
+        import_log_msg = ("- Import instance %s from node %s (iallocator: %s)" %
+                          (instance, enode, self.opts.iallocator))
+      elif self.opts.disk_template not in constants.DTS_NET_MIRROR:
+        snode = None
+        import_log_msg = ("- Import instance %s from node %s to node %s" %
+                          (instance, enode, pnode))
+      else:
+        import_log_msg = ("- Import instance %s from node %s to nodes %s/%s" %
+                          (instance, enode, pnode, snode))
+
       exp_op = opcodes.OpExportInstance(instance_name=instance,
                                            target_node=enode,
                                            shutdown=True)
@@ -313,7 +326,8 @@ class Burner(object):
                                         wait_for_sync=True,
                                         mac="auto",
                                         file_storage_dir=None,
-                                        file_driver=None)
+                                        file_driver=None,
+                                        iallocator=self.opts.iallocator)
       erem_op = opcodes.OpRemoveExport(instance_name=instance)
 
       Log("- Export instance %s to node %s" % (instance, enode))
@@ -321,8 +335,7 @@ class Burner(object):
       Log("- Remove instance %s" % (instance))
       self.ExecOp(rem_op)
       self.to_rem.remove(instance)
-      Log("- Import instance %s from node %s to node %s" %
-          (instance, enode, pnode))
+      Log(import_log_msg)
       self.ExecOp(imp_op)
       Log("- Remove export of instance %s" % (instance))
       self.ExecOp(erem_op)
-- 
GitLab