diff options
| author | Michael Still <mikal@stillhq.com> | 2013-05-08 12:02:59 +1000 |
|---|---|---|
| committer | Michael Still <mikal@stillhq.com> | 2013-05-08 12:02:59 +1000 |
| commit | f53df8c4f50437eb7568979636c7503fcd43afee (patch) | |
| tree | fb347698d94b06911d2272f08724cc244eac83c1 | |
| parent | f917d24bd333e7068ae17cc1027dd8e80896e5a5 (diff) | |
| download | nova-f53df8c4f50437eb7568979636c7503fcd43afee.tar.gz nova-f53df8c4f50437eb7568979636c7503fcd43afee.tar.xz nova-f53df8c4f50437eb7568979636c7503fcd43afee.zip | |
Fix format error in claims.
I have now seen two bug reports today about log message formatting
in the claims code. I'm not 100% sure what's going on here, but
I've removed the use of locals() in the hope it makes it clearer.
I've also moved to treating limits as floats because I think it
makes the messages clearer, but it is not a functional change.
Resolves bug 1175923.
Change-Id: I8b7b31f2637d1ab41d0fb2f274545181f9fddd9d
| -rw-r--r-- | nova/compute/claims.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/nova/compute/claims.py b/nova/compute/claims.py index fc170839f..935c0f2aa 100644 --- a/nova/compute/claims.py +++ b/nova/compute/claims.py @@ -159,28 +159,33 @@ class Claim(NopClaim): """Test if the given type of resource needed for a claim can be safely allocated. """ - msg = _("Total %(type_)s: %(total)d %(unit)s, used: %(used)d %(unit)s") - LOG.audit(msg % locals(), instance=self.instance) + LOG.audit(_('Total %(type)s: %(total)d %(unit)s, used: %(used).02f ' + '%(unit)s'), + {'type': type_, 'total': total, 'unit': unit, 'used': used}, + instance=self.instance) if limit is None: # treat resource as unlimited: - LOG.audit(_("%(type_)s limit not specified, defaulting to " - "unlimited") % locals(), instance=self.instance) + LOG.audit(_('%(type)s limit not specified, defaulting to ' + 'unlimited'), {'type': type_}, instance=self.instance) return True free = limit - used # Oversubscribed resource policy info: - msg = _("%(type_)s limit: %(limit)d %(unit)s, free: %(free)d " - "%(unit)s") % locals() - LOG.audit(msg, instance=self.instance) + LOG.audit(_('%(type)s limit: %(limit).02f %(unit)s, free: %(free).02f ' + '%(unit)s'), + {'type': type_, 'limit': limit, 'free': free, 'unit': unit}, + instance=self.instance) can_claim = requested <= free if not can_claim: - msg = _("Unable to claim resources. Free %(type_)s %(free)d " - "%(unit)s < requested %(requested)d %(unit)s") % locals() - LOG.info(msg, instance=self.instance) + LOG.info(_('Unable to claim resources. Free %(type)s %(free).02f ' + '%(unit)s < requested %(requested)d %(unit)s'), + {'type': type_, 'free': free, 'unit': unit, + 'requested': requested}, + instance=self.instance) return can_claim |
