Update for new pep8 rules E402 and W503

Change-Id: I181f396b002d0c3b89579c4fc33c34b1c099953e
This commit is contained in:
Michael Johnson 2017-03-08 11:29:15 -08:00 committed by Ihar Hrachyshka
parent 56eaa21f9f
commit 7fdc8a1e06
46 changed files with 147 additions and 147 deletions

View File

@ -27,6 +27,7 @@ import subprocess
import sys
import warnings
from octavia.version import version_info
import openstackdocstheme
extensions = [
@ -71,7 +72,6 @@ copyright = u'2017-present, OpenStack Foundation'
# |version| and |release|, also used in various other places throughout the
# built documents.
#
from octavia.version import version_info
# The full version, including alpha/beta/rc tags.
release = version_info.release_string()
# The short X.Y version.

View File

@ -131,8 +131,8 @@ class AmphoraInfo(object):
for interface in netns.get_links():
interface_name = None
for item in interface['attrs']:
if (item[0] == 'IFLA_IFNAME'
and not item[1].startswith('eth')):
if (item[0] == 'IFLA_IFNAME' and
not item[1].startswith('eth')):
break
elif item[0] == 'IFLA_IFNAME':
interface_name = item[1]

View File

@ -115,8 +115,8 @@ class BaseType(wtypes.Base):
else:
continue
attr_name = attr
if (hasattr(self, '_type_to_model_map')
and attr in self._type_to_model_map):
if (hasattr(self, '_type_to_model_map') and
attr in self._type_to_model_map):
renamed = self._type_to_model_map[attr]
if '.' in renamed:
parent, child = renamed.split('.')

View File

@ -111,10 +111,10 @@ class ListenersController(base.BaseController):
Update the load balancer db when provisioning status changes.
"""
if (listener_dict
and listener_dict.get('insert_headers')
and list(set(listener_dict['insert_headers'].keys()) -
set(constants.SUPPORTED_HTTP_HEADERS))):
if (listener_dict and
listener_dict.get('insert_headers') and
list(set(listener_dict['insert_headers'].keys()) -
set(constants.SUPPORTED_HTTP_HEADERS))):
raise exceptions.InvalidOption(
value=listener_dict.get('insert_headers'),
option='insert_headers')

View File

@ -138,9 +138,9 @@ class LoadBalancersController(base.BaseController):
load_balancer.project_id = project_id
if not (load_balancer.vip.port_id
or load_balancer.vip.network_id
or load_balancer.vip.subnet_id):
if not (load_balancer.vip.port_id or
load_balancer.vip.network_id or
load_balancer.vip.subnet_id):
raise exceptions.ValidationException(detail=_(
"VIP must contain one of: port_id, network_id, subnet_id."))

View File

@ -57,8 +57,8 @@ class AnchorCertGenerator(local.LocalCertGenerator):
if r.status_code != 200:
LOG.debug('Anchor returned: %s', r.content)
raise AnchorException("Anchor returned Status Code : "
+ str(r.status_code))
raise AnchorException("Anchor returned Status Code : " +
str(r.status_code))
return r.content

View File

@ -16,13 +16,13 @@ import sys
import eventlet
eventlet.monkey_patch()
from oslo_config import cfg
from oslo_reports import guru_meditation_report as gmr
from oslo_service import service
from oslo_config import cfg # noqa: E402
from oslo_reports import guru_meditation_report as gmr # noqa: E402
from oslo_service import service # noqa: E402
from octavia.common import service as octavia_service
from octavia.controller.queue import consumer
from octavia import version
from octavia.common import service as octavia_service # noqa: E402
from octavia.controller.queue import consumer # noqa: E402
from octavia import version # noqa: E402
CONF = cfg.CONF

View File

@ -589,10 +589,9 @@ class L7Policy(BaseDataModel):
self.redirect_url = None
pool = self._find_in_graph('Pool' + value)
self.redirect_pool = pool
if len(self.l7rules) > 0 and (self.enabled is True or
('enabled' in update_dict.keys()
and update_dict['enabled']
is True)):
if len(self.l7rules) > 0 and (self.enabled is True or (
'enabled' in update_dict.keys() and
update_dict['enabled'] is True)):
if pool not in self.listener.pools:
self.listener.pools.append(pool)
if self.listener not in pool.listeners:
@ -612,15 +611,15 @@ class L7Policy(BaseDataModel):
self.listener.l7policies.insert(value - 1, self)
elif key == 'enabled':
if (value is True and self.action ==
constants.L7POLICY_ACTION_REDIRECT_TO_POOL
and self.redirect_pool is not None
and len(self.l7rules) > 0
and self.redirect_pool not in self.listener.pools):
constants.L7POLICY_ACTION_REDIRECT_TO_POOL and
self.redirect_pool is not None and
len(self.l7rules) > 0 and
self.redirect_pool not in self.listener.pools):
self.listener.pools.append(self.redirect_pool)
self.redirect_pool.listeners.append(self.listener)
elif (value is False and self.action ==
constants.L7POLICY_ACTION_REDIRECT_TO_POOL
and self.redirect_pool is not None):
constants.L7POLICY_ACTION_REDIRECT_TO_POOL and
self.redirect_pool is not None):
self._conditionally_remove_pool_links(
self.redirect_pool)
setattr(self, key, value)

View File

@ -162,8 +162,8 @@ def sanitize_l7policy_api_args(l7policy, create=False):
l7policy.update({'redirect_pool_id': None})
l7policy.pop('redirect_pool', None)
elif l7policy['action'] == constants.L7POLICY_ACTION_REDIRECT_TO_POOL:
if (not l7policy.get('redirect_pool_id')
and not l7policy.get('redirect_pool')):
if (not l7policy.get('redirect_pool_id') and
not l7policy.get('redirect_pool')):
raise exceptions.InvalidL7PolicyArgs(
msg='redirect_pool_id or redirect_pool must not be None')
l7policy.update({'redirect_url': None})

View File

@ -20,13 +20,13 @@ Create Date: 2014-09-18 16:07:04.859812
'''
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '13500e2e978d'
down_revision = '4c094013699a'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.alter_column(u'provisioning_status', u'name',

View File

@ -20,13 +20,13 @@ Create Date: 2015-01-10 00:53:57.798213
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '14892634e228'
down_revision = '3a1e1cdb7b27'
from alembic import op
import sqlalchemy as sa
def upgrade():
with op.batch_alter_table(u'vip') as batch_op:

View File

@ -21,13 +21,13 @@ Create Date: 2016-01-25 15:12:52.489652
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '186509101b9b'
down_revision = '458c9ee2a011'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column(u'load_balancer', sa.Column(u'server_group_id',

View File

@ -19,14 +19,14 @@ Create Date: 2015-08-06 10:39:54.998797
"""
# revision identifiers, used by Alembic.
revision = '1e4c1d83044c'
down_revision = '5a3ee5472c31'
from alembic import op
import sqlalchemy as sa
from sqlalchemy import sql
# revision identifiers, used by Alembic.
revision = '1e4c1d83044c'
down_revision = '5a3ee5472c31'
def upgrade():
op.create_table(

View File

@ -19,14 +19,14 @@ Create Date: 2015-05-22 11:57:04.703910
"""
# revision identifiers, used by Alembic.
revision = '2351ea316465'
down_revision = '357d17a6d5ac'
from alembic import op
import sqlalchemy as sa
from sqlalchemy import sql
# revision identifiers, used by Alembic.
revision = '2351ea316465'
down_revision = '357d17a6d5ac'
new_protocol = 'TERMINATED_HTTPS'

View File

@ -20,13 +20,13 @@ Create Date: 2015-01-13 16:18:57.359290
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '256852d5ff7c'
down_revision = '14892634e228'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column(u'amphora', sa.Column(u'lb_network_ip', sa.String(64),

View File

@ -20,13 +20,13 @@ Create Date: 2015-07-20 15:25:37.044098
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '298eac0640a7'
down_revision = '4fe8240425b4'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column(u'amphora',

View File

@ -20,13 +20,13 @@ Create Date: 2015-12-09 10:32:12.712932
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '29ff921a6eb'
down_revision = '43287cd10fef'
from alembic import op
import sqlalchemy as sa
def upgrade():
conn = op.get_bind()

View File

@ -21,14 +21,14 @@ Create Date: 2015-07-16 17:41:49.029145
"""
# revision identifiers, used by Alembic.
revision = '357d17a6d5ac'
down_revision = '298eac0640a7'
from alembic import op
import sqlalchemy as sa
from sqlalchemy import sql
# revision identifiers, used by Alembic.
revision = '357d17a6d5ac'
down_revision = '298eac0640a7'
def upgrade():
op.create_table(

View File

@ -20,14 +20,14 @@ Create Date: 2014-08-15 11:01:14.897223
'''
# revision identifiers, used by Alembic.
revision = '35dee79d5865'
down_revision = None
from alembic import op
import sqlalchemy as sa
from sqlalchemy import sql
# revision identifiers, used by Alembic.
revision = '35dee79d5865'
down_revision = None
def upgrade():
# Create lookup tables

View File

@ -20,13 +20,13 @@ Create Date: 2016-04-21 10:45:32.278433
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '36b94648fef8'
down_revision = '4d9cf7d32f2'
from alembic import op
import sqlalchemy as sa
tables = ['member', 'pool', 'load_balancer', 'listener']

View File

@ -20,13 +20,13 @@ Create Date: 2015-01-10 02:01:04.997336
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3a1e1cdb7b27'
down_revision = '4faaa983e7a9'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.alter_column(u'amphora', u'host_id', new_column_name='compute_id',

View File

@ -19,13 +19,13 @@ Create Date: 2015-09-03 17:11:03.724070
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3b199c848b96'
down_revision = '543f5d8e4e56'
from alembic import op
import sqlalchemy as sa
def upgrade():
bind = op.get_bind()

View File

@ -20,13 +20,13 @@ Create Date: 2015-03-24 18:17:36.998604
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3e5b37a0bdb9'
down_revision = '92fe9857279'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column(u'amphora',

View File

@ -19,13 +19,13 @@ Create Date: 2016-09-01 13:59:20.723621
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '3f8ff3be828e'
down_revision = '44a2414dd683'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.create_table(

View File

@ -20,13 +20,13 @@ Create Date: 2016-01-14 10:05:27.803518
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '43287cd10fef'
down_revision = '6abb04f24c5'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.drop_constraint(

View File

@ -19,13 +19,13 @@ Create Date: 2017-02-06 15:21:25.637744
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '443fe6676637'
down_revision = '3f8ff3be828e'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column(u'vip',

View File

@ -20,13 +20,13 @@ Create Date: 2016-12-19 13:14:58.879793
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '44a2414dd683'
down_revision = 'c11292016060'
from alembic import op
import sqlalchemy as sa
tables = ['member', 'health_monitor']

View File

@ -20,14 +20,14 @@ Create Date: 2016-01-07 11:45:45.391851
"""
# revision identifiers, used by Alembic.
revision = '458c9ee2a011'
down_revision = '29ff921a6eb'
from alembic import op
import sqlalchemy as sa
from sqlalchemy import sql
# revision identifiers, used by Alembic.
revision = '458c9ee2a011'
down_revision = '29ff921a6eb'
def upgrade():
# L7 Rule Types

View File

@ -21,14 +21,14 @@ Create Date: 2015-01-20 13:31:30.017959
"""
# revision identifiers, used by Alembic.
revision = '48660b6643f0'
down_revision = '3e5b37a0bdb9'
from alembic import op
import sqlalchemy as sa
from sqlalchemy import sql
# revision identifiers, used by Alembic.
revision = '48660b6643f0'
down_revision = '3e5b37a0bdb9'
def upgrade():
insert_table = sql.table(

View File

@ -20,13 +20,13 @@ Create Date: 2014-09-15 14:42:44.875448
'''
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4c094013699a'
down_revision = '35dee79d5865'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column(

View File

@ -20,13 +20,13 @@ Create Date: 2016-02-21 17:16:22.316744
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4d9cf7d32f2'
down_revision = '9bf4d21caaea'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('listener', sa.Column('insert_headers', sa.PickleType()))

View File

@ -20,13 +20,13 @@ Create Date: 2014-09-29 11:22:16.565071
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4faaa983e7a9'
down_revision = '13500e2e978d'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.alter_column(u'member', u'address', new_column_name=u'ip_address',

View File

@ -19,13 +19,13 @@ Create Date: 2015-07-01 14:27:44.187179
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4fe8240425b4'
down_revision = '48660b6643f0'
from alembic import op
import sqlalchemy as sa
def upgrade():
with op.batch_alter_table(u'vip') as batch_op:

View File

@ -19,13 +19,13 @@ Create Date: 2015-07-27 11:32:16.685383
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '543f5d8e4e56'
down_revision = '2351ea316465'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column(u'amphora_health',

View File

@ -19,13 +19,13 @@ Create Date: 2015-08-20 10:15:19.561066
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '5a3ee5472c31'
down_revision = '3b199c848b96'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column(u'amphora',

View File

@ -20,13 +20,13 @@ Create Date: 2016-06-07 12:59:21.059619
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '62816c232310'
down_revision = '36b94648fef8'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.alter_column(u'sni', u'tls_container_id', type_=sa.String(128),

View File

@ -20,13 +20,13 @@ Create Date: 2015-12-03 15:22:25.390595
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6abb04f24c5'
down_revision = '1e4c1d83044c'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.alter_column('load_balancer', 'tenant_id', new_column_name='project_id',

View File

@ -20,13 +20,13 @@ Create Date: 2016-07-17 14:36:36.698870
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '82b9402e71fd'
down_revision = '4a6ec0ab7284'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.alter_column(u'vip', u'ip_address',

View File

@ -20,13 +20,13 @@ Create Date: 2016-03-23 19:08:53.148812
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8c0851bdf6c3'
down_revision = '186509101b9b'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.alter_column(u'sni', u'tls_container_id', type_=sa.String(128),

View File

@ -19,13 +19,13 @@ Create Date: 2015-01-22 16:58:23.440247
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '92fe9857279'
down_revision = '256852d5ff7c'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.create_table(

View File

@ -20,13 +20,13 @@ Create Date: 2016-09-20 21:46:26.843695
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '9b5473976d6d'
down_revision = '82b9402e71fd'
from alembic import op
import sqlalchemy as sa
def upgrade():

View File

@ -20,13 +20,13 @@ Create Date: 2016-08-12 03:37:38.656962
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c11292016060'
down_revision = '9b5473976d6d'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('listener_statistics',

View File

@ -682,8 +682,9 @@ class ScenarioTest(tempest.test.BaseTestCase):
addresses = (server['addresses'][network['name']]
if network else [])
for address in addresses:
if (address['version'] == CONF.validation.ip_version_for_ssh
and address['OS-EXT-IPS:type'] == 'fixed'):
if (address['version'] ==
CONF.validation.ip_version_for_ssh and
address['OS-EXT-IPS:type'] == 'fixed'):
return address['addr']
raise exceptions.ServerUnreachable(server_id=server['id'])
else:
@ -815,8 +816,8 @@ class NetworkScenarioTest(ScenarioTest):
port_map = [(p["id"], fxip["ip_address"])
for p in ports
for fxip in p["fixed_ips"]
if netutils.is_valid_ipv4(fxip["ip_address"])
and p['status'] in p_status]
if netutils.is_valid_ipv4(fxip["ip_address"]) and
p['status'] in p_status]
inactive = [p for p in ports if p['status'] != 'ACTIVE']
if inactive:
LOG.warning("Instance has ports that are not ACTIVE: %s", inactive)

View File

@ -114,8 +114,8 @@ class ListenerTestCase(base.TestCase):
pass
@mock.patch('os.path.exists')
@mock.patch('octavia.amphorae.backends.agent.api_server'
+ '.util.get_haproxy_pid')
@mock.patch('octavia.amphorae.backends.agent.api_server' +
'.util.get_haproxy_pid')
def test_check_listener_status(self, mock_pid, mock_exists):
mock_pid.return_value = '1245'
mock_exists.side_effect = [True, True]
@ -170,8 +170,8 @@ class ListenerTestCase(base.TestCase):
handle.write.assert_called_once_with(cmd)
@mock.patch('os.path.exists')
@mock.patch('octavia.amphorae.backends.agent.api_server'
+ '.util.get_haproxy_pid')
@mock.patch('octavia.amphorae.backends.agent.api_server' +
'.util.get_haproxy_pid')
def test_check_haproxy_status(self, mock_pid, mock_exists):
mock_pid.return_value = '1245'
mock_exists.side_effect = [True, True]

View File

@ -30,6 +30,7 @@
# sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
from octavia import version
# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'
@ -63,7 +64,6 @@ copyright = u'2015, Octavia Developers'
# built documents.
#
# The short X.Y version.
from octavia import version
# from octavia.version import version_info as octavia_version
# The full version, including alpha/beta/rc tags.
release = version.version_info.version_string_with_vcs()

View File

@ -100,7 +100,7 @@ commands = bandit -r octavia -ll -ii -x octavia/tests {posargs}
[flake8]
# Ignoring O321 because it's unnecessarily restricting use of json package.
# jsonutils version doesn't add additional value
ignore = O321,E402,W503
ignore = O321
show-source = true
builtins = _
exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build