Reuse neutron-lib for pep8 hacking checks

neutron library has a good hacking rules set, we can use these rules
instead of reinvent the wheel. These such rules are:

- [N521] Validate that jsonutils module is used instead of json
- [N532] Validate that LOG.warning is used instead of LOG.warn. The
         latter is deprecated.
- [N537] Don't translate logs.
- [N534] Exception messages should be translated

It also enables H904, which allows the logging package to skip
creating the formatted log message if the message is not going
to be emitted because of the current log level.

Change-Id: I3b3649bbe8a7a3ae69d3ea1553923567b5a350d7
Closes-Bug: #1704691
This commit is contained in:
Ngo Quoc Cuong 2017-07-17 03:44:33 -04:00
parent 12144fbe78
commit 17a3b25921
3 changed files with 8 additions and 5 deletions

View File

@ -99,7 +99,7 @@ class CinderConnector(fuxi_connector.Connector):
brick_connector = brick_get_connector(protocol)
device_info = brick_connector.connect_volume(conn_info['data'])
LOG.info("Get device_info after connect to "
"volume %s" % device_info)
"volume %s", device_info)
try:
link_path = os.path.join(consts.VOLUME_LINK_DIR, volume.id)
utils.execute('ln', '-s', os.path.realpath(device_info['path']),

View File

@ -40,7 +40,8 @@ def init_app_conf():
# Init volume providers.
volume_providers = CONF.volume_providers
if not volume_providers:
raise Exception("Must define volume providers in configuration file")
raise Exception(_("Must define volume providers in "
"configuration file"))
app.volume_providers = collections.OrderedDict()
for provider in volume_providers:
@ -51,7 +52,8 @@ def init_app_conf():
else:
LOG.warning("Could not find volume provider: %s", provider)
if not app.volume_providers:
raise Exception("Not provide at least one effective volume provider")
raise Exception(_("Not provide at least one effective "
"volume provider"))
# Init volume store directory.
try:

View File

@ -41,12 +41,13 @@ setenv = OS_TEST_PATH=./fuxi/tests/fullstack
[flake8]
show-source = True
enable-extensions = H106,H203
enable-extensions = H106,H203,H904
builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,releasenotes
[hacking]
import_exceptions = fuxi.i18n, fuxi.tests
import_exceptions = fuxi.tests
local-check-factory = neutron_lib.hacking.checks.factory
[testenv:genconfig]
commands = oslo-config-generator --config-file=etc/oslo-config-generator/fuxi-config-generator.conf