summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2012-07-26 13:23:23 -0400
committerRussell Bryant <rbryant@redhat.com>2012-07-26 18:46:32 -0400
commit6106973d2fdf57be67d6de4bd5924321ed7e5772 (patch)
treed1292fd1d0d756bf1d40abd6341375040fd299e9 /nova
parenteba4be81a17ada6da228659db7bad2c346e02db8 (diff)
Send a full instance via rpc for get_diagnostics.
Change the get_diagnostics method of the compute rpc API to take a full instance over rpc instead of just the instance UUID. This cuts down on database access needed by nova-compute. Part of blueprint no-db-messaging. Change-Id: Ic4db237849230899ad5f2f0780d4c237895a6631
Diffstat (limited to 'nova')
-rw-r--r--nova/compute/manager.py13
-rw-r--r--nova/compute/rpcapi.py7
-rw-r--r--nova/tests/compute/test_rpcapi.py4
3 files changed, 14 insertions, 10 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index d744a069b..aeebc577a 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -298,7 +298,7 @@ def _get_additional_capabilities():
class ComputeManager(manager.SchedulerDependentManager):
"""Manages the running instances from creation to destruction."""
- RPC_API_VERSION = '1.15'
+ RPC_API_VERSION = '1.16'
def __init__(self, compute_driver=None, *args, **kwargs):
"""Load configuration options and connect to the hypervisor."""
@@ -1777,14 +1777,15 @@ class ComputeManager(manager.SchedulerDependentManager):
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
@wrap_instance_fault
- def get_diagnostics(self, context, instance_uuid):
+ def get_diagnostics(self, context, instance_uuid=None, instance=None):
"""Retrieve diagnostics for an instance on this host."""
- instance_ref = self.db.instance_get_by_uuid(context, instance_uuid)
- current_power_state = self._get_power_state(context, instance_ref)
+ if not instance:
+ instance = self.db.instance_get_by_uuid(context, instance_uuid)
+ current_power_state = self._get_power_state(context, instance)
if current_power_state == power_state.RUNNING:
LOG.audit(_("Retrieving diagnostics"), context=context,
- instance=instance_ref)
- return self.driver.get_diagnostics(instance_ref)
+ instance=instance)
+ return self.driver.get_diagnostics(instance)
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
@checks_instance_lock
diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py
index 35db1fe72..95f7f0d23 100644
--- a/nova/compute/rpcapi.py
+++ b/nova/compute/rpcapi.py
@@ -77,6 +77,7 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.14 - Remove instance_uuid, add instance argument to finish_resize()
1.15 - Remove instance_uuid, add instance argument to
finish_revert_resize()
+ 1.16 - Remove instance_uuid, add instance argument to get_diagnostics()
'''
BASE_RPC_API_VERSION = '1.0'
@@ -181,9 +182,11 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
topic=_compute_topic(self.topic, ctxt, host, None))
def get_diagnostics(self, ctxt, instance):
+ instance_p = jsonutils.to_primitive(instance)
return self.call(ctxt, self.make_msg('get_diagnostics',
- instance_uuid=instance['uuid']),
- topic=_compute_topic(self.topic, ctxt, None, instance))
+ instance=instance_p),
+ topic=_compute_topic(self.topic, ctxt, None, instance),
+ version='1.16')
def get_instance_disk_info(self, ctxt, instance):
return self.call(ctxt, self.make_msg('get_instance_disk_info',
diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py
index 427acf949..bec10009c 100644
--- a/nova/tests/compute/test_rpcapi.py
+++ b/nova/tests/compute/test_rpcapi.py
@@ -53,7 +53,7 @@ class ComputeRpcAPITestCase(test.TestCase):
'check_can_live_migrate_destination',
'check_can_live_migrate_source', 'confirm_resize',
'detach_volume', 'finish_resize', 'finish_revert_resize',
- 'get_console_output',
+ 'get_console_output', 'get_diagnostics',
'pause_instance', 'reboot_instance', 'suspend_instance',
'unpause_instance'
]
@@ -183,7 +183,7 @@ class ComputeRpcAPITestCase(test.TestCase):
def test_get_diagnostics(self):
self._test_compute_api('get_diagnostics', 'call',
- instance=self.fake_instance)
+ instance=self.fake_instance, version='1.16')
def test_get_instance_disk_info(self):
self._test_compute_api('get_instance_disk_info', 'call',