diff --git a/oslo_vmware/exceptions.py b/oslo_vmware/exceptions.py index a7a9bcb2..96b6c56e 100644 --- a/oslo_vmware/exceptions.py +++ b/oslo_vmware/exceptions.py @@ -51,7 +51,8 @@ class VMwareDriverException(Exception): """ msg_fmt = _("An unknown exception occurred.") - __str__ = lambda self: self.description + def __str__(self): + return self.description def __init__(self, message=None, details=None, **kwargs): diff --git a/oslo_vmware/hacking/checks.py b/oslo_vmware/hacking/checks.py index 8591d71d..9c0caddc 100644 --- a/oslo_vmware/hacking/checks.py +++ b/oslo_vmware/hacking/checks.py @@ -14,6 +14,8 @@ import re +from hacking import core + _all_log_levels = {'critical', 'error', 'exception', 'info', 'warning', 'debug'} @@ -28,6 +30,7 @@ _log_translation_hint = re.compile( }) +@core.flake8ext def no_translate_logs(logical_line, filename): """N537 - Don't translate logs. @@ -46,7 +49,3 @@ def no_translate_logs(logical_line, filename): """ if _log_translation_hint.match(logical_line): yield (0, "N537: Log messages should not be translated!") - - -def factory(register): - register(no_translate_logs) diff --git a/oslo_vmware/objects/datastore.py b/oslo_vmware/objects/datastore.py index 7f2c34ce..56b85f08 100644 --- a/oslo_vmware/objects/datastore.py +++ b/oslo_vmware/objects/datastore.py @@ -445,8 +445,8 @@ class DatastoreURL(object): httplib.CannotSendHeader) as excep: excep_msg = _("Error occurred while creating HTTP connection " "to write to file with URL = %s.") % str(self) - LOG.exception(excep_msg) - raise exceptions.VimConnectionException(excep_msg, excep) + LOG.exception(excep_msg) + raise exceptions.VimConnectionException(excep_msg, excep) def get_transfer_ticket(self, session, method): client_factory = session.vim.client.factory diff --git a/oslo_vmware/service.py b/oslo_vmware/service.py index 7fba28bf..f61ce602 100644 --- a/oslo_vmware/service.py +++ b/oslo_vmware/service.py @@ -459,5 +459,6 @@ class SudsLogFilter(logging.Filter): return True + # Set log filter to mask/truncate vCenter credentials in suds logs. suds.client.log.addFilter(SudsLogFilter()) diff --git a/oslo_vmware/tests/test_vim_util.py b/oslo_vmware/tests/test_vim_util.py index 27fecaea..36d63751 100644 --- a/oslo_vmware/tests/test_vim_util.py +++ b/oslo_vmware/tests/test_vim_util.py @@ -102,11 +102,6 @@ class VimUtilTest(base.TestCase): 'skip': False, 'selectSet': [rp_to_rp_sel_spec, rp_to_vm_sel_spec]}, - 'cr_to_rp': {'type': 'ComputeResource', - 'path': 'resourcePool', - 'skip': False, - 'selectSet': [rp_to_rp_sel_spec, - rp_to_vm_sel_spec]}, 'ccr_to_h': {'type': 'ClusterComputeResource', 'path': 'host', 'skip': False, diff --git a/test-requirements.txt b/test-requirements.txt index c4f7f31d..3c8beeb2 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,7 +3,7 @@ # process, which may cause wedges in the gate later. # Hacking already pins down pep8, pyflakes and flake8 -hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 +hacking>=3.0,<3.1.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD mock>=2.0.0 # BSD diff --git a/tox.ini b/tox.ini index b13d3f8f..5fc2f94c 100644 --- a/tox.ini +++ b/tox.ini @@ -44,14 +44,18 @@ commands = {posargs} [flake8] show-source = True -ignore = H405 +ignore = H405,W504 exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,__init__.py [hacking] import_exceptions = oslo_vmware.tests.base tests.base -local-check-factory = oslo_vmware.hacking.checks.factory + +[flake8:local-plugins] +extension = + N537 = checks:no_translate_logs +paths = ./oslo_vmware/hacking [testenv:releasenotes] whitelist_externals = rm