Merge "Add decorator helping to log method calls."
This commit is contained in:
commit
3be4916ed2
34
neutron/common/log.py
Normal file
34
neutron/common/log.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||||
|
#
|
||||||
|
# Author: Sylvain Afchain <sylvain.afchain@enovance.com>
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
"""Log helper functions."""
|
||||||
|
|
||||||
|
from neutron.openstack.common import log as logging
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def log(method):
|
||||||
|
"""Decorator helping to log method calls."""
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
instance = args[0]
|
||||||
|
data = {"class_name": instance.__class__.__name__,
|
||||||
|
"method_name": method.__name__,
|
||||||
|
"args": args[1:], "kwargs": kwargs}
|
||||||
|
LOG.debug(_('%(class_name)s method %(method_name)s'
|
||||||
|
'called with arguments %(args)s %(kwargs)s '), data)
|
||||||
|
return method(*args, **kwargs)
|
||||||
|
return wrapper
|
@ -16,7 +16,7 @@
|
|||||||
#
|
#
|
||||||
# @author: Avishay Balderman, Radware
|
# @author: Avishay Balderman, Radware
|
||||||
|
|
||||||
|
from neutron.common import log
|
||||||
from neutron.openstack.common import log as logging
|
from neutron.openstack.common import log as logging
|
||||||
from neutron.services.loadbalancer.drivers import (
|
from neutron.services.loadbalancer.drivers import (
|
||||||
abstract_driver
|
abstract_driver
|
||||||
@ -25,16 +25,6 @@ from neutron.services.loadbalancer.drivers import (
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def log(method):
|
|
||||||
def wrapper(*args, **kwargs):
|
|
||||||
data = {"method_name": method.__name__, "args": args, "kwargs": kwargs}
|
|
||||||
LOG.debug(_('NoopLbaaSDriver method %(method_name)s'
|
|
||||||
'called with arguments %(args)s %(kwargs)s ')
|
|
||||||
% data)
|
|
||||||
return method(*args, **kwargs)
|
|
||||||
return wrapper
|
|
||||||
|
|
||||||
|
|
||||||
class NoopLbaaSDriver(abstract_driver.LoadBalancerAbstractDriver):
|
class NoopLbaaSDriver(abstract_driver.LoadBalancerAbstractDriver):
|
||||||
|
|
||||||
"""A dummy lbass driver that:
|
"""A dummy lbass driver that:
|
||||||
@ -46,65 +36,65 @@ class NoopLbaaSDriver(abstract_driver.LoadBalancerAbstractDriver):
|
|||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def create_vip(self, context, vip):
|
def create_vip(self, context, vip):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def update_vip(self, context, old_vip, vip):
|
def update_vip(self, context, old_vip, vip):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def delete_vip(self, context, vip):
|
def delete_vip(self, context, vip):
|
||||||
self.plugin._delete_db_vip(context, vip["id"])
|
self.plugin._delete_db_vip(context, vip["id"])
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def create_pool(self, context, pool):
|
def create_pool(self, context, pool):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def update_pool(self, context, old_pool, pool):
|
def update_pool(self, context, old_pool, pool):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def delete_pool(self, context, pool):
|
def delete_pool(self, context, pool):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def stats(self, context, pool_id):
|
def stats(self, context, pool_id):
|
||||||
return {"bytes_in": 0,
|
return {"bytes_in": 0,
|
||||||
"bytes_out": 0,
|
"bytes_out": 0,
|
||||||
"active_connections": 0,
|
"active_connections": 0,
|
||||||
"total_connections": 0}
|
"total_connections": 0}
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def create_member(self, context, member):
|
def create_member(self, context, member):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def update_member(self, context, old_member, member):
|
def update_member(self, context, old_member, member):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def delete_member(self, context, member):
|
def delete_member(self, context, member):
|
||||||
self.plugin._delete_db_member(context, member["id"])
|
self.plugin._delete_db_member(context, member["id"])
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def create_health_monitor(self, context, health_monitor):
|
def create_health_monitor(self, context, health_monitor):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def update_health_monitor(self, context, old_health_monitor,
|
def update_health_monitor(self, context, old_health_monitor,
|
||||||
health_monitor,
|
health_monitor,
|
||||||
pool_association):
|
pool_association):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def create_pool_health_monitor(self, context,
|
def create_pool_health_monitor(self, context,
|
||||||
health_monitor, pool_id):
|
health_monitor, pool_id):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@log
|
@log.log
|
||||||
def delete_pool_health_monitor(self, context, health_monitor, pool_id):
|
def delete_pool_health_monitor(self, context, health_monitor, pool_id):
|
||||||
self.plugin._delete_db_pool_health_monitor(
|
self.plugin._delete_db_pool_health_monitor(
|
||||||
context, health_monitor["id"],
|
context, health_monitor["id"],
|
||||||
|
Loading…
Reference in New Issue
Block a user