Commit b91bde14 authored by Iustin Pop's avatar Iustin Pop
Browse files

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
parent d1c2dd75
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment