From 2aaf430aab248d3ea10fe4987b39942ff3eb56df Mon Sep 17 00:00:00 2001 From: Michael Still Date: Sun, 29 Jul 2012 11:29:08 +1000 Subject: Prefer instance in reboot_instance. Now that we're passed through an instance, or something which is immediately turned into an instance, we should prefer using the full instance inside compute methods. This is especially useful for log messages, as it allows users to format the messages more than they can if only the UUID is passed. Change-Id: I29370f33a63817f3e45d453499bd46131b947d7e --- nova/compute/manager.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index f41b20a97..a6de0f78a 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1073,11 +1073,10 @@ class ComputeManager(manager.SchedulerDependentManager): def reboot_instance(self, context, instance=None, instance_uuid=None, reboot_type="SOFT"): """Reboot an instance on this host.""" - LOG.audit(_("Rebooting instance"), context=context, - instance_uuid=instance_uuid) context = context.elevated() if not instance: instance = self.db.instance_get_by_uuid(context, instance_uuid) + LOG.audit(_("Rebooting instance"), context=context, instance=instance) self._notify_about_instance_usage(context, instance, "reboot.start") @@ -1092,17 +1091,17 @@ class ComputeManager(manager.SchedulerDependentManager): LOG.warn(_('trying to reboot a non-running ' 'instance: (state: %(state)s ' 'expected: %(running)s)') % locals(), - context=context, instance_uuid=instance_uuid) + context=context, instance=instance) network_info = self._get_instance_nw_info(context, instance) try: self.driver.reboot(instance, self._legacy_nw_info(network_info), - reboot_type) + reboot_type) except Exception, exc: LOG.error(_('Cannot reboot instance: %(exc)s'), locals(), - context=context, instance_uuid=instance_uuid) - self.add_instance_fault_from_exc(context, instance_uuid, exc, - sys.exc_info()) + context=context, instance=instance) + self.add_instance_fault_from_exc(context, instance['uuid'], exc, + sys.exc_info()) # Fall through and reset task_state to None current_power_state = self._get_power_state(context, instance) -- cgit