diff options
| author | Vishvananda Ishaya <vishvananda@yahoo.com> | 2010-09-10 01:13:11 -0700 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@yahoo.com> | 2010-09-10 01:13:11 -0700 |
| commit | 1c01b37a5f2372f4e61fdff8a16a9efe6f6b7e7b (patch) | |
| tree | ff5ce57194e55e4c25ab6ff244cde443fcf6579f | |
| parent | 1867c2aae81e4a73374bde0169b4e16cd8e18846 (diff) | |
set host when item is scheduled
| -rw-r--r-- | nova/scheduler/simple.py | 10 |
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") |
