本文整理汇总了Python中neutron.openstack.common.log.getLogger函数的典型用法代码示例。如果您正苦于以下问题:Python getLogger函数的具体用法?Python getLogger怎么用?Python getLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getLogger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _run
def _run(self, application, socket):
"""Start a WSGI service in a new green thread."""
logger = logging.getLogger('eventlet.wsgi.server')
eventlet.wsgi.server(socket,
application,
custom_pool=self.pool,
protocol=UnixDomainHttpProtocol,
log=logging.WritableLogger(logger))
示例2: __call__
def __call__(self, func):
if self.logger is None:
LOG = logging.getLogger(func.__module__)
self.logger = LOG.exception
def call(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as e:
with excutils.save_and_reraise_exception():
self.logger(e)
return call
示例3: notify
def notify(_context, message):
"""Notifies the recipient of the desired event given the model.
Log notifications using openstack's default logging system.
"""
priority = message.get('priority',
CONF.default_notification_level)
priority = priority.lower()
logger = logging.getLogger(
'neutron.openstack.common.notification.%s' %
message['event_type'])
getattr(logger, priority)(jsonutils.dumps(message))
示例4: log
def log(method):
"""Decorator helping to log method calls."""
LOG = logging.getLogger(method.__module__)
@functools.wraps(method)
def wrapper(*args, **kwargs):
instance = args[0]
data = {"class_name": "%s.%s" % (instance.__class__.__module__,
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
示例5: test_not_called_with_low_log_level
def test_not_called_with_low_log_level(self):
LOG = logging.getLogger(__name__)
# make sure we return logging to previous level
current_log_level = LOG.logger.getEffectiveLevel()
self.addCleanup(LOG.logger.setLevel, current_log_level)
my_func = mock.MagicMock()
delayed = utils.DelayedStringRenderer(my_func)
# set to warning so we shouldn't be logging debug messages
LOG.logger.setLevel(logging.logging.WARNING)
LOG.debug("Hello %s", delayed)
self.assertFalse(my_func.called)
# but it should be called with the debug level
LOG.logger.setLevel(logging.logging.DEBUG)
LOG.debug("Hello %s", delayed)
self.assertTrue(my_func.called)
示例6: L3AgentMixin
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import copy
import traceback
from neutron.agent.linux import ip_lib
from neutron.common import constants as l3_constants
from neutron.common import utils as common_utils
from neutron.openstack.common import jsonutils
from neutron.openstack.common import lockutils
from neutron.openstack.common import log as logging
LOG = logging.getLogger('uos_l3')
TOP_CHAIN = 'meter-uos'
WRAP_NAME = 'neutron-vpn-agen-'
FIP_CHAIN_SIZE = 10
TOP_CHAIN_NAME = WRAP_NAME + TOP_CHAIN
class L3AgentMixin(object):
def _uos_get_ex_gw_port(self, ri):
gw_port = ri.router.get('gw_port')
if not gw_port:
return gw_port
if gw_port.get('_uos_fip'):
return gw_port
gateway_ips = ri.router.get('gateway_ips', [])
示例7: BaseDriver
#
# 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
#
from neutron.openstack.common import log as logging
LOG = logging.getLogger("neutron.quark.base")
class BaseDriver(object):
"""Base interface for all Quark drivers.
Usable as a replacement for the sample plugin.
"""
def load_config(self):
LOG.info("load_config")
def get_connection(self):
LOG.info("get_connection")
def create_network(self, context, network_name, tags=None,
network_id=None, **kwargs):
示例8: mac_range_dict
from neutron import manager
from neutron.openstack.common import log as logging
from neutron import wsgi
RESOURCE_NAME = 'mac_address_range'
RESOURCE_COLLECTION = RESOURCE_NAME + "s"
EXTENDED_ATTRIBUTES_2_0 = {
RESOURCE_COLLECTION: {}
}
attr_dict = EXTENDED_ATTRIBUTES_2_0[RESOURCE_COLLECTION]
attr_dict[RESOURCE_NAME] = {'allow_post': True,
'allow_put': False,
'is_visible': True}
LOG = logging.getLogger("neutron.quark.api.extensions.mac_address_ranges")
def mac_range_dict(mac_range):
return dict(address=mac_range["cidr"],
id=mac_range["id"])
class MacAddressRangesController(wsgi.Controller):
def __init__(self, plugin):
self._resource_name = RESOURCE_NAME
self._plugin = plugin
def create(self, request, body=None):
body = self._deserialize(request.body, request.get_content_type())
示例9: JSONStrategy
#
# 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.
import json
from neutron.common import exceptions
from neutron.openstack.common import log as logging
from oslo.config import cfg
LOG = logging.getLogger("neutron.quark")
CONF = cfg.CONF
quark_opts = [
cfg.StrOpt('default_net_strategy', default='{}',
help=_("Default network assignment strategy"))
]
CONF.register_opts(quark_opts, "QUARK")
class JSONStrategy(object):
def __init__(self, strategy=None):
self.reverse_strategy = {}
self.strategy = {}
if not strategy:
self._compile_strategy(CONF.QUARK.default_net_strategy)
示例10:
# 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.
# @author: Haojie Jia, Huawei
from oslo.config import cfg
#from heat.openstack.common import importutils
#from heat.openstack.common import log as logging
from neutron.openstack.common import importutils
from neutron.openstack.common import log as logging
logger = logging.getLogger(__name__)
from neutron.plugins.l2_proxy.agent import neutron_keystoneclient as hkc
from novaclient import client as novaclient
from novaclient import shell as novashell
try:
from swiftclient import client as swiftclient
except ImportError:
swiftclient = None
logger.info('swiftclient not available')
try:
from neutronclient.v2_0 import client as neutronclient
except ImportError:
neutronclient = None
logger.info('neutronclient not available')
示例11: main
from ryu import cfg
import sys
from neutron.openstack.common import log as os_logging
from neutron.common import config as osn_config
from ryu import flags
from ryu import version
from ryu.app import wsgi
from ryu.base.app_manager import AppManager
from ryu.controller import controller
from ryu.topology import switches
LOG = os_logging.getLogger(__name__)
CONF = cfg.CONF
CONF.register_cli_opts([
cfg.ListOpt('app-lists', default=[],
help='application module name to run'),
cfg.MultiStrOpt('app', positional=True, default=[],
help='application module name to run')
])
def main():
try:
CONF(project='ryu', version='ofa_neutron_agent %s' % version,
default_config_files=['/usr/local/etc/ryu/ryu.conf'])
except cfg.ConfigFilesNotFoundError:
CONF(project='ryu', version='ofa_neutron_agent %s' % version)
示例12: akanda_nvp_ipv6_port_security_wrapper
import functools
from neutron.common import topics
from neutron.db import l3_db
from neutron.db import l3_rpc_base as l3_rpc
from neutron.extensions import portsecurity as psec
from neutron.extensions import securitygroup as ext_sg
from neutron.openstack.common import log as logging
from neutron.openstack.common import rpc
from neutron.plugins.nicira.dhcp_meta import rpc as nvp_rpc
from neutron.plugins.nicira.NeutronPlugin import nicira_db
from neutron.plugins.nicira import NeutronPlugin as nvp
from akanda.neutron.plugins import decorators as akanda
LOG = logging.getLogger("NeutronPlugin")
akanda.monkey_patch_ipv6_generator()
def akanda_nvp_ipv6_port_security_wrapper(f):
@functools.wraps(f)
def wrapper(lport_obj, mac_address, fixed_ips, port_security_enabled,
security_profiles, queue_id, mac_learning_enabled,
allowed_address_pairs):
f(lport_obj, mac_address, fixed_ips, port_security_enabled,
security_profiles, queue_id, mac_learning_enabled,
allowed_address_pairs)
# evaulate the state so that we only override the value when enabled
# otherwise we are preserving the underlying behavior of the NVP plugin
示例13: CookbookMechanismDriver
# Import Neutron Database API
from neutron.db import api as db
try:
from neutron.openstack.common import log as logger
except ImportError:
from oslo_log import log as logger
from neutron.plugins.ml2 import driver_api as api
import ch10_ml2_mech_driver_network as cookbook_network_driver
import ch10_ml2_mech_driver_subnet as cookbook_subnet_driver
import ch10_ml2_mech_driver_port as cookbook_port_driver
driver_logger = logger.getLogger(__name__)
class CookbookMechanismDriver(cookbook_network_driver.CookbookNetworkMechanismDriver,
cookbook_subnet_driver.CookbookSubnetMechanismDriver,
cookbook_port_driver.CookbookPortMechanismDriver):
def initialize(self):
driver_logger.info("Inside Mech Driver Initialize")
示例14: KeystoneClient
# License for the specific language governing permissions and limitations
# under the License.
from neutron.openstack.common import context
from neutron.common import exceptions
import eventlet
from keystoneclient.v2_0 import client as kc
from keystoneclient.v3 import client as kc_v3
from oslo.config import cfg
from neutron.openstack.common import importutils
from neutron.openstack.common import log as logging
logger = logging.getLogger(
'neutron.plugins.cascading_proxy_agent.keystoneclient')
class KeystoneClient(object):
"""
Wrap keystone client so we can encapsulate logic used in resources
Note this is intended to be initialized from a resource on a per-session
basis, so the session context is passed in on initialization
Also note that a copy of this is created every resource as self.keystone()
via the code in engine/client.py, so there should not be any need to
directly instantiate instances of this class inside resources themselves
"""
def __init__(self, context):
# We have to maintain two clients authenticated with keystone:
示例15: IpAddressesController
from neutron import manager
from neutron.openstack.common import log as logging
from neutron import wsgi
RESOURCE_NAME = 'ip_address'
RESOURCE_COLLECTION = RESOURCE_NAME + "es"
EXTENDED_ATTRIBUTES_2_0 = {
RESOURCE_COLLECTION: {}
}
attr_dict = EXTENDED_ATTRIBUTES_2_0[RESOURCE_COLLECTION]
attr_dict[RESOURCE_NAME] = {'allow_post': True,
'allow_put': True,
'is_visible': True}
LOG = logging.getLogger("neutron.quark.api.extensions.ip_addresses")
class IpAddressesController(wsgi.Controller):
def __init__(self, plugin):
self._resource_name = RESOURCE_NAME
self._plugin = plugin
def index(self, request):
context = request.context
return {"ip_addresses":
self._plugin.get_ip_addresses(context, **request.GET)}
def show(self, request, id):
context = request.context