From b91bde145c2f2b526423b840f39c3ce44e763219 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 23 Apr 2008 11:00:06 +0000
Subject: [PATCH] Allow burnin to use an iallocator in instance creation

This patch adds iallocator support to burnin, currently only in instance
creation. This means that, depending on the external algorithm, not all
nodes might get instances.

The patch also restricts node selection and iallocator options together.

Reviewed-by: ultrotter
---
 tools/burnin | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/burnin b/tools/burnin
index 0a3a64056..82c851149 100755
--- a/tools/burnin
+++ b/tools/burnin
@@ -138,6 +138,11 @@ class Burner(object):
     parser.add_option("-n", "--nodes", dest="nodes", default="",
                       help="Comma separated list of nodes to perform"
                       " the burnin on (defaults to all nodes)")
+    parser.add_option("--iallocator", dest="iallocator",
+                      default=None, type="string",
+                      help="Perform the allocation using an iallocator"
+                      " instead of fixed node spread (node restrictions no"
+                      " longer apply, therefore -n/--nodes must not be used")
 
     options, args = parser.parse_args()
     if len(args) < 1 or options.os is None:
@@ -151,6 +156,10 @@ class Burner(object):
       Log("Unknown disk template '%s'" % options.disk_template)
       sys.exit(1)
 
+    if options.nodes and options.iallocator:
+      Log("Give either the nodes option or the iallocator option, not both")
+      sys.exit(1)
+
     self.opts = options
     self.instances = args
 
@@ -192,6 +201,8 @@ class Burner(object):
                  islice(cycle(self.nodes), 1, None),
                  self.instances)
     for pnode, snode, instance in mytor:
+      if self.opts.iallocator:
+        pnode = snode = None
       op = opcodes.OpCreateInstance(instance_name=instance,
                                     mem_size=128,
                                     disk_size=self.opts.os_size,
@@ -210,7 +221,8 @@ class Burner(object):
                                     initrd_path=None,
                                     hvm_boot_order=None,
                                     file_driver="loop",
-                                    file_storage_dir=None)
+                                    file_storage_dir=None,
+                                    iallocator=self.opts.iallocator)
       Log("- Add instance %s on nodes %s/%s" % (instance, pnode, snode))
       self.ExecOp(op)
       self.to_rem.append(instance)
-- 
GitLab