diff options
| author | Cerberus <matt.dietz@rackspace.com> | 2011-01-19 10:50:54 -0600 |
|---|---|---|
| committer | Cerberus <matt.dietz@rackspace.com> | 2011-01-19 10:50:54 -0600 |
| commit | 11aaf029fa2de53ca0f8a6d1a0953bb616535cbb (patch) | |
| tree | f415027e0acff284f68e7ed563ce58c4acc34ecc /nova/compute | |
| parent | 2c0f1d78927c14f1d155e617a066b09a00acb100 (diff) | |
| parent | 7d7fbf5dfd8a8e10f584df5d27d3479c4b2b4d3a (diff) | |
| download | nova-11aaf029fa2de53ca0f8a6d1a0953bb616535cbb.tar.gz nova-11aaf029fa2de53ca0f8a6d1a0953bb616535cbb.tar.xz nova-11aaf029fa2de53ca0f8a6d1a0953bb616535cbb.zip | |
Merge from trunk
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/api.py | 44 | ||||
| -rw-r--r-- | nova/compute/manager.py | 4 |
2 files changed, 38 insertions, 10 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 22d5964c6..ae760fd47 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -335,27 +335,55 @@ class API(base.Base): project_id) return self.db.instance_get_all(context) - def _cast_compute_message(self, method, context, instance_id, host=None): - """Generic handler for RPC casts to compute.""" + def _cast_compute_message(self, method, context, instance_id, host=None, + params=None): + """Generic handler for RPC casts to compute. + + :param params: Optional dictionary of arguments to be passed to the + compute worker + + :retval None + """ + if not params: + params = {} 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}} + params['instance_id'] = instance_id + kwargs = {'method': method, 'args': params} rpc.cast(context, queue, kwargs) - def _call_compute_message(self, method, context, instance_id, host=None): - """Generic handler for RPC calls to compute.""" + def _call_compute_message(self, method, context, instance_id, host=None, + params=None): + """Generic handler for RPC calls to compute. + + :param params: Optional dictionary of arguments to be passed to the + compute worker + + :retval: Result returned by compute worker + """ + if not params: + params = {} 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}} + params['instance_id'] = instance_id + kwargs = {'method': method, 'args': params} 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) + """Snapshot the given instance. + + :retval: A dict containing image metadata + """ + data = {'name': name, 'is_public': False} + image_meta = self.image_service.create(context, data) + params = {'image_id': image_meta['id']} + self._cast_compute_message('snapshot_instance', context, instance_id, + params=params) + return image_meta def reboot(self, context, instance_id): """Reboot the given instance.""" diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 714cec209..7f0641d44 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -294,7 +294,7 @@ class ComputeManager(manager.Manager): self._update_state(context, instance_id) @exception.wrap_exception - def snapshot_instance(self, context, instance_id, name): + def snapshot_instance(self, context, instance_id, image_id): """Snapshot an instance on this server.""" context = context.elevated() instance_ref = self.db.instance_get(context, instance_id) @@ -311,7 +311,7 @@ class ComputeManager(manager.Manager): 'instance: %s (state: %s excepted: %s)'), instance_id, instance_ref['state'], power_state.RUNNING) - self.driver.snapshot(instance_ref, name) + self.driver.snapshot(instance_ref, image_id) @exception.wrap_exception @checks_instance_lock |
