From 0e7e3b2c181cfc984f34f25fe57bf2c0f74db380 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Sun, 8 Jan 2012 12:51:35 -0500 Subject: [PATCH] Isolate certain images on certain hosts. This implements a [hosts] <=> [images] mapping in the simple scheduler that partitions your host resources into the part that services a particular image set, and the general cloud. This is useful, for example, if you want to specify a set of hosts to run utility VMs (cloudpipe, bastion, etc) that you don't want consuming resources from your generally available pool. When specifying a host with --isolated_hosts flags (comma-separated list) those hosts will only run the images specified in --isolated_images, and will not run any other images. The isolated images will not run on any other hosts. You can specify --skip_isolated_core_check to allow overcommitting of the isolated hosts. This allows utility vms that are not cpu bound to avoid the resource cheks the scheduler usually performs (based off of --max_cores). Change-Id: Ib2db5a605cb7560a169af9ff2a6dadb649da9c1d --- nova/scheduler/simple.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/nova/scheduler/simple.py b/nova/scheduler/simple.py index aadbe55b..23a58e5b 100644 --- a/nova/scheduler/simple.py +++ b/nova/scheduler/simple.py @@ -36,6 +36,10 @@ flags.DEFINE_integer("max_networks", 1000, "maximum number of networks to allow per host") flags.DEFINE_string('default_schedule_zone', None, 'zone to use when user doesnt specify one') +flags.DEFINE_list('isolated_images', [], 'Images to run on isolated host') +flags.DEFINE_list('isolated_hosts', [], 'Host reserved for specific images') +flags.DEFINE_boolean('skip_isolated_core_check', True, + 'Allow overcommitting vcpus on isolated hosts') class SimpleScheduler(chance.ChanceScheduler): @@ -58,12 +62,21 @@ class SimpleScheduler(chance.ChanceScheduler): return host results = db.service_get_all_compute_sorted(elevated) + in_isolation = instance_opts['image_ref'] in FLAGS.isolated_images + check_cores = not in_isolation or not FLAGS.skip_isolated_core_check if zone: results = [(service, cores) for (service, cores) in results if service['availability_zone'] == zone] for result in results: (service, instance_cores) = result - if instance_cores + instance_opts['vcpus'] > FLAGS.max_cores: + if in_isolation and service['host'] not in FLAGS.isolated_hosts: + # isloated images run on isolated hosts + continue + if service['host'] in FLAGS.isolated_hosts and not in_isolation: + # images that aren't isolated only run on general hosts + continue + if check_cores and \ + instance_cores + instance_opts['vcpus'] > FLAGS.max_cores: msg = _("Not enough allocatable CPU cores remaining") raise exception.NoValidHost(reason=msg) if self.service_is_up(service):