From ba05644bc888d23e571386bbaa6ae8c7597c8c98 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Mon, 30 Mar 2015 18:41:28 +0200 Subject: [PATCH] Replace custom method call logger with oslo.log helper 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 | 16 ++++++++-------- neutron/api/rpc/handlers/dvr_rpc.py | 10 +++++----- neutron/common/log.py | 4 ++++ neutron/db/dvr_mac_db.py | 6 +++--- .../ml2/drivers/freescale/mechanism_fslsdn.py | 10 +++++----- neutron/services/l3_router/l3_arista.py | 12 ++++++------ .../drivers/iptables/iptables_driver.py | 18 +++++++++--------- .../metering/drivers/noop/noop_driver.py | 19 ++++++++++--------- 8 files changed, 50 insertions(+), 45 deletions(-) diff --git a/neutron/agent/l2population_rpc.py b/neutron/agent/l2population_rpc.py index 50ba665b082..509d425edd1 100644 --- a/neutron/agent/l2population_rpc.py +++ b/neutron/agent/l2population_rpc.py @@ -16,11 +16,11 @@ 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_'. @@ -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. diff --git a/neutron/api/rpc/handlers/dvr_rpc.py b/neutron/api/rpc/handlers/dvr_rpc.py index bbfe6e02a46..8b6574707e8 100644 --- a/neutron/api/rpc/handlers/dvr_rpc.py +++ b/neutron/api/rpc/handlers/dvr_rpc.py @@ -13,11 +13,11 @@ # 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) diff --git a/neutron/common/log.py b/neutron/common/log.py index b5fcaf15bb9..fc6c7ba0341 100644 --- a/neutron/common/log.py +++ b/neutron/common/log.py @@ -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__) diff --git a/neutron/db/dvr_mac_db.py b/neutron/db/dvr_mac_db.py index b432d8b84a3..951c45a9991 100644 --- a/neutron/db/dvr_mac_db.py +++ b/neutron/db/dvr_mac_db.py @@ -15,12 +15,12 @@ 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) diff --git a/neutron/plugins/ml2/drivers/freescale/mechanism_fslsdn.py b/neutron/plugins/ml2/drivers/freescale/mechanism_fslsdn.py index 4c750ea7fa3..3f81bfc93b5 100755 --- a/neutron/plugins/ml2/drivers/freescale/mechanism_fslsdn.py +++ b/neutron/plugins/ml2/drivers/freescale/mechanism_fslsdn.py @@ -13,10 +13,10 @@ # 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.""" diff --git a/neutron/services/l3_router/l3_arista.py b/neutron/services/l3_router/l3_arista.py index 583b511f054..c6913c9ec5c 100644 --- a/neutron/services/l3_router/l3_arista.py +++ b/neutron/services/l3_router/l3_arista.py @@ -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.""" diff --git a/neutron/services/metering/drivers/iptables/iptables_driver.py b/neutron/services/metering/drivers/iptables/iptables_driver.py index 20fa347dc62..6a43438b148 100644 --- a/neutron/services/metering/drivers/iptables/iptables_driver.py +++ b/neutron/services/metering/drivers/iptables/iptables_driver.py @@ -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: diff --git a/neutron/services/metering/drivers/noop/noop_driver.py b/neutron/services/metering/drivers/noop/noop_driver.py index e9925a8df31..25df069fa72 100644 --- a/neutron/services/metering/drivers/noop/noop_driver.py +++ b/neutron/services/metering/drivers/noop/noop_driver.py @@ -12,40 +12,41 @@ # 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