Merge lp:~jk0/nova/lp702965 into lp:~hudson-openstack/nova/trunk

Proposed by Josh Kearney
Status: Merged
Approved by: Vish Ishaya
Approved revision: 566
Merged at revision: 566
Proposed branch: lp:~jk0/nova/lp702965
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 40 lines (+14/-2)
1 file modified
nova/compute/api.py (+14/-2)
To merge this branch: bzr merge lp:~jk0/nova/lp702965
Reviewer Review Type Date Requested Status
Vish Ishaya (community) Approve
Trey Morris (community) Approve
Monsyne Dragon (community) Approve
Matt Dietz (community) Approve
Review via email: mp+46291@code.launchpad.net

Commit message

Create and use a generic handler for RPC calls to compute.

To post a comment you must log in.
Revision history for this message
Matt Dietz (cerberus) wrote :

Seems ok.

review: Approve
Revision history for this message
Monsyne Dragon (mdragon) wrote :

Lgtm. Just handling calls the same way as casts.

review: Approve
Revision history for this message
Trey Morris (tr3buchet) wrote :

/2nd

review: Approve
Revision history for this message
Vish Ishaya (vishvananda) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/compute/api.py'
2--- nova/compute/api.py 2011-01-12 19:22:01 +0000
3+++ nova/compute/api.py 2011-01-14 17:27:00 +0000
4@@ -331,7 +331,7 @@
5 return self.db.instance_get_all(context)
6
7 def _cast_compute_message(self, method, context, instance_id, host=None):
8- """Generic handler for RPC calls to compute."""
9+ """Generic handler for RPC casts to compute."""
10 if not host:
11 instance = self.get(context, instance_id)
12 host = instance['host']
13@@ -339,6 +339,15 @@
14 kwargs = {'method': method, 'args': {'instance_id': instance_id}}
15 rpc.cast(context, queue, kwargs)
16
17+ def _call_compute_message(self, method, context, instance_id, host=None):
18+ """Generic handler for RPC calls to compute."""
19+ if not host:
20+ instance = self.get(context, instance_id)
21+ host = instance["host"]
22+ queue = self.db.queue_get_for(context, FLAGS.compute_topic, host)
23+ kwargs = {"method": method, "args": {"instance_id": instance_id}}
24+ return rpc.call(context, queue, kwargs)
25+
26 def snapshot(self, context, instance_id, name):
27 """Snapshot the given instance."""
28 self._cast_compute_message('snapshot_instance', context, instance_id)
29@@ -357,7 +366,10 @@
30
31 def get_diagnostics(self, context, instance_id):
32 """Retrieve diagnostics for the given instance."""
33- self._cast_compute_message('get_diagnostics', context, instance_id)
34+ return self._call_compute_message(
35+ "get_diagnostics",
36+ context,
37+ instance_id)
38
39 def get_actions(self, context, instance_id):
40 """Retrieve actions for the given instance."""