From ac958880594786dd14de6fb22e05f4899b91f1fd Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Fri, 20 Aug 2021 16:56:35 +0200 Subject: [PATCH] Drop an explicit requirement of oslo.log This library is designed for leaf applications (services, CLI). For libraries it's enough to use the generic logging. Unit tests needed adjustment since LOG.exception is implemented via LOG.error internally. Change-Id: I943e1f07a23e76354966acae5e4594e41dd4822b --- ironic_lib/auth_basic.py | 4 ++-- ironic_lib/disk_partitioner.py | 3 ++- ironic_lib/exception.py | 2 +- ironic_lib/json_rpc/client.py | 5 +++-- ironic_lib/json_rpc/server.py | 4 ++-- ironic_lib/keystone.py | 2 +- ironic_lib/mdns.py | 2 +- ironic_lib/metrics_statsd.py | 4 ++-- ironic_lib/tests/test_exception.py | 6 ++++-- requirements.txt | 1 - 10 files changed, 18 insertions(+), 15 deletions(-) diff --git a/ironic_lib/auth_basic.py b/ironic_lib/auth_basic.py index d83e1775..79bf32d8 100644 --- a/ironic_lib/auth_basic.py +++ b/ironic_lib/auth_basic.py @@ -15,15 +15,15 @@ import base64 import binascii +import logging import bcrypt -from oslo_log import log import webob from ironic_lib.common.i18n import _ from ironic_lib import exception -LOG = log.getLogger(__name__) +LOG = logging.getLogger(__name__) class BasicAuthMiddleware(object): diff --git a/ironic_lib/disk_partitioner.py b/ironic_lib/disk_partitioner.py index 3a297911..b8d93c02 100644 --- a/ironic_lib/disk_partitioner.py +++ b/ironic_lib/disk_partitioner.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +import logging + from oslo_config import cfg -from oslo_log import log as logging from ironic_lib.common.i18n import _ from ironic_lib import exception diff --git a/ironic_lib/exception.py b/ironic_lib/exception.py index 93c3329f..fa0b45e5 100644 --- a/ironic_lib/exception.py +++ b/ironic_lib/exception.py @@ -25,9 +25,9 @@ SHOULD include dedicated exception logging. import collections from http import client as http_client import json +import logging from oslo_config import cfg -from oslo_log import log as logging from oslo_utils import excutils from ironic_lib.common.i18n import _ diff --git a/ironic_lib/json_rpc/client.py b/ironic_lib/json_rpc/client.py index bdb497ea..c89feeca 100644 --- a/ironic_lib/json_rpc/client.py +++ b/ironic_lib/json_rpc/client.py @@ -15,8 +15,9 @@ This client is compatible with any JSON RPC 2.0 implementation, including ours. """ +import logging + from oslo_config import cfg -from oslo_log import log from oslo_utils import importutils from oslo_utils import netutils from oslo_utils import strutils @@ -29,7 +30,7 @@ from ironic_lib import keystone CONF = cfg.CONF -LOG = log.getLogger(__name__) +LOG = logging.getLogger(__name__) _SESSION = None diff --git a/ironic_lib/json_rpc/server.py b/ironic_lib/json_rpc/server.py index 2651bff0..8648ed16 100644 --- a/ironic_lib/json_rpc/server.py +++ b/ironic_lib/json_rpc/server.py @@ -20,13 +20,13 @@ https://www.jsonrpc.org/specification. Main differences: """ import json +import logging try: from keystonemiddleware import auth_token except ImportError: auth_token = None from oslo_config import cfg -from oslo_log import log try: import oslo_messaging except ImportError: @@ -43,7 +43,7 @@ from ironic_lib import json_rpc CONF = cfg.CONF -LOG = log.getLogger(__name__) +LOG = logging.getLogger(__name__) _DENY_LIST = {'init_host', 'del_host', 'target', 'iter_nodes'} diff --git a/ironic_lib/keystone.py b/ironic_lib/keystone.py index d017d89a..f03eb7f9 100644 --- a/ironic_lib/keystone.py +++ b/ironic_lib/keystone.py @@ -14,6 +14,7 @@ import copy import functools +import logging from keystoneauth1 import exceptions as ks_exception from keystoneauth1 import loading as ks_loading @@ -21,7 +22,6 @@ from keystoneauth1 import service_token from keystoneauth1 import token_endpoint import os_service_types from oslo_config import cfg -from oslo_log import log as logging from ironic_lib import exception diff --git a/ironic_lib/mdns.py b/ironic_lib/mdns.py index 33f6c5ff..0a6303f8 100644 --- a/ironic_lib/mdns.py +++ b/ironic_lib/mdns.py @@ -18,13 +18,13 @@ https://review.opendev.org/651222. import collections import ipaddress +import logging import socket import time from urllib import parse as urlparse from oslo_config import cfg from oslo_config import types as cfg_types -from oslo_log import log as logging import zeroconf from ironic_lib.common.i18n import _ diff --git a/ironic_lib/metrics_statsd.py b/ironic_lib/metrics_statsd.py index 26c72af2..fe02a7b2 100644 --- a/ironic_lib/metrics_statsd.py +++ b/ironic_lib/metrics_statsd.py @@ -14,10 +14,10 @@ # under the License. import contextlib +import logging import socket from oslo_config import cfg -from oslo_log import log from ironic_lib import metrics @@ -33,7 +33,7 @@ statsd_opts = [ CONF = cfg.CONF CONF.register_opts(statsd_opts, group='metrics_statsd') -LOG = log.getLogger(__name__) +LOG = logging.getLogger(__name__) class StatsdMetricLogger(metrics.MetricLogger): diff --git a/ironic_lib/tests/test_exception.py b/ironic_lib/tests/test_exception.py index c5197564..ce706dcd 100644 --- a/ironic_lib/tests/test_exception.py +++ b/ironic_lib/tests/test_exception.py @@ -51,7 +51,8 @@ class TestIronicException(base.IronicLibTestCase): CONF.set_override('fatal_exception_format_errors', False, group='ironic_lib') e = TestException(spam=Unserializable(), ham='eggs') - message = log_mock.call_args[0][0] % log_mock.call_args[0][1] + message = \ + log_mock.call_args_list[0][0][0] % log_mock.call_args_list[0][0][1] self.assertIsNotNone( re.search('spam: .*JSON.* NotImplementedError: nostr', message), message @@ -64,7 +65,8 @@ class TestIronicException(base.IronicLibTestCase): group='ironic_lib') self.assertRaises(KeyError, TestException, spam=Unserializable(), ham='eggs') - message = log_mock.call_args[0][0] % log_mock.call_args[0][1] + message = \ + log_mock.call_args_list[0][0][0] % log_mock.call_args_list[0][0][1] self.assertIsNotNone( re.search('spam: .*JSON.* NotImplementedError: nostr', message), message diff --git a/requirements.txt b/requirements.txt index 23e13228..c652c430 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,6 @@ oslo.concurrency>=3.26.0 # Apache-2.0 oslo.config>=5.2.0 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0 oslo.utils>=3.34.0 # Apache-2.0 -oslo.log>=3.36.0 # Apache-2.0 zeroconf>=0.24.0 # LGPL bcrypt>=3.1.3 # Apache-2.0 WebOb>=1.7.1 # MIT