diff options
| author | Russell Bryant <rbryant@redhat.com> | 2012-07-26 13:53:33 -0400 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2012-07-26 18:46:32 -0400 |
| commit | 6fa8a0860dace7ba71f32207375d82387bbbbb68 (patch) | |
| tree | 15fcfe00980c2e22eaa6cca4663d9c5f2575e45d /nova/compute | |
| parent | a484f066008487ed89c27ec4bee8a64b011c20f6 (diff) | |
Send a full instance via rpc for inject_file.
Change the inject_file 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: Ife38a87cb8a597b40b2b87d9a6a8c7e81d4439c4
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/manager.py | 16 | ||||
| -rw-r--r-- | nova/compute/rpcapi.py | 7 |
2 files changed, 14 insertions, 9 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 7ae875430..9461faf52 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.17' + RPC_API_VERSION = '1.18' def __init__(self, compute_driver=None, *args, **kwargs): """Load configuration options and connect to the hypervisor.""" @@ -1302,20 +1302,22 @@ class ComputeManager(manager.SchedulerDependentManager): @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) @checks_instance_lock @wrap_instance_fault - def inject_file(self, context, instance_uuid, path, file_contents): + def inject_file(self, context, path, file_contents, instance_uuid=None, + instance=None): """Write a file to the specified path in an instance on this host.""" context = context.elevated() - 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) expected_state = power_state.RUNNING if current_power_state != expected_state: LOG.warn(_('trying to inject a file into a non-running ' '(state: %(current_power_state)s ' 'expected: %(expected_state)s)') % locals(), - instance=instance_ref) + instance=instance) LOG.audit(_('injecting file to %(path)s') % locals(), - instance=instance_ref) - self.driver.inject_file(instance_ref, path, file_contents) + instance=instance) + self.driver.inject_file(instance, path, file_contents) @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 6382716ad..70747e5cc 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -79,6 +79,7 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): finish_revert_resize() 1.16 - Remove instance_uuid, add instance argument to get_diagnostics() 1.17 - Remove instance_uuid, add instance argument to get_vnc_console() + 1.18 - Remove instance_uuid, add instance argument to inject_file() ''' BASE_RPC_API_VERSION = '1.0' @@ -215,10 +216,12 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy): action=action), topic) def inject_file(self, ctxt, instance, path, file_contents): + instance_p = jsonutils.to_primitive(instance) self.cast(ctxt, self.make_msg('inject_file', - instance_uuid=instance['uuid'], path=path, + instance=instance, path=path, file_contents=file_contents), - topic=_compute_topic(self.topic, ctxt, None, instance)) + topic=_compute_topic(self.topic, ctxt, None, instance), + version='1.18') def inject_network_info(self, ctxt, instance): self.cast(ctxt, self.make_msg('inject_network_info', |
