summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-06-06 20:47:59 +0000
committerGerrit Code Review <review@openstack.org>2012-06-06 20:47:59 +0000
commitd15d74dbbd2312f14d12f12fa10cdd6cac00b59a (patch)
tree938f98cfbe0db255c61dd4647c41bde138bd1c8a
parent9c59e515a2f12c64bd9c384659c0d4b5bc3c0601 (diff)
parentb7744f8f7e345928df016a04b6d8a5935470b254 (diff)
downloadnova-d15d74dbbd2312f14d12f12fa10cdd6cac00b59a.tar.gz
nova-d15d74dbbd2312f14d12f12fa10cdd6cac00b59a.tar.xz
nova-d15d74dbbd2312f14d12f12fa10cdd6cac00b59a.zip
Merge "Add get_instance_disk_info to the compute rpcapi."
-rw-r--r--nova/compute/rpcapi.py5
-rw-r--r--nova/scheduler/driver.py6
-rw-r--r--nova/tests/compute/test_rpcapi.py7
-rw-r--r--nova/tests/scheduler/test_scheduler.py8
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 a9b69c4bb..a99644a67 100644
--- a/nova/scheduler/driver.py
+++ b/nova/scheduler/driver.py
@@ -442,11 +442,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()