From: Dirk Mueller Date: Mon, 21 Oct 2013 11:03:04 +0000 (+0200) Subject: Do not concatenate localized strings X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=58859c422a8948f3852bb254aee175b7b29d7dcb;p=openstack-build%2Fneutron-build.git 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 --- diff --git a/neutron/plugins/bigswitch/plugin.py b/neutron/plugins/bigswitch/plugin.py index b949d2b83..c9e8faffc 100644 --- a/neutron/plugins/bigswitch/plugin.py +++ b/neutron/plugins/bigswitch/plugin.py @@ -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 " diff --git a/neutron/tests/unit/bigswitch/test_restproxy_plugin.py b/neutron/tests/unit/bigswitch/test_restproxy_plugin.py index a1b49ea00..6fe30e6a8 100644 --- a/neutron/tests/unit/bigswitch/test_restproxy_plugin.py +++ b/neutron/tests/unit/bigswitch/test_restproxy_plugin.py @@ -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)