diff --git a/.zuul.yaml b/.zuul.yaml index e8c167df..109158b9 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -3,15 +3,39 @@ check: jobs: - openstack-tox-linters - - openstack-tox-pep8 + - nfv-tox-pep8 + - nfv-tox-py27 - nfv-tox-pylint - - openstack-tox-py27 + - nova-api-proxy-tox-pep8 + - nova-api-proxy-tox-pylint gate: jobs: - openstack-tox-linters - - openstack-tox-pep8 + - nfv-tox-pep8 + - nfv-tox-py27 - 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: name: nfv-tox-pylint @@ -21,3 +45,20 @@ - openstack/stx-fault vars: 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 diff --git a/nfv/.gitignore b/nfv/.gitignore index 520e548f..6350e986 100644 --- a/nfv/.gitignore +++ b/nfv/.gitignore @@ -1,6 +1 @@ -!.distro -.distro/centos7/rpmbuild/RPMS -.distro/centos7/rpmbuild/SRPMS -.distro/centos7/rpmbuild/BUILD -.distro/centos7/rpmbuild/BUILDROOT -.distro/centos7/rpmbuild/SOURCES/nfv*tar.gz +.coverage diff --git a/nfv/nfv-tests/nfv_unit_tests/coverage.ini b/nfv/coverage.ini similarity index 55% rename from nfv/nfv-tests/nfv_unit_tests/coverage.ini rename to nfv/coverage.ini index d42cb5de..ae9df785 100755 --- a/nfv/nfv-tests/nfv_unit_tests/coverage.ini +++ b/nfv/coverage.ini @@ -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 # [run] branch = True source = - ../../nfv-common - ../../nfv-plugins - ../../nfv-vim + nfv-common + nfv-plugins + nfv-vim [report] include = diff --git a/nfv/nfv-debug-tools/histogram_analysis/plotter.py b/nfv/nfv-debug-tools/histogram_analysis/plotter.py index b2d19749..aff92078 100755 --- a/nfv/nfv-debug-tools/histogram_analysis/plotter.py +++ b/nfv/nfv-debug-tools/histogram_analysis/plotter.py @@ -45,7 +45,6 @@ import sys import time import plotly import plotly.graph_objs as go -from plotly.graph_objs import Scatter, Layout from plotly import tools from glob import iglob 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 # 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 = {} prevHitTotal = 0 timeList = [[] for p in range(len(procs))] diff --git a/nfv/nfv-docs/doc_builder.py b/nfv/nfv-docs/doc_builder.py index 3307d23b..9fe80f32 100755 --- a/nfv/nfv-docs/doc_builder.py +++ b/nfv/nfv-docs/doc_builder.py @@ -7,12 +7,12 @@ # pip install pyyaml # pip install jinja2 # +import argparse import os +import shutil import six import yaml -import shutil -import pprint -import argparse + from jinja2 import Environment, FileSystemLoader diff --git a/nfv/nfv-docs/html_layout/conf.py b/nfv/nfv-docs/html_layout/conf.py index 7bd1de6c..c13ecf6a 100644 --- a/nfv/nfv-docs/html_layout/conf.py +++ b/nfv/nfv-docs/html_layout/conf.py @@ -12,9 +12,10 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys -import os -import shlex +# Uncomment these imports if the extensions below are enabled +# import sys +# import os +# import shlex # 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 diff --git a/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/openstack/rest_api.py b/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/openstack/rest_api.py index 0044c2a9..94066f99 100755 --- a/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/openstack/rest_api.py +++ b/nfv/nfv-plugins/nfv_plugins/nfvi_plugins/openstack/rest_api.py @@ -404,8 +404,8 @@ def _rest_api_request(token_id, method, api_cmd, api_cmd_headers=None, pass raise OpenStackRestAPIException(method, api_cmd, api_cmd_headers, - api_cmd_payload, e.code, e.message, - "%s" % e, headers, response_raw, reason) + api_cmd_payload, e.code, str(e), + str(e), headers, response_raw, reason) except urllib2.URLError as e: 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))) 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, diff --git a/nfv/nfv-tests/nfv_scenario_tests/tests/__init__.py b/nfv/nfv-tests/nfv_scenario_tests/tests/__init__.py index 369b7eee..f8b542cf 100755 --- a/nfv/nfv-tests/nfv_scenario_tests/tests/__init__.py +++ b/nfv/nfv-tests/nfv_scenario_tests/tests/__init__.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: Apache-2.0 # +# flake8: noqa +# from _test_instances import TestInstanceStart, TestInstanceStop from _test_instances import TestInstancePause, TestInstanceUnpause from _test_instances import TestInstanceSuspend, TestInstanceResume diff --git a/nfv/nfv-tests/nfv_scenario_tests/tests/_test_instances.py b/nfv/nfv-tests/nfv_scenario_tests/tests/_test_instances.py index cafc2a3e..128760a2 100755 --- a/nfv/nfv-tests/nfv_scenario_tests/tests/_test_instances.py +++ b/nfv/nfv-tests/nfv_scenario_tests/tests/_test_instances.py @@ -3,17 +3,16 @@ # # SPDX-License-Identifier: Apache-2.0 # -import os -import time -import shutil import datetime +import os +import shutil +import time from nfv_common import debug 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 nova from nfv_plugins.nfvi_plugins.openstack import openstack import _instances diff --git a/nfv/nfv-tests/nfv_unit_tests/.gitignore b/nfv/nfv-tests/nfv_unit_tests/.gitignore deleted file mode 100755 index c5cb1afa..00000000 --- a/nfv/nfv-tests/nfv_unit_tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.coverage \ No newline at end of file diff --git a/nfv/nfv-tests/nfv_unit_tests/tox.ini b/nfv/nfv-tests/nfv_unit_tests/tox.ini deleted file mode 100755 index 13a7a0d7..00000000 --- a/nfv/nfv-tests/nfv_unit_tests/tox.ini +++ /dev/null @@ -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 diff --git a/nfv/nfv-vim/nfv_vim/database/_database_migrate.py b/nfv/nfv-vim/nfv_vim/database/_database_migrate.py index 90708e6b..ca4c3f35 100755 --- a/nfv/nfv-vim/nfv_vim/database/_database_migrate.py +++ b/nfv/nfv-vim/nfv_vim/database/_database_migrate.py @@ -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 # the flavor referenced from the original instance. - for instance_type in instance_types: - if instance_type.uuid == instance_type_uuid: + instance_type = None + for i_type in instance_types: + if i_type.uuid == instance_type_uuid: + instance_type = i_type break - else: + if instance_type is None: DLOG.error("Missing instance type: %s" % instance_type_uuid) continue diff --git a/nfv/nfv-vim/nfv_vim/strategy/_strategy.py b/nfv/nfv-vim/nfv_vim/strategy/_strategy.py index a179a1b8..642fe8bb 100755 --- a/nfv/nfv-vim/nfv_vim/strategy/_strategy.py +++ b/nfv/nfv-vim/nfv_vim/strategy/_strategy.py @@ -158,7 +158,7 @@ class SwUpdateStrategy(strategy.Strategy): """ 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 peer_instance in instance_table.on_host(peer_host.name): for policy in policies: @@ -308,7 +308,7 @@ class SwUpdateStrategy(strategy.Strategy): continue for peer_host in host_list: - if has_policy_conflict(): + if has_policy_conflict(peer_host): # don't add host to the current list break else: diff --git a/nfv/nfv-vim/nfv_vim/strategy/_strategy_steps.py b/nfv/nfv-vim/nfv_vim/strategy/_strategy_steps.py index 42180852..1afe11bb 100755 --- a/nfv/nfv-vim/nfv_vim/strategy/_strategy_steps.py +++ b/nfv/nfv-vim/nfv_vim/strategy/_strategy_steps.py @@ -1461,10 +1461,11 @@ class QueryAlarmsStep(strategy.StrategyStep): """ 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__( STRATEGY_STEP_NAME.QUERY_ALARMS, timeout_in_secs=60) - + if ignore_alarms is None: + ignore_alarms = [] self._fail_on_alarms = fail_on_alarms self._ignore_alarms = ignore_alarms @@ -1543,10 +1544,11 @@ class WaitDataSyncStep(strategy.StrategyStep): """ 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__( 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._wait_time = 0 self._query_inprogress = False diff --git a/nfv/nfv-tests/nfv_unit_tests/pylint.rc b/nfv/pylint.rc similarity index 97% rename from nfv/nfv-tests/nfv_unit_tests/pylint.rc rename to nfv/pylint.rc index 042d61d9..d3ce7a8c 100755 --- a/nfv/nfv-tests/nfv_unit_tests/pylint.rc +++ b/nfv/pylint.rc @@ -26,7 +26,6 @@ load-plugins= # 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). -# W0102 dangerous-default-value # W0107 unnecessary-pass # W0120 useless-else-on-loop # W0125 using-constant-test @@ -44,12 +43,11 @@ load-plugins= # W0612 Unused variable warning # W0613 Unused argument warning # W0621 redefined-outer-name -# W0631 undefined-loop-variable # W0622 redefined-builtin # W0703 broad except warning # W1401 anomalous-backslash-in-string -disable=C, R, W0102, W0107, W0120, W0125, W0212, W0221, W0223, W0231, W0235, W0311, - W0401, W0403, W0404, W0511, W0603, W0612, W0613, W0621, W0622, W0631, W0703, W1401 +disable=C, R, W0107, W0120, W0125, W0212, W0221, W0223, W0231, W0235, W0311, + W0401, W0403, W0404, W0511, W0603, W0612, W0613, W0621, W0622, W0703, W1401 [REPORTS] diff --git a/nfv/tox.ini b/nfv/tox.ini new file mode 100755 index 00000000..d3bd018b --- /dev/null +++ b/nfv/tox.ini @@ -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 Don’t 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/ diff --git a/nova-api-proxy/pylint.rc b/nova-api-proxy/pylint.rc new file mode 100755 index 00000000..8a2a5694 --- /dev/null +++ b/nova-api-proxy/pylint.rc @@ -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 diff --git a/nova-api-proxy/tox.ini b/nova-api-proxy/tox.ini new file mode 100644 index 00000000..b0bf8d0c --- /dev/null +++ b/nova-api-proxy/tox.ini @@ -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 Don’t 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 + diff --git a/tox.ini b/tox.ini index b311a205..5ca89ea0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,19 +1,30 @@ [tox] -envlist = linters,pep8,py27,pylint +envlist = linters minversion = 2.3 skipsdist = True [testenv] basepython = python3 -install_command = pip install -U {opts} {packages} setenv = VIRTUAL_ENV={envdir} OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_TEST_TIMEOUT=60 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 -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt +deps = -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] whitelist_externals = bash @@ -24,89 +35,3 @@ commands = -o -type f -name '*.yaml' \ -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 '' 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 Don’t 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 -