summaryrefslogtreecommitdiffstats
path: root/nova/scheduler
diff options
context:
space:
mode:
Diffstat (limited to 'nova/scheduler')
-rw-r--r--nova/scheduler/simple.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/nova/scheduler/simple.py b/nova/scheduler/simple.py
index e53e9fa7e..48be4c1a6 100644
--- a/nova/scheduler/simple.py
+++ b/nova/scheduler/simple.py
@@ -37,7 +37,7 @@ flags.DEFINE_integer("max_networks", 1000,
class SimpleScheduler(chance.ChanceScheduler):
"""Implements Naive Scheduler that tries to find least loaded host."""
- def schedule_run_instance(self, context, *_args, **_kwargs):
+ def schedule_run_instance(self, context, instance_id, *_args, **_kwargs):
"""Picks a host that is up and has the fewest running instances."""
results = db.service_get_all_compute_sorted(context)
@@ -46,10 +46,13 @@ class SimpleScheduler(chance.ChanceScheduler):
if instance_count >= FLAGS.max_instances:
raise driver.NoValidHost("All hosts have too many instances")
if self.service_is_up(service):
+ db.instance_update(context,
+ instance_id,
+ {'host': service['host']})
return service['host']
raise driver.NoValidHost("No hosts found")
- def schedule_create_volume(self, context, *_args, **_kwargs):
+ def schedule_create_volume(self, context, volume_id, *_args, **_kwargs):
"""Picks a host that is up and has the fewest volumes."""
results = db.service_get_all_volume_sorted(context)
@@ -58,6 +61,9 @@ class SimpleScheduler(chance.ChanceScheduler):
if instance_count >= FLAGS.max_volumes:
raise driver.NoValidHost("All hosts have too many volumes")
if self.service_is_up(service):
+ db.instance_update(context,
+ volume_id,
+ {'host': service['host']})
return service['host']
raise driver.NoValidHost("No hosts found")