diff options
| author | Russell Bryant <rbryant@redhat.com> | 2012-05-30 14:04:48 -0400 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2012-06-01 14:05:51 -0400 |
| commit | b7744f8f7e345928df016a04b6d8a5935470b254 (patch) | |
| tree | 10dd164760c1ebea2802f206b096abd9f99ee881 | |
| parent | dc0751ff4649d4b1ae642222704c244d5995138a (diff) | |
Add get_instance_disk_info to the compute rpcapi.
Part of bug 1006467.
This patch adds get_instance_disk_info to the compute rpcapi, which is
used by the scheduler.
Change-Id: Ibb4a86d92ef402a3cc993212dfb8ce073c1c542d
| -rw-r--r-- | nova/compute/rpcapi.py | 5 | ||||
| -rw-r--r-- | nova/scheduler/driver.py | 6 | ||||
| -rw-r--r-- | nova/tests/compute/test_rpcapi.py | 7 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_scheduler.py | 8 |
4 files changed, 18 insertions, 8 deletions
diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py index f078f9d64..155c23abf 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -131,6 +131,11 @@ class ComputeAPI(nova.rpc.proxy.RpcProxy): instance_uuid=instance['uuid']), topic=self._compute_topic(ctxt, None, instance)) + def get_instance_disk_info(self, ctxt, instance): + return self.call(ctxt, self.make_msg('get_instance_disk_info', + instance_name=instance['name']), + topic=self._compute_topic(ctxt, None, instance)) + def get_vnc_console(self, ctxt, instance, console_type): return self.call(ctxt, self.make_msg('get_vnc_console', instance_uuid=instance['uuid'], console_type=console_type), diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 87abfde11..94c3395fe 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -444,11 +444,7 @@ class Scheduler(object): available = available_gb * (1024 ** 3) # Getting necessary disk size - topic = rpc.queue_get_for(context, FLAGS.compute_topic, - instance_ref['host']) - ret = rpc.call(context, topic, - {"method": 'get_instance_disk_info', - "args": {'instance_name': instance_ref['name']}}) + ret = self.compute_rpcapi.get_instance_disk_info(context, instance_ref) disk_infos = jsonutils.loads(ret) necessary = 0 diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index 78ca3ee3c..dabb1f4b2 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -61,9 +61,10 @@ class ComputeRpcAPITestCase(test.TestCase): 'pre_live_migration', 'remove_volume_connection', 'post_live_migration_at_destination']: expected_msg['args']['instance_id'] = instance['id'] + elif method == 'get_instance_disk_info': + expected_msg['args']['instance_name'] = instance['name'] else: expected_msg['args']['instance_uuid'] = instance['uuid'] - expected_msg['version'] = rpcapi.RPC_API_VERSION cast_and_call = ['confirm_resize', 'stop_instance'] @@ -145,6 +146,10 @@ class ComputeRpcAPITestCase(test.TestCase): self._test_compute_api('get_diagnostics', 'call', instance=self.fake_instance) + def test_get_instance_disk_info(self): + self._test_compute_api('get_instance_disk_info', 'call', + instance=self.fake_instance) + def test_get_vnc_console(self): self._test_compute_api('get_vnc_console', 'call', instance=self.fake_instance, console_type='type') diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index e7057b406..2ad79eed6 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -509,7 +509,9 @@ class SchedulerTestCase(test.TestCase): instance['host']).AndReturn('src_queue1') rpc.call(self.context, 'src_queue1', {'method': 'get_instance_disk_info', - 'args': {'instance_name': instance['name']}}).AndReturn( + 'args': {'instance_name': instance['name']}, + 'version': compute_rpcapi.ComputeAPI.RPC_API_VERSION}, + None).AndReturn( json.dumps([{'disk_size': 1024 * (1024 ** 3)}])) # Common checks (shared storage ok, same hypervisor,e tc) @@ -724,7 +726,9 @@ class SchedulerTestCase(test.TestCase): instance['host']).AndReturn('src_queue') rpc.call(self.context, 'src_queue', {'method': 'get_instance_disk_info', - 'args': {'instance_name': instance['name']}}).AndReturn( + 'args': {'instance_name': instance['name']}, + 'version': compute_rpcapi.ComputeAPI.RPC_API_VERSION}, + None).AndReturn( json.dumps([{'disk_size': 1024 * (1024 ** 3)}])) self.mox.ReplayAll() |
