summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorArata Notsu <notsu@virtualtech.jp>2012-11-08 01:00:26 +0900
committerArata Notsu <notsu@virtualtech.jp>2012-11-08 01:00:26 +0900
commit7af5bdd41dccd62ee19953b3616bd9d0863253f7 (patch)
treee41b3760023e4a796848c08edd78cdfb066b36ff /nova/tests
parent066b3930cfffcd532ed70360902a14d8155289d4 (diff)
Make HostManager.get_all_host_states() return an iterator
Change the method's returning from a dictionary {host: HostState} to an iterator for HostState, because the only caller of the method (in filter_scheduler.py) is not interested in its key. Change-Id: I84f649795a422e392a4c0d555c6cb29a01fae2d9
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/scheduler/test_host_manager.py23
-rw-r--r--nova/tests/scheduler/test_least_cost.py2
2 files changed, 13 insertions, 12 deletions
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