Adds a pep8 target to tox.ini

The will now run flake8 on all Python files and bashate on all shell
scripts. Right now I'm ignoring the bashate errors, since there were so
many of them. Follow up patches will start fixing those issues.

A few Python files had minor modifications to pass flake8.

Change-Id: I5f773eb6ea9f1311aa045951ff9bdad16cca6491
This commit is contained in:
David Stanek 2015-07-30 22:20:17 +00:00 committed by Jesse Pretorius
parent ffe1b89dc1
commit 2f3d556c5e
4 changed files with 48 additions and 43 deletions

View File

@ -6,3 +6,4 @@ pyflakes==0.8.1
mccabe==0.2.1 # capped for flake8
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
oslosphinx>=2.5.0 # Apache-2.0
bashate>=0.2 # Apache-2.0

View File

@ -17,12 +17,10 @@
import os
import traceback
from distutils import version
from ansible import errors
from ansible import utils
import yaml
from ansible import utils, errors
VERSION_DESCRIPTORS = ['>=', '<=', '==', '!=', '<', '>']

View File

@ -16,14 +16,15 @@
# under the License.
import logging
import os
import sys
import argparse
import random
import time
from logging.handlers import SysLogHandler
from collections import OrderedDict
import logging
from logging.handlers import SysLogHandler
import os
import random
import sys
import time
from neutronclient.neutron import client
@ -117,10 +118,10 @@ def run(args):
def l3_agent_rebalance(qclient, noop=False):
"""
Rebalance l3 agent router count across agents. The number of routers
on each l3 agent will be as close as possible which should help
distribute load as new l3 agents come online.
"""Rebalance l3 agent router count across agents.
The number of routers on each l3 agent will be as close as possible
which should help distribute load as new l3 agents come online.
:param qclient: A neutronclient
:param noop: Optional noop flag
@ -196,7 +197,7 @@ def l3_agent_rebalance(qclient, noop=False):
low_agent_id)
low_agent_router_count += 1
hgh_agent_router_count -= 1
except:
except Exception:
LOG.exception("Failed to migrate router=%s from agent=%s "
"to agent=%s", router_id, hgh_agent_id,
low_agent_id)
@ -205,9 +206,9 @@ def l3_agent_rebalance(qclient, noop=False):
def l3_agent_check(qclient):
"""
Walk the l3 agents searching for agents that are offline. Show routers
that are offline and where we would migrate them to.
"""Walk the l3 agents searching for agents that are offline.
Show routers that are offline and where we would migrate them to.
:param qclient: A neutronclient
@ -242,10 +243,10 @@ def l3_agent_check(qclient):
def l3_agent_migrate(qclient, noop=False, now=False):
"""
Walk the l3 agents searching for agents that are offline. For those that
are offline, we will retrieve a list of routers on them and migrate them to
a random l3 agent that is online.
"""Walk the l3 agents searching for agents that are offline.
For those that are offline, we will retrieve a list of routers on
them and migrate them to a random l3 agent that is online.
:param qclient: A neutronclient
:param noop: Optional noop flag
@ -300,7 +301,7 @@ def l3_agent_migrate(qclient, noop=False, now=False):
if not noop:
migrate_router(qclient, router_id, agent_id, target_id)
migration_count += 1
except:
except Exception:
LOG.exception("There was an error migrating a router")
continue
@ -309,9 +310,9 @@ def l3_agent_migrate(qclient, noop=False, now=False):
def replicate_dhcp(qclient, noop=False):
"""
Retrieve a network list and then probe each DHCP agent to ensure
they have that network assigned.
"""Retrieve a network list and then probe each DHCP agent
This will ensure they have that network assigned.
:param qclient: A neutronclient
:param noop: Optional noop flag
@ -338,7 +339,7 @@ def replicate_dhcp(qclient, noop=False):
LOG.info("Added missing network=%s to dhcp agent=%s",
network_id, dhcp_agent_id)
added += 1
except:
except Exception:
LOG.exception("Failed to add network_id=%s to"
"dhcp_agent=%s", network_id, dhcp_agent_id)
continue
@ -347,8 +348,7 @@ def replicate_dhcp(qclient, noop=False):
def migrate_router(qclient, router_id, agent_id, target_id):
"""
Returns nothing, and raises on exception
"""Returns nothing, and raises on exception
:param qclient: A neutronclient
:param router_id: The id of the router to migrate
@ -379,8 +379,7 @@ def migrate_router(qclient, router_id, agent_id, target_id):
def list_networks(qclient):
"""
Return a list of network objects
"""Return a list of network objects
:param qclient: A neutronclient
"""
@ -391,8 +390,7 @@ def list_networks(qclient):
def list_dhcp_agent_networks(qclient, agent_id):
"""
Return a list of network ids assigned to a particular DHCP agent
"""Return a list of network ids assigned to a particular DHCP agent
:param qclient: A neutronclient
:param agent_id: A DHCP agent id
@ -404,8 +402,7 @@ def list_dhcp_agent_networks(qclient, agent_id):
def list_routers(qclient):
"""
Return a list of router objects
"""Return a list of router objects
:param qclient: A neutronclient
@ -428,8 +425,7 @@ def list_routers(qclient):
def list_routers_on_l3_agent(qclient, agent_id):
"""
Return a list of router ids on an agent
"""Return a list of router ids on an agent
:param qclient: A neutronclient
"""
@ -514,8 +510,7 @@ def list_agents(qclient, agent_type=None):
def agent_alive_id_list(agent_list, agent_type):
"""
Return a list of agents that are alive from an API list of agents
"""Return a list of agents that are alive from an API list of agents
:param agent_list: API response for list_agents()
@ -525,8 +520,7 @@ def agent_alive_id_list(agent_list, agent_type):
def agent_dead_id_list(agent_list, agent_type):
"""
Return a list of agents that are dead from an API list of agents
"""Return a list of agents that are dead from an API list of agents
:param agent_list: API response for list_agents()

16
tox.ini
View File

@ -1,15 +1,15 @@
[tox]
minversion = 1.6
skipsdist = True
envlist = docs
envlist = docs,pep8
[testenv]
usedevelop = True
install_command = pip install -U {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/dev-requirements.txt
[testenv:docs]
deps = -r{toxinidir}/dev-requirements.txt
commands=
python setup.py build_sphinx
@ -17,3 +17,15 @@ commands=
[testenv:venv]
deps = -r{toxinidir}/dev-requirements.txt
commands = {posargs}
[testenv:pep8]
whitelist_externals = bash
commands =
flake8 {posargs}
# Run bash8 during pep8 runs to ensure violations are caught by
# the check and gate queues
bash -c "find {toxinidir} \
-not -path '*/\.*' \ # stay out of the dot directories
-name '*sh' \ # all shell scripts please
-print0 | xargs -0 bashate -v -i E001,E002,E003,E010,E011,E020,E041"