diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-06-01 16:47:19 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-06-01 16:47:19 +0000 |
| commit | aae9f614090c8eca9f596efcc5238d5b8200061b (patch) | |
| tree | 7c51ba783e576a8b67780558392a4eff01028f89 | |
| parent | 31108020fc237624e244f08658646e2f119506db (diff) | |
| parent | 5a1236e469faf0f415989249d8aaa1c510fa8b3d (diff) | |
| download | nova-aae9f614090c8eca9f596efcc5238d5b8200061b.tar.gz nova-aae9f614090c8eca9f596efcc5238d5b8200061b.tar.xz nova-aae9f614090c8eca9f596efcc5238d5b8200061b.zip | |
Merge "Add compare_cpu to the compute rpcapi."
| -rw-r--r-- | nova/compute/rpcapi.py | 4 | ||||
| -rw-r--r-- | nova/scheduler/driver.py | 8 | ||||
| -rw-r--r-- | nova/tests/compute/test_rpcapi.py | 4 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_scheduler.py | 10 |
4 files changed, 19 insertions, 7 deletions
diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py index 0694d6e09..7d7b57151 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -84,6 +84,10 @@ class ComputeAPI(nova.rpc.proxy.RpcProxy): mountpoint=mountpoint), topic=self._compute_topic(ctxt, None, instance)) + def compare_cpu(self, ctxt, cpu_info, host): + return self.call(ctxt, self.make_msg('compare_cpu', cpu_info=cpu_info), + topic=self._compute_topic(ctxt, host, None)) + def confirm_resize(self, ctxt, instance, migration_id, host, cast=True): rpc_method = self.cast if cast else self.call diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 364278584..bf635ddd4 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -23,6 +23,7 @@ Scheduler base class that all Schedulers should inherit from from nova.compute import api as compute_api from nova.compute import power_state +from nova.compute import rpcapi as compute_rpcapi from nova.compute import vm_states from nova import db from nova import exception @@ -137,6 +138,7 @@ class Scheduler(object): self.host_manager = importutils.import_object( FLAGS.scheduler_host_manager) self.compute_api = compute_api.API() + self.compute_rpcapi = compute_rpcapi.ComputeAPI() def get_host_list(self): """Get a list of hosts from the HostManager.""" @@ -354,10 +356,8 @@ class Scheduler(object): # Checking cpuinfo. try: - rpc.call(context, - rpc.queue_get_for(context, FLAGS.compute_topic, dest), - {"method": 'compare_cpu', - "args": {'cpu_info': oservice_ref['cpu_info']}}) + self.compute_rpcapi.compare_cpu(context, oservice_ref['cpu_info'], + dest) except exception.InvalidCPUInfo: src = instance_ref['host'] diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index 7a4fda426..23ac55fc3 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -105,6 +105,10 @@ class ComputeRpcAPITestCase(test.TestCase): self._test_compute_api('attach_volume', 'cast', instance=self.fake_instance, volume_id='id', mountpoint='mp') + def test_compare_cpu(self): + self._test_compute_api('compare_cpu', 'call', cpu_info='info', + host='host') + def test_confirm_resize_cast(self): self._test_compute_api('confirm_resize', 'cast', instance=self.fake_instance, migration_id='id', host='host') diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index 302f22939..e7057b406 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -23,6 +23,7 @@ import json from nova.compute import api as compute_api from nova.compute import power_state +from nova.compute import rpcapi as compute_rpcapi from nova.compute import vm_states from nova import context from nova import db @@ -539,7 +540,9 @@ class SchedulerTestCase(test.TestCase): dest).AndReturn('dest_queue') rpc.call(self.context, 'dest_queue', {'method': 'compare_cpu', - 'args': {'cpu_info': 'fake_cpu_info'}}).AndReturn(True) + 'args': {'cpu_info': 'fake_cpu_info'}, + 'version': compute_rpcapi.ComputeAPI.RPC_API_VERSION}, None + ).AndReturn(True) db.instance_update_and_get_original(self.context, instance['id'], {"vm_state": vm_states.MIGRATING}).AndReturn( @@ -957,8 +960,9 @@ class SchedulerTestCase(test.TestCase): dest).AndReturn('dest_queue') rpc.call(self.context, 'dest_queue', {'method': 'compare_cpu', - 'args': {'cpu_info': 'fake_cpu_info'}}).AndRaise( - rpc_common.RemoteError()) + 'args': {'cpu_info': 'fake_cpu_info'}, + 'version': compute_rpcapi.ComputeAPI.RPC_API_VERSION}, None + ).AndRaise(rpc_common.RemoteError()) self.mox.ReplayAll() self.assertRaises(rpc_common.RemoteError, |
