summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorChangbin Liu <changbin.liu@gmail.com>2013-06-19 12:09:28 -0400
committerChangbin Liu <changbin.liu@gmail.com>2013-06-19 13:41:07 -0400
commit43cf9864b9091319612926a01b07045806cfce49 (patch)
tree0f6cddb1e69396e863ad4fcd228bd528527218ec /nova
parent6808e052dbe9bc51b5836814d0a0331dcc5a6bd2 (diff)
downloadnova-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')
-rw-r--r--nova/scheduler/driver.py8
-rw-r--r--nova/scheduler/filters/aggregate_multitenancy_isolation.py3
-rw-r--r--nova/scheduler/host_manager.py8
-rw-r--r--nova/scheduler/manager.py7
-rw-r--r--nova/scheduler/scheduler_options.py6
5 files changed, 18 insertions, 14 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
diff --git a/nova/scheduler/filters/aggregate_multitenancy_isolation.py b/nova/scheduler/filters/aggregate_multitenancy_isolation.py
index d9192af52..1a9f6bf58 100644
--- a/nova/scheduler/filters/aggregate_multitenancy_isolation.py
+++ b/nova/scheduler/filters/aggregate_multitenancy_isolation.py
@@ -41,7 +41,6 @@ class AggregateMultiTenancyIsolation(filters.BaseHostFilter):
if metadata != {}:
if tenant_id not in metadata["filter_tenant_id"]:
- LOG.debug(_("%(host_state)s fails tenant id on "
- "aggregate"), locals())
+ LOG.debug(_("%s fails tenant id on aggregate"), host_state)
return False
return True
diff --git a/nova/scheduler/host_manager.py b/nova/scheduler/host_manager.py
index b5fbb8594..d5081ace5 100644
--- a/nova/scheduler/host_manager.py
+++ b/nova/scheduler/host_manager.py
@@ -377,12 +377,14 @@ class HostManager(object):
if service_name != 'compute':
LOG.debug(_('Ignoring %(service_name)s service update '
- 'from %(host)s'), locals())
+ 'from %(host)s'), {'service_name': service_name,
+ 'host': host})
return
state_key = (host, capabilities.get('hypervisor_hostname'))
LOG.debug(_("Received %(service_name)s service update from "
- "%(state_key)s.") % locals())
+ "%(state_key)s."), {'service_name': service_name,
+ 'state_key': state_key})
# Copy the capabilities, so we don't modify the original dict
capab_copy = dict(capabilities)
capab_copy["timestamp"] = timeutils.utcnow() # Reported time
@@ -423,7 +425,7 @@ class HostManager(object):
for state_key in dead_nodes:
host, node = state_key
LOG.info(_("Removing dead compute node %(host)s:%(node)s "
- "from scheduler") % locals())
+ "from scheduler") % {'host': host, 'node': node})
del self.host_state_map[state_key]
return self.host_state_map.itervalues()
diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py
index 9429a0662..5c99feb03 100644
--- a/nova/scheduler/manager.py
+++ b/nova/scheduler/manager.py
@@ -208,7 +208,8 @@ class SchedulerManager(manager.Manager):
# The refactoring could go further but trying to minimize changes
# for essex timeframe
- LOG.warning(_("Failed to schedule_%(method)s: %(ex)s") % locals())
+ LOG.warning(_("Failed to schedule_%(method)s: %(ex)s"),
+ {'method': method, 'ex': ex})
vm_state = updates['vm_state']
properties = request_spec.get('instance_properties', {})
@@ -222,8 +223,8 @@ class SchedulerManager(manager.Manager):
for instance_uuid in request_spec.get('instance_uuids') or uuids:
if instance_uuid:
state = vm_state.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) = self.db.instance_update_and_get_original(
diff --git a/nova/scheduler/scheduler_options.py b/nova/scheduler/scheduler_options.py
index bae470d1b..5ba2117cc 100644
--- a/nova/scheduler/scheduler_options.py
+++ b/nova/scheduler/scheduler_options.py
@@ -69,15 +69,15 @@ class SchedulerOptions(object):
except os.error as e:
with excutils.save_and_reraise_exception():
LOG.exception(_("Could not stat scheduler options file "
- "%(filename)s: '%(e)s'"), locals())
+ "%(filename)s: '%(e)s'"),
+ {'filename': filename, 'e': e})
def _load_file(self, handle):
"""Decode the JSON file. Broken out for testing."""
try:
return json.load(handle)
except ValueError as e:
- LOG.exception(_("Could not decode scheduler options: "
- "'%(e)s'") % locals())
+ LOG.exception(_("Could not decode scheduler options: '%s'"), e)
return {}
def _get_time_now(self):