Remove locals() from compute directory
Replace locals() with dictionary of the values to be printed Change-Id: Iec926e859a5b340a04d9ada7c770b58eecd450b6
This commit is contained in:
@@ -313,11 +313,10 @@ class API(base.Base):
|
|||||||
used = quotas[resource] - headroom[resource]
|
used = quotas[resource] - headroom[resource]
|
||||||
total_allowed = used + headroom[resource]
|
total_allowed = used + headroom[resource]
|
||||||
overs = ','.join(overs)
|
overs = ','.join(overs)
|
||||||
|
|
||||||
pid = context.project_id
|
|
||||||
LOG.warn(_("%(overs)s quota exceeded for %(pid)s,"
|
LOG.warn(_("%(overs)s quota exceeded for %(pid)s,"
|
||||||
" tried to run %(min_count)s instances. %(msg)s"),
|
" tried to run %(min_count)s instances. %(msg)s"),
|
||||||
locals())
|
{'overs': overs, 'pid': context.project_id,
|
||||||
|
'min_count': min_count, 'msg': msg})
|
||||||
requested = dict(instances=min_count, cores=req_cores, ram=req_ram)
|
requested = dict(instances=min_count, cores=req_cores, ram=req_ram)
|
||||||
raise exception.TooManyInstances(overs=overs,
|
raise exception.TooManyInstances(overs=overs,
|
||||||
req=requested[resource],
|
req=requested[resource],
|
||||||
@@ -334,9 +333,10 @@ class API(base.Base):
|
|||||||
try:
|
try:
|
||||||
QUOTAS.limit_check(context, metadata_items=num_metadata)
|
QUOTAS.limit_check(context, metadata_items=num_metadata)
|
||||||
except exception.OverQuota as exc:
|
except exception.OverQuota as exc:
|
||||||
pid = context.project_id
|
|
||||||
LOG.warn(_("Quota exceeded for %(pid)s, tried to set "
|
LOG.warn(_("Quota exceeded for %(pid)s, tried to set "
|
||||||
"%(num_metadata)s metadata properties") % locals())
|
"%(num_metadata)s metadata properties"),
|
||||||
|
{'pid': context.project_id,
|
||||||
|
'num_metadata': num_metadata})
|
||||||
quota_metadata = exc.kwargs['quotas']['metadata_items']
|
quota_metadata = exc.kwargs['quotas']['metadata_items']
|
||||||
raise exception.MetadataLimitExceeded(allowed=quota_metadata)
|
raise exception.MetadataLimitExceeded(allowed=quota_metadata)
|
||||||
|
|
||||||
@@ -1258,8 +1258,8 @@ class API(base.Base):
|
|||||||
try:
|
try:
|
||||||
old_inst_type = flavors.get_flavor(old_inst_type_id)
|
old_inst_type = flavors.get_flavor(old_inst_type_id)
|
||||||
except exception.InstanceTypeNotFound:
|
except exception.InstanceTypeNotFound:
|
||||||
LOG.warning(_("instance type %(old_inst_type_id)d "
|
LOG.warning(_("instance type %d not found"),
|
||||||
"not found") % locals())
|
old_inst_type_id)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
instance_vcpus = old_inst_type['vcpus']
|
instance_vcpus = old_inst_type['vcpus']
|
||||||
@@ -2068,7 +2068,9 @@ class API(base.Base):
|
|||||||
new_instance_type_name = new_instance_type['name']
|
new_instance_type_name = new_instance_type['name']
|
||||||
LOG.debug(_("Old instance type %(current_instance_type_name)s, "
|
LOG.debug(_("Old instance type %(current_instance_type_name)s, "
|
||||||
" new instance type %(new_instance_type_name)s"),
|
" new instance type %(new_instance_type_name)s"),
|
||||||
locals(), instance=instance)
|
{'current_instance_type_name': current_instance_type_name,
|
||||||
|
'new_instance_type_name': new_instance_type_name},
|
||||||
|
instance=instance)
|
||||||
|
|
||||||
# FIXME(sirp): both of these should raise InstanceTypeNotFound instead
|
# FIXME(sirp): both of these should raise InstanceTypeNotFound instead
|
||||||
if not new_instance_type:
|
if not new_instance_type:
|
||||||
@@ -2112,10 +2114,9 @@ class API(base.Base):
|
|||||||
used = quotas[resource] - headroom[resource]
|
used = quotas[resource] - headroom[resource]
|
||||||
total_allowed = used + headroom[resource]
|
total_allowed = used + headroom[resource]
|
||||||
overs = ','.join(overs)
|
overs = ','.join(overs)
|
||||||
|
|
||||||
pid = context.project_id
|
|
||||||
LOG.warn(_("%(overs)s quota exceeded for %(pid)s,"
|
LOG.warn(_("%(overs)s quota exceeded for %(pid)s,"
|
||||||
" tried to resize instance."), locals())
|
" tried to resize instance."),
|
||||||
|
{'overs': overs, 'pid': context.project_id})
|
||||||
raise exception.TooManyInstances(overs=overs,
|
raise exception.TooManyInstances(overs=overs,
|
||||||
req=deltas[resource],
|
req=deltas[resource],
|
||||||
used=used, allowed=total_allowed,
|
used=used, allowed=total_allowed,
|
||||||
@@ -2578,9 +2579,8 @@ class API(base.Base):
|
|||||||
inst_host = instance['host']
|
inst_host = instance['host']
|
||||||
service = self.db.service_get_by_compute_host(context, inst_host)
|
service = self.db.service_get_by_compute_host(context, inst_host)
|
||||||
if self.servicegroup_api.service_is_up(service):
|
if self.servicegroup_api.service_is_up(service):
|
||||||
msg = (_('Instance compute service state on %(inst_host)s '
|
msg = (_('Instance compute service state on %s '
|
||||||
'expected to be down, but it was up.'
|
'expected to be down, but it was up.') % inst_host)
|
||||||
) % locals())
|
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.ComputeServiceUnavailable(msg)
|
raise exception.ComputeServiceUnavailable(msg)
|
||||||
|
|
||||||
|
|||||||
@@ -1877,8 +1877,8 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||||||
LOG.warning(_('Reboot failed but instance is running'),
|
LOG.warning(_('Reboot failed but instance is running'),
|
||||||
context=context, instance=instance)
|
context=context, instance=instance)
|
||||||
else:
|
else:
|
||||||
LOG.error(_('Cannot reboot instance: %(error)s'),
|
LOG.error(_('Cannot reboot instance: %s'), error,
|
||||||
locals(), context=context, instance=instance)
|
context=context, instance=instance)
|
||||||
self._set_instance_error_state(context, instance['uuid'])
|
self._set_instance_error_state(context, instance['uuid'])
|
||||||
raise type_, value, tb
|
raise type_, value, tb
|
||||||
|
|
||||||
|
|||||||
@@ -536,14 +536,14 @@ class ResourceTracker(object):
|
|||||||
def _update_usage_from_orphans(self, resources, orphans):
|
def _update_usage_from_orphans(self, resources, orphans):
|
||||||
"""Include orphaned instances in usage."""
|
"""Include orphaned instances in usage."""
|
||||||
for orphan in orphans:
|
for orphan in orphans:
|
||||||
uuid = orphan['uuid']
|
|
||||||
memory_mb = orphan['memory_mb']
|
memory_mb = orphan['memory_mb']
|
||||||
|
|
||||||
LOG.warn(_("Detected running orphan instance: %(uuid)s (consuming "
|
LOG.warn(_("Detected running orphan instance: %(uuid)s (consuming "
|
||||||
"%(memory_mb)s MB memory") % locals())
|
"%(memory_mb)s MB memory)"),
|
||||||
|
{'uuid': orphan['uuid'], 'memory_mb': memory_mb})
|
||||||
|
|
||||||
# just record memory usage for the orphan
|
# just record memory usage for the orphan
|
||||||
usage = {'memory_mb': orphan['memory_mb']}
|
usage = {'memory_mb': memory_mb}
|
||||||
self._update_usage(resources, usage)
|
self._update_usage(resources, usage)
|
||||||
|
|
||||||
def _verify_resources(self, resources):
|
def _verify_resources(self, resources):
|
||||||
|
|||||||
@@ -138,7 +138,8 @@ def get_device_name_for_instance(context, instance, bdms, device):
|
|||||||
prefix = '/dev/xvd'
|
prefix = '/dev/xvd'
|
||||||
|
|
||||||
if req_prefix != prefix:
|
if req_prefix != prefix:
|
||||||
LOG.debug(_("Using %(prefix)s instead of %(req_prefix)s") % locals())
|
LOG.debug(_("Using %(prefix)s instead of %(req_prefix)s"),
|
||||||
|
{'prefix': prefix, 'req_prefix': req_prefix})
|
||||||
|
|
||||||
used_letters = set()
|
used_letters = set()
|
||||||
for device_path in mappings.itervalues():
|
for device_path in mappings.itervalues():
|
||||||
|
|||||||
Reference in New Issue
Block a user