]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Replace custom method call logger with oslo.log helper
authorIhar Hrachyshka <ihrachys@redhat.com>
Mon, 30 Mar 2015 16:41:28 +0000 (18:41 +0200)
committerIhar Hrachyshka <ihrachys@redhat.com>
Mon, 20 Apr 2015 15:16:54 +0000 (15:16 +0000)
oslo.log now provides a logging helper that is similar to custom neutron
helper (actually, the helper in oslo.log started from neutron version).

Now switching to library implementation.

Deprecated neutron.common.log.log

Change-Id: I85d5fc570950ff18cfdb8db20ad20b166e195299

neutron/agent/l2population_rpc.py
neutron/api/rpc/handlers/dvr_rpc.py
neutron/common/log.py
neutron/db/dvr_mac_db.py
neutron/plugins/ml2/drivers/freescale/mechanism_fslsdn.py
neutron/services/l3_router/l3_arista.py
neutron/services/metering/drivers/iptables/iptables_driver.py
neutron/services/metering/drivers/noop/noop_driver.py

index 50ba665b082c5faed4c89ae59d0e8c6da1bc50ab..509d425edd1fd7fc28f548936bc8973a4e6581d4 100644 (file)
 import abc
 
 from oslo_config import cfg
+from oslo_log import helpers as log_helpers
 from oslo_log import log as logging
 import six
 
 from neutron.common import constants as n_const
-from neutron.common import log
 from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc
 
 LOG = logging.getLogger(__name__)
@@ -36,17 +36,17 @@ class L2populationRpcCallBackMixin(object):
         fdb_add(), fdb_remove(), fdb_update()
     '''
 
-    @log.log
+    @log_helpers.log_method_call
     def add_fdb_entries(self, context, fdb_entries, host=None):
         if not host or host == cfg.CONF.host:
             self.fdb_add(context, self._unmarshall_fdb_entries(fdb_entries))
 
-    @log.log
+    @log_helpers.log_method_call
     def remove_fdb_entries(self, context, fdb_entries, host=None):
         if not host or host == cfg.CONF.host:
             self.fdb_remove(context, self._unmarshall_fdb_entries(fdb_entries))
 
-    @log.log
+    @log_helpers.log_method_call
     def update_fdb_entries(self, context, fdb_entries, host=None):
         if not host or host == cfg.CONF.host:
             self.fdb_update(context, self._unmarshall_fdb_entries(fdb_entries))
@@ -224,7 +224,7 @@ class L2populationRpcCallBackTunnelMixin(L2populationRpcCallBackMixin):
             agent_ports = values.get('ports')
             yield (lvm, agent_ports)
 
-    @log.log
+    @log_helpers.log_method_call
     def fdb_add_tun(self, context, br, lvm, agent_ports, lookup_port):
         for remote_ip, ports in agent_ports.items():
             # Ensure we have a tunnel port with this remote agent
@@ -237,7 +237,7 @@ class L2populationRpcCallBackTunnelMixin(L2populationRpcCallBackMixin):
             for port in ports:
                 self.add_fdb_flow(br, port, remote_ip, lvm, ofport)
 
-    @log.log
+    @log_helpers.log_method_call
     def fdb_remove_tun(self, context, br, lvm, agent_ports, lookup_port):
         for remote_ip, ports in agent_ports.items():
             ofport = lookup_port(lvm.network_type, remote_ip)
@@ -249,7 +249,7 @@ class L2populationRpcCallBackTunnelMixin(L2populationRpcCallBackMixin):
                     # Check if this tunnel port is still used
                     self.cleanup_tunnel_port(br, ofport, lvm.network_type)
 
-    @log.log
+    @log_helpers.log_method_call
     def fdb_update(self, context, fdb_entries):
         '''Call methods named '_fdb_<action>'.
 
@@ -264,7 +264,7 @@ class L2populationRpcCallBackTunnelMixin(L2populationRpcCallBackMixin):
 
             getattr(self, method)(context, values)
 
-    @log.log
+    @log_helpers.log_method_call
     def fdb_chg_ip_tun(self, context, br, fdb_entries, local_ip,
                        local_vlan_map):
         '''fdb update when an IP of a port is updated.
index bbfe6e02a4609dec3851c67b69510aac9402d293..8b6574707e8d9ac8a97181e289e7ce0bef2200e2 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+from oslo_log import helpers as log_helpers
 from oslo_log import log as logging
 import oslo_messaging
 
 from neutron.common import constants
-from neutron.common import log
 from neutron.common import rpc as n_rpc
 from neutron.common import topics
 from neutron import manager
@@ -38,23 +38,23 @@ class DVRServerRpcApi(object):
                                        namespace=constants.RPC_NAMESPACE_DVR)
         self.client = n_rpc.get_client(target)
 
-    @log.log
+    @log_helpers.log_method_call
     def get_dvr_mac_address_by_host(self, context, host):
         cctxt = self.client.prepare()
         return cctxt.call(context, 'get_dvr_mac_address_by_host', host=host)
 
-    @log.log
+    @log_helpers.log_method_call
     def get_dvr_mac_address_list(self, context):
         cctxt = self.client.prepare()
         return cctxt.call(context, 'get_dvr_mac_address_list')
 
-    @log.log
+    @log_helpers.log_method_call
     def get_ports_on_host_by_subnet(self, context, host, subnet):
         cctxt = self.client.prepare()
         return cctxt.call(context, 'get_ports_on_host_by_subnet',
                           host=host, subnet=subnet)
 
-    @log.log
+    @log_helpers.log_method_call
     def get_subnet_for_dvr(self, context, subnet):
         cctxt = self.client.prepare()
         return cctxt.call(context, 'get_subnet_for_dvr', subnet=subnet)
index b5fcaf15bb9a5336066b7b571e41c7e91a2e02cb..fc6c7ba03411504d51311ae4b8ef84c93d88544d 100644 (file)
@@ -17,7 +17,11 @@ import functools
 
 from oslo_log import log as logging
 
+from neutron.openstack.common import versionutils
 
+
+@versionutils.deprecated(as_of=versionutils.deprecated.LIBERTY,
+                         in_favor_of='oslo_log.helpers.log_method_call')
 def log(method):
     """Decorator helping to log method calls."""
     LOG = logging.getLogger(method.__module__)
index b432d8b84a3fb00c9530456fce72ec10a12a9825..951c45a9991e331d8c6bbc3afe47689893902b3b 100644 (file)
 
 from oslo_config import cfg
 from oslo_db import exception as db_exc
+from oslo_log import helpers as log_helpers
 from oslo_log import log as logging
 import sqlalchemy as sa
 from sqlalchemy.orm import exc
 
 from neutron.common import exceptions as q_exc
-from neutron.common import log
 from neutron.common import utils
 from neutron.db import model_base
 from neutron.extensions import dvr as ext_dvr
@@ -123,7 +123,7 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase):
         return {'host': dvr_mac_entry['host'],
                 'mac_address': dvr_mac_entry['mac_address']}
 
-    @log.log
+    @log_helpers.log_method_call
     def get_ports_on_host_by_subnet(self, context, host, subnet):
         """Returns ports of interest, on a given subnet in the input host
 
@@ -154,7 +154,7 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase):
                    'ports': ports_by_host})
         return ports_by_host
 
-    @log.log
+    @log_helpers.log_method_call
     def get_subnet_for_dvr(self, context, subnet):
         try:
             subnet_info = self.plugin.get_subnet(context, subnet)
index 4c750ea7fa3e18a2280e7cfe6372c557994d829e..3f81bfc93b5d4a00cae1f6bdd4e1403f7ba095cc 100755 (executable)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from oslo_log import helpers as log_helpers
 from oslo_log import log as logging
 
 from neutron.common import constants as n_const
-from neutron.common import log
 from neutron.extensions import portbindings
 from neutron.i18n import _LI
 from neutron.plugins.common import constants
@@ -31,7 +31,7 @@ class FslsdnMechanismDriver(api.MechanismDriver):
 
     """Freescale SDN OS Mechanism Driver for ML2 Plugin."""
 
-    @log.log
+    @log_helpers.log_method_call
     def initialize(self):
         """Initialize the Mechanism driver."""
 
@@ -42,7 +42,7 @@ class FslsdnMechanismDriver(api.MechanismDriver):
 
     # Network Management
     @staticmethod
-    @log.log
+    @log_helpers.log_method_call
     def _prepare_crd_network(network, segments):
         """Helper function to create 'network' data."""
 
@@ -137,7 +137,7 @@ class FslsdnMechanismDriver(api.MechanismDriver):
 
     # Subnet Management
     @staticmethod
-    @log.log
+    @log_helpers.log_method_call
     def _prepare_crd_subnet(subnet):
         """Helper function to prepare 'subnet' data."""
 
@@ -220,7 +220,7 @@ class FslsdnMechanismDriver(api.MechanismDriver):
                            'physnet': segment[api.PHYSICAL_NETWORK],
                            'nettype': segment[api.NETWORK_TYPE]})
 
-    @log.log
+    @log_helpers.log_method_call
     def check_segment(self, segment):
         """Verify a segment is valid for the FSL SDN MechanismDriver."""
 
index 583b511f05417af4ba58abd1cd778b280362ada6..c6913c9ec5cebce44569c323f81bfe41f54e3d08 100644 (file)
@@ -18,13 +18,13 @@ import threading
 from networking_arista.common import db_lib
 from networking_arista.l3Plugin import arista_l3_driver
 from oslo_config import cfg
+from oslo_log import helpers as log_helpers
 from oslo_log import log as logging
 from oslo_utils import excutils
 
 from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
 from neutron.api.rpc.handlers import l3_rpc
 from neutron.common import constants as q_const
-from neutron.common import log
 from neutron.common import rpc as q_rpc
 from neutron.common import topics
 from neutron import context as nctx
@@ -94,7 +94,7 @@ class AristaL3ServicePlugin(db_base_plugin_v2.NeutronDbPluginV2,
             self.timer.cancel()
             self.timer = None
 
-    @log.log
+    @log_helpers.log_method_call
     def create_router(self, context, router):
         """Create a new router entry in DB, and create it Arista HW."""
 
@@ -116,7 +116,7 @@ class AristaL3ServicePlugin(db_base_plugin_v2.NeutronDbPluginV2,
                 super(AristaL3ServicePlugin, self).delete_router(context,
                                                     new_router['id'])
 
-    @log.log
+    @log_helpers.log_method_call
     def update_router(self, context, router_id, router):
         """Update an existing router in DB, and update it in Arista HW."""
 
@@ -137,7 +137,7 @@ class AristaL3ServicePlugin(db_base_plugin_v2.NeutronDbPluginV2,
             LOG.error(_LE("Error updating router on Arista HW router=%s "),
                       new_router)
 
-    @log.log
+    @log_helpers.log_method_call
     def delete_router(self, context, router_id):
         """Delete an existing router from Arista HW as well as from the DB."""
 
@@ -157,7 +157,7 @@ class AristaL3ServicePlugin(db_base_plugin_v2.NeutronDbPluginV2,
             super(AristaL3ServicePlugin, self).delete_router(context,
                                                              router_id)
 
-    @log.log
+    @log_helpers.log_method_call
     def add_router_interface(self, context, router_id, interface_info):
         """Add a subnet of a network to an existing router."""
 
@@ -203,7 +203,7 @@ class AristaL3ServicePlugin(db_base_plugin_v2.NeutronDbPluginV2,
                                                     router_id,
                                                     interface_info)
 
-    @log.log
+    @log_helpers.log_method_call
     def remove_router_interface(self, context, router_id, interface_info):
         """Remove a subnet of a network from an existing router."""
 
index 20fa347dc62c9187bbdce04297fc000d814912aa..6a43438b1488464f970c2766390391cf27ee0bc1 100644 (file)
@@ -13,6 +13,7 @@
 # under the License.
 
 from oslo_config import cfg
+from oslo_log import helpers as log_helpers
 from oslo_log import log as logging
 from oslo_utils import importutils
 import six
@@ -22,7 +23,6 @@ from neutron.agent.linux import interface
 from neutron.agent.linux import iptables_manager
 from neutron.common import constants as constants
 from neutron.common import ipv6_utils
-from neutron.common import log
 from neutron.i18n import _LE, _LI
 from neutron.services.metering.drivers import abstract_driver
 
@@ -99,7 +99,7 @@ class IptablesMeteringDriver(abstract_driver.MeteringAbstractDriver):
 
         return r
 
-    @log.log
+    @log_helpers.log_method_call
     def update_routers(self, context, routers):
         # disassociate removed routers
         router_ids = set(router['id'] for router in routers)
@@ -123,7 +123,7 @@ class IptablesMeteringDriver(abstract_driver.MeteringAbstractDriver):
                 elif gw_port_id:
                     self._process_associate_metering_label(router)
 
-    @log.log
+    @log_helpers.log_method_call
     def remove_router(self, context, router_id):
         if router_id in self.routers:
             del self.routers[router_id]
@@ -248,22 +248,22 @@ class IptablesMeteringDriver(abstract_driver.MeteringAbstractDriver):
 
                 del rm.metering_labels[label_id]
 
-    @log.log
+    @log_helpers.log_method_call
     def add_metering_label(self, context, routers):
         for router in routers:
             self._process_associate_metering_label(router)
 
-    @log.log
+    @log_helpers.log_method_call
     def add_metering_label_rule(self, context, routers):
         for router in routers:
             self._add_metering_label_rule(router)
 
-    @log.log
+    @log_helpers.log_method_call
     def remove_metering_label_rule(self, context, routers):
         for router in routers:
             self._remove_metering_label_rule(router)
 
-    @log.log
+    @log_helpers.log_method_call
     def update_metering_label_rules(self, context, routers):
         for router in routers:
             self._update_metering_label_rules(router)
@@ -330,12 +330,12 @@ class IptablesMeteringDriver(abstract_driver.MeteringAbstractDriver):
                                                        label_chain,
                                                        rules_chain)
 
-    @log.log
+    @log_helpers.log_method_call
     def remove_metering_label(self, context, routers):
         for router in routers:
             self._process_disassociate_metering_label(router)
 
-    @log.log
+    @log_helpers.log_method_call
     def get_traffic_counters(self, context, routers):
         accs = {}
         for router in routers:
index e9925a8df31f8532197e8ccce8a80456abe0ed3b..25df069fa72a334089ded62a4ac464a5b3919741 100644 (file)
 # License for the specific language governing permissions and limitations
 # under the License.
 
-from neutron.common import log
+from oslo_log import helpers as log_helpers
+
 from neutron.services.metering.drivers import abstract_driver
 
 
 class NoopMeteringDriver(abstract_driver.MeteringAbstractDriver):
 
-    @log.log
+    @log_helpers.log_method_call
     def update_routers(self, context, routers):
         pass
 
-    @log.log
+    @log_helpers.log_method_call
     def remove_router(self, context, router_id):
         pass
 
-    @log.log
+    @log_helpers.log_method_call
     def update_metering_label_rules(self, context, routers):
         pass
 
-    @log.log
+    @log_helpers.log_method_call
     def add_metering_label_rule(self, context, routers):
         pass
 
-    @log.log
+    @log_helpers.log_method_call
     def remove_metering_label_rule(self, context, routers):
         pass
 
-    @log.log
+    @log_helpers.log_method_call
     def add_metering_label(self, context, routers):
         pass
 
-    @log.log
+    @log_helpers.log_method_call
     def remove_metering_label(self, context, routers):
         pass
 
-    @log.log
+    @log_helpers.log_method_call
     def get_traffic_counters(self, context, routers):
         pass