diff options
author | Changbin Liu <changbin.liu@gmail.com> | 2013-06-19 12:09:28 -0400 |
---|---|---|
committer | Changbin Liu <changbin.liu@gmail.com> | 2013-06-19 13:41:07 -0400 |
commit | 43cf9864b9091319612926a01b07045806cfce49 (patch) | |
tree | 0f6cddb1e69396e863ad4fcd228bd528527218ec /nova/scheduler/driver.py | |
parent | 6808e052dbe9bc51b5836814d0a0331dcc5a6bd2 (diff) | |
download | nova-43cf9864b9091319612926a01b07045806cfce49.tar.gz nova-43cf9864b9091319612926a01b07045806cfce49.tar.xz nova-43cf9864b9091319612926a01b07045806cfce49.zip |
Remove usage of locals() for formatting from nova.scheduler.*
Using of locals() for formatting string is a nasty thing because:
1) It is not so clear as using explicit dicts
2) It could produce hidden errors during refactoring
3) Changing name of variable causes change in message
4) Creating a lot of unused variables
fixes bug #1171936
Change-Id: I7639631846a9145c3a18f2a704b71184ec781f45
Diffstat (limited to 'nova/scheduler/driver.py')
-rw-r--r-- | nova/scheduler/driver.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 5fed1e397..d5a1eedea 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -60,8 +60,8 @@ def handle_schedule_error(context, ex, instance_uuid, request_spec): if not isinstance(ex, exception.NoValidHost): LOG.exception(_("Exception during scheduler.run_instance")) state = vm_states.ERROR.upper() - LOG.warning(_('Setting instance to %(state)s state.'), - locals(), instance_uuid=instance_uuid) + LOG.warning(_('Setting instance to %s state.'), state, + instance_uuid=instance_uuid) # update instance state and notify on the transition (old_ref, new_ref) = db.instance_update_and_get_original(context, @@ -339,7 +339,9 @@ class Scheduler(object): reason = _("Unable to migrate %(instance_uuid)s to %(dest)s: " "Lack of memory(host:%(avail)s <= " "instance:%(mem_inst)s)") - raise exception.MigrationPreCheckError(reason=reason % locals()) + raise exception.MigrationPreCheckError(reason=reason % + {'instance_uuid': instance_uuid, 'dest': dest, 'avail': avail, + 'mem_inst': mem_inst}) def _get_compute_info(self, context, host): """get compute node's information specified by key |