From 79adee9c00e475d8f742470c1657ea8502566443 Mon Sep 17 00:00:00 2001 From: Bo Chi Date: Sun, 6 Dec 2015 23:59:16 -0500 Subject: [PATCH] change name of rally.common.log module Copied `rally.common.log` to `rally.common.logging` Marked `rally.common.log` as deprecated Change-Id: Ia7926e5f8a716a8a5b74c0f46d9b797e4fe23ddc Closes-Bug: #1521573 --- doc/source/plugins.rst | 2 +- rally/api.py | 2 +- rally/cli/cliutils.py | 2 +- rally/cli/commands/task.py | 2 +- rally/common/broker.py | 2 +- rally/common/log.py | 260 +---------------- rally/common/logging.py | 273 ++++++++++++++++++ rally/common/opts.py | 4 +- rally/common/plugin/discover.py | 2 +- rally/common/sshutils.py | 2 +- rally/common/utils.py | 2 +- rally/deployment/engine.py | 2 +- rally/deployment/engines/devstack.py | 2 +- rally/deployment/engines/lxc.py | 2 +- rally/deployment/fuel/fuelclient.py | 2 +- .../serverprovider/providers/lxc.py | 2 +- .../serverprovider/providers/openstack.py | 2 +- rally/exceptions.py | 2 +- rally/osclients.py | 2 +- rally/plugins/common/runners/constant.py | 2 +- rally/plugins/common/runners/rps.py | 2 +- .../openstack/context/ceilometer/samples.py | 2 +- .../openstack/context/cinder/volumes.py | 2 +- .../openstack/context/cleanup/context.py | 2 +- .../openstack/context/cleanup/manager.py | 2 +- .../openstack/context/cleanup/resources.py | 2 +- .../plugins/openstack/context/ec2/servers.py | 2 +- rally/plugins/openstack/context/fuel.py | 2 +- .../openstack/context/glance/images.py | 2 +- .../plugins/openstack/context/heat/stacks.py | 2 +- .../context/keystone/api_versions.py | 2 +- .../context/keystone/existing_users.py | 2 +- .../openstack/context/keystone/roles.py | 2 +- .../openstack/context/keystone/users.py | 2 +- .../context/manila/manila_share_networks.py | 9 +- .../context/murano/murano_packages.py | 2 +- .../openstack/context/network/allow_ssh.py | 2 +- .../context/network/existing_network.py | 2 +- .../openstack/context/network/networks.py | 2 +- .../openstack/context/neutron/lbaas.py | 2 +- .../context/not_for_production/tempest.py | 2 +- .../plugins/openstack/context/nova/flavors.py | 2 +- .../openstack/context/nova/keypairs.py | 2 +- .../plugins/openstack/context/nova/servers.py | 2 +- .../openstack/context/quotas/cinder_quotas.py | 2 +- .../context/quotas/designate_quotas.py | 2 +- .../context/quotas/neutron_quotas.py | 2 +- .../openstack/context/quotas/nova_quotas.py | 2 +- .../openstack/context/quotas/quotas.py | 2 +- .../context/sahara/sahara_cluster.py | 2 +- .../openstack/context/sahara/sahara_image.py | 2 +- .../sahara/sahara_input_data_sources.py | 2 +- .../context/sahara/sahara_job_binaries.py | 2 +- .../sahara/sahara_output_data_sources.py | 2 +- .../openstack/context/swift/objects.py | 2 +- .../openstack/context/vm/custom_image.py | 2 +- .../openstack/scenarios/ceilometer/stats.py | 6 +- .../openstack/scenarios/cinder/volumes.py | 2 +- .../openstack/scenarios/ec2/servers.py | 2 +- .../plugins/openstack/scenarios/heat/utils.py | 2 +- .../openstack/scenarios/keystone/basic.py | 2 +- .../openstack/scenarios/manila/shares.py | 2 +- .../scenarios/murano/environments.py | 2 +- .../openstack/scenarios/neutron/utils.py | 2 +- .../openstack/scenarios/nova/hypervisors.py | 2 +- .../openstack/scenarios/nova/servers.py | 2 +- .../openstack/scenarios/sahara/clusters.py | 2 +- .../openstack/scenarios/sahara/jobs.py | 2 +- .../openstack/scenarios/sahara/utils.py | 2 +- rally/plugins/openstack/scenarios/vm/utils.py | 2 +- .../plugins/openstack/scenarios/vm/vmtasks.py | 2 +- .../openstack/scenarios/zaqar/basic.py | 2 +- rally/plugins/openstack/wrappers/cinder.py | 2 +- rally/plugins/openstack/wrappers/keystone.py | 2 +- rally/plugins/openstack/wrappers/network.py | 2 +- rally/task/context.py | 2 +- rally/task/engine.py | 2 +- rally/task/runner.py | 2 +- rally/task/scenario.py | 2 +- rally/task/utils.py | 2 +- rally/verification/tempest/config.py | 2 +- rally/verification/tempest/tempest.py | 2 +- samples/plugins/context/context_plugin.py | 2 +- tests/hacking/checks.py | 10 +- .../common/{test_log.py => test_logging.py} | 2 +- .../openstack/scenarios/vm/test_vmtasks.py | 2 +- tests/unit/test_hacking.py | 10 +- tests/unit/{test_log.py => test_logging.py} | 32 +- 88 files changed, 393 insertions(+), 371 deletions(-) create mode 100644 rally/common/logging.py rename tests/unit/common/{test_log.py => test_logging.py} (98%) rename tests/unit/{test_log.py => test_logging.py} (89%) diff --git a/doc/source/plugins.rst b/doc/source/plugins.rst index bfd9174b99..fddfecd463 100644 --- a/doc/source/plugins.rst +++ b/doc/source/plugins.rst @@ -138,7 +138,7 @@ Inherit a class for your plugin from the base *Context* class. Then, implement t .. code-block:: python from rally.task import context - from rally.common import log as logging + from rally.common import logging from rally import consts from rally import osclients diff --git a/rally/api.py b/rally/api.py index 85d2af8366..028b2c4882 100644 --- a/rally/api.py +++ b/rally/api.py @@ -24,7 +24,7 @@ import jinja2.meta import jsonschema from rally.common.i18n import _, _LI -from rally.common import log as logging +from rally.common import logging from rally.common import objects from rally import consts from rally.deployment import engine as deploy_engine diff --git a/rally/cli/cliutils.py b/rally/cli/cliutils.py index 8d90560f12..1ac1927ca5 100644 --- a/rally/cli/cliutils.py +++ b/rally/cli/cliutils.py @@ -30,7 +30,7 @@ import six import sqlalchemy.exc from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common.plugin import discover from rally.common.plugin import info from rally.common import version diff --git a/rally/cli/commands/task.py b/rally/cli/commands/task.py index 77b56ad5f6..90242aa182 100644 --- a/rally/cli/commands/task.py +++ b/rally/cli/commands/task.py @@ -32,7 +32,7 @@ from rally.cli import envutils from rally.common import fileutils from rally.common.i18n import _ from rally.common import junit -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally import exceptions diff --git a/rally/common/broker.py b/rally/common/broker.py index e32aca1c5c..c8652fd81a 100644 --- a/rally/common/broker.py +++ b/rally/common/broker.py @@ -17,7 +17,7 @@ import collections import threading from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging LOG = logging.getLogger(__name__) diff --git a/rally/common/log.py b/rally/common/log.py index e5259723cc..f4fea0a33c 100644 --- a/rally/common/log.py +++ b/rally/common/log.py @@ -13,260 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import functools -import logging +from rally.common.logging import * # noqa -from oslo_config import cfg -from oslo_log import handlers -from oslo_log import log as oslogging - -from rally.common.i18n import _ - -DEBUG_OPTS = [cfg.BoolOpt( - "rally-debug", - default=False, - help="Print debugging output only for Rally. " - "Off-site components stay quiet.")] - -CONF = cfg.CONF -CONF.register_cli_opts(DEBUG_OPTS) -oslogging.register_options(CONF) - -logging.RDEBUG = logging.DEBUG + 1 -logging.addLevelName(logging.RDEBUG, "RALLYDEBUG") - -CRITICAL = logging.CRITICAL -DEBUG = logging.DEBUG -ERROR = logging.ERROR -FATAL = logging.FATAL -INFO = logging.INFO -NOTSET = logging.NOTSET -RDEBUG = logging.RDEBUG -WARN = logging.WARN -WARNING = logging.WARNING - - -def setup(product_name, version="unknown"): - dbg_color = handlers.ColorHandler.LEVEL_COLORS[logging.DEBUG] - handlers.ColorHandler.LEVEL_COLORS[logging.RDEBUG] = dbg_color - - oslogging.setup(CONF, product_name, version) - - if CONF.rally_debug: - oslogging.getLogger( - project=product_name).logger.setLevel(logging.RDEBUG) - - -class RallyContextAdapter(oslogging.KeywordArgumentAdapter): - - def debug(self, msg, *args, **kwargs): - self.log(logging.RDEBUG, msg, *args, **kwargs) - - -def getLogger(name="unknown", version="unknown"): - - if name not in oslogging._loggers: - oslogging._loggers[name] = RallyContextAdapter(logging.getLogger(name), - {"project": "rally", - "version": version}) - return oslogging._loggers[name] - - -LOG = getLogger(__name__) - - -class ExceptionLogger(object): - """Context that intercepts and logs exceptions. - - Usage:: - LOG = logging.getLogger(__name__) - ... - - def foobar(): - with ExceptionLogger(LOG, "foobar warning") as e: - return house_of_raising_exception() - - if e.exception: - raise e.exception # remove if not required - """ - - def __init__(self, logger, warn=None): - self.logger = logger - self.warn = warn - self.exception = None - - def __enter__(self): - return self - - def __exit__(self, type_, value, traceback): - if value: - self.exception = value - - if self.warn: - self.logger.warning(self.warn) - self.logger.debug(value) - if is_debug(): - self.logger.exception(value) - return True - - -class CatcherHandler(logging.handlers.BufferingHandler): - def __init__(self): - logging.handlers.BufferingHandler.__init__(self, 0) - - def shouldFlush(self): - return False - - def emit(self, record): - self.buffer.append(record) - - -class LogCatcher(object): - """Context manager that catches log messages. - - User can make an assertion on their content or fetch them all. - - Usage:: - LOG = logging.getLogger(__name__) - ... - - def foobar(): - with LogCatcher(LOG) as catcher_in_rye: - LOG.warning("Running Kids") - - catcher_in_rye.assertInLogs("Running Kids") - """ - def __init__(self, logger): - self.logger = getattr(logger, "logger", logger) - self.handler = CatcherHandler() - - def __enter__(self): - self.logger.addHandler(self.handler) - return self - - def __exit__(self, type_, value, traceback): - self.logger.removeHandler(self.handler) - - def assertInLogs(self, msg): - """Assert that `msg' is a substring at least of one logged message. - - :param msg: Substring to look for. - :return: Log messages where the `msg' was found. - Raises AssertionError if none. - """ - in_logs = [record.msg - for record in self.handler.buffer if msg in record.msg] - if not in_logs: - raise AssertionError("Expected `%s' is not in logs" % msg) - return in_logs - - def fetchLogRecords(self): - """Returns all logged Records.""" - return self.handler.buffer - - def fetchLogs(self): - """Returns all logged messages.""" - return [record.msg for record in self.handler.buffer] - - -def _log_wrapper(obj, log_function, msg, **kw): - """A logging wrapper for any method of a class. - - Class instances that use this decorator should have self.task or - self.deployment attribute. The wrapper produces logs messages both - before and after the method execution, in the following format - (example for tasks): - - "Task | Starting: " - [Method execution...] - "Task | Completed: " - - :param obj: task or deployment which must be attribute of "self" - :param log_function: Logging method to be used, e.g. LOG.info - :param msg: Text message (possibly parameterized) to be put to the log - :param **kw: Parameters for msg - """ - def decorator(f): - @functools.wraps(f) - def wrapper(self, *args, **kwargs): - params = {"msg": msg % kw, "obj_name": obj.title(), - "uuid": getattr(self, obj)["uuid"]} - log_function(_("%(obj_name)s %(uuid)s | Starting: %(msg)s") % - params) - result = f(self, *args, **kwargs) - log_function(_("%(obj_name)s %(uuid)s | Completed: %(msg)s") % - params) - return result - return wrapper - return decorator - - -def log_task_wrapper(log_function, msg, **kw): - return _log_wrapper("task", log_function, msg, **kw) - - -def log_deploy_wrapper(log_function, msg, **kw): - return _log_wrapper("deployment", log_function, msg, **kw) - - -def log_verification_wrapper(log_function, msg, **kw): - return _log_wrapper("verification", log_function, msg, **kw) - - -def log_deprecated(message, rally_version, log_function=None, once=False): - """A wrapper marking a certain method as deprecated. - - :param message: Message that describes why the method was deprecated - :param rally_version: version of Rally when the method was deprecated - :param log_function: Logging method to be used, e.g. LOG.info - :param once: Show only once (default is each) - """ - log_function = log_function or LOG.warning - - def decorator(f): - @functools.wraps(f) - def wrapper(*args, **kwargs): - if (not once) or (not getattr(f, "_warned_dep_method", False)): - log_function("'%(func)s' is deprecated in Rally v%(version)s: " - "%(msg)s" % {"msg": message, - "version": rally_version, - "func": f.__name__}) - setattr(f, "_warned_dep_method", once) - return f(*args, **kwargs) - return wrapper - return decorator - - -def log_deprecated_args(message, rally_version, deprecated_args, - log_function=None, once=False): - """A wrapper marking certain arguments as deprecated. - - :param message: Message that describes why the arguments were deprecated - :param rally_version: version of Rally when the arguments were deprecated - :param deprecated_args: List of deprecated args. - :param log_function: Logging method to be used, e.g. LOG.info - :param once: Show only once (default is each) - """ - log_function = log_function or LOG.warning - - def decorator(f): - @functools.wraps(f) - def wrapper(*args, **kwargs): - if (not once) or (not getattr(f, "_warned_dep_args", False)): - deprecated = ", ".join([ - "`%s'" % x for x in deprecated_args if x in kwargs]) - if deprecated: - log_function( - "%(msg)s (args %(args)s deprecated in Rally " - "v%(version)s)" % - {"msg": message, "version": rally_version, - "args": deprecated}) - setattr(f, "_warned_dep_args", once) - result = f(*args, **kwargs) - return result - return wrapper - return decorator - - -def is_debug(): - return CONF.debug or CONF.rally_debug +import warnings +warnings.warn("rally.common.log is deprecated since Rally 0.1.2. " + "Please use rally.common.logging instead.") diff --git a/rally/common/logging.py b/rally/common/logging.py new file mode 100644 index 0000000000..bdf3e6af00 --- /dev/null +++ b/rally/common/logging.py @@ -0,0 +1,273 @@ +# Copyright 2014: Mirantis Inc. +# 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. + +import functools + +from oslo_config import cfg +from oslo_log import handlers +from oslo_log import log as oslogging + +from rally.common.i18n import _ + +log = __import__("logging") + +DEBUG_OPTS = [cfg.BoolOpt( + "rally-debug", + default=False, + help="Print debugging output only for Rally. " + "Off-site components stay quiet.")] + +CONF = cfg.CONF +CONF.register_cli_opts(DEBUG_OPTS) +oslogging.register_options(CONF) + +log.RDEBUG = log.DEBUG + 1 +log.addLevelName(log.RDEBUG, "RALLYDEBUG") + +CRITICAL = log.CRITICAL +DEBUG = log.DEBUG +ERROR = log.ERROR +FATAL = log.FATAL +INFO = log.INFO +NOTSET = log.NOTSET +RDEBUG = log.RDEBUG +WARN = log.WARN +WARNING = log.WARNING + + +def setup(product_name, version="unknown"): + dbg_color = handlers.ColorHandler.LEVEL_COLORS[log.DEBUG] + handlers.ColorHandler.LEVEL_COLORS[log.RDEBUG] = dbg_color + + oslogging.setup(CONF, product_name, version) + + if CONF.rally_debug: + oslogging.getLogger( + project=product_name).logger.setLevel(log.RDEBUG) + + +class RallyContextAdapter(oslogging.KeywordArgumentAdapter): + + def debug(self, msg, *args, **kwargs): + self.log(log.RDEBUG, msg, *args, **kwargs) + + +def getLogger(name="unknown", version="unknown"): + + if name not in oslogging._loggers: + oslogging._loggers[name] = RallyContextAdapter(log.getLogger(name), + {"project": "rally", + "version": version}) + return oslogging._loggers[name] + + +LOG = getLogger(__name__) + + +class ExceptionLogger(object): + """Context that intercepts and logs exceptions. + + Usage:: + LOG = logging.getLogger(__name__) + ... + + def foobar(): + with ExceptionLogger(LOG, "foobar warning") as e: + return house_of_raising_exception() + + if e.exception: + raise e.exception # remove if not required + """ + + def __init__(self, logger, warn=None): + self.logger = logger + self.warn = warn + self.exception = None + + def __enter__(self): + return self + + def __exit__(self, type_, value, traceback): + if value: + self.exception = value + + if self.warn: + self.logger.warning(self.warn) + self.logger.debug(value) + if is_debug(): + self.logger.exception(value) + return True + + +class CatcherHandler(log.handlers.BufferingHandler): + def __init__(self): + log.handlers.BufferingHandler.__init__(self, 0) + + def shouldFlush(self): + return False + + def emit(self, record): + self.buffer.append(record) + + +class LogCatcher(object): + """Context manager that catches log messages. + + User can make an assertion on their content or fetch them all. + + Usage:: + LOG = logging.getLogger(__name__) + ... + + def foobar(): + with LogCatcher(LOG) as catcher_in_rye: + LOG.warning("Running Kids") + + catcher_in_rye.assertInLogs("Running Kids") + """ + def __init__(self, logger): + self.logger = getattr(logger, "logger", logger) + self.handler = CatcherHandler() + + def __enter__(self): + self.logger.addHandler(self.handler) + return self + + def __exit__(self, type_, value, traceback): + self.logger.removeHandler(self.handler) + + def assertInLogs(self, msg): + """Assert that `msg' is a substring at least of one logged message. + + :param msg: Substring to look for. + :return: Log messages where the `msg' was found. + Raises AssertionError if none. + """ + in_logs = [record.msg + for record in self.handler.buffer if msg in record.msg] + if not in_logs: + raise AssertionError("Expected `%s' is not in logs" % msg) + return in_logs + + def fetchLogRecords(self): + """Returns all logged Records.""" + return self.handler.buffer + + def fetchLogs(self): + """Returns all logged messages.""" + return [record.msg for record in self.handler.buffer] + + +def _log_wrapper(obj, log_function, msg, **kw): + """A logging wrapper for any method of a class. + + Class instances that use this decorator should have self.task or + self.deployment attribute. The wrapper produces logs messages both + before and after the method execution, in the following format + (example for tasks): + + "Task | Starting: " + [Method execution...] + "Task | Completed: " + + :param obj: task or deployment which must be attribute of "self" + :param log_function: Logging method to be used, e.g. LOG.info + :param msg: Text message (possibly parameterized) to be put to the log + :param **kw: Parameters for msg + """ + def decorator(f): + @functools.wraps(f) + def wrapper(self, *args, **kwargs): + params = {"msg": msg % kw, "obj_name": obj.title(), + "uuid": getattr(self, obj)["uuid"]} + log_function(_("%(obj_name)s %(uuid)s | Starting: %(msg)s") % + params) + result = f(self, *args, **kwargs) + log_function(_("%(obj_name)s %(uuid)s | Completed: %(msg)s") % + params) + return result + return wrapper + return decorator + + +def log_task_wrapper(log_function, msg, **kw): + return _log_wrapper("task", log_function, msg, **kw) + + +def log_deploy_wrapper(log_function, msg, **kw): + return _log_wrapper("deployment", log_function, msg, **kw) + + +def log_verification_wrapper(log_function, msg, **kw): + return _log_wrapper("verification", log_function, msg, **kw) + + +def log_deprecated(message, rally_version, log_function=None, once=False): + """A wrapper marking a certain method as deprecated. + + :param message: Message that describes why the method was deprecated + :param rally_version: version of Rally when the method was deprecated + :param log_function: Logging method to be used, e.g. LOG.info + :param once: Show only once (default is each) + """ + log_function = log_function or LOG.warning + + def decorator(f): + @functools.wraps(f) + def wrapper(*args, **kwargs): + if (not once) or (not getattr(f, "_warned_dep_method", False)): + log_function("'%(func)s' is deprecated in Rally v%(version)s: " + "%(msg)s" % {"msg": message, + "version": rally_version, + "func": f.__name__}) + setattr(f, "_warned_dep_method", once) + return f(*args, **kwargs) + return wrapper + return decorator + + +def log_deprecated_args(message, rally_version, deprecated_args, + log_function=None, once=False): + """A wrapper marking certain arguments as deprecated. + + :param message: Message that describes why the arguments were deprecated + :param rally_version: version of Rally when the arguments were deprecated + :param deprecated_args: List of deprecated args. + :param log_function: Logging method to be used, e.g. LOG.info + :param once: Show only once (default is each) + """ + log_function = log_function or LOG.warning + + def decorator(f): + @functools.wraps(f) + def wrapper(*args, **kwargs): + if (not once) or (not getattr(f, "_warned_dep_args", False)): + deprecated = ", ".join([ + "`%s'" % x for x in deprecated_args if x in kwargs]) + if deprecated: + log_function( + "%(msg)s (args %(args)s deprecated in Rally " + "v%(version)s)" % + {"msg": message, "version": rally_version, + "args": deprecated}) + setattr(f, "_warned_dep_args", once) + result = f(*args, **kwargs) + return result + return wrapper + return decorator + + +def is_debug(): + return CONF.debug or CONF.rally_debug diff --git a/rally/common/opts.py b/rally/common/opts.py index fab3d85c3d..34cc52fb18 100644 --- a/rally/common/opts.py +++ b/rally/common/opts.py @@ -14,7 +14,7 @@ import itertools -from rally.common import log +from rally.common import logging from rally import osclients from rally.plugins.openstack.context.cleanup import base as cleanup_base from rally.plugins.openstack.context.keystone import users @@ -34,7 +34,7 @@ from rally.verification.tempest import config as tempest_conf def list_opts(): return [ ("DEFAULT", - itertools.chain(log.DEBUG_OPTS, + itertools.chain(logging.DEBUG_OPTS, osclients.OSCLIENTS_OPTS)), ("benchmark", itertools.chain(cinder_utils.CINDER_BENCHMARK_OPTS, diff --git a/rally/common/plugin/discover.py b/rally/common/plugin/discover.py index ef59543957..00fcbc74f3 100644 --- a/rally/common/plugin/discover.py +++ b/rally/common/plugin/discover.py @@ -21,7 +21,7 @@ from oslo_utils import importutils import rally from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging LOG = logging.getLogger(__name__) diff --git a/rally/common/sshutils.py b/rally/common/sshutils.py index 07bfc6d85c..ccb073865b 100644 --- a/rally/common/sshutils.py +++ b/rally/common/sshutils.py @@ -66,7 +66,7 @@ import paramiko import six from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging LOG = logging.getLogger(__name__) diff --git a/rally/common/utils.py b/rally/common/utils.py index 43bf8b5d3a..65be3a90ba 100644 --- a/rally/common/utils.py +++ b/rally/common/utils.py @@ -27,7 +27,7 @@ import time from six import moves -from rally.common import log as logging +from rally.common import logging from rally import exceptions LOG = logging.getLogger(__name__) diff --git a/rally/deployment/engine.py b/rally/deployment/engine.py index de8e7c8ada..bf6ca95069 100644 --- a/rally/deployment/engine.py +++ b/rally/deployment/engine.py @@ -19,7 +19,7 @@ import jsonschema import six from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common.plugin import plugin from rally import consts from rally.deployment.serverprovider import provider diff --git a/rally/deployment/engines/devstack.py b/rally/deployment/engines/devstack.py index ab9086b932..39fbf1df2a 100644 --- a/rally/deployment/engines/devstack.py +++ b/rally/deployment/engines/devstack.py @@ -18,7 +18,7 @@ import os import six from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import objects from rally import consts from rally.deployment import engine diff --git a/rally/deployment/engines/lxc.py b/rally/deployment/engines/lxc.py index 25413f62e3..b6dab1bcba 100644 --- a/rally/deployment/engines/lxc.py +++ b/rally/deployment/engines/lxc.py @@ -19,7 +19,7 @@ import netaddr import six from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import objects from rally.deployment import engine from rally.deployment.serverprovider import provider diff --git a/rally/deployment/fuel/fuelclient.py b/rally/deployment/fuel/fuelclient.py index acfa8799c3..4ee7cce04f 100644 --- a/rally/deployment/fuel/fuelclient.py +++ b/rally/deployment/fuel/fuelclient.py @@ -19,7 +19,7 @@ import time import requests -from rally.common import log as logging +from rally.common import logging LOG = logging.getLogger(__name__) diff --git a/rally/deployment/serverprovider/providers/lxc.py b/rally/deployment/serverprovider/providers/lxc.py index 1123e0dffd..79ec55cb7f 100644 --- a/rally/deployment/serverprovider/providers/lxc.py +++ b/rally/deployment/serverprovider/providers/lxc.py @@ -22,7 +22,7 @@ import six from six import moves from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.deployment.serverprovider import provider from rally import exceptions diff --git a/rally/deployment/serverprovider/providers/openstack.py b/rally/deployment/serverprovider/providers/openstack.py index 68cfe52d35..f34c31651e 100644 --- a/rally/deployment/serverprovider/providers/openstack.py +++ b/rally/deployment/serverprovider/providers/openstack.py @@ -20,7 +20,7 @@ import os import novaclient.exceptions from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import objects from rally.deployment.serverprovider import provider from rally import exceptions diff --git a/rally/exceptions.py b/rally/exceptions.py index bc1a3aa896..852fc43ec4 100644 --- a/rally/exceptions.py +++ b/rally/exceptions.py @@ -16,7 +16,7 @@ import six from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging LOG = logging.getLogger(__name__) diff --git a/rally/osclients.py b/rally/osclients.py index 7d1b631efe..72226a89e6 100644 --- a/rally/osclients.py +++ b/rally/osclients.py @@ -19,7 +19,7 @@ import os from oslo_config import cfg from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import objects from rally.common.plugin import plugin from rally import consts diff --git a/rally/plugins/common/runners/constant.py b/rally/plugins/common/runners/constant.py index db5272296b..592ef90c59 100644 --- a/rally/plugins/common/runners/constant.py +++ b/rally/plugins/common/runners/constant.py @@ -20,7 +20,7 @@ import time from six.moves import queue as Queue -from rally.common import log as logging +from rally.common import logging from rally.common import utils from rally import consts from rally.task import runner diff --git a/rally/plugins/common/runners/rps.py b/rally/plugins/common/runners/rps.py index 204bb216f0..fc83ce941a 100644 --- a/rally/plugins/common/runners/rps.py +++ b/rally/plugins/common/runners/rps.py @@ -20,7 +20,7 @@ import time from six.moves import queue as Queue -from rally.common import log as logging +from rally.common import logging from rally.common import utils from rally import consts from rally.task import runner diff --git a/rally/plugins/openstack/context/ceilometer/samples.py b/rally/plugins/openstack/context/ceilometer/samples.py index 46e0fc0396..d095580d2d 100644 --- a/rally/plugins/openstack/context/ceilometer/samples.py +++ b/rally/plugins/openstack/context/ceilometer/samples.py @@ -15,7 +15,7 @@ from six import moves from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally import exceptions diff --git a/rally/plugins/openstack/context/cinder/volumes.py b/rally/plugins/openstack/context/cinder/volumes.py index fe53997db8..28569013fc 100644 --- a/rally/plugins/openstack/context/cinder/volumes.py +++ b/rally/plugins/openstack/context/cinder/volumes.py @@ -13,7 +13,7 @@ # under the License. from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally.plugins.openstack.context.cleanup import manager as resource_manager diff --git a/rally/plugins/openstack/context/cleanup/context.py b/rally/plugins/openstack/context/cleanup/context.py index 0be3694ad7..064cb3feab 100644 --- a/rally/plugins/openstack/context/cleanup/context.py +++ b/rally/plugins/openstack/context/cleanup/context.py @@ -16,7 +16,7 @@ import sys from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally import consts from rally import exceptions from rally.plugins.openstack.context.cleanup import manager diff --git a/rally/plugins/openstack/context/cleanup/manager.py b/rally/plugins/openstack/context/cleanup/manager.py index e55e3a3018..bc8cd8afc4 100644 --- a/rally/plugins/openstack/context/cleanup/manager.py +++ b/rally/plugins/openstack/context/cleanup/manager.py @@ -17,7 +17,7 @@ import time from rally.common import broker from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common.plugin import discover from rally.common import utils as rutils from rally import osclients diff --git a/rally/plugins/openstack/context/cleanup/resources.py b/rally/plugins/openstack/context/cleanup/resources.py index 41f404679c..60019911b6 100644 --- a/rally/plugins/openstack/context/cleanup/resources.py +++ b/rally/plugins/openstack/context/cleanup/resources.py @@ -17,7 +17,7 @@ from boto import exception as boto_exception from neutronclient.common import exceptions as neutron_exceptions from saharaclient.api import base as saharaclient_base -from rally.common import log as logging +from rally.common import logging from rally.common.plugin import discover from rally.common import utils from rally.plugins.openstack.context.cleanup import base diff --git a/rally/plugins/openstack/context/ec2/servers.py b/rally/plugins/openstack/context/ec2/servers.py index 17f5e9b7b2..f03b8a4e67 100644 --- a/rally/plugins/openstack/context/ec2/servers.py +++ b/rally/plugins/openstack/context/ec2/servers.py @@ -13,7 +13,7 @@ # under the License. from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally import osclients diff --git a/rally/plugins/openstack/context/fuel.py b/rally/plugins/openstack/context/fuel.py index 0818466618..b83a66944d 100644 --- a/rally/plugins/openstack/context/fuel.py +++ b/rally/plugins/openstack/context/fuel.py @@ -16,7 +16,7 @@ import collections from rally.common import broker from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally import consts from rally import exceptions from rally.plugins.openstack.scenarios.fuel import utils as fuel_utils diff --git a/rally/plugins/openstack/context/glance/images.py b/rally/plugins/openstack/context/glance/images.py index 6de6b5db7a..b42ee9bf0e 100644 --- a/rally/plugins/openstack/context/glance/images.py +++ b/rally/plugins/openstack/context/glance/images.py @@ -13,7 +13,7 @@ # under the License. from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally.plugins.openstack.context.cleanup import manager as resource_manager diff --git a/rally/plugins/openstack/context/heat/stacks.py b/rally/plugins/openstack/context/heat/stacks.py index a46445d440..d7875e689e 100644 --- a/rally/plugins/openstack/context/heat/stacks.py +++ b/rally/plugins/openstack/context/heat/stacks.py @@ -14,7 +14,7 @@ # under the License. from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally.plugins.openstack.context.cleanup import manager as resource_manager diff --git a/rally/plugins/openstack/context/keystone/api_versions.py b/rally/plugins/openstack/context/keystone/api_versions.py index 8d91cb9591..9642cf6d9c 100644 --- a/rally/plugins/openstack/context/keystone/api_versions.py +++ b/rally/plugins/openstack/context/keystone/api_versions.py @@ -15,7 +15,7 @@ import random import six from rally.common.i18n import _, _LE -from rally.common import log as logging +from rally.common import logging from rally import consts from rally import exceptions from rally import osclients diff --git a/rally/plugins/openstack/context/keystone/existing_users.py b/rally/plugins/openstack/context/keystone/existing_users.py index 0ace1bb13d..186d2a9f02 100644 --- a/rally/plugins/openstack/context/keystone/existing_users.py +++ b/rally/plugins/openstack/context/keystone/existing_users.py @@ -14,7 +14,7 @@ from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import objects from rally import osclients from rally.plugins.openstack.context.keystone import users diff --git a/rally/plugins/openstack/context/keystone/roles.py b/rally/plugins/openstack/context/keystone/roles.py index 05a738ed3e..abf9f925ba 100644 --- a/rally/plugins/openstack/context/keystone/roles.py +++ b/rally/plugins/openstack/context/keystone/roles.py @@ -14,7 +14,7 @@ # under the License. from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally import consts from rally import exceptions from rally import osclients diff --git a/rally/plugins/openstack/context/keystone/users.py b/rally/plugins/openstack/context/keystone/users.py index 7c6a61a5d3..ae1a231df6 100644 --- a/rally/plugins/openstack/context/keystone/users.py +++ b/rally/plugins/openstack/context/keystone/users.py @@ -22,7 +22,7 @@ import six from rally.common import broker from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import objects from rally.common import utils as rutils from rally import consts diff --git a/rally/plugins/openstack/context/manila/manila_share_networks.py b/rally/plugins/openstack/context/manila/manila_share_networks.py index aa372ecfa2..71459f4122 100644 --- a/rally/plugins/openstack/context/manila/manila_share_networks.py +++ b/rally/plugins/openstack/context/manila/manila_share_networks.py @@ -16,7 +16,7 @@ from oslo_config import cfg from rally.common.i18n import _ -from rally.common import log +from rally.common import logging from rally.common import utils from rally import consts as rally_consts from rally import exceptions @@ -25,7 +25,7 @@ from rally.plugins.openstack.scenarios.manila import utils as manila_utils from rally.task import context CONF = cfg.CONF -LOG = log.getLogger(__name__) +LOG = logging.getLogger(__name__) CONTEXT_NAME = consts.SHARE_NETWORKS_CONTEXT_NAME @@ -124,7 +124,8 @@ class ManilaShareNetworks(context.Context): self.context["tenants"][tenant_id][CONTEXT_NAME]["sn_iterator"] = ( utils.RAMInt()) - @log.log_task_wrapper(LOG.info, _("Enter context: `%s`") % CONTEXT_NAME) + @logging.log_task_wrapper(LOG.info, _("Enter context: `%s`") + % CONTEXT_NAME) def setup(self): self.context[CONTEXT_NAME] = {} if not self.config["use_share_networks"]: @@ -135,7 +136,7 @@ class ManilaShareNetworks(context.Context): # TODO(vponomaryov): add support of autocreated resources pass - @log.log_task_wrapper(LOG.info, _("Exit context: `%s`") % CONTEXT_NAME) + @logging.log_task_wrapper(LOG.info, _("Exit context: `%s`") % CONTEXT_NAME) def cleanup(self): # TODO(vponomaryov): add cleanup for autocreated resources when appear. return diff --git a/rally/plugins/openstack/context/murano/murano_packages.py b/rally/plugins/openstack/context/murano/murano_packages.py index c877aaef60..ed89c08bad 100644 --- a/rally/plugins/openstack/context/murano/murano_packages.py +++ b/rally/plugins/openstack/context/murano/murano_packages.py @@ -19,7 +19,7 @@ import zipfile from rally.common import fileutils from rally.common.i18n import _ from rally.common.i18n import _LE -from rally.common import log as logging +from rally.common import logging from rally.common import utils from rally import consts from rally import exceptions diff --git a/rally/plugins/openstack/context/network/allow_ssh.py b/rally/plugins/openstack/context/network/allow_ssh.py index 7fe63fcd3e..97aacd88a9 100644 --- a/rally/plugins/openstack/context/network/allow_ssh.py +++ b/rally/plugins/openstack/context/network/allow_ssh.py @@ -16,7 +16,7 @@ import six from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils from rally import osclients from rally.plugins.openstack.wrappers import network diff --git a/rally/plugins/openstack/context/network/existing_network.py b/rally/plugins/openstack/context/network/existing_network.py index e8b4f62ac6..d556120ea0 100644 --- a/rally/plugins/openstack/context/network/existing_network.py +++ b/rally/plugins/openstack/context/network/existing_network.py @@ -14,7 +14,7 @@ from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils from rally import consts from rally import osclients diff --git a/rally/plugins/openstack/context/network/networks.py b/rally/plugins/openstack/context/network/networks.py index a1688de791..93cdbabdea 100644 --- a/rally/plugins/openstack/context/network/networks.py +++ b/rally/plugins/openstack/context/network/networks.py @@ -16,7 +16,7 @@ import six from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils from rally import consts from rally import osclients diff --git a/rally/plugins/openstack/context/neutron/lbaas.py b/rally/plugins/openstack/context/neutron/lbaas.py index 977cec743b..bc1d6b34f3 100644 --- a/rally/plugins/openstack/context/neutron/lbaas.py +++ b/rally/plugins/openstack/context/neutron/lbaas.py @@ -13,7 +13,7 @@ import six from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils from rally import consts from rally import osclients diff --git a/rally/plugins/openstack/context/not_for_production/tempest.py b/rally/plugins/openstack/context/not_for_production/tempest.py index b8087b17c2..f108bfc93e 100644 --- a/rally/plugins/openstack/context/not_for_production/tempest.py +++ b/rally/plugins/openstack/context/not_for_production/tempest.py @@ -18,7 +18,7 @@ import shutil import tempfile from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally import consts from rally import exceptions from rally.task import context diff --git a/rally/plugins/openstack/context/nova/flavors.py b/rally/plugins/openstack/context/nova/flavors.py index 69e724985f..85c1d3285f 100644 --- a/rally/plugins/openstack/context/nova/flavors.py +++ b/rally/plugins/openstack/context/nova/flavors.py @@ -16,7 +16,7 @@ from novaclient import exceptions as nova_exceptions from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally import osclients diff --git a/rally/plugins/openstack/context/nova/keypairs.py b/rally/plugins/openstack/context/nova/keypairs.py index 70a3f5358c..176be3d1bd 100644 --- a/rally/plugins/openstack/context/nova/keypairs.py +++ b/rally/plugins/openstack/context/nova/keypairs.py @@ -16,7 +16,7 @@ import novaclient.exceptions from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally import osclients from rally.plugins.openstack.context.cleanup import manager as resource_manager from rally.task import context diff --git a/rally/plugins/openstack/context/nova/servers.py b/rally/plugins/openstack/context/nova/servers.py index d32e3ca312..ec3df900b9 100644 --- a/rally/plugins/openstack/context/nova/servers.py +++ b/rally/plugins/openstack/context/nova/servers.py @@ -13,7 +13,7 @@ # under the License. from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally import osclients diff --git a/rally/plugins/openstack/context/quotas/cinder_quotas.py b/rally/plugins/openstack/context/quotas/cinder_quotas.py index 248a52dfe0..7426c8503b 100644 --- a/rally/plugins/openstack/context/quotas/cinder_quotas.py +++ b/rally/plugins/openstack/context/quotas/cinder_quotas.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.common import log as logging +from rally.common import logging LOG = logging.getLogger(__name__) diff --git a/rally/plugins/openstack/context/quotas/designate_quotas.py b/rally/plugins/openstack/context/quotas/designate_quotas.py index 5d0490f5a6..0d46643452 100644 --- a/rally/plugins/openstack/context/quotas/designate_quotas.py +++ b/rally/plugins/openstack/context/quotas/designate_quotas.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.common import log as logging +from rally.common import logging LOG = logging.getLogger(__name__) diff --git a/rally/plugins/openstack/context/quotas/neutron_quotas.py b/rally/plugins/openstack/context/quotas/neutron_quotas.py index 0f006e70d0..94463c06de 100644 --- a/rally/plugins/openstack/context/quotas/neutron_quotas.py +++ b/rally/plugins/openstack/context/quotas/neutron_quotas.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.common import log as logging +from rally.common import logging LOG = logging.getLogger(__name__) diff --git a/rally/plugins/openstack/context/quotas/nova_quotas.py b/rally/plugins/openstack/context/quotas/nova_quotas.py index 63ec93cfb0..19f7948072 100644 --- a/rally/plugins/openstack/context/quotas/nova_quotas.py +++ b/rally/plugins/openstack/context/quotas/nova_quotas.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.common import log as logging +from rally.common import logging LOG = logging.getLogger(__name__) diff --git a/rally/plugins/openstack/context/quotas/quotas.py b/rally/plugins/openstack/context/quotas/quotas.py index cb1d3d2526..c47fe457e8 100644 --- a/rally/plugins/openstack/context/quotas/quotas.py +++ b/rally/plugins/openstack/context/quotas/quotas.py @@ -14,7 +14,7 @@ # under the License. from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally import consts from rally import osclients from rally.plugins.openstack.context.quotas import cinder_quotas diff --git a/rally/plugins/openstack/context/sahara/sahara_cluster.py b/rally/plugins/openstack/context/sahara/sahara_cluster.py index 05d47c1266..f26f871467 100644 --- a/rally/plugins/openstack/context/sahara/sahara_cluster.py +++ b/rally/plugins/openstack/context/sahara/sahara_cluster.py @@ -16,7 +16,7 @@ from oslo_config import cfg from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally import exceptions diff --git a/rally/plugins/openstack/context/sahara/sahara_image.py b/rally/plugins/openstack/context/sahara/sahara_image.py index 99fb40055d..9fb0cbd390 100644 --- a/rally/plugins/openstack/context/sahara/sahara_image.py +++ b/rally/plugins/openstack/context/sahara/sahara_image.py @@ -13,7 +13,7 @@ # under the License. from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally import exceptions diff --git a/rally/plugins/openstack/context/sahara/sahara_input_data_sources.py b/rally/plugins/openstack/context/sahara/sahara_input_data_sources.py index 08648b9245..6bdd208f0d 100644 --- a/rally/plugins/openstack/context/sahara/sahara_input_data_sources.py +++ b/rally/plugins/openstack/context/sahara/sahara_input_data_sources.py @@ -17,7 +17,7 @@ import requests from six.moves.urllib import parse from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally import osclients diff --git a/rally/plugins/openstack/context/sahara/sahara_job_binaries.py b/rally/plugins/openstack/context/sahara/sahara_job_binaries.py index cda447ceae..38a570bace 100644 --- a/rally/plugins/openstack/context/sahara/sahara_job_binaries.py +++ b/rally/plugins/openstack/context/sahara/sahara_job_binaries.py @@ -16,7 +16,7 @@ import requests from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally import exceptions diff --git a/rally/plugins/openstack/context/sahara/sahara_output_data_sources.py b/rally/plugins/openstack/context/sahara/sahara_output_data_sources.py index b6920ffaf3..78de33b701 100644 --- a/rally/plugins/openstack/context/sahara/sahara_output_data_sources.py +++ b/rally/plugins/openstack/context/sahara/sahara_output_data_sources.py @@ -14,7 +14,7 @@ # under the License. from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally import osclients diff --git a/rally/plugins/openstack/context/swift/objects.py b/rally/plugins/openstack/context/swift/objects.py index 8891d35101..4f9e0b4069 100644 --- a/rally/plugins/openstack/context/swift/objects.py +++ b/rally/plugins/openstack/context/swift/objects.py @@ -14,7 +14,7 @@ # under the License. from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally import consts from rally import exceptions from rally.plugins.openstack.context.swift import utils as swift_utils diff --git a/rally/plugins/openstack/context/vm/custom_image.py b/rally/plugins/openstack/context/vm/custom_image.py index 0999cdf78d..358fc9793b 100644 --- a/rally/plugins/openstack/context/vm/custom_image.py +++ b/rally/plugins/openstack/context/vm/custom_image.py @@ -19,7 +19,7 @@ import six from rally.common import broker from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils from rally import consts from rally import osclients diff --git a/rally/plugins/openstack/scenarios/ceilometer/stats.py b/rally/plugins/openstack/scenarios/ceilometer/stats.py index 93e549e3d7..d18686fa7f 100644 --- a/rally/plugins/openstack/scenarios/ceilometer/stats.py +++ b/rally/plugins/openstack/scenarios/ceilometer/stats.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.common import log +from rally.common import logging from rally import consts from rally.plugins.openstack import scenario from rally.plugins.openstack.scenarios.ceilometer import utils @@ -22,8 +22,8 @@ from rally.task import validation class CeilometerStats(utils.CeilometerScenario): """Benchmark scenarios for Ceilometer Stats API.""" - @log.log_deprecated("Use 'get_stats' method, now samples are created in " - "context", "0.1.2") + @logging.log_deprecated("Use 'get_stats' method, now samples are created" + "in context", "0.1.2") @validation.required_services(consts.Service.CEILOMETER) @validation.required_openstack(users=True) @scenario.configure() diff --git a/rally/plugins/openstack/scenarios/cinder/volumes.py b/rally/plugins/openstack/scenarios/cinder/volumes.py index 0c1d7b18f5..2844ab6d74 100644 --- a/rally/plugins/openstack/scenarios/cinder/volumes.py +++ b/rally/plugins/openstack/scenarios/cinder/volumes.py @@ -15,7 +15,7 @@ import random -from rally.common import log as logging +from rally.common import logging from rally import consts from rally import exceptions from rally.plugins.openstack import scenario diff --git a/rally/plugins/openstack/scenarios/ec2/servers.py b/rally/plugins/openstack/scenarios/ec2/servers.py index f3a8e57b10..c69f974be7 100644 --- a/rally/plugins/openstack/scenarios/ec2/servers.py +++ b/rally/plugins/openstack/scenarios/ec2/servers.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.common import log as logging +from rally.common import logging from rally import consts from rally.plugins.openstack import scenario from rally.plugins.openstack.scenarios.ec2 import utils diff --git a/rally/plugins/openstack/scenarios/heat/utils.py b/rally/plugins/openstack/scenarios/heat/utils.py index 02bcb273bd..7079b9252b 100644 --- a/rally/plugins/openstack/scenarios/heat/utils.py +++ b/rally/plugins/openstack/scenarios/heat/utils.py @@ -18,7 +18,7 @@ import time from oslo_config import cfg import requests -from rally.common import log as logging +from rally.common import logging from rally import exceptions from rally.plugins.openstack import scenario from rally.task import atomic diff --git a/rally/plugins/openstack/scenarios/keystone/basic.py b/rally/plugins/openstack/scenarios/keystone/basic.py index 03c9a22305..801f4d2a92 100644 --- a/rally/plugins/openstack/scenarios/keystone/basic.py +++ b/rally/plugins/openstack/scenarios/keystone/basic.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.common import log as logging +from rally.common import logging from rally.plugins.openstack import scenario from rally.plugins.openstack.scenarios.keystone import utils as kutils from rally.task import validation diff --git a/rally/plugins/openstack/scenarios/manila/shares.py b/rally/plugins/openstack/scenarios/manila/shares.py index 5f8a0632f0..6339d79e4c 100644 --- a/rally/plugins/openstack/scenarios/manila/shares.py +++ b/rally/plugins/openstack/scenarios/manila/shares.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.common import log as logging +from rally.common import logging from rally import consts from rally.plugins.openstack import scenario from rally.plugins.openstack.scenarios.manila import utils diff --git a/rally/plugins/openstack/scenarios/murano/environments.py b/rally/plugins/openstack/scenarios/murano/environments.py index ea21f05eac..273b182041 100644 --- a/rally/plugins/openstack/scenarios/murano/environments.py +++ b/rally/plugins/openstack/scenarios/murano/environments.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.common import log as logging +from rally.common import logging from rally import consts from rally.plugins.openstack import scenario from rally.plugins.openstack.scenarios.murano import utils diff --git a/rally/plugins/openstack/scenarios/neutron/utils.py b/rally/plugins/openstack/scenarios/neutron/utils.py index e1f8121503..ef0f17771e 100644 --- a/rally/plugins/openstack/scenarios/neutron/utils.py +++ b/rally/plugins/openstack/scenarios/neutron/utils.py @@ -16,7 +16,7 @@ import random from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally import exceptions from rally.plugins.openstack import scenario from rally.plugins.openstack.wrappers import network as network_wrapper diff --git a/rally/plugins/openstack/scenarios/nova/hypervisors.py b/rally/plugins/openstack/scenarios/nova/hypervisors.py index eb701d66b1..6af0ca4f72 100644 --- a/rally/plugins/openstack/scenarios/nova/hypervisors.py +++ b/rally/plugins/openstack/scenarios/nova/hypervisors.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.common import log as logging +from rally.common import logging from rally import consts from rally.plugins.openstack import scenario from rally.plugins.openstack.scenarios.nova import utils diff --git a/rally/plugins/openstack/scenarios/nova/servers.py b/rally/plugins/openstack/scenarios/nova/servers.py index edbb8354d8..274b14d33e 100644 --- a/rally/plugins/openstack/scenarios/nova/servers.py +++ b/rally/plugins/openstack/scenarios/nova/servers.py @@ -15,7 +15,7 @@ import jsonschema -from rally.common import log as logging +from rally.common import logging from rally import consts from rally import exceptions as rally_exceptions from rally.plugins.openstack import scenario diff --git a/rally/plugins/openstack/scenarios/sahara/clusters.py b/rally/plugins/openstack/scenarios/sahara/clusters.py index 7cab7af9ce..7c04dde558 100644 --- a/rally/plugins/openstack/scenarios/sahara/clusters.py +++ b/rally/plugins/openstack/scenarios/sahara/clusters.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.common import log as logging +from rally.common import logging from rally import consts from rally.plugins.openstack import scenario from rally.plugins.openstack.scenarios.sahara import utils diff --git a/rally/plugins/openstack/scenarios/sahara/jobs.py b/rally/plugins/openstack/scenarios/sahara/jobs.py index bcab73f14b..1928f4c667 100644 --- a/rally/plugins/openstack/scenarios/sahara/jobs.py +++ b/rally/plugins/openstack/scenarios/sahara/jobs.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.common import log as logging +from rally.common import logging from rally import consts from rally.plugins.openstack import scenario from rally.plugins.openstack.scenarios.sahara import utils diff --git a/rally/plugins/openstack/scenarios/sahara/utils.py b/rally/plugins/openstack/scenarios/sahara/utils.py index 1320803a97..916caf593a 100644 --- a/rally/plugins/openstack/scenarios/sahara/utils.py +++ b/rally/plugins/openstack/scenarios/sahara/utils.py @@ -20,7 +20,7 @@ from oslo_utils import uuidutils from saharaclient.api import base as sahara_base from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils as rutils from rally import consts from rally import exceptions diff --git a/rally/plugins/openstack/scenarios/vm/utils.py b/rally/plugins/openstack/scenarios/vm/utils.py index d456525f1a..12c2dd0d09 100644 --- a/rally/plugins/openstack/scenarios/vm/utils.py +++ b/rally/plugins/openstack/scenarios/vm/utils.py @@ -21,7 +21,7 @@ from oslo_config import cfg import six from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import sshutils from rally.plugins.openstack.scenarios.cinder import utils as cinder_utils from rally.plugins.openstack.scenarios.nova import utils as nova_utils diff --git a/rally/plugins/openstack/scenarios/vm/vmtasks.py b/rally/plugins/openstack/scenarios/vm/vmtasks.py index 879b755148..38265831f0 100644 --- a/rally/plugins/openstack/scenarios/vm/vmtasks.py +++ b/rally/plugins/openstack/scenarios/vm/vmtasks.py @@ -15,7 +15,7 @@ import json -from rally.common import log as logging +from rally.common import logging from rally import consts from rally import exceptions from rally.plugins.openstack import scenario diff --git a/rally/plugins/openstack/scenarios/zaqar/basic.py b/rally/plugins/openstack/scenarios/zaqar/basic.py index 79d409ca44..ceed43f23b 100644 --- a/rally/plugins/openstack/scenarios/zaqar/basic.py +++ b/rally/plugins/openstack/scenarios/zaqar/basic.py @@ -14,7 +14,7 @@ import random -from rally.common import log as logging +from rally.common import logging from rally.plugins.openstack import scenario from rally.plugins.openstack.scenarios.zaqar import utils as zutils diff --git a/rally/plugins/openstack/wrappers/cinder.py b/rally/plugins/openstack/wrappers/cinder.py index 963863110a..47f78d1deb 100644 --- a/rally/plugins/openstack/wrappers/cinder.py +++ b/rally/plugins/openstack/wrappers/cinder.py @@ -15,7 +15,7 @@ import abc -from rally.common import log as logging +from rally.common import logging from rally import exceptions import six diff --git a/rally/plugins/openstack/wrappers/keystone.py b/rally/plugins/openstack/wrappers/keystone.py index e8117c1863..b2f8a97052 100644 --- a/rally/plugins/openstack/wrappers/keystone.py +++ b/rally/plugins/openstack/wrappers/keystone.py @@ -19,7 +19,7 @@ import collections from keystoneclient import exceptions import six -from rally.common import log as logging +from rally.common import logging LOG = logging.getLogger(__name__) diff --git a/rally/plugins/openstack/wrappers/network.py b/rally/plugins/openstack/wrappers/network.py index b47157bd47..2d1e35dc46 100644 --- a/rally/plugins/openstack/wrappers/network.py +++ b/rally/plugins/openstack/wrappers/network.py @@ -19,7 +19,7 @@ import netaddr import six from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import utils from rally import consts from rally import exceptions diff --git a/rally/task/context.py b/rally/task/context.py index cd290c8aa2..051040f1c3 100644 --- a/rally/task/context.py +++ b/rally/task/context.py @@ -19,7 +19,7 @@ import copy import jsonschema import six -from rally.common import log as logging +from rally.common import logging from rally.common.plugin import plugin from rally.common import utils from rally import exceptions diff --git a/rally/task/engine.py b/rally/task/engine.py index d7a33c7998..2404caa602 100644 --- a/rally/task/engine.py +++ b/rally/task/engine.py @@ -23,7 +23,7 @@ import jsonschema import six from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import objects from rally import consts from rally import exceptions diff --git a/rally/task/runner.py b/rally/task/runner.py index 561588a4c7..bf5a7e5fb2 100644 --- a/rally/task/runner.py +++ b/rally/task/runner.py @@ -20,7 +20,7 @@ import time import jsonschema -from rally.common import log as logging +from rally.common import logging from rally.common.plugin import plugin from rally.common import utils as rutils from rally import consts diff --git a/rally/task/scenario.py b/rally/task/scenario.py index b4a13c13d8..3e052d7a4a 100644 --- a/rally/task/scenario.py +++ b/rally/task/scenario.py @@ -19,7 +19,7 @@ import time import six -from rally.common import log as logging +from rally.common import logging from rally.common.plugin import plugin from rally.common import utils from rally import consts diff --git a/rally/task/utils.py b/rally/task/utils.py index 065b4578a8..d16ea293d4 100644 --- a/rally/task/utils.py +++ b/rally/task/utils.py @@ -22,7 +22,7 @@ from novaclient import exceptions as nova_exc import six from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally import consts from rally import exceptions diff --git a/rally/verification/tempest/config.py b/rally/verification/tempest/config.py index 73326436c6..4822670d98 100644 --- a/rally/verification/tempest/config.py +++ b/rally/verification/tempest/config.py @@ -24,7 +24,7 @@ from six.moves.urllib import parse from rally.common import db from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from rally.common import objects from rally.common import utils from rally import exceptions diff --git a/rally/verification/tempest/tempest.py b/rally/verification/tempest/tempest.py index 0cdb76d8f2..58a6cab0e9 100644 --- a/rally/verification/tempest/tempest.py +++ b/rally/verification/tempest/tempest.py @@ -25,7 +25,7 @@ from oslo_utils import encodeutils from rally.common import costilius from rally.common.i18n import _ from rally.common.io import subunit_v2 -from rally.common import log as logging +from rally.common import logging from rally import consts from rally import exceptions from rally.verification.tempest import config diff --git a/samples/plugins/context/context_plugin.py b/samples/plugins/context/context_plugin.py index 25b653c9a2..4f662fe313 100644 --- a/samples/plugins/context/context_plugin.py +++ b/samples/plugins/context/context_plugin.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from rally.common import log as logging +from rally.common import logging from rally import consts from rally import osclients from rally.task import context diff --git a/tests/hacking/checks.py b/tests/hacking/checks.py index aebeff13cf..48fcea682d 100644 --- a/tests/hacking/checks.py +++ b/tests/hacking/checks.py @@ -138,8 +138,8 @@ def check_import_of_logging(logical_line, filename): N310 """ - excluded_files = ["./rally/common/log.py", - "./tests/unit/test_log.py", + excluded_files = ["./rally/common/logging.py", + "./tests/unit/test_logging.py", "./tests/ci/rally_verify.py"] forbidden_imports = ["from oslo_log", @@ -150,7 +150,7 @@ def check_import_of_logging(logical_line, filename): for forbidden_import in forbidden_imports: if logical_line.startswith(forbidden_import): yield (0, "N310 Wrong module for logging is imported. Please " - "use `rally.common.log` instead.") + "use `rally.common.logging` instead.") @skip_ignored_lines @@ -182,12 +182,12 @@ def no_use_conf_debug_check(logical_line, filename): N312 """ - excluded_files = ["./rally/common/log.py"] + excluded_files = ["./rally/common/logging.py"] point = logical_line.find("CONF.debug") if point != -1 and filename not in excluded_files: yield(point, "N312 Don't use `CONF.debug`. " - "Function `rally.common.log.is_debug` " + "Function `rally.common.logging.is_debug` " "should be used instead.") diff --git a/tests/unit/common/test_log.py b/tests/unit/common/test_logging.py similarity index 98% rename from tests/unit/common/test_log.py rename to tests/unit/common/test_logging.py index 67f8774a4d..9933506fcb 100644 --- a/tests/unit/common/test_log.py +++ b/tests/unit/common/test_logging.py @@ -16,7 +16,7 @@ import mock from rally.common.i18n import _ -from rally.common import log as logging +from rally.common import logging from tests.unit import test diff --git a/tests/unit/plugins/openstack/scenarios/vm/test_vmtasks.py b/tests/unit/plugins/openstack/scenarios/vm/test_vmtasks.py index 8da63f7dc1..63a764fc24 100644 --- a/tests/unit/plugins/openstack/scenarios/vm/test_vmtasks.py +++ b/tests/unit/plugins/openstack/scenarios/vm/test_vmtasks.py @@ -15,7 +15,7 @@ import mock -from rally.common import log as logging +from rally.common import logging from rally import exceptions from rally.plugins.openstack.scenarios.vm import vmtasks from tests.unit import test diff --git a/tests/unit/test_hacking.py b/tests/unit/test_hacking.py index b76df7cba2..d628d985dd 100644 --- a/tests/unit/test_hacking.py +++ b/tests/unit/test_hacking.py @@ -88,17 +88,17 @@ class HackingTestCase(test.TestCase): bad_imports = ["from oslo_log import log", "import oslo_log", "import logging"] - good_imports = ["from rally.common import log", - "from rally.common.log", - "import rally.common.log"] + good_imports = ["from rally.common import logging", + "from rally.common.logging", + "import rally.common.logging"] for bad_import in bad_imports: checkres = checks.check_import_of_logging(bad_import, "fakefile") self.assertIsNotNone(next(checkres)) for bad_import in bad_imports: - checkres = checks.check_import_of_logging(bad_import, - "./rally/common/log.py") + checkres = checks.check_import_of_logging( + bad_import, "./rally/common/logging.py") self.assertEqual([], list(checkres)) for good_import in good_imports: diff --git a/tests/unit/test_log.py b/tests/unit/test_logging.py similarity index 89% rename from tests/unit/test_log.py rename to tests/unit/test_logging.py index cac5114e17..35cc0873bc 100644 --- a/tests/unit/test_log.py +++ b/tests/unit/test_logging.py @@ -17,15 +17,15 @@ import logging import mock -from rally.common import log +from rally.common import logging as log from tests.unit import test class LogTestCase(test.TestCase): - @mock.patch("rally.common.log.CONF") - @mock.patch("rally.common.log.handlers") - @mock.patch("rally.common.log.oslogging") + @mock.patch("rally.common.logging.CONF") + @mock.patch("rally.common.logging.handlers") + @mock.patch("rally.common.logging.oslogging") def test_setup(self, mock_oslogging, mock_handlers, mock_conf): proj = "fakep" @@ -45,11 +45,11 @@ class LogTestCase(test.TestCase): mock_oslogging.getLogger(None).logger.setLevel.assert_called_once_with( logging.RDEBUG) - @mock.patch("rally.common.log.logging") - @mock.patch("rally.common.log.RallyContextAdapter") - @mock.patch("rally.common.log.oslogging") + @mock.patch("rally.common.logging.log") + @mock.patch("rally.common.logging.RallyContextAdapter") + @mock.patch("rally.common.logging.oslogging") def test_getLogger(self, mock_oslogging, mock_rally_context_adapter, - mock_logging): + mock_log): name = "fake" vers = "fake" @@ -59,31 +59,31 @@ class LogTestCase(test.TestCase): self.assertIn(name, mock_oslogging._loggers) mock_rally_context_adapter.assert_called_once_with( - mock_logging.getLogger(name), + mock_log.getLogger(name), {"project": "rally", "version": vers}) self.assertEqual(mock_oslogging._loggers[name], returned_logger) class LogRallyContaxtAdapter(test.TestCase): - @mock.patch("rally.common.log.logging") - @mock.patch("rally.common.log.oslogging.KeywordArgumentAdapter") - def test_debug(self, mock_keyword_argument_adapter, mock_logging): + @mock.patch("rally.common.logging.log") + @mock.patch("rally.common.logging.oslogging.KeywordArgumentAdapter") + def test_debug(self, mock_keyword_argument_adapter, mock_log): - mock_logging.RDEBUG = 123 + mock_log.RDEBUG = 123 fake_msg = "fake message" radapter = log.RallyContextAdapter(mock.MagicMock(), "fakep") radapter.log = mock.MagicMock() radapter.debug(fake_msg) - radapter.log.assert_called_once_with(mock_logging.RDEBUG, + radapter.log.assert_called_once_with(mock_log.RDEBUG, fake_msg) class ExceptionLoggerTestCase(test.TestCase): - @mock.patch("rally.common.log.is_debug") + @mock.patch("rally.common.logging.is_debug") def test_context(self, mock_is_debug): # Prepare mock_is_debug.return_value = True @@ -147,7 +147,7 @@ class CatcherHandlerTestCase(test.TestCase): class LogCatcherUnitTestCase(test.TestCase): def setUp(self): super(LogCatcherUnitTestCase, self).setUp() - patcher = mock.patch("rally.common.log.CatcherHandler") + patcher = mock.patch("rally.common.logging.CatcherHandler") self.catcher_handler = patcher.start() self.catcher_handler.return_value.buffer = [ mock.Mock(msg="foo"), mock.Mock(msg="bar")]