From 43cf9864b9091319612926a01b07045806cfce49 Mon Sep 17 00:00:00 2001 From: Changbin Liu Date: Wed, 19 Jun 2013 12:09:28 -0400 Subject: 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 --- nova/scheduler/driver.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'nova/scheduler/driver.py') 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 -- cgit