]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Enforce log hints in neutron.services.l3_router
authorCedric Brandily <zzelle@gmail.com>
Tue, 11 Nov 2014 14:26:14 +0000 (15:26 +0100)
committerCedric Brandily <zzelle@gmail.com>
Thu, 20 Nov 2014 17:01:58 +0000 (17:01 +0000)
This change enforces log hints use and removes debug level log
translation, modifications are validated through a hacking rule.

Validate that hacking rules apply to directories:
    - neutron/services/l3_router

Change-Id: I2a832c5e0c4ed2a944d199d6a2d6233b8cf838dd
Partial-bug: #1320867

neutron/hacking/checks.py
neutron/services/l3_router/brocade/l3_router_plugin.py
neutron/services/l3_router/l3_arista.py

index 37afc2d8a31d48d8c994fcfbff75ecc3e7f49d31..8a204b5a538d3897c20ed1aa9e12203ef8c473d7 100644 (file)
@@ -56,7 +56,8 @@ def _directory_to_check_translation(filename):
             "neutron/notifiers",
             "neutron/openstack",
             "neutron/scheduler",
-            "neutron/server"]
+            "neutron/server",
+            "neutron/services/l3_router"]
     return any([dir in filename for dir in dirs])
 
 
index 1826b83a6aed7522f7d34fbd2a24612a6941eab1..079e6fc681d2d9fab473f29b6bceac3777b43d24 100644 (file)
@@ -21,6 +21,7 @@ from oslo.config import cfg
 
 from neutron.common import constants as l3_constants
 from neutron.openstack.common import excutils
+from neutron.openstack.common.gettextutils import _LE, _LI
 from neutron.openstack.common import log as logging
 from neutron.plugins.ml2 import db
 from neutron.plugins.ml2.drivers.brocade.db import models as brocade_db
@@ -70,7 +71,7 @@ class BrocadeSVIPlugin(router.L3RouterPlugin):
                         'rbridge_id': cfg.CONF.ml2_brocade.rbridge_id
                         }
         self._driver = driver.NOSdriver()
-        LOG.info(_("rbridge id %s"), self._switch['rbridge_id'])
+        LOG.info(_LI("rbridge id %s"), self._switch['rbridge_id'])
 
     def create_router(self, context, router):
         """ creates a vrf on NOS device."""
@@ -149,7 +150,8 @@ class BrocadeSVIPlugin(router.L3RouterPlugin):
                             'device_owner': [DEVICE_OWNER_ROUTER_INTF]}
             port_count = self._core_plugin.get_ports_count(context,
                                                            port_filters)
-            LOG.info(_("BrocadeSVIPlugin.add_router_interface ports_count %d"),
+            LOG.info(_LI("BrocadeSVIPlugin.add_router_interface ports_count "
+                         "%d"),
                      port_count)
 
             # port count is checked against 2 since the current port is already
@@ -157,10 +159,10 @@ class BrocadeSVIPlugin(router.L3RouterPlugin):
             if port_count == 2:
                 # This subnet is already part of some router
                 # (this is not supported in this version of brocade svi plugin)
-                LOG.error(_("BrocadeSVIPlugin: adding redundant router "
-                            "interface is not supported"))
-                raise Exception(_("BrocadeSVIPlugin:adding redundant router "
-                                  "interface is not supported"))
+                msg = _("BrocadeSVIPlugin: adding redundant router interface "
+                        "is not supported")
+                LOG.error(msg)
+                raise Exception(msg)
 
         try:
             switch = self._switch
@@ -172,8 +174,8 @@ class BrocadeSVIPlugin(router.L3RouterPlugin):
                                     gateway_ip_cidr,
                                     str(router_id))
         except Exception:
-            LOG.error(_("Failed to create Brocade resources to add router "
-                        "interface. info=%(info)s, router_id=%(router_id)s"),
+            LOG.error(_LE("Failed to create Brocade resources to add router "
+                          "interface. info=%(info)s, router_id=%(router_id)s"),
                       {"info": info, "router_id": router_id})
             with excutils.save_and_reraise_exception():
                 with context.session.begin(subtransactions=True):
@@ -218,10 +220,10 @@ class BrocadeSVIPlugin(router.L3RouterPlugin):
                                         str(router_id))
             except Exception:
                 with excutils.save_and_reraise_exception():
-                    LOG.error(_("Fail remove of interface from brocade router "
-                                "interface. info=%(info)s, "
-                                "router_id=%(router_id)s") %
-                              ({"info": info, "router_id": router_id}))
+                    LOG.error(_LE("Fail remove of interface from brocade "
+                                  "router interface. info=%(info)s, "
+                                  "router_id=%(router_id)s"),
+                              {"info": info, "router_id": router_id})
         return True
 
     @staticmethod
index 89fc98b37e956878f803adff62b8f933ad00d869..f1c12d7e34d4b7a6e92b0b3d64f5edcb96e47414 100644 (file)
@@ -29,6 +29,7 @@ from neutron.db import extraroute_db
 from neutron.db import l3_agentschedulers_db
 from neutron.db import l3_gwmode_db
 from neutron.openstack.common import excutils
+from neutron.openstack.common.gettextutils import _LE, _LI
 from neutron.openstack.common import log as logging
 from neutron.plugins.common import constants
 from neutron.plugins.ml2.driver_context import NetworkContext  # noqa
@@ -109,8 +110,8 @@ class AristaL3ServicePlugin(db_base_plugin_v2.NeutronDbPluginV2,
             return new_router
         except Exception:
             with excutils.save_and_reraise_exception():
-                LOG.error(_("Error creating router on Arista HW "
-                            "router=%s ") % new_router)
+                LOG.error(_LE("Error creating router on Arista HW router=%s "),
+                          new_router)
                 super(AristaL3ServicePlugin, self).delete_router(context,
                                                     new_router['id'])
 
@@ -132,8 +133,8 @@ class AristaL3ServicePlugin(db_base_plugin_v2.NeutronDbPluginV2,
                                       original_router, new_router)
             return new_router
         except Exception:
-            LOG.error(_("Error updating router on Arista HW "
-                        "router=%s ") % new_router)
+            LOG.error(_LE("Error updating router on Arista HW router=%s "),
+                      new_router)
 
     @log.log
     def delete_router(self, context, router_id):
@@ -147,8 +148,8 @@ class AristaL3ServicePlugin(db_base_plugin_v2.NeutronDbPluginV2,
         try:
             self.driver.delete_router(context, tenant_id, router_id, router)
         except Exception as e:
-            LOG.error(_("Error deleting router on Arista HW "
-                        "router %(r)s exception=%(e)s") %
+            LOG.error(_LE("Error deleting router on Arista HW "
+                          "router %(r)s exception=%(e)s"),
                       {'r': router, 'e': e})
 
         with context.session.begin(subtransactions=True):
@@ -193,8 +194,8 @@ class AristaL3ServicePlugin(db_base_plugin_v2.NeutronDbPluginV2,
             return new_router
         except Exception:
             with excutils.save_and_reraise_exception():
-                LOG.error(_("Error Adding subnet %(subnet)s to "
-                            "router %(router_id)s on Arista HW") %
+                LOG.error(_LE("Error Adding subnet %(subnet)s to "
+                              "router %(router_id)s on Arista HW"),
                           {'subnet': subnet, 'router_id': router_id})
                 super(AristaL3ServicePlugin, self).remove_router_interface(
                                                     context,
@@ -227,11 +228,11 @@ class AristaL3ServicePlugin(db_base_plugin_v2.NeutronDbPluginV2,
             self.driver.remove_router_interface(context, router_info)
             return new_router
         except Exception as exc:
-            LOG.error(_("Error removing interface %(interface)s from "
-                        "router %(router_id)s on Arista HW"
-                        "Exception =(exc)s") % {'interface': interface_info,
-                                                'router_id': router_id,
-                                                'exc': exc})
+            LOG.error(_LE("Error removing interface %(interface)s from "
+                          "router %(router_id)s on Arista HW"
+                          "Exception =(exc)s"),
+                      {'interface': interface_info, 'router_id': router_id,
+                       'exc': exc})
 
     def synchronize(self):
         """Synchronizes Router DB from Neturon DB with EOS.
@@ -242,7 +243,7 @@ class AristaL3ServicePlugin(db_base_plugin_v2.NeutronDbPluginV2,
         Uses idempotent properties of EOS configuration, which means
         same commands can be repeated.
         """
-        LOG.info(_('Syncing Neutron Router DB <-> EOS'))
+        LOG.info(_LI('Syncing Neutron Router DB <-> EOS'))
         ctx = nctx.get_admin_context()
 
         routers = super(AristaL3ServicePlugin, self).get_routers(ctx)
@@ -273,10 +274,9 @@ class AristaL3ServicePlugin(db_base_plugin_v2.NeutronDbPluginV2,
                     try:
                         self.driver.add_router_interface(self, r)
                     except Exception:
-                        LOG.error(_("Error Adding interface %(subnet_id)s to "
-                                    "router %(router_id)s on Arista HW") %
-                                  {'subnet_id': subnet_id,
-                                   'router_id': r})
+                        LOG.error(_LE("Error Adding interface %(subnet_id)s "
+                                      "to router %(router_id)s on Arista HW"),
+                                  {'subnet_id': subnet_id, 'router_id': r})
 
     def _validate_interface_info(self, interface_info):
         port_id_specified = interface_info and 'port_id' in interface_info