summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-02-22 18:30:02 +0000
committerGerrit Code Review <review@openstack.org>2012-02-22 18:30:02 +0000
commit00f8caaeff15b03062db99290b8ebbe96a6712c5 (patch)
tree463e495668fd1a9a1bf8a44cdbb73a71150a91e9 /nova
parentad0e030103ba34f2ac50ffe3bc09d8a1d1c22d46 (diff)
parent02130b6f9ab6d3443918ae987b419d3b229b39fa (diff)
downloadnova-00f8caaeff15b03062db99290b8ebbe96a6712c5.tar.gz
nova-00f8caaeff15b03062db99290b8ebbe96a6712c5.tar.xz
nova-00f8caaeff15b03062db99290b8ebbe96a6712c5.zip
Merge "Fix WeightedHost"
Diffstat (limited to 'nova')
-rw-r--r--nova/scheduler/least_cost.py2
-rw-r--r--nova/tests/scheduler/test_least_cost.py22
2 files changed, 22 insertions, 2 deletions
diff --git a/nova/scheduler/least_cost.py b/nova/scheduler/least_cost.py
index 27878ec68..899cfd38c 100644
--- a/nova/scheduler/least_cost.py
+++ b/nova/scheduler/least_cost.py
@@ -63,8 +63,6 @@ class WeightedHost(object):
x = dict(weight=self.weight)
if self.host_state:
x['host'] = self.host_state.host
- if self.zone:
- x['zone'] = self.zone
return x
diff --git a/nova/tests/scheduler/test_least_cost.py b/nova/tests/scheduler/test_least_cost.py
index 6b72b026d..7c09e4e69 100644
--- a/nova/tests/scheduler/test_least_cost.py
+++ b/nova/tests/scheduler/test_least_cost.py
@@ -16,6 +16,7 @@
Tests For Least Cost functions.
"""
from nova import context
+from nova.scheduler import host_manager
from nova.scheduler import least_cost
from nova import test
from nova.tests.scheduler import fakes
@@ -89,3 +90,24 @@ class LeastCostTestCase(test.TestCase):
options)
self.assertEqual(weighted_host.weight, 10512)
self.assertEqual(weighted_host.host_state.host, 'host1')
+
+
+class TestWeightedHost(test.TestCase):
+
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ def test_dict_conversion_without_host_state(self):
+ host = least_cost.WeightedHost('someweight')
+ expected = {'weight': 'someweight'}
+ self.assertDictMatch(host.to_dict(), expected)
+
+ def test_dict_conversion_with_host_state(self):
+ host_state = host_manager.HostState('somehost', 'sometopic')
+ host = least_cost.WeightedHost('someweight', host_state)
+ expected = {'weight': 'someweight',
+ 'host': 'somehost'}
+ self.assertDictMatch(host.to_dict(), expected)