]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Update i18n translation for Metaplugin plugin
authorGary Kotton <gkotton@vmware.com>
Wed, 26 Nov 2014 17:01:36 +0000 (09:01 -0800)
committerGary Kotton <gkotton@vmware.com>
Wed, 3 Dec 2014 20:10:38 +0000 (12:10 -0800)
All the existing LOG.info, LOG.warning, LOG.error and LOG.critical
messages should have _LI, _LW, _LE and _LC respectively. Also, debug
level log shouldn't be translated. This patch set will cover the
metaplugin directory.

Change-Id: I34437019fc8ffc38f11114d1d83dce54170ab989
Partial-Bug: #1320867

neutron/hacking/checks.py
neutron/plugins/metaplugin/meta_neutron_plugin.py
neutron/plugins/metaplugin/proxy_neutron_plugin.py

index 68dcfa1f9b8069445e4fa75c2d3676ead3a47e04..f68f2063479b02aa5e86c4833c896a5593897a49 100644 (file)
@@ -82,7 +82,7 @@ def _directory_to_check_translation(filename):
             "neutron/plugins/hyperv",
             #"neutron/plugins/ibm",
             "neutron/plugins/linuxbridge",
-            #"neutron/plugins/metaplugin",
+            "neutron/plugins/metaplugin",
             "neutron/plugins/midonet",
             "neutron/plugins/ml2",
             "neutron/plugins/mlnx",
index e956eaee687a87009367d8b698f9cdd9b9854590..feff7e2f03448524591023e159493db1d1a00293 100644 (file)
@@ -25,6 +25,7 @@ from neutron.db import extraroute_db
 from neutron.db import l3_db
 from neutron.db import models_v2
 from neutron.extensions import flavor as ext_flavor
+from neutron.i18n import _LE
 from neutron.openstack.common import log as logging
 from neutron.plugins.metaplugin.common import config  # noqa
 from neutron.plugins.metaplugin import meta_db_v2
@@ -69,7 +70,7 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
 
     def __init__(self, configfile=None):
         super(MetaPluginV2, self).__init__()
-        LOG.debug(_("Start initializing metaplugin"))
+        LOG.debug("Start initializing metaplugin")
         self.supported_extension_aliases = ['flavor', 'external-net']
         if cfg.CONF.META.supported_extension_aliases:
             cfg_aliases = cfg.CONF.META.supported_extension_aliases.split(',')
@@ -162,7 +163,7 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
             _meta_flavor_filter_hook)
 
     def _load_plugin(self, plugin_provider):
-        LOG.debug(_("Plugin location: %s"), plugin_provider)
+        LOG.debug("Plugin location: %s", plugin_provider)
         plugin_klass = importutils.import_class(plugin_provider)
         return plugin_klass()
 
@@ -213,17 +214,17 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
             flavor = self.default_flavor
         plugin = self._get_plugin(flavor)
         net = plugin.create_network(context, network)
-        LOG.debug(_("Created network: %(net_id)s with flavor "
-                    "%(flavor)s"), {'net_id': net['id'], 'flavor': flavor})
+        LOG.debug("Created network: %(net_id)s with flavor "
+                  "%(flavor)s", {'net_id': net['id'], 'flavor': flavor})
         try:
             meta_db_v2.add_network_flavor_binding(context.session,
                                                   flavor, str(net['id']))
         except Exception:
-            LOG.exception(_('Failed to add flavor bindings'))
+            LOG.exception(_LE('Failed to add flavor bindings'))
             plugin.delete_network(context, net['id'])
             raise FaildToAddFlavorBinding()
 
-        LOG.debug(_("Created network: %s"), net['id'])
+        LOG.debug("Created network: %s", net['id'])
         self._extend_network_dict(context, net)
         return net
 
@@ -356,18 +357,18 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
             flavor = self.default_l3_flavor
         plugin = self._get_l3_plugin(flavor)
         r_in_db = plugin.create_router(context, router)
-        LOG.debug(_("Created router: %(router_id)s with flavor "
-                    "%(flavor)s"),
+        LOG.debug("Created router: %(router_id)s with flavor "
+                  "%(flavor)s",
                   {'router_id': r_in_db['id'], 'flavor': flavor})
         try:
             meta_db_v2.add_router_flavor_binding(context.session,
                                                  flavor, str(r_in_db['id']))
         except Exception:
-            LOG.exception(_('Failed to add flavor bindings'))
+            LOG.exception(_LE('Failed to add flavor bindings'))
             plugin.delete_router(context, r_in_db['id'])
             raise FaildToAddFlavorBinding()
 
-        LOG.debug(_("Created router: %s"), r_in_db['id'])
+        LOG.debug("Created router: %s", r_in_db['id'])
         self._extend_router_dict(context, r_in_db)
         return r_in_db
 
index 1309adc0a86300ed419564c0c8ba6041d600db9f..35d4b4a5795ba90f0aa1a28b945f95334575eb92 100644 (file)
@@ -18,6 +18,7 @@ from oslo.config import cfg
 from neutron.db import db_base_plugin_v2
 from neutron.db import external_net_db
 from neutron.db import l3_db
+from neutron.i18n import _LE, _LW
 from neutron.openstack.common import log as logging
 from neutronclient.common import exceptions
 from neutronclient.v2_0 import client
@@ -63,14 +64,14 @@ class ProxyPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
         try:
             self._get_client().update_subnet(id, subnet)
         except Exception as e:
-            LOG.error(_("Update subnet failed: %s"), e)
+            LOG.error(_LE("Update subnet failed: %s"), e)
         return subnet_in_db
 
     def delete_subnet(self, context, id):
         try:
             self._get_client().delete_subnet(id)
         except exceptions.NotFound:
-            LOG.warn(_("Subnet in remote have already deleted"))
+            LOG.warn(_LW("Subnet in remote have already deleted"))
         return super(ProxyPluginV2, self).delete_subnet(context, id)
 
     def create_network(self, context, network):
@@ -91,14 +92,14 @@ class ProxyPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
         try:
             self._get_client().update_network(id, network)
         except Exception as e:
-            LOG.error(_("Update network failed: %s"), e)
+            LOG.error(_LE("Update network failed: %s"), e)
         return network_in_db
 
     def delete_network(self, context, id):
         try:
             self._get_client().delete_network(id)
         except exceptions.NetworkNotFoundClient:
-            LOG.warn(_("Network in remote have already deleted"))
+            LOG.warn(_LW("Network in remote have already deleted"))
         return super(ProxyPluginV2, self).delete_network(context, id)
 
     def create_port(self, context, port):
@@ -119,7 +120,7 @@ class ProxyPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
         try:
             self._get_client().update_port(id, port)
         except Exception as e:
-            LOG.error(_("Update port failed: %s"), e)
+            LOG.error(_LE("Update port failed: %s"), e)
         return port_in_db
 
     def delete_port(self, context, id, l3_port_check=True):
@@ -130,5 +131,5 @@ class ProxyPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
         try:
             self._get_client().delete_port(id)
         except exceptions.PortNotFoundClient:
-            LOG.warn(_("Port in remote have already deleted"))
+            LOG.warn(_LW("Port in remote have already deleted"))
         return super(ProxyPluginV2, self).delete_port(context, id)