Do not concatenate localized strings

This makes it hard for translators to understand what is going
on. Use string formatting with kwargs expansion.

Change-Id: Ic9ad8bb4e3d9c32188f4175bb0359e268921696b
This commit is contained in:
Dirk Mueller 2013-10-21 13:03:04 +02:00
parent b6db00554c
commit 4bd11ebfc5
2 changed files with 6 additions and 10 deletions

View File

@ -166,13 +166,8 @@ METADATA_SERVER_IP = '169.254.169.254'
class RemoteRestError(exceptions.NeutronException):
def __init__(self, message):
if message is None:
message = "None"
self.message = _("Error in REST call to remote network "
"controller") + ": " + message
super(RemoteRestError, self).__init__()
message = _("Error in REST call to remote network "
"controller: %(reason)s")
class ServerProxy(object):
@ -330,7 +325,7 @@ class ServerPool(object):
resp = self.rest_call(action, resource, data, headers, ignore_codes)
if self.server_failure(resp, ignore_codes):
LOG.error(_("NeutronRestProxyV2: ") + errstr, resp[2])
raise RemoteRestError(resp[2])
raise RemoteRestError(reason=resp[2])
if resp[0] in ignore_codes:
LOG.warning(_("NeutronRestProxyV2: Received and ignored error "
"code %(code)s on %(action)s action to resource "

View File

@ -91,7 +91,8 @@ class TestBigSwitchProxyPortsV2(test_plugin.TestPortsV2,
plugin_obj = NeutronManager.get_plugin()
with patch.object(plugin_obj.servers,
'rest_plug_interface') as mock_plug_interface:
mock_plug_interface.side_effect = RemoteRestError('fake error')
mock_plug_interface.side_effect = RemoteRestError(
reason='fake error')
kwargs = {'device_id': 'somedevid',
'tenant_id': n['network']['tenant_id']}
self._create_port('json', n['network']['id'],
@ -142,7 +143,7 @@ class TestBigSwitchProxyPortsV2(test_plugin.TestPortsV2,
'rest_delete_port'
) as mock_plug_interface:
mock_plug_interface.side_effect = RemoteRestError(
'fake error')
reason='fake error')
self._delete('ports', port['port']['id'],
expected_code=
webob.exc.HTTPInternalServerError.code)