From a57bc7e99499f39e4eb31265983d75a9b09e1932 Mon Sep 17 00:00:00 2001 From: Mark Washenberger Date: Mon, 28 Nov 2011 16:26:36 -0500 Subject: Use uuids for file injection. Related to blueprint internal-uuids. Change-Id: I35f2a4c5cafde7ed8831a01cb7a2816ccbc39808 --- nova/compute/api.py | 3 +-- nova/compute/manager.py | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index 32f329a04..a55cc142a 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1448,10 +1448,9 @@ class API(base.Base): @scheduler_api.reroute_compute("inject_file") def inject_file(self, context, instance, path, file_contents): """Write a file to the given instance.""" - instance_id = instance['id'] params = {'path': path, 'file_contents': file_contents} self._cast_compute_message('inject_file', context, - instance_id, params=params) + instance['uuid'], params=params) def get_ajax_console(self, context, instance): """Get a url to an AJAX Console.""" diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 2eed738c1..905d43968 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -903,17 +903,16 @@ class ComputeManager(manager.SchedulerDependentManager): continue @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) - @checks_instance_lock - def inject_file(self, context, instance_id, path, file_contents): + @checks_instance_lock_uuid + def inject_file(self, context, instance_uuid, path, file_contents): """Write a file to the specified path in an instance on this host.""" context = context.elevated() - instance_ref = self.db.instance_get(context, instance_id) - instance_id = instance_ref['id'] + instance_ref = self.db.instance_get_by_uuid(context, instance_uuid) instance_state = instance_ref['power_state'] expected_state = power_state.RUNNING if instance_state != expected_state: LOG.warn(_('trying to inject a file into a non-running ' - 'instance: %(instance_id)s (state: %(instance_state)s ' + 'instance: %(instance_uuid)s (state: %(instance_state)s ' 'expected: %(expected_state)s)') % locals()) nm = instance_ref['name'] msg = _('instance %(nm)s: injecting file to %(path)s') % locals() -- cgit