Migrate to oslo_log

Use oslo_log instead of logging module.

Change-Id: I0e9c9b9b68ba9c8c4f1c0cdd0746991c53e2d7e5
Closes-bug: #1475690
This commit is contained in:
Yuiko Takada 2015-07-27 15:07:16 +09:00
parent b383c87dfc
commit 6ce87e8f42
16 changed files with 130 additions and 41 deletions

@ -24,10 +24,6 @@
# Its value may be silently ignored in the future. # Its value may be silently ignored in the future.
#authenticate = <None> #authenticate = <None>
# Debug mode enabled/disabled. (boolean value)
# Deprecated group/name - [discoverd]/debug
#debug = false
# Timeout after which introspection is considered failed, set to 0 to # Timeout after which introspection is considered failed, set to 0 to
# disable. (integer value) # disable. (integer value)
# Deprecated group/name - [discoverd]/timeout # Deprecated group/name - [discoverd]/timeout
@ -63,6 +59,96 @@
# affected by introspection_delay setting. (string value) # affected by introspection_delay setting. (string value)
#introspection_delay_drivers = ^.*_ssh$ #introspection_delay_drivers = ^.*_ssh$
#
# From oslo.log
#
# Print debugging output (set logging level to DEBUG instead of
# default INFO level). (boolean value)
#debug = false
# If set to false, will disable INFO logging level, making WARNING the
# default. (boolean value)
# This option is deprecated for removal.
# Its value may be silently ignored in the future.
#verbose = true
# 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.
# (string value)
# Deprecated group/name - [DEFAULT]/log_config
#log_config_append = <None>
# 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. (string value)
#log_format = <None>
# Format string for %%(asctime)s in log records. Default: %(default)s
# . (string value)
#log_date_format = %Y-%m-%d %H:%M:%S
# (Optional) Name of log file to output to. If no default is set,
# logging will go to stdout. (string value)
# Deprecated group/name - [DEFAULT]/logfile
#log_file = <None>
# (Optional) The base directory used for relative --log-file paths.
# (string value)
# Deprecated group/name - [DEFAULT]/logdir
#log_dir = <None>
# Use syslog for logging. Existing syslog format is DEPRECATED and
# will be changed later to honor RFC5424. (boolean value)
#use_syslog = false
# (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 K, and
# will be removed in M, along with this option. (boolean value)
# This option is deprecated for removal.
# Its value may be silently ignored in the future.
#use_syslog_rfc_format = true
# Syslog facility to receive log lines. (string value)
#syslog_log_facility = LOG_USER
# Log output to standard error. (boolean value)
#use_stderr = true
# Format string to use for log messages with context. (string value)
#logging_context_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s
# Format string to use for log messages without context. (string
# value)
#logging_default_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s
# Data to append to log format when level is DEBUG. (string value)
#logging_debug_format_suffix = %(funcName)s %(pathname)s:%(lineno)d
# Prefix each line of exception output with this format. (string
# value)
#logging_exception_prefix = %(asctime)s.%(msecs)03d %(process)d ERROR %(name)s %(instance)s
# List of logger=LEVEL pairs. (list value)
#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,requests.packages.urllib3.util.retry=WARN,urllib3.util.retry=WARN,keystonemiddleware=WARN,routes.middleware=WARN,stevedore=WARN,taskflow=WARN
# Enables or disables publication of error events. (boolean value)
#publish_errors = false
# The format for an instance that is passed with the log message.
# (string value)
#instance_format = "[instance: %(uuid)s] "
# The format for an instance UUID that is passed with the log message.
# (string value)
#instance_uuid_format = "[instance: %(uuid)s] "
# Enables or disables fatal status of deprecations. (boolean value)
#fatal_deprecations = false
[database] [database]

@ -13,9 +13,8 @@
# Mostly copied from ironic/common/swift.py # Mostly copied from ironic/common/swift.py
import logging
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log
from swiftclient import client as swift_client from swiftclient import client as swift_client
from swiftclient import exceptions as swift_exceptions from swiftclient import exceptions as swift_exceptions
@ -25,7 +24,7 @@ from ironic_inspector import utils
CONF = cfg.CONF CONF = cfg.CONF
LOG = logging.getLogger('ironic_inspector.common.swift') LOG = log.getLogger('ironic_inspector.common.swift')
SWIFT_OPTS = [ SWIFT_OPTS = [

@ -193,10 +193,6 @@ SERVICE_OPTS = [
help='DEPRECATED: use auth_strategy.', help='DEPRECATED: use auth_strategy.',
deprecated_group='discoverd', deprecated_group='discoverd',
deprecated_for_removal=True), deprecated_for_removal=True),
cfg.BoolOpt('debug',
default=False,
help='Debug mode enabled/disabled.',
deprecated_group='discoverd'),
cfg.IntOpt('timeout', cfg.IntOpt('timeout',
default=3600, default=3600,
help='Timeout after which introspection is considered failed, ' help='Timeout after which introspection is considered failed, '

@ -11,11 +11,11 @@
# 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.
import logging
import subprocess import subprocess
from eventlet import semaphore from eventlet import semaphore
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log
from ironic_inspector.common.i18n import _LE from ironic_inspector.common.i18n import _LE
from ironic_inspector import node_cache from ironic_inspector import node_cache
@ -23,7 +23,7 @@ from ironic_inspector import utils
CONF = cfg.CONF CONF = cfg.CONF
LOG = logging.getLogger("ironic_inspector.firewall") LOG = log.getLogger("ironic_inspector.firewall")
NEW_CHAIN = None NEW_CHAIN = None
CHAIN = None CHAIN = None
INTERFACE = None INTERFACE = None

@ -13,7 +13,6 @@
"""Handling introspection request.""" """Handling introspection request."""
import logging
import re import re
import string import string
import time import time
@ -21,6 +20,7 @@ import time
from eventlet import semaphore from eventlet import semaphore
from ironicclient import exceptions from ironicclient import exceptions
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log
from ironic_inspector.common.i18n import _, _LI, _LW from ironic_inspector.common.i18n import _, _LI, _LW
from ironic_inspector import firewall from ironic_inspector import firewall
@ -30,7 +30,7 @@ from ironic_inspector import utils
CONF = cfg.CONF CONF = cfg.CONF
LOG = logging.getLogger("ironic_inspector.introspect") LOG = log.getLogger("ironic_inspector.introspect")
PASSWORD_ACCEPTED_CHARS = set(string.ascii_letters + string.digits) PASSWORD_ACCEPTED_CHARS = set(string.ascii_letters + string.digits)
PASSWORD_MAX_LENGTH = 20 # IPMI v2.0 PASSWORD_MAX_LENGTH = 20 # IPMI v2.0

@ -16,17 +16,16 @@ eventlet.monkey_patch()
import functools import functools
import json import json
import logging
import ssl import ssl
import sys import sys
import flask import flask
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log
from oslo_utils import uuidutils from oslo_utils import uuidutils
from ironic_inspector import db from ironic_inspector import db
from ironic_inspector.common.i18n import _, _LC, _LE, _LI, _LW from ironic_inspector.common.i18n import _, _LC, _LE, _LI, _LW
# Import configuration options
from ironic_inspector import conf # noqa from ironic_inspector import conf # noqa
from ironic_inspector import firewall from ironic_inspector import firewall
from ironic_inspector import introspect from ironic_inspector import introspect
@ -39,7 +38,7 @@ CONF = cfg.CONF
app = flask.Flask(__name__) app = flask.Flask(__name__)
LOG = logging.getLogger('ironic_inspector.main') LOG = log.getLogger('ironic_inspector.main')
MINIMUM_API_VERSION = (1, 0) MINIMUM_API_VERSION = (1, 0)
CURRENT_API_VERSION = (1, 0) CURRENT_API_VERSION = (1, 0)
@ -241,16 +240,17 @@ def create_ssl_context():
def main(args=sys.argv[1:], in_functional_test=False): # pragma: no cover def main(args=sys.argv[1:], in_functional_test=False): # pragma: no cover
log.register_options(CONF)
CONF(args, project='ironic-inspector') CONF(args, project='ironic-inspector')
debug = CONF.debug debug = CONF.debug
logging.basicConfig(level=logging.DEBUG if debug else logging.INFO) log.set_defaults(default_log_levels=[
for third_party in ('urllib3.connectionpool', 'urllib3.connectionpool=WARN',
'keystonemiddleware.auth_token', 'keystonemiddleware.auth_token=WARN',
'requests.packages.urllib3.connectionpool'): 'requests.packages.urllib3.connectionpool=WARN',
logging.getLogger(third_party).setLevel(logging.WARNING) ('ironicclient.common.http=INFO' if debug else
logging.getLogger('ironicclient.common.http').setLevel( 'ironicclient.common.http=ERROR')])
logging.INFO if debug else logging.ERROR) log.setup(CONF, 'ironic_inspector')
app_kwargs = {'debug': debug and not in_functional_test, app_kwargs = {'debug': debug and not in_functional_test,
'host': CONF.listen_address, 'host': CONF.listen_address,

@ -14,12 +14,12 @@
"""Cache for nodes currently under introspection.""" """Cache for nodes currently under introspection."""
import json import json
import logging
import time import time
from ironicclient import exceptions from ironicclient import exceptions
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
from sqlalchemy import text from sqlalchemy import text
from ironic_inspector import db from ironic_inspector import db
@ -29,7 +29,7 @@ from ironic_inspector import utils
CONF = cfg.CONF CONF = cfg.CONF
LOG = logging.getLogger("ironic_inspector.node_cache") LOG = log.getLogger("ironic_inspector.node_cache")
MACS_ATTRIBUTE = 'mac' MACS_ATTRIBUTE = 'mac'

@ -13,12 +13,12 @@
"""Example plugin.""" """Example plugin."""
import logging from oslo_log import log
from ironic_inspector.plugins import base from ironic_inspector.plugins import base
LOG = logging.getLogger('ironic_inspector.plugins.example') LOG = log.getLogger('ironic_inspector.plugins.example')
class ExampleProcessingHook(base.ProcessingHook): # pragma: no cover class ExampleProcessingHook(base.ProcessingHook): # pragma: no cover

@ -19,9 +19,9 @@ is stored in the 'inspector' container.
""" """
import json import json
import logging
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log
from ironic_inspector.common.i18n import _LW from ironic_inspector.common.i18n import _LW
from ironic_inspector.common import swift from ironic_inspector.common import swift
@ -30,7 +30,7 @@ from ironic_inspector.plugins import base
CONF = cfg.CONF CONF = cfg.CONF
LOG = logging.getLogger('ironic_inspector.plugins.extra_hardware') LOG = log.getLogger('ironic_inspector.plugins.extra_hardware')
class ExtraHardwareHook(base.ProcessingHook): class ExtraHardwareHook(base.ProcessingHook):

@ -13,13 +13,13 @@
"""Gather root device hint from recognized block devices.""" """Gather root device hint from recognized block devices."""
import logging from oslo_log import log
from ironic_inspector.common.i18n import _LI, _LW from ironic_inspector.common.i18n import _LI, _LW
from ironic_inspector.plugins import base from ironic_inspector.plugins import base
LOG = logging.getLogger('ironic_inspector.plugins.root_device_hint') LOG = log.getLogger('ironic_inspector.plugins.root_device_hint')
class RootDeviceHintHook(base.ProcessingHook): class RootDeviceHintHook(base.ProcessingHook):

@ -15,11 +15,11 @@
import base64 import base64
import datetime import datetime
import logging
import os import os
import sys import sys
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log
from ironic_inspector.common.i18n import _, _LC, _LI, _LW from ironic_inspector.common.i18n import _, _LC, _LI, _LW
from ironic_inspector import conf from ironic_inspector import conf
@ -29,7 +29,7 @@ from ironic_inspector import utils
CONF = cfg.CONF CONF = cfg.CONF
LOG = logging.getLogger('ironic_inspector.plugins.standard') LOG = log.getLogger('ironic_inspector.plugins.standard')
class SchedulerHook(base.ProcessingHook): class SchedulerHook(base.ProcessingHook):

@ -13,10 +13,9 @@
"""Handling introspection data from the ramdisk.""" """Handling introspection data from the ramdisk."""
import logging
import eventlet import eventlet
from ironicclient import exceptions from ironicclient import exceptions
from oslo_log import log
from ironic_inspector.common.i18n import _, _LE, _LI from ironic_inspector.common.i18n import _, _LE, _LI
from ironic_inspector import firewall from ironic_inspector import firewall
@ -25,7 +24,7 @@ from ironic_inspector.plugins import base as plugins_base
from ironic_inspector import utils from ironic_inspector import utils
LOG = logging.getLogger("ironic_inspector.process") LOG = log.getLogger("ironic_inspector.process")
_CREDENTIALS_WAIT_RETRIES = 10 _CREDENTIALS_WAIT_RETRIES = 10
_CREDENTIALS_WAIT_PERIOD = 3 _CREDENTIALS_WAIT_PERIOD = 3

@ -16,6 +16,7 @@ import unittest
import mock import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_db import options as db_opts from oslo_db import options as db_opts
from oslo_log import log
from ironic_inspector.common import i18n from ironic_inspector.common import i18n
# Import configuration options # Import configuration options
@ -36,6 +37,12 @@ def init_test_conf():
CONF.reset() CONF.reset()
for group in ('firewall', 'processing', 'ironic'): for group in ('firewall', 'processing', 'ironic'):
CONF.register_group(cfg.OptGroup(group)) CONF.register_group(cfg.OptGroup(group))
try:
# Functional tests
log.register_options(CONF)
except Exception:
# Unit tests
pass
db_opts.set_defaults(CONF) db_opts.set_defaults(CONF)
CONF.set_default('slave_connection', False, group='database') CONF.set_default('slave_connection', False, group='database')
CONF.set_default('max_retries', 10, group='database') CONF.set_default('max_retries', 10, group='database')

@ -11,7 +11,6 @@
# 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.
import logging
import re import re
import socket import socket
@ -20,6 +19,7 @@ from ironicclient import client
import keystoneclient.v2_0.client as keystone_client import keystoneclient.v2_0.client as keystone_client
from keystonemiddleware import auth_token from keystonemiddleware import auth_token
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log
import six import six
from ironic_inspector.common.i18n import _, _LE, _LI from ironic_inspector.common.i18n import _, _LE, _LI
@ -30,7 +30,7 @@ CONF = cfg.CONF
VALID_STATES = {'enroll', 'manageable', 'inspecting', 'inspectfail'} VALID_STATES = {'enroll', 'manageable', 'inspecting', 'inspectfail'}
LOG = logging.getLogger('ironic_inspector.utils') LOG = log.getLogger('ironic_inspector.utils')
GREEN_POOL = None GREEN_POOL = None

@ -11,6 +11,7 @@ python-keystoneclient>=1.6.0
oslo.config>=1.11.0 # Apache-2.0 oslo.config>=1.11.0 # Apache-2.0
oslo.db>=1.12.0 # Apache-2.0 oslo.db>=1.12.0 # Apache-2.0
oslo.i18n>=1.5.0 # Apache-2.0 oslo.i18n>=1.5.0 # Apache-2.0
oslo.log>=1.8.0 # Apache-2.0
oslo.utils>=1.9.0 # Apache-2.0 oslo.utils>=1.9.0 # Apache-2.0
six>=1.9.0 six>=1.9.0
stevedore>=1.5.0 # Apache-2.0 stevedore>=1.5.0 # Apache-2.0

@ -35,7 +35,8 @@ commands =
--namespace ironic_inspector \ --namespace ironic_inspector \
--namespace keystonemiddleware.auth_token \ --namespace keystonemiddleware.auth_token \
--namespace ironic_inspector.common.swift \ --namespace ironic_inspector.common.swift \
--namespace oslo.db --namespace oslo.db \
--namespace oslo.log
[flake8] [flake8]
max-complexity=15 max-complexity=15