Migrate to oslo.log

It's mostly a matter of changing imports to a new location.

Non-obvious changes needed:
* pass overwrite= argument to oslo_context since oslo.log reads context
  from its thread local store and not local.store from incubator
* don't store context at local.store now that there is no code that
  would consume it
* LOG.deprecated() -> versionutils.report_deprecated_feature()
* dropped LOG.audit check from hacking rule since now the method does
  not exist
* WritableLogger is now located in oslo_log.loggers

Dropped log module from the tree. Also dropped local module that is now
of no use (and obsolete, as per oslo team).

Added versionutils back to openstack-common.conf since now we use the
module directly from neutron code and not just as a dependency of some
other oslo-incubator module.

Note: tempest tests are expected to be broken now, so instead of fixing
all the oslo.log related issues for the subtree in this patch, I only
added TODOs with directions for later fix.

Closes-Bug: #1425013
Change-Id: I310e059a815377579de6bb2aa204de168e72571e
This commit is contained in:
Ihar Hrachyshka 2015-02-26 23:26:41 +01:00
parent e3df45daa7
commit 22328baf1f
211 changed files with 297 additions and 1029 deletions

View File

@ -16,9 +16,9 @@
import os import os
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from neutron.common import config from neutron.common import config
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -19,6 +19,7 @@ import os
import eventlet import eventlet
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from oslo_utils import importutils from oslo_utils import importutils
@ -34,7 +35,6 @@ from neutron.common import utils
from neutron import context from neutron import context
from neutron.i18n import _LE, _LI, _LW from neutron.i18n import _LE, _LI, _LW
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from neutron.openstack.common import loopingcall from neutron.openstack.common import loopingcall
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -16,11 +16,11 @@
import abc import abc
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
import six import six
from neutron.common import constants as n_const from neutron.common import constants as n_const
from neutron.common import log from neutron.common import log
from neutron.openstack.common import log as logging
from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -16,6 +16,7 @@
import eventlet import eventlet
import netaddr import netaddr
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from oslo_utils import excutils from oslo_utils import excutils
from oslo_utils import importutils from oslo_utils import importutils
@ -45,7 +46,6 @@ from neutron.common import utils as common_utils
from neutron import context as n_context from neutron import context as n_context
from neutron.i18n import _LE, _LI, _LW from neutron.i18n import _LE, _LI, _LW
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from neutron.openstack.common import loopingcall from neutron.openstack.common import loopingcall
from neutron.openstack.common import periodic_task from neutron.openstack.common import periodic_task
from neutron.services import advanced_service as adv_svc from neutron.services import advanced_service as adv_svc

View File

@ -13,16 +13,17 @@
# under the License. # under the License.
import binascii import binascii
import netaddr
import weakref import weakref
import netaddr
from oslo_log import log as logging
from neutron.agent.l3 import dvr_fip_ns from neutron.agent.l3 import dvr_fip_ns
from neutron.agent.l3 import dvr_snat_ns from neutron.agent.l3 import dvr_snat_ns
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.agent.linux import iptables_manager from neutron.agent.linux import iptables_manager
from neutron.common import constants as l3_constants from neutron.common import constants as l3_constants
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -12,15 +12,16 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import netaddr
import os import os
import netaddr
from oslo_log import log as logging
from neutron.agent.l3 import link_local_allocator as lla from neutron.agent.l3 import link_local_allocator as lla
from neutron.agent.l3 import namespaces from neutron.agent.l3 import namespaces
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.agent.linux import iptables_manager from neutron.agent.linux import iptables_manager
from neutron.common import utils as common_utils from neutron.common import utils as common_utils
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
from neutron.agent.l3 import dvr_fip_ns from neutron.agent.l3 import dvr_fip_ns
@ -21,7 +22,6 @@ from neutron.agent.linux import ip_lib
from neutron.common import constants as l3_constants from neutron.common import constants as l3_constants
from neutron.common import utils as common_utils from neutron.common import utils as common_utils
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -10,9 +10,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from neutron.agent.l3 import namespaces from neutron.agent.l3 import namespaces
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
SNAT_NS_PREFIX = 'snat-' SNAT_NS_PREFIX = 'snat-'

View File

@ -16,11 +16,11 @@
import os import os
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from neutron.agent.linux import keepalived from neutron.agent.linux import keepalived
from neutron.common import constants as l3_constants from neutron.common import constants as l3_constants
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -12,17 +12,18 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import netaddr
import shutil import shutil
import signal import signal
import netaddr
from oslo_log import log as logging
from neutron.agent.l3 import router_info as router from neutron.agent.l3 import router_info as router
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.agent.linux import keepalived from neutron.agent.linux import keepalived
from neutron.agent.metadata import driver as metadata_driver from neutron.agent.metadata import driver as metadata_driver
from neutron.common import constants as n_consts from neutron.common import constants as n_consts
from neutron.common import utils as common_utils from neutron.common import utils as common_utils
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
HA_DEV_PREFIX = 'ha-' HA_DEV_PREFIX = 'ha-'

View File

@ -10,11 +10,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from neutron.agent.l3 import dvr_snat_ns from neutron.agent.l3 import dvr_snat_ns
from neutron.agent.l3 import namespaces from neutron.agent.l3 import namespaces
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,9 +13,10 @@
# under the License. # under the License.
# #
from oslo_log import log as logging
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from neutron.agent.l3 import namespaces from neutron.agent.l3 import namespaces
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.agent.linux import iptables_manager from neutron.agent.linux import iptables_manager
@ -19,7 +21,6 @@ from neutron.common import constants as l3_constants
from neutron.common import exceptions as n_exc from neutron.common import exceptions as n_exc
from neutron.common import utils as common_utils from neutron.common import utils as common_utils
from neutron.i18n import _LW from neutron.i18n import _LW
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
INTERNAL_DEV_PREFIX = 'qr-' INTERNAL_DEV_PREFIX = 'qr-'

View File

@ -15,11 +15,11 @@
import eventlet import eventlet
import eventlet.event import eventlet.event
import eventlet.queue import eventlet.queue
from oslo_log import log as logging
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.agent.linux import utils from neutron.agent.linux import utils
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -20,9 +20,10 @@ import pwd
import signal import signal
import sys import sys
from oslo_log import log as logging
from neutron.common import exceptions from neutron.common import exceptions
from neutron.i18n import _LE, _LI from neutron.i18n import _LE, _LI
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -20,6 +20,7 @@ import re
import shutil import shutil
import netaddr import netaddr
from oslo_log import log as logging
from oslo_utils import importutils from oslo_utils import importutils
import six import six
@ -31,7 +32,6 @@ from neutron.common import exceptions
from neutron.common import ipv6_utils from neutron.common import ipv6_utils
from neutron.common import utils as commonutils from neutron.common import utils as commonutils
from neutron.i18n import _LE, _LI, _LW from neutron.i18n import _LE, _LI, _LW
from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -20,13 +20,13 @@ import six
import eventlet import eventlet
from oslo_concurrency import lockutils from oslo_concurrency import lockutils
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from neutron.agent.common import config as agent_cfg from neutron.agent.common import config as agent_cfg
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.agent.linux import utils from neutron.agent.linux import utils
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import fileutils from neutron.openstack.common import fileutils
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -17,6 +17,7 @@ import abc
import netaddr import netaddr
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils from oslo_utils import importutils
import six import six
@ -27,7 +28,6 @@ from neutron.common import constants as n_const
from neutron.common import exceptions from neutron.common import exceptions
from neutron.extensions import flavor from neutron.extensions import flavor
from neutron.i18n import _LE, _LI from neutron.i18n import _LE, _LI
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,14 +14,13 @@
# under the License. # under the License.
import eventlet import eventlet
import netaddr import netaddr
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from neutron.agent.linux import utils from neutron.agent.linux import utils
from neutron.common import exceptions from neutron.common import exceptions
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,10 +15,11 @@
import re import re
from oslo_log import log as logging
from neutron.agent.linux import utils from neutron.agent.linux import utils
from neutron.common import exceptions as n_exc from neutron.common import exceptions as n_exc
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,11 +13,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
from neutron.agent.linux import async_process from neutron.agent.linux import async_process
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,6 +15,7 @@
import netaddr import netaddr
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from neutron.agent import firewall from neutron.agent import firewall
from neutron.agent.linux import ipset_manager from neutron.agent.linux import ipset_manager
@ -23,7 +24,6 @@ from neutron.agent.linux import iptables_manager
from neutron.common import constants from neutron.common import constants
from neutron.common import ipv6_utils from neutron.common import ipv6_utils
from neutron.i18n import _LI from neutron.i18n import _LI
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -25,6 +25,7 @@ import sys
from oslo_concurrency import lockutils from oslo_concurrency import lockutils
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
from neutron.agent.common import config from neutron.agent.common import config
@ -33,7 +34,6 @@ from neutron.agent.linux import utils as linux_utils
from neutron.common import exceptions as n_exc from neutron.common import exceptions as n_exc
from neutron.common import utils from neutron.common import utils
from neutron.i18n import _LE, _LW from neutron.i18n import _LE, _LW
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -19,11 +19,11 @@ import stat
import netaddr import netaddr
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from neutron.agent.linux import external_process from neutron.agent.linux import external_process
from neutron.agent.linux import utils from neutron.agent.linux import utils
from neutron.common import exceptions from neutron.common import exceptions
from neutron.openstack.common import log as logging
VALID_STATES = ['MASTER', 'BACKUP'] VALID_STATES = ['MASTER', 'BACKUP']
VALID_NOTIFY_STATES = ['master', 'backup', 'fault'] VALID_NOTIFY_STATES = ['master', 'backup', 'fault']

View File

@ -18,6 +18,7 @@ import itertools
import operator import operator
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
import retrying import retrying
import six import six
@ -27,7 +28,6 @@ from neutron.agent.linux import utils
from neutron.agent.ovsdb import api as ovsdb from neutron.agent.ovsdb import api as ovsdb
from neutron.common import exceptions from neutron.common import exceptions
from neutron.i18n import _LE, _LI, _LW from neutron.i18n import _LE, _LI, _LW
from neutron.openstack.common import log as logging
from neutron.plugins.common import constants from neutron.plugins.common import constants
# Default timeout for ovs-vsctl command # Default timeout for ovs-vsctl command

View File

@ -13,10 +13,10 @@
# under the License. # under the License.
import eventlet import eventlet
from oslo_log import log as logging
from neutron.agent.linux import async_process from neutron.agent.linux import async_process
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -16,12 +16,12 @@
import jinja2 import jinja2
import netaddr import netaddr
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
import six import six
from neutron.agent.linux import external_process from neutron.agent.linux import external_process
from neutron.agent.linux import utils from neutron.agent.linux import utils
from neutron.common import constants from neutron.common import constants
from neutron.openstack.common import log as logging
RADVD_SERVICE_NAME = 'radvd' RADVD_SERVICE_NAME = 'radvd'

View File

@ -25,13 +25,13 @@ import eventlet
from eventlet.green import subprocess from eventlet.green import subprocess
from eventlet import greenthread from eventlet import greenthread
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
from neutron.agent.common import config from neutron.agent.common import config
from neutron.common import constants from neutron.common import constants
from neutron.common import utils from neutron.common import utils
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -21,6 +21,8 @@ import eventlet
import httplib2 import httplib2
from neutronclient.v2_0 import client from neutronclient.v2_0 import client
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from oslo_log import loggers
import oslo_messaging import oslo_messaging
from oslo_utils import excutils from oslo_utils import excutils
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
@ -34,7 +36,6 @@ from neutron.common import utils
from neutron import context from neutron import context
from neutron.i18n import _LE, _LW from neutron.i18n import _LE, _LW
from neutron.openstack.common.cache import cache from neutron.openstack.common.cache import cache
from neutron.openstack.common import log as logging
from neutron.openstack.common import loopingcall from neutron.openstack.common import loopingcall
from neutron import wsgi from neutron import wsgi
@ -294,7 +295,7 @@ class UnixDomainWSGIServer(wsgi.Server):
application, application,
max_size=self.num_threads, max_size=self.num_threads,
protocol=UnixDomainHttpProtocol, protocol=UnixDomainHttpProtocol,
log=logging.WritableLogger(logger)) log=loggers.WritableLogger(logger))
class UnixDomainMetadataProxy(object): class UnixDomainMetadataProxy(object):

View File

@ -16,11 +16,11 @@
import os import os
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from neutron.agent.common import config from neutron.agent.common import config
from neutron.agent.linux import external_process from neutron.agent.linux import external_process
from neutron.common import exceptions from neutron.common import exceptions
from neutron.openstack.common import log as logging
from neutron.services import advanced_service from neutron.services import advanced_service
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -17,6 +17,7 @@ import socket
import httplib2 import httplib2
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
import webob import webob
@ -25,7 +26,6 @@ from neutron.common import config
from neutron.common import exceptions from neutron.common import exceptions
from neutron.common import utils from neutron.common import utils
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
from neutron import wsgi from neutron import wsgi
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,6 +15,7 @@
import sys import sys
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from neutron.agent.common import config as agent_conf from neutron.agent.common import config as agent_conf
from neutron.agent.metadata import agent from neutron.agent.metadata import agent
@ -22,7 +23,6 @@ from neutron.agent.metadata import config as metadata_conf
from neutron.common import config from neutron.common import config
from neutron.common import utils from neutron.common import utils
from neutron.openstack.common.cache import cache from neutron.openstack.common.cache import cache
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -16,13 +16,13 @@ import collections
import itertools import itertools
import uuid import uuid
from oslo_log import log as logging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import excutils from oslo_utils import excutils
from neutron.agent.linux import utils from neutron.agent.linux import utils
from neutron.agent.ovsdb import api as ovsdb from neutron.agent.ovsdb import api as ovsdb
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,6 +14,8 @@
# under the License. # under the License.
import itertools import itertools
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from oslo_utils import timeutils from oslo_utils import timeutils
@ -21,7 +23,6 @@ from neutron.common import constants
from neutron.common import rpc as n_rpc from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron.i18n import _LW from neutron.i18n import _LW
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -17,6 +17,7 @@
import functools import functools
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from oslo_utils import importutils from oslo_utils import importutils
@ -25,7 +26,6 @@ from neutron.common import constants
from neutron.common import rpc as n_rpc from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron.i18n import _LI, _LW from neutron.i18n import _LI, _LW
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
# history # history

View File

@ -16,12 +16,12 @@
import urllib import urllib
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from webob import exc from webob import exc
from neutron.common import constants from neutron.common import constants
from neutron.common import exceptions from neutron.common import exceptions
from neutron.i18n import _LW from neutron.i18n import _LW
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -21,6 +21,7 @@ import itertools
import os import os
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
import routes import routes
import six import six
import webob.dec import webob.dec
@ -31,7 +32,6 @@ from neutron.common import repos
import neutron.extensions import neutron.extensions
from neutron.i18n import _LE, _LI, _LW from neutron.i18n import _LE, _LI, _LW
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from neutron import wsgi from neutron import wsgi

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from neutron.common import constants from neutron.common import constants
@ -21,7 +22,6 @@ from neutron.common import topics
from neutron.common import utils from neutron.common import utils
from neutron.i18n import _LE, _LW from neutron.i18n import _LE, _LW
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,6 +15,7 @@
import random import random
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from neutron.common import constants from neutron.common import constants
@ -23,7 +24,6 @@ from neutron.common import topics
from neutron.common import utils from neutron.common import utils
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from neutron.plugins.common import constants as service_constants from neutron.plugins.common import constants as service_constants

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from neutron.common import constants from neutron.common import constants
@ -19,7 +20,6 @@ from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron.common import utils from neutron.common import utils
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from neutron.plugins.common import constants as service_constants from neutron.plugins.common import constants as service_constants
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -18,6 +18,7 @@ import operator
from oslo_config import cfg from oslo_config import cfg
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from oslo_utils import excutils from oslo_utils import excutils
@ -28,7 +29,6 @@ from neutron.common import utils
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.i18n import _LW from neutron.i18n import _LW
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from neutron.common import constants from neutron.common import constants
@ -20,7 +21,6 @@ from neutron.common import log
from neutron.common import rpc as n_rpc from neutron.common import rpc as n_rpc
from neutron.common import topics from neutron.common import topics
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,6 +14,7 @@
# limitations under the License. # limitations under the License.
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
@ -25,7 +26,6 @@ from neutron.extensions import l3
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from neutron.plugins.common import constants as plugin_constants from neutron.plugins.common import constants as plugin_constants

View File

@ -13,12 +13,13 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import netaddr
import re import re
import netaddr
from oslo_log import log as logging
from neutron.common import constants from neutron.common import constants
from neutron.common import exceptions as n_exc from neutron.common import exceptions as n_exc
from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils

View File

@ -14,11 +14,12 @@
# under the License. # under the License.
import copy import copy
import netaddr
import webob.exc
import netaddr
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
import webob.exc
from neutron.api import api_common from neutron.api import api_common
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
@ -28,7 +29,6 @@ from neutron.common import constants as const
from neutron.common import exceptions from neutron.common import exceptions
from neutron.common import rpc as n_rpc from neutron.common import rpc as n_rpc
from neutron.i18n import _LE, _LI from neutron.i18n import _LE, _LI
from neutron.openstack.common import log as logging
from neutron.openstack.common import policy as common_policy from neutron.openstack.common import policy as common_policy
from neutron import policy from neutron import policy
from neutron import quota from neutron import quota

View File

@ -21,13 +21,13 @@ import sys
import netaddr import netaddr
import oslo_i18n import oslo_i18n
from oslo_log import log as logging
import six import six
import webob.dec import webob.dec
import webob.exc import webob.exc
from neutron.common import exceptions from neutron.common import exceptions
from neutron.i18n import _LE, _LI from neutron.i18n import _LE, _LI
from neutron.openstack.common import log as logging
from neutron.openstack.common import policy as common_policy from neutron.openstack.common import policy as common_policy
from neutron import wsgi from neutron import wsgi

View File

@ -14,6 +14,7 @@
# limitations under the License. # limitations under the License.
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
import routes as routes_mapper import routes as routes_mapper
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
import webob import webob
@ -24,7 +25,6 @@ from neutron.api import extensions
from neutron.api.v2 import attributes from neutron.api.v2 import attributes
from neutron.api.v2 import base from neutron.api.v2 import base
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from neutron import policy from neutron import policy
from neutron import wsgi from neutron import wsgi

View File

@ -14,10 +14,10 @@
# under the License. # under the License.
import oslo_i18n import oslo_i18n
from oslo_log import log as logging
import webob.dec import webob.dec
from neutron.api.views import versions as versions_view from neutron.api.views import versions as versions_view
from neutron.openstack.common import log as logging
from neutron import wsgi from neutron import wsgi

View File

@ -13,12 +13,12 @@
# under the License. # under the License.
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from oslo_middleware import request_id from oslo_middleware import request_id
import webob.dec import webob.dec
import webob.exc import webob.exc
from neutron import context from neutron import context
from neutron.openstack.common import log as logging
from neutron import wsgi from neutron import wsgi
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,13 +13,13 @@
import collections import collections
import weakref import weakref
from oslo_log import log as logging
from oslo_utils import reflection from oslo_utils import reflection
from neutron.callbacks import events from neutron.callbacks import events
from neutron.callbacks import exceptions from neutron.callbacks import exceptions
from neutron.callbacks import resources from neutron.callbacks import resources
from neutron.i18n import _LE, _LI from neutron.i18n import _LE, _LI
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -17,6 +17,7 @@ import re
import time import time
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils from oslo_utils import importutils
from neutron.agent.common import config as agent_config from neutron.agent.common import config as agent_config
@ -29,7 +30,6 @@ from neutron.agent.linux import ovs_lib
from neutron.api.v2 import attributes from neutron.api.v2 import attributes
from neutron.common import config from neutron.common import config
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,6 +14,7 @@
# under the License. # under the License.
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from neutron.agent.common import config as agent_config from neutron.agent.common import config as agent_config
from neutron.agent.l3 import config as l3_config from neutron.agent.l3 import config as l3_config
@ -22,7 +23,6 @@ from neutron.agent.linux import ip_lib
from neutron.agent.linux import ovs_lib from neutron.agent.linux import ovs_lib
from neutron.common import config from neutron.common import config
from neutron.i18n import _LI from neutron.i18n import _LI
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -16,6 +16,7 @@
import re import re
import netaddr import netaddr
from oslo_log import log as logging
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.agent.linux import ip_link_support from neutron.agent.linux import ip_link_support
@ -23,7 +24,6 @@ from neutron.agent.linux import ovs_lib
from neutron.agent.linux import utils as agent_utils from neutron.agent.linux import utils as agent_utils
from neutron.common import utils from neutron.common import utils
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants as const from neutron.plugins.common import constants as const
from neutron.plugins.openvswitch.common import constants as ovs_const from neutron.plugins.openvswitch.common import constants as ovs_const

View File

@ -15,12 +15,13 @@
import sys import sys
from oslo_config import cfg
from oslo_log import log as logging
from neutron.agent import dhcp_agent from neutron.agent import dhcp_agent
from neutron.cmd.sanity import checks from neutron.cmd.sanity import checks
from neutron.common import config from neutron.common import config
from neutron.i18n import _LE, _LW from neutron.i18n import _LE, _LW
from neutron.openstack.common import log as logging
from oslo_config import cfg
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -24,13 +24,13 @@ from keystoneclient import auth
from keystoneclient import session as ks_session from keystoneclient import session as ks_session
from oslo_config import cfg from oslo_config import cfg
from oslo_db import options as db_options from oslo_db import options as db_options
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from paste import deploy from paste import deploy
from neutron.api.v2 import attributes from neutron.api.v2 import attributes
from neutron.common import utils from neutron.common import utils
from neutron.i18n import _LI from neutron.i18n import _LI
from neutron.openstack.common import log as logging
from neutron import version from neutron import version
@ -163,6 +163,8 @@ nova_opts = [
] ]
cfg.CONF.register_opts(nova_opts, group=NOVA_CONF_SECTION) cfg.CONF.register_opts(nova_opts, group=NOVA_CONF_SECTION)
logging.register_options(cfg.CONF)
def init(args, **kwargs): def init(args, **kwargs):
cfg.CONF(args=args, project='neutron', cfg.CONF(args=args, project='neutron',
@ -185,7 +187,7 @@ def init(args, **kwargs):
def setup_logging(): def setup_logging():
"""Sets up the logging options for a log with supplied name.""" """Sets up the logging options for a log with supplied name."""
product_name = "neutron" product_name = "neutron"
logging.setup(product_name) logging.setup(cfg.CONF, product_name)
LOG.info(_LI("Logging enabled!")) LOG.info(_LI("Logging enabled!"))
LOG.info(_LI("%(prog)s version %(version)s"), LOG.info(_LI("%(prog)s version %(version)s"),
{'prog': sys.argv[0], {'prog': sys.argv[0],

View File

@ -19,10 +19,10 @@ IPv6-related utilities and helper functions.
import os import os
import netaddr import netaddr
from oslo_log import log
from neutron.common import constants from neutron.common import constants
from neutron.i18n import _LI from neutron.i18n import _LI
from neutron.openstack.common import log
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)

View File

@ -15,7 +15,7 @@
"""Log helper functions.""" """Log helper functions."""
import functools import functools
from neutron.openstack.common import log as logging from oslo_log import log as logging
def log(method): def log(method):

View File

@ -18,8 +18,7 @@ import importlib
import os import os
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,12 +15,12 @@
# under the License. # under the License.
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from oslo_messaging import serializer as om_serializer from oslo_messaging import serializer as om_serializer
from neutron.common import exceptions from neutron.common import exceptions
from neutron import context from neutron import context
from neutron.openstack.common import log as logging
from neutron.openstack.common import service from neutron.openstack.common import service

View File

@ -33,10 +33,10 @@ import uuid
from eventlet.green import subprocess from eventlet.green import subprocess
from oslo_concurrency import lockutils from oslo_concurrency import lockutils
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
from neutron.common import constants as q_const from neutron.common import constants as q_const
from neutron.openstack.common import log as logging
TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"

View File

@ -19,10 +19,9 @@ import copy
import datetime import datetime
from oslo_context import context as oslo_context from oslo_context import context as oslo_context
from oslo_log import log as logging
from neutron.db import api as db_api from neutron.db import api as db_api
from neutron.openstack.common import local
from neutron.openstack.common import log as logging
from neutron import policy from neutron import policy
@ -55,7 +54,8 @@ class ContextBase(oslo_context.RequestContext):
super(ContextBase, self).__init__(auth_token=auth_token, super(ContextBase, self).__init__(auth_token=auth_token,
user=user_id, tenant=tenant_id, user=user_id, tenant=tenant_id,
is_admin=is_admin, is_admin=is_admin,
request_id=request_id) request_id=request_id,
overwrite=overwrite)
self.user_name = user_name self.user_name = user_name
self.tenant_name = tenant_name self.tenant_name = tenant_name
@ -73,10 +73,6 @@ class ContextBase(oslo_context.RequestContext):
admin_roles = policy.get_admin_roles() admin_roles = policy.get_admin_roles()
if admin_roles: if admin_roles:
self.roles = list(set(self.roles) | set(admin_roles)) self.roles = list(set(self.roles) | set(admin_roles))
# Allow openstack.common.log to access the context
if overwrite or not hasattr(local.store, 'context'):
local.store.context = self
# Log only once the context has been configured to prevent # Log only once the context has been configured to prevent
# format errors. # format errors.
if kwargs: if kwargs:

View File

@ -14,9 +14,9 @@
# under the License. # under the License.
from eventlet import greenthread from eventlet import greenthread
from oslo_config import cfg from oslo_config import cfg
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import timeutils from oslo_utils import timeutils
@ -31,7 +31,6 @@ from neutron.db import models_v2
from neutron.extensions import agent as ext_agent from neutron.extensions import agent as ext_agent
from neutron.i18n import _LW from neutron.i18n import _LW
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
cfg.CONF.register_opt( cfg.CONF.register_opt(

View File

@ -18,6 +18,7 @@ import random
import time import time
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import timeutils from oslo_utils import timeutils
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import orm from sqlalchemy import orm
@ -32,7 +33,6 @@ from neutron.db import model_base
from neutron.extensions import agent as ext_agent from neutron.extensions import agent as ext_agent
from neutron.extensions import dhcpagentscheduler from neutron.extensions import dhcpagentscheduler
from neutron.i18n import _LE, _LI, _LW from neutron.i18n import _LE, _LI, _LW
from neutron.openstack.common import log as logging
from neutron.openstack.common import loopingcall from neutron.openstack.common import loopingcall

View File

@ -16,6 +16,7 @@
import netaddr import netaddr
from oslo_config import cfg from oslo_config import cfg
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
from sqlalchemy import and_ from sqlalchemy import and_
from sqlalchemy import event from sqlalchemy import event
@ -35,7 +36,6 @@ from neutron.extensions import l3
from neutron.i18n import _LE, _LI from neutron.i18n import _LE, _LI
from neutron import manager from neutron import manager
from neutron import neutron_plugin_base_v2 from neutron import neutron_plugin_base_v2
from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants as service_constants from neutron.plugins.common import constants as service_constants

View File

@ -13,9 +13,11 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_config import cfg
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_log import log as logging
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy.orm import exc
from neutron.common import exceptions as q_exc from neutron.common import exceptions as q_exc
from neutron.common import log from neutron.common import log
@ -25,12 +27,11 @@ from neutron.extensions import dvr as ext_dvr
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from oslo_config import cfg
from sqlalchemy.orm import exc
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
dvr_mac_address_opts = [ dvr_mac_address_opts = [
cfg.StrOpt('dvr_base_mac', cfg.StrOpt('dvr_base_mac',
default="fa:16:3f:00:00:00", default="fa:16:3f:00:00:00",

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import orm from sqlalchemy import orm
@ -21,7 +22,7 @@ from neutron.db import db_base_plugin_v2
from neutron.db import model_base from neutron.db import model_base
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.extensions import extra_dhcp_opt as edo_ext from neutron.extensions import extra_dhcp_opt as edo_ext
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,6 +15,7 @@
import netaddr import netaddr
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import orm from sqlalchemy import orm
@ -25,7 +26,6 @@ from neutron.db import model_base
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.extensions import extraroute from neutron.extensions import extraroute
from neutron.extensions import l3 from neutron.extensions import l3
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -12,8 +12,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_config import cfg from oslo_config import cfg
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import func from sqlalchemy import func
@ -32,7 +34,6 @@ from neutron.db import model_base
from neutron.extensions import l3agentscheduler from neutron.extensions import l3agentscheduler
from neutron.i18n import _LE, _LI, _LW from neutron.i18n import _LE, _LI, _LW
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,6 +13,7 @@
# under the License. # under the License.
import netaddr import netaddr
from oslo_log import log as logging
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import orm from sqlalchemy import orm
from sqlalchemy.orm import exc from sqlalchemy.orm import exc
@ -35,7 +36,6 @@ from neutron.extensions import external_net
from neutron.extensions import l3 from neutron.extensions import l3
from neutron.i18n import _LI from neutron.i18n import _LI
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants from neutron.plugins.common import constants

View File

@ -13,6 +13,7 @@
# under the License. # under the License.
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from neutron.api.v2 import attributes from neutron.api.v2 import attributes
from neutron.common import constants as l3_const from neutron.common import constants as l3_const
@ -26,7 +27,6 @@ from neutron.extensions import l3
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.i18n import _LI from neutron.i18n import _LI
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from neutron.plugins.common import constants from neutron.plugins.common import constants

View File

@ -16,6 +16,7 @@
import random import random
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_log import log as logging
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import orm from sqlalchemy import orm
from sqlalchemy.orm import exc from sqlalchemy.orm import exc
@ -28,7 +29,6 @@ from neutron.db import l3_agentschedulers_db as l3agent_sch_db
from neutron.db import model_base from neutron.db import model_base
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.i18n import _LI, _LW from neutron.i18n import _LI, _LW
from neutron.openstack.common import log as logging
from neutron.plugins.ml2 import db as ml2_db from neutron.plugins.ml2 import db as ml2_db
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,13 +13,13 @@
# under the License. # under the License.
# #
from oslo_log import log as logging
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import sql from sqlalchemy import sql
from neutron.db import db_base_plugin_v2 from neutron.db import db_base_plugin_v2
from neutron.db import l3_db from neutron.db import l3_db
from neutron.extensions import l3 from neutron.extensions import l3
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -16,6 +16,7 @@
import netaddr import netaddr
from oslo_config import cfg from oslo_config import cfg
from oslo_db import exception as db_exc from oslo_db import exception as db_exc
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import orm from sqlalchemy import orm
@ -28,7 +29,6 @@ from neutron.db import model_base
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.extensions import l3_ext_ha_mode as l3_ha from neutron.extensions import l3_ext_ha_mode as l3_ha
from neutron.i18n import _LI, _LW from neutron.i18n import _LI, _LW
from neutron.openstack.common import log as logging
VR_ID_RANGE = set(range(1, 255)) VR_ID_RANGE = set(range(1, 255))
MAX_ALLOCATION_TRIES = 10 MAX_ALLOCATION_TRIES = 10

View File

@ -13,6 +13,7 @@
# under the License. # under the License.
import netaddr import netaddr
from oslo_log import log as logging
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import orm from sqlalchemy import orm
from sqlalchemy import sql from sqlalchemy import sql
@ -24,7 +25,6 @@ from neutron.db import l3_db
from neutron.db import model_base from neutron.db import model_base
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.extensions import metering from neutron.extensions import metering
from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils

View File

@ -12,13 +12,13 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from neutron.common import constants as consts from neutron.common import constants as consts
from neutron.common import utils from neutron.common import utils
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from neutron.plugins.common import constants as service_constants from neutron.plugins.common import constants as service_constants
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import orm from sqlalchemy import orm
from sqlalchemy.orm import exc from sqlalchemy.orm import exc
@ -21,7 +22,6 @@ from neutron.db import db_base_plugin_v2
from neutron.db import model_base from neutron.db import model_base
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.extensions import portsecurity as psec from neutron.extensions import portsecurity as psec
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,6 +14,7 @@
import netaddr import netaddr
from oslo_db import exception from oslo_db import exception
from oslo_log import log as logging
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import orm from sqlalchemy import orm
from sqlalchemy.orm import exc from sqlalchemy.orm import exc
@ -25,7 +26,6 @@ from neutron.db import db_base_plugin_v2
from neutron.db import model_base from neutron.db import model_base
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.extensions import securitygroup as ext_sg from neutron.extensions import securitygroup as ext_sg
from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -14,6 +14,7 @@
# under the License. # under the License.
import netaddr import netaddr
from oslo_log import log as logging
from sqlalchemy.orm import exc from sqlalchemy.orm import exc
from neutron.common import constants as q_const from neutron.common import constants as q_const
@ -24,7 +25,6 @@ from neutron.db import models_v2
from neutron.db import securitygroups_db as sg_db from neutron.db import securitygroups_db as sg_db
from neutron.extensions import securitygroup as ext_sg from neutron.extensions import securitygroup as ext_sg
from neutron.i18n import _LW from neutron.i18n import _LW
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
import sqlalchemy as sa import sqlalchemy as sa
from neutron.db import model_base from neutron.db import model_base
from neutron.openstack.common import log as logging
from neutron.services import provider_configuration as pconf from neutron.services import provider_configuration as pconf
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,12 +13,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from six import moves from six import moves
import sqlalchemy import sqlalchemy
from sqlalchemy.orm import properties from sqlalchemy.orm import properties
from neutron.common import exceptions as n_exc from neutron.common import exceptions as n_exc
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -17,9 +17,9 @@ from cliff import lister
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.neutron import v2_0 as client from neutronclient.neutron import v2_0 as client
from neutronclient.neutron.v2_0 import port from neutronclient.neutron.v2_0 import port
from oslo_log import log as logging
from neutron.i18n import _LI from neutron.i18n import _LI
from neutron.openstack.common import log as logging
class ProbeCommand(client.NeutronCommand): class ProbeCommand(client.NeutronCommand):

View File

@ -18,12 +18,12 @@ import socket
import netaddr import netaddr
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from neutron.agent.linux import dhcp from neutron.agent.linux import dhcp
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.agent.linux import utils from neutron.agent.linux import utils
from neutron.i18n import _LW from neutron.i18n import _LW
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from neutron.api import extensions from neutron.api import extensions
from neutron.api.v2 import attributes from neutron.api.v2 import attributes
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -15,6 +15,7 @@
import abc import abc
from oslo_log import log as logging
import webob.exc import webob.exc
from neutron.api import extensions from neutron.api import extensions
@ -26,7 +27,6 @@ from neutron.common import rpc as n_rpc
from neutron.extensions import agent from neutron.extensions import agent
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from neutron.plugins.common import constants as service_constants from neutron.plugins.common import constants as service_constants
from neutron import policy from neutron import policy
from neutron import wsgi from neutron import wsgi

View File

@ -14,13 +14,13 @@
import abc import abc
from oslo_log import log as logging
import six import six
from neutron.api import extensions from neutron.api import extensions
from neutron.api.v2 import attributes as attr from neutron.api.v2 import attributes as attr
from neutron.api.v2 import resource_helper from neutron.api.v2 import resource_helper
from neutron.common import exceptions as nexception from neutron.common import exceptions as nexception
from neutron.openstack.common import log as logging
from neutron.plugins.common import constants from neutron.plugins.common import constants
from neutron.services import service_base from neutron.services import service_base

View File

@ -13,11 +13,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from neutron.api import extensions from neutron.api import extensions
from neutron.api.v2 import attributes from neutron.api.v2 import attributes
from neutron.api.v2 import base from neutron.api.v2 import base
from neutron.db import servicetype_db from neutron.db import servicetype_db
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -29,8 +29,6 @@ import pep8
# neutron/tests/unit/hacking/test_checks.py # neutron/tests/unit/hacking/test_checks.py
_all_log_levels = { _all_log_levels = {
# NOTE(yamamoto): Following nova which uses _() for audit.
'audit': '_',
'error': '_LE', 'error': '_LE',
'info': '_LI', 'info': '_LI',
'warn': '_LW', 'warn': '_LW',

View File

@ -16,12 +16,12 @@
import weakref import weakref
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from oslo_utils import importutils from oslo_utils import importutils
from neutron.common import utils from neutron.common import utils
from neutron.i18n import _LE, _LI from neutron.i18n import _LE, _LI
from neutron.openstack.common import log as logging
from neutron.openstack.common import periodic_task from neutron.openstack.common import periodic_task
from neutron.plugins.common import constants from neutron.plugins.common import constants

View File

@ -20,6 +20,7 @@ from keystoneclient import session as ks_session
from novaclient import client as nova_client from novaclient import client as nova_client
from novaclient import exceptions as nova_exceptions from novaclient import exceptions as nova_exceptions
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils from oslo_utils import importutils
from sqlalchemy.orm import attributes as sql_attr from sqlalchemy.orm import attributes as sql_attr
@ -27,7 +28,6 @@ from neutron.common import constants
from neutron import context from neutron import context
from neutron.i18n import _LE, _LI, _LW from neutron.i18n import _LE, _LI, _LW
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils

View File

@ -1,45 +0,0 @@
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# 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.
"""Local storage of variables using weak references"""
import threading
import weakref
class WeakLocal(threading.local):
def __getattribute__(self, attr):
rval = super(WeakLocal, self).__getattribute__(attr)
if rval:
# NOTE(mikal): this bit is confusing. What is stored is a weak
# reference, not the value itself. We therefore need to lookup
# the weak reference and return the inner value here.
rval = rval()
return rval
def __setattr__(self, attr, value):
value = weakref.ref(value)
return super(WeakLocal, self).__setattr__(attr, value)
# NOTE(mikal): the name "store" should be deprecated in the future
store = WeakLocal()
# A "weak" store uses weak references and allows an object to fall out of scope
# when it falls out of scope in the code that uses the thread local storage. A
# "strong" store will hold a reference to the object so that it never falls out
# of scope.
weak_store = WeakLocal()
strong_store = threading.local()

View File

@ -1,718 +0,0 @@
# Copyright 2011 OpenStack Foundation.
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# 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.
"""OpenStack logging handler.
This module adds to logging functionality by adding the option to specify
a context object when calling the various log methods. If the context object
is not specified, default formatting is used. Additionally, an instance uuid
may be passed as part of the log message, which is intended to make it easier
for admins to find messages related to a specific instance.
It also allows setting of formatting information through conf.
"""
import copy
import inspect
import itertools
import logging
import logging.config
import logging.handlers
import os
import socket
import sys
import traceback
from oslo.config import cfg
from oslo.serialization import jsonutils
from oslo.utils import importutils
import six
from six import moves
_PY26 = sys.version_info[0:2] == (2, 6)
from neutron.openstack.common._i18n import _
from neutron.openstack.common import local
_DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
common_cli_opts = [
cfg.BoolOpt('debug',
short='d',
default=False,
help='Print debugging output (set logging level to '
'DEBUG instead of default WARNING level).'),
cfg.BoolOpt('verbose',
short='v',
default=False,
help='Print more verbose output (set logging level to '
'INFO instead of default WARNING level).'),
]
logging_cli_opts = [
cfg.StrOpt('log-config-append',
metavar='PATH',
deprecated_name='log-config',
help='The name of a logging configuration file. This file '
'is appended to any existing logging configuration '
'files. For details about logging configuration files, '
'see the Python logging module documentation.'),
cfg.StrOpt('log-format',
metavar='FORMAT',
help='DEPRECATED. '
'A logging.Formatter log message format string which may '
'use any of the available logging.LogRecord attributes. '
'This option is deprecated. Please use '
'logging_context_format_string and '
'logging_default_format_string instead.'),
cfg.StrOpt('log-date-format',
default=_DEFAULT_LOG_DATE_FORMAT,
metavar='DATE_FORMAT',
help='Format string for %%(asctime)s in log records. '
'Default: %(default)s .'),
cfg.StrOpt('log-file',
metavar='PATH',
deprecated_name='logfile',
help='(Optional) Name of log file to output to. '
'If no default is set, logging will go to stdout.'),
cfg.StrOpt('log-dir',
deprecated_name='logdir',
help='(Optional) The base directory used for relative '
'--log-file paths.'),
cfg.BoolOpt('use-syslog',
default=False,
help='Use syslog for logging. '
'Existing syslog format is DEPRECATED during I, '
'and will change in J to honor RFC5424.'),
cfg.BoolOpt('use-syslog-rfc-format',
# TODO(bogdando) remove or use True after existing
# syslog format deprecation in J
default=False,
help='(Optional) Enables or disables syslog rfc5424 format '
'for logging. If enabled, prefixes the MSG part of the '
'syslog message with APP-NAME (RFC5424). The '
'format without the APP-NAME is deprecated in I, '
'and will be removed in J.'),
cfg.StrOpt('syslog-log-facility',
default='LOG_USER',
help='Syslog facility to receive log lines.')
]
generic_log_opts = [
cfg.BoolOpt('use_stderr',
default=True,
help='Log output to standard error.')
]
DEFAULT_LOG_LEVELS = ['amqp=WARN', 'amqplib=WARN', 'boto=WARN',
'qpid=WARN', 'sqlalchemy=WARN', 'suds=INFO',
'oslo.messaging=INFO', 'iso8601=WARN',
'requests.packages.urllib3.connectionpool=WARN',
'urllib3.connectionpool=WARN', 'websocket=WARN',
"keystonemiddleware=WARN", "routes.middleware=WARN",
"stevedore=WARN"]
log_opts = [
cfg.StrOpt('logging_context_format_string',
default='%(asctime)s.%(msecs)03d %(process)d %(levelname)s '
'%(name)s [%(request_id)s %(user_identity)s] '
'%(instance)s%(message)s',
help='Format string to use for log messages with context.'),
cfg.StrOpt('logging_default_format_string',
default='%(asctime)s.%(msecs)03d %(process)d %(levelname)s '
'%(name)s [-] %(instance)s%(message)s',
help='Format string to use for log messages without context.'),
cfg.StrOpt('logging_debug_format_suffix',
default='%(funcName)s %(pathname)s:%(lineno)d',
help='Data to append to log format when level is DEBUG.'),
cfg.StrOpt('logging_exception_prefix',
default='%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s '
'%(instance)s',
help='Prefix each line of exception output with this format.'),
cfg.ListOpt('default_log_levels',
default=DEFAULT_LOG_LEVELS,
help='List of logger=LEVEL pairs.'),
cfg.BoolOpt('publish_errors',
default=False,
help='Enables or disables publication of error events.'),
cfg.BoolOpt('fatal_deprecations',
default=False,
help='Enables or disables fatal status of deprecations.'),
# NOTE(mikal): there are two options here because sometimes we are handed
# a full instance (and could include more information), and other times we
# are just handed a UUID for the instance.
cfg.StrOpt('instance_format',
default='[instance: %(uuid)s] ',
help='The format for an instance that is passed with the log '
'message.'),
cfg.StrOpt('instance_uuid_format',
default='[instance: %(uuid)s] ',
help='The format for an instance UUID that is passed with the '
'log message.'),
]
CONF = cfg.CONF
CONF.register_cli_opts(common_cli_opts)
CONF.register_cli_opts(logging_cli_opts)
CONF.register_opts(generic_log_opts)
CONF.register_opts(log_opts)
def list_opts():
"""Entry point for oslo.config-generator."""
return [(None, copy.deepcopy(common_cli_opts)),
(None, copy.deepcopy(logging_cli_opts)),
(None, copy.deepcopy(generic_log_opts)),
(None, copy.deepcopy(log_opts)),
]
# our new audit level
# NOTE(jkoelker) Since we synthesized an audit level, make the logging
# module aware of it so it acts like other levels.
logging.AUDIT = logging.INFO + 1
logging.addLevelName(logging.AUDIT, 'AUDIT')
try:
NullHandler = logging.NullHandler
except AttributeError: # NOTE(jkoelker) NullHandler added in Python 2.7
class NullHandler(logging.Handler):
def handle(self, record):
pass
def emit(self, record):
pass
def createLock(self):
self.lock = None
def _dictify_context(context):
if context is None:
return None
if not isinstance(context, dict) and getattr(context, 'to_dict', None):
context = context.to_dict()
return context
def _get_binary_name():
return os.path.basename(inspect.stack()[-1][1])
def _get_log_file_path(binary=None):
logfile = CONF.log_file
logdir = CONF.log_dir
if logfile and not logdir:
return logfile
if logfile and logdir:
return os.path.join(logdir, logfile)
if logdir:
binary = binary or _get_binary_name()
return '%s.log' % (os.path.join(logdir, binary),)
return None
class BaseLoggerAdapter(logging.LoggerAdapter):
def audit(self, msg, *args, **kwargs):
self.log(logging.AUDIT, msg, *args, **kwargs)
def isEnabledFor(self, level):
if _PY26:
# This method was added in python 2.7 (and it does the exact
# same logic, so we need to do the exact same logic so that
# python 2.6 has this capability as well).
return self.logger.isEnabledFor(level)
else:
return super(BaseLoggerAdapter, self).isEnabledFor(level)
class LazyAdapter(BaseLoggerAdapter):
def __init__(self, name='unknown', version='unknown'):
self._logger = None
self.extra = {}
self.name = name
self.version = version
@property
def logger(self):
if not self._logger:
self._logger = getLogger(self.name, self.version)
if six.PY3:
# In Python 3, the code fails because the 'manager' attribute
# cannot be found when using a LoggerAdapter as the
# underlying logger. Work around this issue.
self._logger.manager = self._logger.logger.manager
return self._logger
class ContextAdapter(BaseLoggerAdapter):
warn = logging.LoggerAdapter.warning
def __init__(self, logger, project_name, version_string):
self.logger = logger
self.project = project_name
self.version = version_string
self._deprecated_messages_sent = dict()
@property
def handlers(self):
return self.logger.handlers
def deprecated(self, msg, *args, **kwargs):
"""Call this method when a deprecated feature is used.
If the system is configured for fatal deprecations then the message
is logged at the 'critical' level and :class:`DeprecatedConfig` will
be raised.
Otherwise, the message will be logged (once) at the 'warn' level.
:raises: :class:`DeprecatedConfig` if the system is configured for
fatal deprecations.
"""
stdmsg = _("Deprecated: %s") % msg
if CONF.fatal_deprecations:
self.critical(stdmsg, *args, **kwargs)
raise DeprecatedConfig(msg=stdmsg)
# Using a list because a tuple with dict can't be stored in a set.
sent_args = self._deprecated_messages_sent.setdefault(msg, list())
if args in sent_args:
# Already logged this message, so don't log it again.
return
sent_args.append(args)
self.warn(stdmsg, *args, **kwargs)
def process(self, msg, kwargs):
# NOTE(jecarey): If msg is not unicode, coerce it into unicode
# before it can get to the python logging and
# possibly cause string encoding trouble
if not isinstance(msg, six.text_type):
msg = six.text_type(msg)
if 'extra' not in kwargs:
kwargs['extra'] = {}
extra = kwargs['extra']
context = kwargs.pop('context', None)
if not context:
context = getattr(local.store, 'context', None)
if context:
extra.update(_dictify_context(context))
instance = kwargs.pop('instance', None)
instance_uuid = (extra.get('instance_uuid') or
kwargs.pop('instance_uuid', None))
instance_extra = ''
if instance:
instance_extra = CONF.instance_format % instance
elif instance_uuid:
instance_extra = (CONF.instance_uuid_format
% {'uuid': instance_uuid})
extra['instance'] = instance_extra
extra.setdefault('user_identity', kwargs.pop('user_identity', None))
extra['project'] = self.project
extra['version'] = self.version
extra['extra'] = extra.copy()
return msg, kwargs
class JSONFormatter(logging.Formatter):
def __init__(self, fmt=None, datefmt=None):
# NOTE(jkoelker) we ignore the fmt argument, but its still there
# since logging.config.fileConfig passes it.
self.datefmt = datefmt
def formatException(self, ei, strip_newlines=True):
lines = traceback.format_exception(*ei)
if strip_newlines:
lines = [moves.filter(
lambda x: x,
line.rstrip().splitlines()) for line in lines]
lines = list(itertools.chain(*lines))
return lines
def format(self, record):
message = {'message': record.getMessage(),
'asctime': self.formatTime(record, self.datefmt),
'name': record.name,
'msg': record.msg,
'args': record.args,
'levelname': record.levelname,
'levelno': record.levelno,
'pathname': record.pathname,
'filename': record.filename,
'module': record.module,
'lineno': record.lineno,
'funcname': record.funcName,
'created': record.created,
'msecs': record.msecs,
'relative_created': record.relativeCreated,
'thread': record.thread,
'thread_name': record.threadName,
'process_name': record.processName,
'process': record.process,
'traceback': None}
if hasattr(record, 'extra'):
message['extra'] = record.extra
if record.exc_info:
message['traceback'] = self.formatException(record.exc_info)
return jsonutils.dumps(message)
def _create_logging_excepthook(product_name):
def logging_excepthook(exc_type, value, tb):
extra = {'exc_info': (exc_type, value, tb)}
getLogger(product_name).critical(
"".join(traceback.format_exception_only(exc_type, value)),
**extra)
return logging_excepthook
class LogConfigError(Exception):
message = _('Error loading logging config %(log_config)s: %(err_msg)s')
def __init__(self, log_config, err_msg):
self.log_config = log_config
self.err_msg = err_msg
def __str__(self):
return self.message % dict(log_config=self.log_config,
err_msg=self.err_msg)
def _load_log_config(log_config_append):
try:
logging.config.fileConfig(log_config_append,
disable_existing_loggers=False)
except (moves.configparser.Error, KeyError) as exc:
raise LogConfigError(log_config_append, six.text_type(exc))
def setup(product_name, version='unknown'):
"""Setup logging."""
if CONF.log_config_append:
_load_log_config(CONF.log_config_append)
else:
_setup_logging_from_conf(product_name, version)
sys.excepthook = _create_logging_excepthook(product_name)
def set_defaults(logging_context_format_string=None,
default_log_levels=None):
# Just in case the caller is not setting the
# default_log_level. This is insurance because
# we introduced the default_log_level parameter
# later in a backwards in-compatible change
if default_log_levels is not None:
cfg.set_defaults(
log_opts,
default_log_levels=default_log_levels)
if logging_context_format_string is not None:
cfg.set_defaults(
log_opts,
logging_context_format_string=logging_context_format_string)
def _find_facility_from_conf():
facility_names = logging.handlers.SysLogHandler.facility_names
facility = getattr(logging.handlers.SysLogHandler,
CONF.syslog_log_facility,
None)
if facility is None and CONF.syslog_log_facility in facility_names:
facility = facility_names.get(CONF.syslog_log_facility)
if facility is None:
valid_facilities = facility_names.keys()
consts = ['LOG_AUTH', 'LOG_AUTHPRIV', 'LOG_CRON', 'LOG_DAEMON',
'LOG_FTP', 'LOG_KERN', 'LOG_LPR', 'LOG_MAIL', 'LOG_NEWS',
'LOG_AUTH', 'LOG_SYSLOG', 'LOG_USER', 'LOG_UUCP',
'LOG_LOCAL0', 'LOG_LOCAL1', 'LOG_LOCAL2', 'LOG_LOCAL3',
'LOG_LOCAL4', 'LOG_LOCAL5', 'LOG_LOCAL6', 'LOG_LOCAL7']
valid_facilities.extend(consts)
raise TypeError(_('syslog facility must be one of: %s') %
', '.join("'%s'" % fac
for fac in valid_facilities))
return facility
class RFCSysLogHandler(logging.handlers.SysLogHandler):
def __init__(self, *args, **kwargs):
self.binary_name = _get_binary_name()
# Do not use super() unless type(logging.handlers.SysLogHandler)
# is 'type' (Python 2.7).
# Use old style calls, if the type is 'classobj' (Python 2.6)
logging.handlers.SysLogHandler.__init__(self, *args, **kwargs)
def format(self, record):
# Do not use super() unless type(logging.handlers.SysLogHandler)
# is 'type' (Python 2.7).
# Use old style calls, if the type is 'classobj' (Python 2.6)
msg = logging.handlers.SysLogHandler.format(self, record)
msg = self.binary_name + ' ' + msg
return msg
def _setup_logging_from_conf(project, version):
log_root = getLogger(None).logger
for handler in log_root.handlers:
log_root.removeHandler(handler)
logpath = _get_log_file_path()
if logpath:
filelog = logging.handlers.WatchedFileHandler(logpath)
log_root.addHandler(filelog)
if CONF.use_stderr:
streamlog = ColorHandler()
log_root.addHandler(streamlog)
elif not logpath:
# pass sys.stdout as a positional argument
# python2.6 calls the argument strm, in 2.7 it's stream
streamlog = logging.StreamHandler(sys.stdout)
log_root.addHandler(streamlog)
if CONF.publish_errors:
handler = importutils.import_object(
"oslo.messaging.notify.log_handler.PublishErrorsHandler",
logging.ERROR)
log_root.addHandler(handler)
datefmt = CONF.log_date_format
for handler in log_root.handlers:
# NOTE(alaski): CONF.log_format overrides everything currently. This
# should be deprecated in favor of context aware formatting.
if CONF.log_format:
handler.setFormatter(logging.Formatter(fmt=CONF.log_format,
datefmt=datefmt))
log_root.info('Deprecated: log_format is now deprecated and will '
'be removed in the next release')
else:
handler.setFormatter(ContextFormatter(project=project,
version=version,
datefmt=datefmt))
if CONF.debug:
log_root.setLevel(logging.DEBUG)
elif CONF.verbose:
log_root.setLevel(logging.INFO)
else:
log_root.setLevel(logging.WARNING)
for pair in CONF.default_log_levels:
mod, _sep, level_name = pair.partition('=')
logger = logging.getLogger(mod)
# NOTE(AAzza) in python2.6 Logger.setLevel doesn't convert string name
# to integer code.
if sys.version_info < (2, 7):
level = logging.getLevelName(level_name)
logger.setLevel(level)
else:
logger.setLevel(level_name)
if CONF.use_syslog:
try:
facility = _find_facility_from_conf()
# TODO(bogdando) use the format provided by RFCSysLogHandler
# after existing syslog format deprecation in J
if CONF.use_syslog_rfc_format:
syslog = RFCSysLogHandler(address='/dev/log',
facility=facility)
else:
syslog = logging.handlers.SysLogHandler(address='/dev/log',
facility=facility)
log_root.addHandler(syslog)
except socket.error:
log_root.error('Unable to add syslog handler. Verify that syslog '
'is running.')
_loggers = {}
def getLogger(name='unknown', version='unknown'):
if name not in _loggers:
_loggers[name] = ContextAdapter(logging.getLogger(name),
name,
version)
return _loggers[name]
def getLazyLogger(name='unknown', version='unknown'):
"""Returns lazy logger.
Creates a pass-through logger that does not create the real logger
until it is really needed and delegates all calls to the real logger
once it is created.
"""
return LazyAdapter(name, version)
class WritableLogger(object):
"""A thin wrapper that responds to `write` and logs."""
def __init__(self, logger, level=logging.INFO):
self.logger = logger
self.level = level
def write(self, msg):
self.logger.log(self.level, msg.rstrip())
class ContextFormatter(logging.Formatter):
"""A context.RequestContext aware formatter configured through flags.
The flags used to set format strings are: logging_context_format_string
and logging_default_format_string. You can also specify
logging_debug_format_suffix to append extra formatting if the log level is
debug.
For information about what variables are available for the formatter see:
http://docs.python.org/library/logging.html#formatter
If available, uses the context value stored in TLS - local.store.context
"""
def __init__(self, *args, **kwargs):
"""Initialize ContextFormatter instance
Takes additional keyword arguments which can be used in the message
format string.
:keyword project: project name
:type project: string
:keyword version: project version
:type version: string
"""
self.project = kwargs.pop('project', 'unknown')
self.version = kwargs.pop('version', 'unknown')
logging.Formatter.__init__(self, *args, **kwargs)
def format(self, record):
"""Uses contextstring if request_id is set, otherwise default."""
# NOTE(jecarey): If msg is not unicode, coerce it into unicode
# before it can get to the python logging and
# possibly cause string encoding trouble
if not isinstance(record.msg, six.text_type):
record.msg = six.text_type(record.msg)
# store project info
record.project = self.project
record.version = self.version
# store request info
context = getattr(local.store, 'context', None)
if context:
d = _dictify_context(context)
for k, v in d.items():
setattr(record, k, v)
# NOTE(sdague): default the fancier formatting params
# to an empty string so we don't throw an exception if
# they get used
for key in ('instance', 'color', 'user_identity'):
if key not in record.__dict__:
record.__dict__[key] = ''
if record.__dict__.get('request_id'):
fmt = CONF.logging_context_format_string
else:
fmt = CONF.logging_default_format_string
if (record.levelno == logging.DEBUG and
CONF.logging_debug_format_suffix):
fmt += " " + CONF.logging_debug_format_suffix
if sys.version_info < (3, 2):
self._fmt = fmt
else:
self._style = logging.PercentStyle(fmt)
self._fmt = self._style._fmt
# Cache this on the record, Logger will respect our formatted copy
if record.exc_info:
record.exc_text = self.formatException(record.exc_info, record)
return logging.Formatter.format(self, record)
def formatException(self, exc_info, record=None):
"""Format exception output with CONF.logging_exception_prefix."""
if not record:
return logging.Formatter.formatException(self, exc_info)
stringbuffer = moves.StringIO()
traceback.print_exception(exc_info[0], exc_info[1], exc_info[2],
None, stringbuffer)
lines = stringbuffer.getvalue().split('\n')
stringbuffer.close()
if CONF.logging_exception_prefix.find('%(asctime)') != -1:
record.asctime = self.formatTime(record, self.datefmt)
formatted_lines = []
for line in lines:
pl = CONF.logging_exception_prefix % record.__dict__
fl = '%s%s' % (pl, line)
formatted_lines.append(fl)
return '\n'.join(formatted_lines)
class ColorHandler(logging.StreamHandler):
LEVEL_COLORS = {
logging.DEBUG: '\033[00;32m', # GREEN
logging.INFO: '\033[00;36m', # CYAN
logging.AUDIT: '\033[01;36m', # BOLD CYAN
logging.WARN: '\033[01;33m', # BOLD YELLOW
logging.ERROR: '\033[01;31m', # BOLD RED
logging.CRITICAL: '\033[01;31m', # BOLD RED
}
def format(self, record):
record.color = self.LEVEL_COLORS[record.levelno]
return logging.StreamHandler.format(self, record)
class DeprecatedConfig(Exception):
message = _("Fatal call to deprecated config: %(msg)s")
def __init__(self, msg):
super(Exception, self).__init__(self.message % dict(msg=msg))

View File

@ -21,6 +21,7 @@
from oslo_config import cfg from oslo_config import cfg
from oslo_context import context as oslo_context from oslo_context import context as oslo_context
from oslo_log import log as logging
import oslo_messaging import oslo_messaging
from oslo_utils import importutils from oslo_utils import importutils
@ -47,7 +48,6 @@ from neutron.db import securitygroups_rpc_base as sg_db_rpc
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.extensions import securitygroup as ext_sg from neutron.extensions import securitygroup as ext_sg
from neutron.i18n import _LE, _LI from neutron.i18n import _LE, _LI
from neutron.openstack.common import log as logging
from neutron.plugins.brocade.db import models as brocade_db from neutron.plugins.brocade.db import models as brocade_db
from neutron.plugins.brocade import vlanbm as vbm from neutron.plugins.brocade import vlanbm as vbm
from neutron.plugins.common import constants as svc_constants from neutron.plugins.common import constants as svc_constants

View File

@ -19,10 +19,10 @@ Neutron network life-cycle management.
""" """
from ncclient import manager from ncclient import manager
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
from neutron.i18n import _LE from neutron.i18n import _LE
from neutron.openstack.common import log as logging
from neutron.plugins.brocade.nos import nctemplates as template from neutron.plugins.brocade.nos import nctemplates as template

View File

@ -21,7 +21,8 @@ from __future__ import print_function
import argparse import argparse
from neutron.openstack.common import log as logging from oslo_log import log as logging
from neutron.plugins.brocade.nos import nosdriver as nos from neutron.plugins.brocade.nos import nosdriver as nos
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -12,8 +12,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import netaddr
import re import re
import netaddr
from oslo_log import log as logging
from sqlalchemy.orm import exc from sqlalchemy.orm import exc
from sqlalchemy import sql from sqlalchemy import sql
@ -23,7 +25,6 @@ from neutron.common import exceptions as n_exc
import neutron.db.api as db import neutron.db.api as db
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.i18n import _LW from neutron.i18n import _LW
from neutron.openstack.common import log as logging
from neutron.plugins.cisco.common import cisco_constants as c_const from neutron.plugins.cisco.common import cisco_constants as c_const
from neutron.plugins.cisco.common import cisco_exceptions as c_exc from neutron.plugins.cisco.common import cisco_exceptions as c_exc
from neutron.plugins.cisco.common import config as c_conf from neutron.plugins.cisco.common import config as c_conf

View File

@ -12,12 +12,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy import sql from sqlalchemy import sql
from neutron.db import model_base from neutron.db import model_base
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.openstack.common import log as logging
from neutron.plugins.cisco.common import cisco_constants from neutron.plugins.cisco.common import cisco_constants

View File

@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import log as logging
from sqlalchemy.orm import exc from sqlalchemy.orm import exc
from neutron.db import api as db from neutron.db import api as db
from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
from neutron.plugins.cisco.common import cisco_constants as const from neutron.plugins.cisco.common import cisco_constants as const
from neutron.plugins.cisco.common import cisco_exceptions as c_exc from neutron.plugins.cisco.common import cisco_exceptions as c_exc

View File

@ -15,6 +15,7 @@
import inspect import inspect
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
from oslo_utils import importutils from oslo_utils import importutils
@ -23,7 +24,6 @@ from neutron.extensions import portbindings
from neutron.extensions import providernet as provider from neutron.extensions import providernet as provider
from neutron.i18n import _LE, _LI from neutron.i18n import _LE, _LI
from neutron import neutron_plugin_base_v2 from neutron import neutron_plugin_base_v2
from neutron.openstack.common import log as logging
from neutron.plugins.cisco.common import cisco_constants as const from neutron.plugins.cisco.common import cisco_constants as const
from neutron.plugins.cisco.common import cisco_credentials_v2 as cred from neutron.plugins.cisco.common import cisco_credentials_v2 as cred
from neutron.plugins.cisco.common import config as conf from neutron.plugins.cisco.common import config as conf

View File

@ -16,12 +16,12 @@ import base64
import eventlet import eventlet
import netaddr import netaddr
from oslo_log import log as logging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import requests import requests
from neutron.common import exceptions as n_exc from neutron.common import exceptions as n_exc
from neutron.extensions import providernet from neutron.extensions import providernet
from neutron.openstack.common import log as logging
from neutron.plugins.cisco.common import cisco_constants as c_const from neutron.plugins.cisco.common import cisco_constants as c_const
from neutron.plugins.cisco.common import cisco_credentials_v2 as c_cred from neutron.plugins.cisco.common import cisco_credentials_v2 as c_cred
from neutron.plugins.cisco.common import cisco_exceptions as c_exc from neutron.plugins.cisco.common import cisco_exceptions as c_exc

View File

@ -13,8 +13,8 @@
# under the License. # under the License.
import eventlet import eventlet
from oslo_config import cfg as q_conf from oslo_config import cfg as q_conf
from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
from oslo_utils import importutils from oslo_utils import importutils
@ -37,7 +37,6 @@ from neutron.extensions import portbindings
from neutron.extensions import providernet from neutron.extensions import providernet
from neutron.i18n import _LW from neutron.i18n import _LW
from neutron import manager from neutron import manager
from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils as uuidutils from neutron.openstack.common import uuidutils as uuidutils
from neutron.plugins.cisco.common import cisco_constants as c_const from neutron.plugins.cisco.common import cisco_constants as c_const
from neutron.plugins.cisco.common import cisco_credentials_v2 as c_cred from neutron.plugins.cisco.common import cisco_credentials_v2 as c_cred

Some files were not shown because too many files have changed in this diff Show More