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
=== modified file 'nova/compute/api.py'
--- nova/compute/api.py 2011-01-12 19:22:01 +0000
+++ nova/compute/api.py 2011-01-14 17:27:00 +0000
@@ -331,7 +331,7 @@
331 return self.db.instance_get_all(context)331 return self.db.instance_get_all(context)
332332
333 def _cast_compute_message(self, method, context, instance_id, host=None):333 def _cast_compute_message(self, method, context, instance_id, host=None):
334 """Generic handler for RPC calls to compute."""334 """Generic handler for RPC casts to compute."""
335 if not host:335 if not host:
336 instance = self.get(context, instance_id)336 instance = self.get(context, instance_id)
337 host = instance['host']337 host = instance['host']
@@ -339,6 +339,15 @@
339 kwargs = {'method': method, 'args': {'instance_id': instance_id}}339 kwargs = {'method': method, 'args': {'instance_id': instance_id}}
340 rpc.cast(context, queue, kwargs)340 rpc.cast(context, queue, kwargs)
341341
342 def _call_compute_message(self, method, context, instance_id, host=None):
343 """Generic handler for RPC calls to compute."""
344 if not host:
345 instance = self.get(context, instance_id)
346 host = instance["host"]
347 queue = self.db.queue_get_for(context, FLAGS.compute_topic, host)
348 kwargs = {"method": method, "args": {"instance_id": instance_id}}
349 return rpc.call(context, queue, kwargs)
350
342 def snapshot(self, context, instance_id, name):351 def snapshot(self, context, instance_id, name):
343 """Snapshot the given instance."""352 """Snapshot the given instance."""
344 self._cast_compute_message('snapshot_instance', context, instance_id)353 self._cast_compute_message('snapshot_instance', context, instance_id)
@@ -357,7 +366,10 @@
357366
358 def get_diagnostics(self, context, instance_id):367 def get_diagnostics(self, context, instance_id):
359 """Retrieve diagnostics for the given instance."""368 """Retrieve diagnostics for the given instance."""
360 self._cast_compute_message('get_diagnostics', context, instance_id)369 return self._call_compute_message(
370 "get_diagnostics",
371 context,
372 instance_id)
361373
362 def get_actions(self, context, instance_id):374 def get_actions(self, context, instance_id):
363 """Retrieve actions for the given instance."""375 """Retrieve actions for the given instance."""