]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Do not concatenate localized strings
authorDirk Mueller <dirk@dmllr.de>
Mon, 21 Oct 2013 11:03:04 +0000 (13:03 +0200)
committerDirk Mueller <dirk@dmllr.de>
Fri, 6 Dec 2013 12:29:56 +0000 (13:29 +0100)
This makes it hard for translators to understand what is going
on. Use string formatting with kwargs expansion.

Change-Id: Ic9ad8bb4e3d9c32188f4175bb0359e268921696b

neutron/plugins/bigswitch/plugin.py
neutron/tests/unit/bigswitch/test_restproxy_plugin.py

index b949d2b83cb826c7a6234f0abae8c119383e0076..c9e8faffc6c6b5d338fa22b74d6be3d6d840bf0c 100644 (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 "
index a1b49ea002f389aab0421c31c810342acc3f2e0b..6fe30e6a821f757dd7783d379c023bfd4297736d 100644 (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)