Browse Source

Merge "fix pep8 failures"

Zuul 5 months ago
parent
commit
98b1bab15c
18 changed files with 69 additions and 69 deletions
  1. 6
    6
      networking_bigswitch/plugins/bigswitch/agent/restproxy_agent.py
  2. 3
    3
      networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/1086543dfc0f_update_column_type_for_testpath_result.py
  3. 2
    2
      networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/1ef57200f387_testpath_modify_uniq_constraint.py
  4. 6
    6
      networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/2dc6f1b7c0a1_testpath_add_column_logical_path.py
  5. 4
    4
      networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/34f888285695_support_multiple_logical_routers.py
  6. 5
    5
      networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/66cc6bc031de_tenant_policy_plugin.py
  7. 0
    1
      networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/7db8cd315b95_clear_consistency_db.py
  8. 3
    4
      networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/f774eae87144_rename_tenant_to_project.py
  9. 6
    6
      networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/kilo_add_base_bsn_plugin.py
  10. 5
    5
      networking_bigswitch/plugins/bigswitch/db/tenant_policy_db.py
  11. 6
    8
      networking_bigswitch/plugins/bigswitch/plugin.py
  12. 6
    6
      networking_bigswitch/plugins/ml2/drivers/mech_bigswitch/driver.py
  13. 2
    2
      networking_bigswitch/tests/unit/bigswitch/fake_server.py
  14. 2
    2
      networking_bigswitch/tests/unit/bigswitch/test_restproxy_plugin.py
  15. 3
    2
      networking_bigswitch/tests/unit/bigswitch/test_servermanager.py
  16. 2
    1
      networking_bigswitch/tests/unit/ml2/drivers/test_bigswitch_mech.py
  17. 2
    2
      networking_bigswitch/tests/unit/test_taas_bsn.py
  18. 6
    4
      tox.ini

+ 6
- 6
networking_bigswitch/plugins/bigswitch/agent/restproxy_agent.py View File

@@ -20,15 +20,18 @@ import sys
20 20
 import time
21 21
 
22 22
 import eventlet
23
-eventlet.monkey_patch()
23
+import oslo_messaging
24 24
 
25
+from neutron_lib.agent import topics
26
+from neutron_lib import constants as q_const
27
+from neutron_lib import context as q_context
25 28
 from oslo_config import cfg
26 29
 from oslo_log import log
27
-import oslo_messaging
28 30
 from oslo_service import loopingcall
29 31
 from oslo_utils import excutils
30 32
 from oslo_utils import importutils
31 33
 
34
+from networking_bigswitch.plugins.bigswitch import config as pl_config
32 35
 from neutron.agent.common import ovs_lib
33 36
 from neutron.agent.linux import utils
34 37
 from neutron.agent import rpc as agent_rpc
@@ -36,11 +39,8 @@ from neutron.agent import securitygroups_rpc as sg_rpc
36 39
 from neutron.api.rpc.handlers import securitygroups_rpc as api_sg_rpc
37 40
 from neutron.common import config
38 41
 from neutron.extensions import securitygroup as ext_sg
39
-from neutron_lib.agent import topics
40
-from neutron_lib import constants as q_const
41
-from neutron_lib import context as q_context
42 42
 
43
-from networking_bigswitch.plugins.bigswitch import config as pl_config
43
+eventlet.monkey_patch()
44 44
 
45 45
 IVS_PORT_MTU = 9000
46 46
 IVS_VM_PORT_PREFIX = 'qvo'

+ 3
- 3
networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/1086543dfc0f_update_column_type_for_testpath_result.py View File

@@ -21,15 +21,15 @@ Create Date: 2016-04-25 11:54:44.646798
21 21
 
22 22
 """
23 23
 
24
+from alembic import op
25
+from sqlalchemy.types import Enum
26
+
24 27
 # revision identifiers, used by Alembic.
25 28
 revision = '1086543dfc0f'
26 29
 down_revision = 'kilo'
27 30
 branch_labels = None
28 31
 depends_on = None
29 32
 
30
-from alembic import op
31
-from sqlalchemy.types import Enum
32
-
33 33
 
34 34
 def upgrade():
35 35
     op.alter_column(

+ 2
- 2
networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/1ef57200f387_testpath_modify_uniq_constraint.py View File

@@ -21,14 +21,14 @@ Create Date: 2016-06-18 14:04:20.625692
21 21
 
22 22
 """
23 23
 
24
+from alembic import op
25
+
24 26
 # revision identifiers, used by Alembic.
25 27
 revision = '1ef57200f387'
26 28
 down_revision = '1086543dfc0f'
27 29
 branch_labels = None
28 30
 depends_on = None
29 31
 
30
-from alembic import op
31
-
32 32
 
33 33
 def upgrade():
34 34
     op.drop_constraint(

+ 6
- 6
networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/2dc6f1b7c0a1_testpath_add_column_logical_path.py View File

@@ -20,12 +20,6 @@ Create Date: 2017-10-12 14:12:51.467479
20 20
 
21 21
 """
22 22
 
23
-# revision identifiers, used by Alembic.
24
-revision = '2dc6f1b7c0a1'
25
-down_revision = 'f774eae87144'
26
-branch_labels = None
27
-depends_on = None
28
-
29 23
 import sqlalchemy as sa
30 24
 
31 25
 from alembic import op
@@ -33,6 +27,12 @@ from oslo_serialization import jsonutils
33 27
 from sqlalchemy.dialects.mysql.base import VARCHAR
34 28
 from sqlalchemy.types import TypeDecorator
35 29
 
30
+# revision identifiers, used by Alembic.
31
+revision = '2dc6f1b7c0a1'
32
+down_revision = 'f774eae87144'
33
+branch_labels = None
34
+depends_on = None
35
+
36 36
 
37 37
 class JSONEncodedDict(TypeDecorator):
38 38
     """Represents an immutable structure as a json-encoded string.

+ 4
- 4
networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/34f888285695_support_multiple_logical_routers.py View File

@@ -20,16 +20,16 @@ Create Date: 2017-01-17 04:44:12.582865
20 20
 
21 21
 """
22 22
 
23
+from alembic import op
24
+from oslo_db.exception import DBError
25
+import sqlalchemy as sa
26
+
23 27
 # revision identifiers, used by Alembic.
24 28
 revision = '34f888285695'
25 29
 down_revision = '1ef57200f387'
26 30
 branch_labels = None
27 31
 depends_on = None
28 32
 
29
-from alembic import op
30
-from oslo_db.exception import DBError
31
-import sqlalchemy as sa
32
-
33 33
 
34 34
 def upgrade():
35 35
     # add column tenant_id. allow nullable until we add values

+ 5
- 5
networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/66cc6bc031de_tenant_policy_plugin.py View File

@@ -20,17 +20,17 @@ Create Date: 2017-06-27 12:10:07.018858
20 20
 
21 21
 """
22 22
 
23
+from alembic import op
24
+from oslo_utils import uuidutils
25
+import sqlalchemy as sa
26
+from sqlalchemy.types import Enum
27
+
23 28
 # revision identifiers, used by Alembic.
24 29
 revision = '66cc6bc031de'
25 30
 down_revision = '2dc6f1b7c0a1'
26 31
 branch_labels = None
27 32
 depends_on = None
28 33
 
29
-from alembic import op
30
-from oslo_utils import uuidutils
31
-import sqlalchemy as sa
32
-from sqlalchemy.types import Enum
33
-
34 34
 
35 35
 def upgrade():
36 36
     op.create_table(

+ 0
- 1
networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/7db8cd315b95_clear_consistency_db.py View File

@@ -22,7 +22,6 @@ Create Date: 2018-05-08 12:38:56.871617
22 22
 """
23 23
 from alembic import op
24 24
 
25
-
26 25
 # revision identifiers, used by Alembic.
27 26
 revision = '7db8cd315b95'
28 27
 down_revision = '2dc6f1b7c0a1'

+ 3
- 4
networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/f774eae87144_rename_tenant_to_project.py View File

@@ -20,16 +20,15 @@ Create Date: 2017-03-23 11:44:25.544323
20 20
 
21 21
 """
22 22
 
23
+from alembic import op
24
+import sqlalchemy as sa
25
+
23 26
 # revision identifiers, used by Alembic.
24 27
 revision = 'f774eae87144'
25 28
 down_revision = '34f888285695'
26 29
 branch_labels = None
27 30
 depends_on = None
28 31
 
29
-from alembic import op
30
-import sqlalchemy as sa
31
-
32
-
33 32
 _INSPECTOR = None
34 33
 
35 34
 

+ 6
- 6
networking_bigswitch/plugins/bigswitch/db/migration/alembic_migrations/versions/kilo_add_base_bsn_plugin.py View File

@@ -21,12 +21,6 @@ Create Date: 2016-01-04 17:59:34.311932
21 21
 
22 22
 """
23 23
 
24
-# revision identifiers, used by Alembic.
25
-revision = 'kilo'
26
-down_revision = None
27
-branch_labels = None
28
-depends_on = None
29
-
30 24
 from alembic import op
31 25
 from oslo_serialization import jsonutils
32 26
 
@@ -34,6 +28,12 @@ import sqlalchemy as sa
34 28
 from sqlalchemy.dialects.mysql.base import VARCHAR
35 29
 from sqlalchemy.types import Enum, TIMESTAMP, TypeDecorator
36 30
 
31
+# revision identifiers, used by Alembic.
32
+revision = 'kilo'
33
+down_revision = None
34
+branch_labels = None
35
+depends_on = None
36
+
37 37
 
38 38
 class JSONEncodedDict(TypeDecorator):
39 39
     """Represents an immutable structure as a json-encoded string.

+ 5
- 5
networking_bigswitch/plugins/bigswitch/db/tenant_policy_db.py View File

@@ -140,17 +140,17 @@ class TenantPolicyDbMixin(common_db_mixin.CommonDbMixin):
140 140
     def _validate_priority(self, priority):
141 141
         msg = None
142 142
         int_priority = int(priority)
143
-        if (int_priority not in range(1, 3001)
144
-                and int_priority != DEFAULT_POLICY_PRIORITY):
143
+        if (int_priority not in range(1, 3001) and
144
+                int_priority != DEFAULT_POLICY_PRIORITY):
145 145
             msg = _("User must provide valid priority between 1 and 3000. "
146 146
                     "%s was provided.") % priority
147 147
         return msg
148 148
 
149 149
     def _validate_port_protocol(self, policy_data):
150 150
         msg = None
151
-        if ((int(policy_data['source_port']) > 0
152
-             or int(policy_data['destination_port']) > 0)
153
-                and policy_data['protocol'] not in ['tcp', 'udp']):
151
+        if ((int(policy_data['source_port']) > 0 or
152
+                int(policy_data['destination_port']) > 0) and
153
+                policy_data['protocol'] not in ['tcp', 'udp']):
154 154
             msg = _("Protocol must be select if either source or destination "
155 155
                     "port is specified.")
156 156
         return msg

+ 6
- 8
networking_bigswitch/plugins/bigswitch/plugin.py View File

@@ -362,8 +362,8 @@ class NeutronRestProxyV2Base(db_base_plugin_v2.NeutronDbPluginV2,
362 362
             # L3 plugin also includes tenant policies
363 363
             # data.update({'policies': tenant_policies})
364 364
 
365
-        if (get_sgs and self.l3_plugin
366
-                and cfg.CONF.RESTPROXY.sync_security_groups):
365
+        if (get_sgs and self.l3_plugin and
366
+                cfg.CONF.RESTPROXY.sync_security_groups):
367 367
             sgs = plugin.get_security_groups(admin_context) or []
368 368
             new_sgs = []
369 369
             for sg in sgs:
@@ -769,8 +769,8 @@ class NeutronRestProxyV2Base(db_base_plugin_v2.NeutronDbPluginV2,
769 769
         # if bridge_name not available, sets it to just 'host-id'
770 770
         vif_type = prepped_port.get(portbindings.VIF_TYPE)
771 771
         if (vif_type and
772
-                (vif_type == portbindings.VIF_TYPE_OVS
773
-                 or vif_type == portbindings.VIF_TYPE_VHOST_USER)):
772
+                (vif_type == portbindings.VIF_TYPE_OVS or
773
+                 vif_type == portbindings.VIF_TYPE_VHOST_USER)):
774 774
             prepped_port[portbindings.HOST_ID] = (
775 775
                 self._get_ovs_dpdk_port_hostid(prepped_port, network))
776 776
 
@@ -1122,8 +1122,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
1122 1122
             new_port = super(NeutronRestProxyV2, self).create_port(context,
1123 1123
                                                                    port)
1124 1124
             self._process_port_create_security_group(context, new_port, sgids)
1125
-        if (portbindings.HOST_ID in port['port']
1126
-                and 'id' in new_port):
1125
+        if (portbindings.HOST_ID in port['port'] and 'id' in new_port):
1127 1126
             host_id = port['port'][portbindings.HOST_ID]
1128 1127
             porttracker_db.put_port_hostid(context, new_port['id'],
1129 1128
                                            host_id)
@@ -1216,8 +1215,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
1216 1215
                                                  new_port)
1217 1216
             old_host_id = porttracker_db.get_port_hostid(context,
1218 1217
                                                          orig_port['id'])
1219
-            if (portbindings.HOST_ID in port['port']
1220
-                    and 'id' in new_port):
1218
+            if (portbindings.HOST_ID in port['port'] and 'id' in new_port):
1221 1219
                 host_id = port['port'][portbindings.HOST_ID]
1222 1220
                 porttracker_db.put_port_hostid(context, new_port['id'],
1223 1221
                                                host_id)

+ 6
- 6
networking_bigswitch/plugins/ml2/drivers/mech_bigswitch/driver.py View File

@@ -240,16 +240,16 @@ class BigSwitchMechanismDriver(plugin.NeutronRestProxyV2Base,
240 240
         # we retain this section for security groups, because it handles
241 241
         # other events as well. Ignore security group events if disabled in
242 242
         # config
243
-        if (event_type == 'security_group.create.end'
244
-                and cfg.CONF.RESTPROXY.sync_security_groups):
243
+        if (event_type == 'security_group.create.end' and
244
+                cfg.CONF.RESTPROXY.sync_security_groups):
245 245
             LOG.debug("Security group created: %s", payload)
246 246
             self.bsn_create_security_group(sg=payload['security_group'])
247
-        elif (event_type == 'security_group.delete.end'
248
-              and cfg.CONF.RESTPROXY.sync_security_groups):
247
+        elif (event_type == 'security_group.delete.end' and
248
+                cfg.CONF.RESTPROXY.sync_security_groups):
249 249
             LOG.debug("Security group deleted: %s", payload)
250 250
             self.bsn_delete_security_group(payload['security_group_id'])
251
-        elif (event_type == 'security_group_rule.delete.end'
252
-              and cfg.CONF.RESTPROXY.sync_security_groups):
251
+        elif (event_type == 'security_group_rule.delete.end' and
252
+                cfg.CONF.RESTPROXY.sync_security_groups):
253 253
             LOG.debug("Security group rule deleted: %s", payload)
254 254
             self.bsn_delete_sg_rule(payload['security_group_rule'], ctxt)
255 255
         elif event_type == 'identity.project.deleted':

+ 2
- 2
networking_bigswitch/tests/unit/bigswitch/fake_server.py View File

@@ -84,8 +84,8 @@ class HTTPConnectionMock(object):
84 84
             self.response = HTTPResponseMock(None)
85 85
 
86 86
         # Port creations/updates must contain binding information
87
-        if ('port' in uri and 'attachment' not in uri
88
-                and 'binding' not in body and action in ('POST', 'PUT')):
87
+        if ('port' in uri and 'attachment' not in uri and
88
+                'binding' not in body and action in ('POST', 'PUT')):
89 89
             errmsg = "Port binding info missing in port request '%s'" % body
90 90
             self.response = HTTPResponseMock500(None, errmsg=errmsg)
91 91
             return

+ 2
- 2
networking_bigswitch/tests/unit/bigswitch/test_restproxy_plugin.py View File

@@ -213,8 +213,8 @@ class TestBigSwitchProxyPortsV2(test_plugin.TestPortsV2,
213 213
             self.subnet() as s,\
214 214
             patch(HTTPCON, create=True,
215 215
                   new=fake_server.HTTPConnectionMock404),\
216
-            patch(bsn_test_base.RESTPROXY_PKG_PATH
217
-                  + '.NeutronRestProxyV2._send_all_data') as mock_send_all:
216
+            patch(bsn_test_base.RESTPROXY_PKG_PATH +
217
+                  '.NeutronRestProxyV2._send_all_data') as mock_send_all:
218 218
             with self.port(subnet=s, device_id='somedevid') as p:
219 219
                 # wait for the async port thread to finish
220 220
                 plugin = directory.get_plugin()

+ 3
- 2
networking_bigswitch/tests/unit/bigswitch/test_servermanager.py View File

@@ -302,8 +302,9 @@ class ServerManagerTests(test_rp.BigSwitchProxyPluginV2TestCase):
302 302
         pl.servers.ssl = True
303 303
         cfg.CONF.set_override('ssl_sticky', False, 'RESTPROXY')
304 304
         # pretend base dir exists, 3 children don't, and host cert does
305
-        with mock.patch('os.path.exists', side_effect=[True, False, False,
306
-                                                       False, True]) as exmock,\
305
+        with mock.patch('os.path.exists',
306
+                        side_effect=[True, False, False,
307
+                                     False, True]) as exmock,\
307 308
                 mock.patch('os.makedirs') as makemock,\
308 309
                 mock.patch(
309 310
                     SERVERMANAGER + '.ServerPool._combine_certs_to_file')\

+ 2
- 1
networking_bigswitch/tests/unit/ml2/drivers/test_bigswitch_mech.py View File

@@ -266,7 +266,8 @@ class TestBigSwitchMechDriverPortsV2(test_db_base_plugin_v2.TestPortsV2,
266 266
         host_arg = {portbindings.HOST_ID: 'hostname',
267 267
                     portbindings.VNIC_TYPE: portbindings.VNIC_DIRECT}
268 268
         with\
269
-            mock.patch(SERVER_POOL + '.rest_get_switch', return_value=True) as rmock,\
269
+            mock.patch(SERVER_POOL + '.rest_get_switch',
270
+                       return_value=True) as rmock,\
270 271
             self.port(arg_list=(portbindings.HOST_ID, portbindings.VNIC_TYPE),
271 272
                       **host_arg):
272 273
 

+ 2
- 2
networking_bigswitch/tests/unit/test_taas_bsn.py View File

@@ -63,8 +63,8 @@ class TestBSNTaasCase(test_bsm.TestBigSwitchMechDriverBase):
63 63
     def setUp(self, plugin=None, service_plugins=None, ext_mgr=None):
64 64
         ext_mgr = TaasExtensionManager()
65 65
         service_plugins = {'taas_plugin_name': DB_TAAS_PLUGIN_KLASS}
66
-        taas_provider = (taas_const.TAAS + ':BSN:' + BSN_TAAS_DRIVER_KLASS
67
-                         + ':default')
66
+        taas_provider = (taas_const.TAAS + ':BSN:' + BSN_TAAS_DRIVER_KLASS +
67
+                         ':default')
68 68
         mock.patch.object(provconf.NeutronModule, 'service_providers',
69 69
                           return_value=[taas_provider]).start()
70 70
         manager = sdb.ServiceTypeManager.get_instance()

+ 6
- 4
tox.ini View File

@@ -54,10 +54,12 @@ commands = {posargs}
54 54
 commands = sphinx-build -W -d doc/build/doctrees -b html doc/source/ doc/build/html
55 55
 
56 56
 [flake8]
57
-# N530  direct neutron imports not allowed
58
-# N536  Use assertIsNone rather than assertEqual to check for None values
59
-# N537  Log messages should not be translated!
60
-ignore = N530,N536,N537
57
+# I100: Import statements are in the wrong order
58
+# I201: Missing newline before sections or imports
59
+# N530: direct neutron imports not allowed
60
+# N536: Use assertIsNone rather than assertEqual to check for None values
61
+# N537: Log messages should not be translated!
62
+ignore = I100,I201,N530,N536,N537
61 63
 # H106: Don’t put vim configuration in source files
62 64
 # H203: Use assertIs(Not)None to check for None
63 65
 # H904: Delay string interpolations at logging calls

Loading…
Cancel
Save