diff options
| author | Michael Still <mikal@stillhq.com> | 2012-07-29 11:29:08 +1000 |
|---|---|---|
| committer | Michael Still <mikal@stillhq.com> | 2012-07-29 11:29:08 +1000 |
| commit | 2aaf430aab248d3ea10fe4987b39942ff3eb56df (patch) | |
| tree | 2d4a41762d89de0128649f6a994da4162f5772d9 | |
| parent | bad0a496c0e765da3cc879235c988b7cc617f367 (diff) | |
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
| -rw-r--r-- | nova/compute/manager.py | 13 |
1 files 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) |
