Add bugbear to flake8 and cleanup some errors

Added a python3 tool called bugbear as part of flake8
Moved the tox.ini for nfv to a new location.
Removed nfv tox calls from the bottom level tox.ini file
Specified the queens upper-constraint. This is because the
kubernetes client from pike is not what is shipped.

Adds a separate tox.ini for nova-api-proxy.

Fix two of the errors flagged by bugbear:
  B006: Do not use mutable data structures for argument defaults.
  B306: BaseException.message has been deprecated as of Python 2.6
       and is removed in Python 3.

Fix unused imports in Flake8
  F401 '<module>' imported but unused

Clean up two pylint errors:
 W0102 dangerous-default-value
 W0631 undefined-loop-variable

Story: 2003499
Task: 26410
Change-Id: I61deb6a002f963cd58fe019bb54a4c3296809391
Signed-off-by: Al Bailey <Al.Bailey@windriver.com>
This commit is contained in:
Al Bailey 2018-09-12 13:42:49 -05:00
parent 6cf70c6c51
commit cb1b85b13f
19 changed files with 544 additions and 234 deletions

View File

@ -3,15 +3,39 @@
check: check:
jobs: jobs:
- openstack-tox-linters - openstack-tox-linters
- openstack-tox-pep8 - nfv-tox-pep8
- nfv-tox-py27
- nfv-tox-pylint - nfv-tox-pylint
- openstack-tox-py27 - nova-api-proxy-tox-pep8
- nova-api-proxy-tox-pylint
gate: gate:
jobs: jobs:
- openstack-tox-linters - openstack-tox-linters
- openstack-tox-pep8 - nfv-tox-pep8
- nfv-tox-py27
- nfv-tox-pylint - nfv-tox-pylint
- openstack-tox-py27 - nova-api-proxy-tox-pep8
- nova-api-proxy-tox-pylint
- job:
name: nfv-tox-py27
parent: tox
description: Run py27 for nfv
required-projects:
- openstack/stx-fault
vars:
tox_envlist: py27
tox_extra_args: -c nfv/tox.ini
- job:
name: nfv-tox-pep8
parent: tox
description: Run pep8 for nfv
required-projects:
- openstack/stx-fault
vars:
tox_envlist: pep8
tox_extra_args: -c nfv/tox.ini
- job: - job:
name: nfv-tox-pylint name: nfv-tox-pylint
@ -21,3 +45,20 @@
- openstack/stx-fault - openstack/stx-fault
vars: vars:
tox_envlist: pylint tox_envlist: pylint
tox_extra_args: -c nfv/tox.ini
- job:
name: nova-api-proxy-tox-pep8
parent: tox
description: Run pep8 for nova-api-proxy
vars:
tox_envlist: pep8
tox_extra_args: -c nova-api-proxy/tox.ini
- job:
name: nova-api-proxy-tox-pylint
parent: tox
description: Run pylint for nova-api-proxy
vars:
tox_envlist: pylint
tox_extra_args: -c nova-api-proxy/tox.ini

7
nfv/.gitignore vendored
View File

@ -1,6 +1 @@
!.distro .coverage
.distro/centos7/rpmbuild/RPMS
.distro/centos7/rpmbuild/SRPMS
.distro/centos7/rpmbuild/BUILD
.distro/centos7/rpmbuild/BUILDROOT
.distro/centos7/rpmbuild/SOURCES/nfv*tar.gz

View File

@ -1,14 +1,14 @@
# #
# Copyright (c) 2015-2016 Wind River Systems, Inc. # Copyright (c) 2018 Wind River Systems, Inc.
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
[run] [run]
branch = True branch = True
source = source =
../../nfv-common nfv-common
../../nfv-plugins nfv-plugins
../../nfv-vim nfv-vim
[report] [report]
include = include =

View File

@ -45,7 +45,6 @@ import sys
import time import time
import plotly import plotly
import plotly.graph_objs as go import plotly.graph_objs as go
from plotly.graph_objs import Scatter, Layout
from plotly import tools from plotly import tools
from glob import iglob from glob import iglob
import subprocess import subprocess
@ -252,7 +251,9 @@ def pCommand(pList):
# Stores the average execution time, or delta hit count data into into a plotly graph obj, and restricts sample to be within a certain # Stores the average execution time, or delta hit count data into into a plotly graph obj, and restricts sample to be within a certain
# date range if specified. If plots is 1, one graph will be generated. If plots is 2, two graphs will be generated with one above the other. # date range if specified. If plots is 1, one graph will be generated. If plots is 2, two graphs will be generated with one above the other.
def storeGraphData(procs, dateRange=[], execTime=False, hits=False, plots=1): def storeGraphData(procs, dateRange=None, execTime=False, hits=False, plots=1):
if dateRange is None:
dateRange = []
graphData = {} graphData = {}
prevHitTotal = 0 prevHitTotal = 0
timeList = [[] for p in range(len(procs))] timeList = [[] for p in range(len(procs))]

View File

@ -7,12 +7,12 @@
# pip install pyyaml # pip install pyyaml
# pip install jinja2 # pip install jinja2
# #
import argparse
import os import os
import shutil
import six import six
import yaml import yaml
import shutil
import pprint
import argparse
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader

View File

@ -12,9 +12,10 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import sys # Uncomment these imports if the extensions below are enabled
import os # import sys
import shlex # import os
# import shlex
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the

View File

@ -404,8 +404,8 @@ def _rest_api_request(token_id, method, api_cmd, api_cmd_headers=None,
pass pass
raise OpenStackRestAPIException(method, api_cmd, api_cmd_headers, raise OpenStackRestAPIException(method, api_cmd, api_cmd_headers,
api_cmd_payload, e.code, e.message, api_cmd_payload, e.code, str(e),
"%s" % e, headers, response_raw, reason) str(e), headers, response_raw, reason)
except urllib2.URLError as e: except urllib2.URLError as e:
now_ms = timers.get_monotonic_timestamp_in_ms() now_ms = timers.get_monotonic_timestamp_in_ms()
@ -416,7 +416,7 @@ def _rest_api_request(token_id, method, api_cmd, api_cmd_headers=None,
int(elapsed_ms))) int(elapsed_ms)))
raise OpenStackException(method, api_cmd, api_cmd_headers, raise OpenStackException(method, api_cmd, api_cmd_headers,
api_cmd_payload, e.message, "%s" % e) api_cmd_payload, str(e), str(e))
def rest_api_request(token, method, api_cmd, api_cmd_headers=None, def rest_api_request(token, method, api_cmd, api_cmd_headers=None,

View File

@ -3,6 +3,8 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
# flake8: noqa
#
from _test_instances import TestInstanceStart, TestInstanceStop from _test_instances import TestInstanceStart, TestInstanceStop
from _test_instances import TestInstancePause, TestInstanceUnpause from _test_instances import TestInstancePause, TestInstanceUnpause
from _test_instances import TestInstanceSuspend, TestInstanceResume from _test_instances import TestInstanceSuspend, TestInstanceResume

View File

@ -3,17 +3,16 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
import os
import time
import shutil
import datetime import datetime
import os
import shutil
import time
from nfv_common import debug from nfv_common import debug
from nfv_plugins.nfvi_plugins import config from nfv_plugins.nfvi_plugins import config
from nfv_plugins.nfvi_plugins.openstack import nova
from nfv_plugins.nfvi_plugins.openstack import sysinv
from nfv_plugins.nfvi_plugins.openstack import fm from nfv_plugins.nfvi_plugins.openstack import fm
from nfv_plugins.nfvi_plugins.openstack import nova
from nfv_plugins.nfvi_plugins.openstack import openstack from nfv_plugins.nfvi_plugins.openstack import openstack
import _instances import _instances

View File

@ -1 +0,0 @@
.coverage

View File

@ -1,100 +0,0 @@
#
# Copyright (c) 2015-2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[nfv]
nfv_base_dir = ../..
nfv_client_dir = ../../nfv-client
nfv_common_dir = ../../nfv-common
nfv_plugins_dir = ../../nfv-plugins
nfv_vim_dir = ../../nfv-vim
stx_fault_dir = ../../../../stx-fault
nfv_client_src_dir = {[nfv]nfv_client_dir}/nfv_client
nfv_common_src_dir = {[nfv]nfv_common_dir}/nfv_common
nfv_plugins_src_dir = {[nfv]nfv_plugins_dir}/nfv_plugins
nfv_vim_src_dir = {[nfv]nfv_vim_dir}/nfv_vim
deps = {[nfv]nfv_client_dir}
{[nfv]nfv_common_dir}
{[nfv]nfv_plugins_dir}
{[nfv]nfv_vim_dir}
{[nfv]stx_fault_dir}/fm-api
iso8601
keyring
kombu
kubernetes
passlib
pecan
pyparsing
PyYAML
sqlalchemy
stevedore
wsme
[nosetests]
verbosity=2
[tox]
toxworkdir = /tmp/{env:USER}_nfvtox
envlist = pep8,py27-sqlite
[testenv]
recreate = True
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
[testenv:pep8]
deps = flake8
commands = flake8 --max-line-length 84 {[nfv]nfv_client_dir}
flake8 --max-line-length 84 {[nfv]nfv_common_dir}
flake8 --max-line-length 84 {[nfv]nfv_plugins_dir}
flake8 --max-line-length 84 {[nfv]nfv_vim_dir}
[testenv:lint]
deps = {[nfv]deps}
pylint
basepython = python2.7
commands = pylint {[nfv]nfv_client_src_dir} \
{[nfv]nfv_common_src_dir} \
{[nfv]nfv_plugins_src_dir} \
{[nfv]nfv_vim_src_dir} \
--rcfile=./pylint.rc
[bandit]
# These are the bandit codes that are failing for stx-nfv
# B104: hardcoded_bind_all_interfaces
# B108: Probable insecure usage of temp file/directory
# B110: Try, Except, Pass detected.
# B310: Audit url open for permitted schemes
# B506: Test for use of yaml load
skips = B104,B108,B110,B310,B506
exclude = nfv-docs,nfv-tests,nfv-debug-tools,unit_test
[testenv:bandit]
deps = {[nfv]deps}
bandit
basepython = python2.7
commands = bandit --ini tox.ini -f txt -r {[nfv]nfv_base_dir}
[testenv:py27-sqlite]
basepython = py27-sqlite: python2.7
deps = {[nfv]deps}
mock
nose
coverage
setenv = PYTHONDONTWRITEBYTECODE=True
#commands = nosetests --pdb --exe -w tests/
commands = cp -v ./test_data/nfv_vim_db_18.03_GA {envdir}/
{envbindir}/nosetests --exe -w tests/ '{posargs}'
# Use the following for code coverage
# {envbindir}/nosetests --exe --cover-erase --cover-branches \
# --cover-package=nfv_common,nfv_vim --with-coverage -w tests/
whitelist_externals = cp

View File

@ -29,10 +29,12 @@ def _migrate_instances_v4_to_v5(session, instances_v4, instances_v5):
# We can build the flavor details embedded in the instance from # We can build the flavor details embedded in the instance from
# the flavor referenced from the original instance. # the flavor referenced from the original instance.
for instance_type in instance_types: instance_type = None
if instance_type.uuid == instance_type_uuid: for i_type in instance_types:
if i_type.uuid == instance_type_uuid:
instance_type = i_type
break break
else: if instance_type is None:
DLOG.error("Missing instance type: %s" % instance_type_uuid) DLOG.error("Missing instance type: %s" % instance_type_uuid)
continue continue

View File

@ -158,7 +158,7 @@ class SwUpdateStrategy(strategy.Strategy):
""" """
from nfv_vim import tables from nfv_vim import tables
def has_policy_conflict(): def has_policy_conflict(peer_host):
for instance in instance_table.on_host(host.name): for instance in instance_table.on_host(host.name):
for peer_instance in instance_table.on_host(peer_host.name): for peer_instance in instance_table.on_host(peer_host.name):
for policy in policies: for policy in policies:
@ -308,7 +308,7 @@ class SwUpdateStrategy(strategy.Strategy):
continue continue
for peer_host in host_list: for peer_host in host_list:
if has_policy_conflict(): if has_policy_conflict(peer_host):
# don't add host to the current list # don't add host to the current list
break break
else: else:

View File

@ -1461,10 +1461,11 @@ class QueryAlarmsStep(strategy.StrategyStep):
""" """
Query Alarms - Strategy Step Query Alarms - Strategy Step
""" """
def __init__(self, fail_on_alarms=False, ignore_alarms=[]): def __init__(self, fail_on_alarms=False, ignore_alarms=None):
super(QueryAlarmsStep, self).__init__( super(QueryAlarmsStep, self).__init__(
STRATEGY_STEP_NAME.QUERY_ALARMS, timeout_in_secs=60) STRATEGY_STEP_NAME.QUERY_ALARMS, timeout_in_secs=60)
if ignore_alarms is None:
ignore_alarms = []
self._fail_on_alarms = fail_on_alarms self._fail_on_alarms = fail_on_alarms
self._ignore_alarms = ignore_alarms self._ignore_alarms = ignore_alarms
@ -1543,10 +1544,11 @@ class WaitDataSyncStep(strategy.StrategyStep):
""" """
Alarm Wait - Strategy Step Alarm Wait - Strategy Step
""" """
def __init__(self, timeout_in_secs=300, ignore_alarms=[]): def __init__(self, timeout_in_secs=300, ignore_alarms=None):
super(WaitDataSyncStep, self).__init__( super(WaitDataSyncStep, self).__init__(
STRATEGY_STEP_NAME.WAIT_DATA_SYNC, timeout_in_secs=timeout_in_secs) STRATEGY_STEP_NAME.WAIT_DATA_SYNC, timeout_in_secs=timeout_in_secs)
if ignore_alarms is None:
ignore_alarms = []
self._ignore_alarms = ignore_alarms self._ignore_alarms = ignore_alarms
self._wait_time = 0 self._wait_time = 0
self._query_inprogress = False self._query_inprogress = False

View File

@ -26,7 +26,6 @@ load-plugins=
# can either give multiple identifier separated by comma (,) or put this option # can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where # multiple time (only on the command line, not in the configuration file where
# it should appear only once). # it should appear only once).
# W0102 dangerous-default-value
# W0107 unnecessary-pass # W0107 unnecessary-pass
# W0120 useless-else-on-loop # W0120 useless-else-on-loop
# W0125 using-constant-test # W0125 using-constant-test
@ -44,12 +43,11 @@ load-plugins=
# W0612 Unused variable warning # W0612 Unused variable warning
# W0613 Unused argument warning # W0613 Unused argument warning
# W0621 redefined-outer-name # W0621 redefined-outer-name
# W0631 undefined-loop-variable
# W0622 redefined-builtin # W0622 redefined-builtin
# W0703 broad except warning # W0703 broad except warning
# W1401 anomalous-backslash-in-string # W1401 anomalous-backslash-in-string
disable=C, R, W0102, W0107, W0120, W0125, W0212, W0221, W0223, W0231, W0235, W0311, disable=C, R, W0107, W0120, W0125, W0212, W0221, W0223, W0231, W0235, W0311,
W0401, W0403, W0404, W0511, W0603, W0612, W0613, W0621, W0622, W0631, W0703, W1401 W0401, W0403, W0404, W0511, W0603, W0612, W0613, W0621, W0622, W0703, W1401
[REPORTS] [REPORTS]

158
nfv/tox.ini Executable file
View File

@ -0,0 +1,158 @@
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[tox]
toxworkdir = /tmp/{env:USER}_nfvtox
envlist = pep8,py27,pylint
skipsdist = True
stxdir = {toxinidir}/../..
[testenv]
recreate = True
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/queens} {opts} {packages}
whitelist_externals = cp
[nfv]
nfv_base_dir = .
nfv_client_dir = ./nfv-client
nfv_common_dir = ./nfv-common
nfv_plugins_dir = ./nfv-plugins
nfv_vim_dir = ./nfv-vim
stx_fault_dir = ../../stx-fault
nfv_client_src_dir = {[nfv]nfv_client_dir}/nfv_client
nfv_common_src_dir = {[nfv]nfv_common_dir}/nfv_common
nfv_plugins_src_dir = {[nfv]nfv_plugins_dir}/nfv_plugins
nfv_vim_src_dir = {[nfv]nfv_vim_dir}/nfv_vim
deps = {[nfv]nfv_client_dir}
{[nfv]nfv_common_dir}
{[nfv]nfv_plugins_dir}
{[nfv]nfv_vim_dir}
{[nfv]stx_fault_dir}/fm-api
iso8601
keyring
kombu
kubernetes
passlib
pecan
pyparsing
PyYAML
sqlalchemy
stevedore
wsme
[nosetests]
verbosity=2
[flake8]
# Temporarily ignoring these warnings
# E121 continuation line under-indented for hanging indent
# E122 continuation line missing indentation or outdented
# E123 closing bracket does not match indentation of opening bracket
# E124 closing bracket does not match visual indentation
# E126 continuation line over-indented for hanging indent
# E127 continuation line over-indented for visual indent
# E128 continuation line under-indented for visual indent
# E129 visually indented line with same indent as next logical line
# E501 line too long
# E712 comparison to bool should be reworded
# - hacking codes -
# H102: license header not found
# H104: File contains nothing but comments
# H301: one import per line
# H306: imports not in alphabetical order
# H401: docstring should not start with a space
# H404: multi line docstring should start without a leading new line
# H405: multi line docstring summary not separated with an empty line
# H501: Do not use self.__dict__ for string formatting
# - flake8 codes -
# F821 undefined name 'unicode' (python3 specific)
# - bugbear codes -
# B007 Loop control variable 'X' not used within the loop body. If this is intended, start the name with an underscore.
# B301 Python 3 does not include `.iter*` methods on dictionaries.
ignore = E121,E122,E123,E124,E126,E127,E128,E129,E501,E712,
H102,H104,H301,H306,H401,H404,H405,H501,
F821,
B007, B301
# H106 Dont put vim configuration in source files (off by default).
# H203 Use assertIs(Not)None to check for None (off by default).
# TODO: enable: H904 Delay string interpolations at logging calls (off by default).
enable-extensions = H106,H203
max-line-length = 84
[testenv:pep8]
basepython = python3.5
usedevelop = False
skip_install = True
deps =
hacking
flake8-bugbear
flake8
commands =
flake8 {[nfv]nfv_base_dir}
[testenv:pylint]
deps = {[nfv]deps}
pylint
basepython = python2.7
commands = pylint {[nfv]nfv_client_src_dir} \
{[nfv]nfv_common_src_dir} \
{[nfv]nfv_plugins_src_dir} \
{[nfv]nfv_vim_src_dir} \
--rcfile=./pylint.rc
[bandit]
# These are the bandit codes that are failing for stx-nfv
# B104: hardcoded_bind_all_interfaces
# B108: Probable insecure usage of temp file/directory
# B110: Try, Except, Pass detected.
# B310: Audit url open for permitted schemes
# B506: Test for use of yaml load
skips = B104,B108,B110,B310,B506
exclude = nfv-docs,nfv-tests,nfv-debug-tools,unit_test
[testenv:bandit]
deps = {[nfv]deps}
bandit
basepython = python2.7
commands = bandit --ini tox.ini -f txt -r {[nfv]nfv_base_dir}
[testenv:py27]
basepython = python2.7
deps = {[nfv]deps}
mock
nose
coverage
setenv = PYTHONDONTWRITEBYTECODE=True
commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_18.03_GA {envdir}/
{envbindir}/nosetests --exe -w {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests/ '{posargs}'
[testenv:py35]
basepython = python3.5
deps = {[nfv]deps}
mock
nose
coverage
setenv = PYTHONDONTWRITEBYTECODE=True
commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_18.03_GA {envdir}/
{envbindir}/nosetests --exe -w {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests/ '{posargs}'
[testenv:cover]
basepython = python2.7
deps = {[nfv]deps}
mock
nose
coverage
setenv = PYTHONDONTWRITEBYTECODE=True
commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_18.03_GA {envdir}/
{envbindir}/nosetests --exe --cover-erase --cover-branches \
--cover-package=nfv_common,nfv_vim --with-coverage -w {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests/

222
nova-api-proxy/pylint.rc Executable file
View File

@ -0,0 +1,222 @@
[MASTER]
# Specify a configuration file.
rcfile=pylint.rc
# Python code to execute, usually for sys.path manipulation such as pygtk.require().
#init-hook=
# Add files or directories to the blacklist. They should be base names, not paths.
ignore=unit_test.py
# Pickle collected data for later comparisons.
persistent=yes
# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=
[MESSAGES CONTROL]
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time.
#enable=
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
# E1101 no-member
# E1121: Too many positional arguments for function call
# W0107 unnecessary-pass
# W0404 reimported
# W0601 Global variable %r undefined at the module level
# W0603 Using the global statement warning
# W0613 Unused argument warning
# W0621 Redefining name %r from outer scope
# W0703 broad except warning
disable=C, R, E1101, E1121, W0107, W0404, W0601, W0603, W0613, W0621, W0703
[REPORTS]
# Set the output format. Available formats are text, parseable, colorized, msvs
# (visual studio) and html
output-format=text
# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
# written in a file name "pylint_global.[txt|html]".
files-output=no
# Tells whether to display a full report or only the messages
reports=no
# Python expression which should return a note less than 10 (10 is the highest
# note). You have access to the variables errors warning, statement which
# respectively contain the number of errors / warnings messages and the total
# number of statements analyzed. This is used by the global evaluation report
# (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
[SIMILARITIES]
# Minimum lines number of a similarity.
min-similarity-lines=4
# Ignore comments when computing similarities.
ignore-comments=yes
# Ignore docstrings when computing similarities.
ignore-docstrings=yes
[FORMAT]
# Maximum number of characters on a single line.
max-line-length=85
# Maximum number of lines in a module
max-module-lines=1000
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 tab).
indent-string=' '
[TYPECHECK]
# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
ignore-mixin-members=yes
# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set).
# The following VIM objects are ignored: ObjectData, GuestService, Network, SwUpdate
ignored-classes=SQLObject,sqlalchemy,scoped_session,_socketobject,ObjectData,GuestService,Network,SwUpdate
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E0201 when accessed. Python regular
# expressions are accepted.
generated-members=REQUEST,acl_users,aq_parent
[BASIC]
# List of builtins function names that should not be used, separated by a comma
bad-functions=map,filter,apply,input
# Regular expression which should only match correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
# Regular expression which should only match correct module level names
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
# Regular expression which should only match correct class names
class-rgx=[A-Z_][a-zA-Z0-9]+$
# Regular expression which should only match correct function names
function-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct method names
method-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct instance attribute names
attr-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct argument names
argument-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct variable names
variable-rgx=[a-z_][a-z0-9_]{2,30}$
# Regular expression which should only match correct list comprehension /
# generator expression variable names
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
# Good variable names which should always be accepted, separated by a comma
good-names=i,j,k,ex,Run,_
# Bad variable names which should always be refused, separated by a comma
bad-names=foo,bar,baz,toto,tutu,tata
# Regular expression which should only match functions or classes name which do
# not require a docstring
no-docstring-rgx=__.*__
[MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma.
notes=FIXME,XXX,TODO
[VARIABLES]
# Tells whether we should check for unused import in __init__ files.
init-import=no
# A regular expression matching the beginning of the name of dummy variables
# (i.e. not used).
dummy-variables-rgx=_|dummy
# List of additional names supposed to be defined in builtins. Remember that
# you should avoid to define new builtins when possible.
additional-builtins=
[IMPORTS]
# Deprecated modules which should not be used, separated by a comma
deprecated-modules=regsub,string,TERMIOS,Bastion,rexec
# Create a graph of every (i.e. internal and external) dependencies in the
# given file (report RP0402 must not be disabled)
import-graph=
# Create a graph of external dependencies in the given file (report RP0402 must
# not be disabled)
ext-import-graph=
# Create a graph of internal dependencies in the given file (report RP0402 must
# not be disabled)
int-import-graph=
[DESIGN]
# Maximum number of arguments for function / method
max-args=5
# Argument names that match this expression will be ignored. Default to name
# with leading underscore
ignored-argument-names=_.*
# Maximum number of locals for function / method body
max-locals=15
# Maximum number of return / yield for function / method body
max-returns=6
# Maximum number of branch for function / method body
max-branchs=12
# Maximum number of statements in function / method body
max-statements=50
# Maximum number of parents for a class (see R0901).
max-parents=7
# Maximum number of attributes for a class (see R0902).
max-attributes=7
# Minimum number of public methods for a class (see R0903).
min-public-methods=2
# Maximum number of public methods for a class (see R0904).
max-public-methods=20
[CLASSES]
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,__new__,setUp
# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
[EXCEPTIONS]
# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception

65
nova-api-proxy/tox.ini Normal file
View File

@ -0,0 +1,65 @@
[tox]
envlist = pep8,pylint
minversion = 2.3
skipsdist = True
[testenv]
basepython = python3
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/pike} {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=60
PYTHONDONTWRITEBYTECODE=True
commands = find {toxinidir} -type f -not -path '{toxinidir}/.tox/*' -not -path '*/__pycache__/*' -name '*.py[c|o]' -delete
whitelist_externals = find
[testenv:venv]
commands = {posargs}
[flake8]
# Temporarily ignoring these warnings
# E123 closing bracket does not match indentation of opening bracket
# E127 continuation line over-indented for visual indent
# E129 visually indented line with same indent as next logical line
# - hacking codes -
# H104: File contains nothing but comments
# H301: one import per line
# H306: imports not in alphabetical order
# H404: multi line docstring should start without a leading new line
# H405: multi line docstring summary not separated with an empty line
# H501: Do not use self.__dict__ for string formatting
# - flake8 codes -
# F821 undefined name 'unicode' (python3 specific)
ignore=E123,E127,E129
H104,H301,H306,H404,H405,H501,
F821
# H106 Dont put vim configuration in source files (off by default).
# H203 Use assertIs(Not)None to check for None (off by default).
# TODO: enable: H904 Delay string interpolations at logging calls (off by default).
enable-extensions = H106,H203
max-line-length=84
[testenv:pep8]
usedevelop = False
skip_install = True
deps =
hacking
flake8-bugbear
flake8
commands =
flake8
[testenv:pylint]
basepython = python2.7
deps =
eventlet
oslo.config
oslo.log
paste
PasteDeploy
routes
webob
pylint
commands = pylint nova-api-proxy/nova_api_proxy --rcfile=pylint.rc

105
tox.ini
View File

@ -1,19 +1,30 @@
[tox] [tox]
envlist = linters,pep8,py27,pylint envlist = linters
minversion = 2.3 minversion = 2.3
skipsdist = True skipsdist = True
[testenv] [testenv]
basepython = python3 basepython = python3
install_command = pip install -U {opts} {packages}
setenv = VIRTUAL_ENV={envdir} setenv = VIRTUAL_ENV={envdir}
OS_STDOUT_CAPTURE=1 OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1 OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=60 OS_TEST_TIMEOUT=60
PYTHONDONTWRITEBYTECODE=True PYTHONDONTWRITEBYTECODE=True
install_command = pip install -U {opts} {packages}
commands = find {toxinidir} -type f -not -path '{toxinidir}/.tox/*' -not -path '*/__pycache__/*' -name '*.py[c|o]' -delete commands = find {toxinidir} -type f -not -path '{toxinidir}/.tox/*' -not -path '*/__pycache__/*' -name '*.py[c|o]' -delete
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/test-requirements.txt
[testenv:venv]
commands = {posargs}
[testenv:flake8]
description = Dummy environment to allow flake8 to be run in subdir tox
[testenv:pep8]
description = Dummy environment to allow pep8 to be run in subdir tox
[testenv:pylint]
description = Dummy environment to allow pylint to be run in subdir tox
[testenv:linters] [testenv:linters]
whitelist_externals = bash whitelist_externals = bash
@ -24,89 +35,3 @@ commands =
-o -type f -name '*.yaml' \ -o -type f -name '*.yaml' \
-print0 | xargs -0 yamllint" -print0 | xargs -0 yamllint"
[flake8]
# Temporarily ignoring these warnings
# E121 continuation line under-indented for hanging indent
# E122 continuation line missing indentation or outdented
# E123 closing bracket does not match indentation of opening bracket
# E124 closing bracket does not match visual indentation
# E126 continuation line over-indented for hanging indent
# E127 continuation line over-indented for visual indent
# E128 continuation line under-indented for visual indent
# E129 visually indented line with same indent as next logical line
# E501 line too long
# E712 comparison to bool should be reworded
# - hacking codes -
# H102: license header not found
# H104: File contains nothing but comments
# H301: one import per line
# H306: imports not in alphabetical order
# H401: docstring should not start with a space
# H404: multi line docstring should start without a leading new line
# H405: multi line docstring summary not separated with an empty line
# H501: Do not use self.__dict__ for string formatting
# - flake8 codes -
# F401 '<module>' imported but unused
# F821 undefined name 'unicode' (python3 specific)
ignore = E121,E122,E123,E124,E126,E127,E128,E129,E501,E712,
H102,H104,H301,H306,H401,H404,H405,H501,
F401,F821,
# H106 Dont put vim configuration in source files (off by default).
# H203 Use assertIs(Not)None to check for None (off by default).
# TODO: enable: H904 Delay string interpolations at logging calls (off by default).
enable-extensions = H106,H203
[testenv:pep8]
usedevelop = False
skip_install = True
deps =
hacking
flake8
commands =
flake8
[testenv:venv]
commands = {posargs}
[nosetests]
verbosity=2
[testenv:py27]
basepython = python2.7
deps = {[testenv]deps}
{toxinidir}/nfv/nfv-client
{toxinidir}/nfv/nfv-common
{toxinidir}/nfv/nfv-plugins
{toxinidir}/nfv/nfv-vim
whitelist_externals = cp
find
recreate = True
commands = {[testenv]commands}
cp -v nfv/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_18.03_GA {envdir}/
nosetests --exe -w nfv/nfv-tests/nfv_unit_tests/tests/ '{posargs}'
[testenv:pylint]
basepython = python2.7
deps = {[testenv]deps}
{toxinidir}/nfv/nfv-client
{toxinidir}/nfv/nfv-common
{toxinidir}/nfv/nfv-plugins
{toxinidir}/nfv/nfv-vim
{toxinidir}/../stx-fault/fm-api
iso8601
keyring
kombu
kubernetes
passlib
pecan
pyparsing
wsme
pylint
whitelist_externals = cp
find
commands = pylint nfv/nfv-client/nfv_client \
nfv/nfv-common/nfv_common \
nfv/nfv-plugins/nfv_plugins \
nfv/nfv-vim/nfv_vim \
--rcfile=nfv/nfv-tests/nfv_unit_tests/pylint.rc