diff options
| author | Josh Kearney <josh.kearney@rackspace.com> | 2011-01-14 11:24:45 -0600 |
|---|---|---|
| committer | Josh Kearney <josh.kearney@rackspace.com> | 2011-01-14 11:24:45 -0600 |
| commit | cf0e5bd3eeb6b175b53df6ae0a0ef8957ec7ba13 (patch) | |
| tree | 22b1c7d24d44fbb264aebb1e3c396652feae223b /nova/compute | |
| parent | 9fb1e7b1f627b10fda1249754e4bc612d697110c (diff) | |
| download | nova-cf0e5bd3eeb6b175b53df6ae0a0ef8957ec7ba13.tar.gz nova-cf0e5bd3eeb6b175b53df6ae0a0ef8957ec7ba13.tar.xz nova-cf0e5bd3eeb6b175b53df6ae0a0ef8957ec7ba13.zip | |
Create and use a generic handler for RPC calls
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/api.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 90273da36..40b9e33e8 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -331,7 +331,7 @@ class API(base.Base): return self.db.instance_get_all(context) def _cast_compute_message(self, method, context, instance_id, host=None): - """Generic handler for RPC calls to compute.""" + """Generic handler for RPC casts to compute.""" if not host: instance = self.get(context, instance_id) host = instance['host'] @@ -339,6 +339,15 @@ class API(base.Base): kwargs = {'method': method, 'args': {'instance_id': instance_id}} rpc.cast(context, queue, kwargs) + def _call_compute_message(self, method, context, instance_id, host=None): + """Generic handler for RPC calls to compute.""" + if not host: + instance = self.get(context, instance_id) + host = instance["host"] + queue = self.db.queue_get_for(context, FLAGS.compute_topic, host) + kwargs = {"method": method, "args": {"instance_id": instance_id}} + return rpc.call(context, queue, kwargs) + def snapshot(self, context, instance_id, name): """Snapshot the given instance.""" self._cast_compute_message('snapshot_instance', context, instance_id) @@ -357,7 +366,10 @@ class API(base.Base): def get_diagnostics(self, context, instance_id): """Retrieve diagnostics for the given instance.""" - self._cast_compute_message('get_diagnostics', context, instance_id) + return self._call_compute_message( + "get_diagnostics", + context, + instance_id) def get_actions(self, context, instance_id): """Retrieve actions for the given instance.""" |
