Fix formatting strings in LOG.error

Following OpenStack Style Guidelines:
http://docs.openstack.org/developer/hacking/#internationalization-i18n-strings

Using multiple variables for formmatting strings is not clear as using
explicit dictionaries and can hide errors during refactoring.

Change-Id: I5dda1f550f6369b6154403ea5257e371014de53f
This commit is contained in:
Luong Anh Tuan 2016-08-26 19:40:46 +07:00 committed by Tuan
parent 3919c29a99
commit d6eb452839
2 changed files with 7 additions and 3 deletions

View File

@ -147,8 +147,11 @@ def get_ipmi_address(node):
ip = socket.gethostbyname(value)
return ip
except socket.gaierror:
msg = ('Failed to resolve the hostname (%s) for node %s')
raise utils.Error(msg % (value, node.uuid), node_info=node)
msg = _('Failed to resolve the hostname (%(value)s)'
' for node %(uuid)s')
raise utils.Error(msg % {'value': value,
'uuid': node.uuid},
node_info=node)
def get_client(token=None,

View File

@ -46,7 +46,8 @@ def _iptables(*args, **kwargs):
except subprocess.CalledProcessError as exc:
output = exc.output.replace('\n', '. ')
if ignore:
LOG.debug('Ignoring failed iptables %s: %s', args, output)
LOG.debug('Ignoring failed iptables %(args)s: %(output)s',
{'args': args, 'output': output})
else:
LOG.error(_LE('iptables %(iptables)s failed: %(exc)s') %
{'iptables': args, 'exc': output})