summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/scheduler/filter_scheduler.py7
-rw-r--r--nova/scheduler/host_manager.py11
-rw-r--r--nova/tests/scheduler/test_host_manager.py23
-rw-r--r--nova/tests/scheduler/test_least_cost.py2
4 files changed, 19 insertions, 24 deletions
diff --git a/nova/scheduler/filter_scheduler.py b/nova/scheduler/filter_scheduler.py
index c43e48876..b2802931c 100644
--- a/nova/scheduler/filter_scheduler.py
+++ b/nova/scheduler/filter_scheduler.py
@@ -257,14 +257,11 @@ class FilterScheduler(driver.Scheduler):
# host, we virtually consume resources on it so subsequent
# selections can adjust accordingly.
- # unfiltered_hosts_dict is {host : ZoneManager.HostInfo()}
- unfiltered_hosts_dict = self.host_manager.get_all_host_states(
- elevated, topic)
-
# Note: remember, we are using an iterator here. So only
# traverse this list once. This can bite you if the hosts
# are being scanned in a filter or weighing function.
- hosts = unfiltered_hosts_dict.itervalues()
+ hosts = self.host_manager.get_all_host_states(
+ elevated, topic)
selected_hosts = []
if instance_uuids:
diff --git a/nova/scheduler/host_manager.py b/nova/scheduler/host_manager.py
index 91e16ad34..1f4b6d956 100644
--- a/nova/scheduler/host_manager.py
+++ b/nova/scheduler/host_manager.py
@@ -336,12 +336,9 @@ class HostManager(object):
self.service_states[host] = service_caps
def get_all_host_states(self, context, topic):
- """Returns a dict of all the hosts the HostManager
- knows about. Also, each of the consumable resources in HostState
- are pre-populated and adjusted based on data in the db.
-
- For example:
- {'192.168.1.100': HostState(), ...}
+ """Returns a list of HostStates that represents all the hosts
+ the HostManager knows about. Also, each of the consumable resources
+ in HostState are pre-populated and adjusted based on data in the db.
Note: this can be very slow with a lot of instances.
InstanceType table isn't required since a copy is stored
@@ -372,4 +369,4 @@ class HostManager(object):
self.host_state_map[host] = host_state
host_state.update_from_compute_node(compute)
- return self.host_state_map
+ return self.host_state_map.itervalues()
diff --git a/nova/tests/scheduler/test_host_manager.py b/nova/tests/scheduler/test_host_manager.py
index 74c24d56b..4d1e00852 100644
--- a/nova/tests/scheduler/test_host_manager.py
+++ b/nova/tests/scheduler/test_host_manager.py
@@ -136,27 +136,28 @@ class HostManagerTestCase(test.TestCase):
host_manager.LOG.warn("No service for compute ID 5")
self.mox.ReplayAll()
- host_states = self.host_manager.get_all_host_states(context, topic)
+ self.host_manager.get_all_host_states(context, topic)
+ host_states_map = self.host_manager.host_state_map
- self.assertEqual(len(host_states), 4)
+ self.assertEqual(len(host_states_map), 4)
# Check that .service is set properly
for i in xrange(4):
compute_node = fakes.COMPUTE_NODES[i]
host = compute_node['service']['host']
- self.assertEqual(host_states[host].service,
+ self.assertEqual(host_states_map[host].service,
compute_node['service'])
- self.assertEqual(host_states['host1'].free_ram_mb, 512)
+ self.assertEqual(host_states_map['host1'].free_ram_mb, 512)
# 511GB
- self.assertEqual(host_states['host1'].free_disk_mb, 524288)
- self.assertEqual(host_states['host2'].free_ram_mb, 1024)
+ self.assertEqual(host_states_map['host1'].free_disk_mb, 524288)
+ self.assertEqual(host_states_map['host2'].free_ram_mb, 1024)
# 1023GB
- self.assertEqual(host_states['host2'].free_disk_mb, 1048576)
- self.assertEqual(host_states['host3'].free_ram_mb, 3072)
+ self.assertEqual(host_states_map['host2'].free_disk_mb, 1048576)
+ self.assertEqual(host_states_map['host3'].free_ram_mb, 3072)
# 3071GB
- self.assertEqual(host_states['host3'].free_disk_mb, 3145728)
- self.assertEqual(host_states['host4'].free_ram_mb, 8192)
+ self.assertEqual(host_states_map['host3'].free_disk_mb, 3145728)
+ self.assertEqual(host_states_map['host4'].free_ram_mb, 8192)
# 8191GB
- self.assertEqual(host_states['host4'].free_disk_mb, 8388608)
+ self.assertEqual(host_states_map['host4'].free_disk_mb, 8388608)
class HostStateTestCase(test.TestCase):
diff --git a/nova/tests/scheduler/test_least_cost.py b/nova/tests/scheduler/test_least_cost.py
index df4e13244..64cda0b2a 100644
--- a/nova/tests/scheduler/test_least_cost.py
+++ b/nova/tests/scheduler/test_least_cost.py
@@ -41,7 +41,7 @@ class LeastCostTestCase(test.TestCase):
fakes.mox_host_manager_db_calls(self.mox, ctxt)
self.mox.ReplayAll()
host_states = self.host_manager.get_all_host_states(ctxt,
- 'compute').values()
+ 'compute')
self.mox.VerifyAll()
self.mox.ResetAll()
return host_states