From 625b6526ca91137068af404b5db5e1db1052898a Mon Sep 17 00:00:00 2001 From: elajkat Date: Tue, 6 Feb 2024 15:17:56 +0100 Subject: [PATCH] Bump hacking hacking 3.0.x is too old. Try to synchronize pylint ignore and extension list with other Networking projects. With new pip the order of packages is not relevant, so the related comment from requirements.txts is removed, see pip documentation: https://pip.pypa.io/en/stable/cli/pip_install/#installation-order Change-Id: I99a2d30149088d3d71d56351d180e665c38686ef --- .../contract/458aa42b14b_fw_table_alter.py | 2 +- .../f83a0b2964d0_rename_tenant_to_project.py | 3 +- neutron_fwaas/extensions/firewall_v2.py | 5 +- .../firewall/service_drivers/agents/agents.py | 4 +- .../agents/drivers/linux/iptables_fwaas_v2.py | 8 +- .../linux/l2/openvswitch_firewall/firewall.py | 2 +- .../l3reference/firewall_l3_agent_v2.py | 6 +- .../firewall/service_drivers/driver_api.py | 6 +- .../services/logapi/agents/l3/fwg_log.py | 2 +- .../tests/fullstack/resources/environment.py | 13 +-- .../tests/fullstack/resources/machine.py | 2 +- .../db/firewall/v2/test_firewall_db_v2.py | 40 +++++---- .../drivers/linux/test_netlink_conntrack.py | 3 +- .../agents/l2/test_fwaas_v2.py | 14 +-- .../service_drivers/agents/test_agents.py | 89 ++++++++++--------- .../tests/unit/services/logapi/base.py | 2 +- requirements.txt | 9 -- test-requirements.txt | 7 +- tox.ini | 20 ++--- 19 files changed, 111 insertions(+), 126 deletions(-) diff --git a/neutron_fwaas/db/migration/alembic_migrations/versions/mitaka/contract/458aa42b14b_fw_table_alter.py b/neutron_fwaas/db/migration/alembic_migrations/versions/mitaka/contract/458aa42b14b_fw_table_alter.py index 1f645e5b9..50012629f 100644 --- a/neutron_fwaas/db/migration/alembic_migrations/versions/mitaka/contract/458aa42b14b_fw_table_alter.py +++ b/neutron_fwaas/db/migration/alembic_migrations/versions/mitaka/contract/458aa42b14b_fw_table_alter.py @@ -1,4 +1,4 @@ -#Copyright 2015 OpenStack Foundation +# Copyright 2015 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain diff --git a/neutron_fwaas/db/migration/alembic_migrations/versions/newton/contract/f83a0b2964d0_rename_tenant_to_project.py b/neutron_fwaas/db/migration/alembic_migrations/versions/newton/contract/f83a0b2964d0_rename_tenant_to_project.py index cb45304d1..7d65781a7 100644 --- a/neutron_fwaas/db/migration/alembic_migrations/versions/newton/contract/f83a0b2964d0_rename_tenant_to_project.py +++ b/neutron_fwaas/db/migration/alembic_migrations/versions/newton/contract/f83a0b2964d0_rename_tenant_to_project.py @@ -54,8 +54,7 @@ def get_inspector(): def get_tables(): - """ - Returns hardcoded list of tables which have ``tenant_id`` column. + """Returns hardcoded list of tables which have ``tenant_id`` column. The list is hardcoded to match the state of the schema when this upgrade script is run. diff --git a/neutron_fwaas/extensions/firewall_v2.py b/neutron_fwaas/extensions/firewall_v2.py index e7fed8822..aea9d7821 100644 --- a/neutron_fwaas/extensions/firewall_v2.py +++ b/neutron_fwaas/extensions/firewall_v2.py @@ -145,9 +145,8 @@ class Firewall_v2(extensions.APIExtensionDescriptor): return Firewallv2PluginBase -class Firewallv2PluginBase( - service_base.ServicePluginBase, - metaclass=abc.ABCMeta): +class Firewallv2PluginBase(service_base.ServicePluginBase, + metaclass=abc.ABCMeta): def get_plugin_type(self): return fwaas_constants.FIREWALL_V2 diff --git a/neutron_fwaas/services/firewall/service_drivers/agents/agents.py b/neutron_fwaas/services/firewall/service_drivers/agents/agents.py index b73f88de7..29d3edfa4 100644 --- a/neutron_fwaas/services/firewall/service_drivers/agents/agents.py +++ b/neutron_fwaas/services/firewall/service_drivers/agents/agents.py @@ -241,7 +241,7 @@ class FirewallAgentDriver(driver_api.FirewallDriverDB, 'status': port_db['status'], } if device_owner.startswith( - nl_constants.DEVICE_OWNER_COMPUTE_PREFIX): + nl_constants.DEVICE_OWNER_COMPUTE_PREFIX): port_details[port_id].update( {'host': port_db[pb_def.HOST_ID]}) return port_details @@ -314,7 +314,7 @@ class FirewallAgentDriver(driver_api.FirewallDriverDB, # the old group had the same number of ports that need to be deleted. fwg_with_rules['last-port'] = (len(old_firewall_group['ports']) == len( fwg_with_rules['del-port-ids']) and - not(new_firewall_group['ports'])) + not new_firewall_group['ports']) LOG.debug("update_firewall_group %s: Add Ports: %s, Del Ports: %s", new_firewall_group['id'], diff --git a/neutron_fwaas/services/firewall/service_drivers/agents/drivers/linux/iptables_fwaas_v2.py b/neutron_fwaas/services/firewall/service_drivers/agents/drivers/linux/iptables_fwaas_v2.py index 6492a1f6e..8a04511e2 100644 --- a/neutron_fwaas/services/firewall/service_drivers/agents/drivers/linux/iptables_fwaas_v2.py +++ b/neutron_fwaas/services/firewall/service_drivers/agents/drivers/linux/iptables_fwaas_v2.py @@ -281,7 +281,7 @@ class IptablesFwaasDriver(fwaas_base_v2.FwaasDriverBase): for pre_fw_rule in pre_fw_rules: for fw_rule in fw_rules: if (pre_fw_rule.get('id') == fw_rule.get('id') and - pre_fw_rule != fw_rule): + pre_fw_rule != fw_rule): changed_rules.append(pre_fw_rule) changed_rules.append(fw_rule) return changed_rules @@ -476,7 +476,7 @@ class IptablesFwaasDriver(fwaas_base_v2.FwaasDriverBase): # iptables adds '-m protocol' when any source # or destination port number is specified if (rule.get('source_port') is not None or - rule.get('destination_port') is not None): + rule.get('destination_port') is not None): args += self._match_arg(rule.get('protocol')) args += self._port_arg('sport', @@ -512,7 +512,7 @@ class IptablesFwaasDriver(fwaas_base_v2.FwaasDriverBase): return [] if (protocol == constants.PROTO_NAME_ICMP and - ip_version == constants.IP_VERSION_6): + ip_version == constants.IP_VERSION_6): protocol = constants.PROTO_NAME_IPV6_ICMP args = ['-p', protocol] @@ -543,7 +543,7 @@ class IptablesFwaasDriver(fwaas_base_v2.FwaasDriverBase): def _ip_prefix_arg(self, direction, ip_prefix): - if not(ip_prefix): + if not ip_prefix: return [] args = ['-%s' % direction, '%s' % utils.ip_to_cidr(ip_prefix)] diff --git a/neutron_fwaas/services/firewall/service_drivers/agents/drivers/linux/l2/openvswitch_firewall/firewall.py b/neutron_fwaas/services/firewall/service_drivers/agents/drivers/linux/l2/openvswitch_firewall/firewall.py index df958e6ee..1143e5e05 100644 --- a/neutron_fwaas/services/firewall/service_drivers/agents/drivers/linux/l2/openvswitch_firewall/firewall.py +++ b/neutron_fwaas/services/firewall/service_drivers/agents/drivers/linux/l2/openvswitch_firewall/firewall.py @@ -287,7 +287,7 @@ class OVSFirewallDriver(driver_base.FirewallL2DriverBase): def _drop_all_unmatched_flows(self): for table in fwaas_ovs_consts.OVS_FIREWALL_TABLES: if (table == fwaas_ovs_consts.FW_ACCEPT_OR_INGRESS_TABLE and - self.sg_with_ovs): + self.sg_with_ovs): continue self.int_br.br.add_flow(table=table, priority=0, actions='drop') diff --git a/neutron_fwaas/services/firewall/service_drivers/agents/l3reference/firewall_l3_agent_v2.py b/neutron_fwaas/services/firewall/service_drivers/agents/l3reference/firewall_l3_agent_v2.py index ecd7fd9c8..6043023a0 100644 --- a/neutron_fwaas/services/firewall/service_drivers/agents/l3reference/firewall_l3_agent_v2.py +++ b/neutron_fwaas/services/firewall/service_drivers/agents/l3reference/firewall_l3_agent_v2.py @@ -86,7 +86,7 @@ class FWaaSL3AgentExtension(l3_extension.L3AgentExtension): self.agent_api = agent_api def _register_rpc_consumers(self, connection): - #TODO(njohnston): Add RPC consumer connection loading here. + # TODO(njohnston): Add RPC consumer connection loading here. pass def start_rpc_listeners(self, host, conf): @@ -309,7 +309,7 @@ class FWaaSL3AgentExtension(l3_extension.L3AgentExtension): try: self._process_router_update(updated_router) except Exception: - #TODO(njohnston): This repr should be replaced. + # TODO(njohnston): This repr should be replaced. LOG.exception( "FWaaS router update RPC info call failed for %s", repr(updated_router)) @@ -320,7 +320,7 @@ class FWaaSL3AgentExtension(l3_extension.L3AgentExtension): in the context of FWaaS with an IPTables driver; the namespace will already have been deleted, taking the IPTables rules with it. """ - #TODO(njohnston): When another firewall driver is implemented, look at + # TODO(njohnston): When another firewall driver is implemented, look at # expanding this out so that the driver can handle deletion calls. pass diff --git a/neutron_fwaas/services/firewall/service_drivers/driver_api.py b/neutron_fwaas/services/firewall/service_drivers/driver_api.py index a23951b77..17d692d7f 100644 --- a/neutron_fwaas/services/firewall/service_drivers/driver_api.py +++ b/neutron_fwaas/services/firewall/service_drivers/driver_api.py @@ -441,7 +441,7 @@ class FirewallDriverDB(FirewallDriverDBMixin): related records in the databases. """ - #Firewal Group + # Firewall Group def create_firewall_group_precommit(self, context, firewall_group): pass @@ -462,7 +462,7 @@ class FirewallDriverDB(FirewallDriverDBMixin): def delete_firewall_group_postcommit(self, context, firewall_group): pass - #Firewall Policy + # Firewall Policy def create_firewall_policy_precommit(self, context, firewall_policy): pass @@ -483,7 +483,7 @@ class FirewallDriverDB(FirewallDriverDBMixin): def delete_firewall_policy_postcommit(self, context, firewall_policy): pass - #Firewall Rule + # Firewall Rule def create_firewall_rule_precommit(self, context, firewall_rule): pass diff --git a/neutron_fwaas/services/logapi/agents/l3/fwg_log.py b/neutron_fwaas/services/logapi/agents/l3/fwg_log.py index 82dc647ad..4d5262ba9 100644 --- a/neutron_fwaas/services/logapi/agents/l3/fwg_log.py +++ b/neutron_fwaas/services/logapi/agents/l3/fwg_log.py @@ -18,7 +18,7 @@ from neutron.services.logapi.agent import log_extension as log_ext from neutron.services.logapi.rpc import agent as agent_rpc from neutron_lib.agent import l3_extension -#TODO(annp) move to neutron-lib +# TODO(annp) move to neutron-lib FIREWALL_LOG_DRIVER_NAME = 'fwaas_v2_log' diff --git a/neutron_fwaas/tests/fullstack/resources/environment.py b/neutron_fwaas/tests/fullstack/resources/environment.py index 454502a7f..955e67a1a 100644 --- a/neutron_fwaas/tests/fullstack/resources/environment.py +++ b/neutron_fwaas/tests/fullstack/resources/environment.py @@ -137,8 +137,8 @@ class Host(fixtures.Fixture): self.ovs_agent.agent_cfg_fixture.get_br_int_name())) def setup_host_with_linuxbridge_agent(self): - #First we need to provide connectivity for agent to prepare proper - #bridge mappings in agent's config: + # First we need to provide connectivity for agent to prepare proper + # bridge mappings in agent's config: self.host_namespace = self.useFixture( net_helpers.NamespaceFixture(prefix="host-") ).name @@ -269,7 +269,8 @@ class Environment(fixtures.Fixture): """ def __init__(self, env_desc, hosts_desc): - """ + """Environment, represents a deployment topology + :param env_desc: An EnvironmentDescription instance. :param hosts_desc: A list of HostDescription instances. """ @@ -308,13 +309,13 @@ class Environment(fixtures.Fixture): def _setUp(self): self.temp_dir = self.useFixture(fixtures.TempDir()).path - #we need this bridge before rabbit and neutron service will start + # we need this bridge before rabbit and neutron service will start self.central_data_bridge = self.useFixture( net_helpers.OVSBridgeFixture('cnt-data')).bridge self.central_external_bridge = self.useFixture( net_helpers.OVSBridgeFixture('cnt-ex')).bridge - #Get rabbitmq address (and cnt-data network) + # Get rabbitmq address (and cnt-data network) rabbitmq_ip_address = self._configure_port_for_rabbitmq() self.rabbitmq_environment = self.useFixture( process.RabbitmqEnvironmentFixture(host=rabbitmq_ip_address) @@ -349,7 +350,7 @@ class Environment(fixtures.Fixture): return rabbitmq_ip def _get_network_range(self): - #NOTE(slaweq): We need to choose IP address on which rabbitmq will be + # NOTE(slaweq): We need to choose IP address on which rabbitmq will be # available because LinuxBridge agents are spawned in their own # namespaces and need to know where the rabbitmq server is listening. # For ovs agent it is not necessary because agents are spawned in diff --git a/neutron_fwaas/tests/fullstack/resources/machine.py b/neutron_fwaas/tests/fullstack/resources/machine.py index e9eaecc1e..c263a2f05 100644 --- a/neutron_fwaas/tests/fullstack/resources/machine.py +++ b/neutron_fwaas/tests/fullstack/resources/machine.py @@ -99,7 +99,7 @@ class FakeFullstackMachine(machine_fixtures.FakeMachineBase): def _configure_ipaddress(self, fixed_ip): if (netaddr.IPAddress(fixed_ip['ip_address']).version == - constants.IP_VERSION_6): + constants.IP_VERSION_6): # v6Address/default_route is auto-configured. self._ipv6 = fixed_ip['ip_address'] else: diff --git a/neutron_fwaas/tests/unit/db/firewall/v2/test_firewall_db_v2.py b/neutron_fwaas/tests/unit/db/firewall/v2/test_firewall_db_v2.py index e111edabb..b6ff1ee32 100644 --- a/neutron_fwaas/tests/unit/db/firewall/v2/test_firewall_db_v2.py +++ b/neutron_fwaas/tests/unit/db/firewall/v2/test_firewall_db_v2.py @@ -393,7 +393,8 @@ class TestFirewallDBPluginV2(test_fwaas_plugin_v2.FirewallPluginV2TestCase): self.assertEqual(webob.exc.HTTPConflict.code, res.status_int) def test_update_default_fwg_policy(self): - """ + """Test that fw group associated policy can't be updated + Make sure that neither admin nor non-admin can update policy associated with default firewall group """ @@ -835,21 +836,21 @@ class TestFirewallDBPluginV2(test_fwaas_plugin_v2.FirewallPluginV2TestCase): def test_create_firewall_group_with_router_port(self): with self.port( - device_owner=nl_constants.DEVICE_OWNER_ROUTER_INTF) as port: + device_owner=nl_constants.DEVICE_OWNER_ROUTER_INTF) as port: attrs = self._get_test_firewall_group_attrs("fwg1") attrs['ports'] = [port['port']['id']] self._test_create_firewall_group(attrs) def test_create_firewall_group_with_dvr_port(self): with self.port( - device_owner=nl_constants.DEVICE_OWNER_DVR_INTERFACE) as port: + device_owner=nl_constants.DEVICE_OWNER_DVR_INTERFACE) as port: attrs = self._get_test_firewall_group_attrs("fwg1") attrs['ports'] = [port['port']['id']] self._test_create_firewall_group(attrs) def test_create_firewall_group_with_router_port_l3ha(self): - with self.port( - device_owner=nl_constants.DEVICE_OWNER_HA_REPLICATED_INT) as port: + dev_owner_ha_repl_int = nl_constants.DEVICE_OWNER_HA_REPLICATED_INT + with self.port(device_owner=dev_owner_ha_repl_int) as port: attrs = self._get_test_firewall_group_attrs("fwg1") attrs['ports'] = [port['port']['id']] self._test_create_firewall_group(attrs) @@ -993,7 +994,7 @@ class TestFirewallDBPluginV2(test_fwaas_plugin_v2.FirewallPluginV2TestCase): for rule_id in policy['firewall_rules']: rule = self._show_req( 'firewall_rules', rule_id)['firewall_rule'] - self.assertTrue(direction in rule["description"]) + self.assertIn(direction, rule["description"]) for obj in result_map: res = self._list_req(obj) @@ -1098,8 +1099,8 @@ class TestFirewallDBPluginV2(test_fwaas_plugin_v2.FirewallPluginV2TestCase): def test_show_firewall_group_with_ports(self): attrs = self._get_test_firewall_group_attrs('fwg1') - with self.port( - device_owner=nl_constants.DEVICE_OWNER_ROUTER_INTF) as dummy_port: + dev_owner_router_intf = nl_constants.DEVICE_OWNER_ROUTER_INTF + with self.port(device_owner=dev_owner_router_intf) as dummy_port: attrs['ports'] = [dummy_port['port']['id']] self._test_show_firewall_group(attrs) @@ -1161,8 +1162,8 @@ class TestFirewallDBPluginV2(test_fwaas_plugin_v2.FirewallPluginV2TestCase): ctx = self._get_nonadmin_context() def_fwg_id = self._build_default_fwg(ctx=ctx)['id'] with self.port( - device_owner=nl_constants.DEVICE_OWNER_ROUTER_INTF, - tenant_id=ctx.project_id) as dummy_port: + device_owner=nl_constants.DEVICE_OWNER_ROUTER_INTF, + tenant_id=ctx.project_id) as dummy_port: port_id = dummy_port['port']['id'] success_cases = [ {'ports': [port_id]}, @@ -1182,8 +1183,8 @@ class TestFirewallDBPluginV2(test_fwaas_plugin_v2.FirewallPluginV2TestCase): ctx = self._get_nonadmin_context() def_fwg_id = self._build_default_fwg(ctx=ctx)['id'] with self.port( - device_owner=nl_constants.DEVICE_OWNER_ROUTER_INTF, - tenant_id=ctx.project_id) as dummy_port: + device_owner=nl_constants.DEVICE_OWNER_ROUTER_INTF, + tenant_id=ctx.project_id) as dummy_port: port_id = dummy_port['port']['id'] conflict_cases = [ {'name': ''}, @@ -1208,8 +1209,8 @@ class TestFirewallDBPluginV2(test_fwaas_plugin_v2.FirewallPluginV2TestCase): def test_update_default_firewall_group_with_admin_success(self): ctx = self._get_admin_context() with self.port( - device_owner=nl_constants.DEVICE_OWNER_ROUTER_INTF, - tenant_id=ctx.project_id) as dummy_port: + device_owner=nl_constants.DEVICE_OWNER_ROUTER_INTF, + tenant_id=ctx.project_id) as dummy_port: port_id = dummy_port['port']['id'] def_fwg_id = self._build_default_fwg(ctx=ctx)['id'] success_cases = [ @@ -1233,8 +1234,8 @@ class TestFirewallDBPluginV2(test_fwaas_plugin_v2.FirewallPluginV2TestCase): def test_update_default_firewall_group_with_admin_failure(self): ctx = self._get_admin_context() with self.port( - device_owner=nl_constants.DEVICE_OWNER_ROUTER_INTF, - tenant_id=ctx.project_id) as dummy_port: + device_owner=nl_constants.DEVICE_OWNER_ROUTER_INTF, + tenant_id=ctx.project_id) as dummy_port: port_id = dummy_port['port']['id'] def_fwg_id = self._build_default_fwg(ctx=ctx)['id'] conflict_cases = [ @@ -1272,9 +1273,10 @@ class TestFirewallDBPluginV2(test_fwaas_plugin_v2.FirewallPluginV2TestCase): self.assertEqual(200, res.status_int) def test_change_fwg_name_to_default(self): - """ - Make sure that neither admin nor non-admin can change name of - existing firewall group to default + """Test that fw group name can't be changed + + Make sure that neither admin nor non-admin can change name of + existing firewall group to default """ admin_ctx = self._get_admin_context() nonadmin_ctx = self._get_nonadmin_context() diff --git a/neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/drivers/linux/test_netlink_conntrack.py b/neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/drivers/linux/test_netlink_conntrack.py index c9091d8bc..6265298ce 100644 --- a/neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/drivers/linux/test_netlink_conntrack.py +++ b/neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/drivers/linux/test_netlink_conntrack.py @@ -185,7 +185,8 @@ class ConntrackNetlinkTestCase(base.BaseTestCase): not_in_dport_range = [(4, 'tcp', 1, 2, '1.1.1.1', '2.2.2.2'), (4, 'tcp', [1], ['3', '100']), -1] for entry, rule_filter, expect in [ - wrong_ipv, wrong_proto, not_in_sport_range, not_in_dport_range]: + wrong_ipv, wrong_proto, not_in_sport_range, + not_in_dport_range]: self._test_entry_to_delete(rule_filter, entry, expect) def test_get_filter_from_rules(self): diff --git a/neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/l2/test_fwaas_v2.py b/neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/l2/test_fwaas_v2.py index d5ff54f4f..5d9cfc22e 100644 --- a/neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/l2/test_fwaas_v2.py +++ b/neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/l2/test_fwaas_v2.py @@ -401,13 +401,13 @@ class TestIsPortLayer2(TestFWaasV2AgentExtensionBase): def test_not_vm_port(self): for device_owner in [nl_consts.DEVICE_OWNER_ROUTER_INTF, - nl_consts.DEVICE_OWNER_ROUTER_GW, - nl_consts.DEVICE_OWNER_DHCP, - nl_consts.DEVICE_OWNER_DVR_INTERFACE, - nl_consts.DEVICE_OWNER_AGENT_GW, - nl_consts.DEVICE_OWNER_ROUTER_SNAT, - 'unknown device_owner', - '']: + nl_consts.DEVICE_OWNER_ROUTER_GW, + nl_consts.DEVICE_OWNER_DHCP, + nl_consts.DEVICE_OWNER_DVR_INTERFACE, + nl_consts.DEVICE_OWNER_AGENT_GW, + nl_consts.DEVICE_OWNER_ROUTER_SNAT, + 'unknown device_owner', + '']: self.port['device_owner'] = device_owner self.assertFalse(self.l2._is_port_layer2(self.port)) diff --git a/neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/test_agents.py b/neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/test_agents.py index b1ee88f3e..258305736 100644 --- a/neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/test_agents.py +++ b/neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/test_agents.py @@ -40,9 +40,10 @@ DELETEFW_PATH = (FIREWALL_AGENT_PLUGIN + '.FirewallAgentApi.' class FakeAgentApi(agents.FirewallAgentCallbacks): - """ - This class used to mock the AgentAPI delete method inherits from - FirewallCallbacks because it needs access to the firewall_deleted method. + """This class used to mock the AgentAPI delete method + + It inherits from FirewallCallbacks because it needs access to + the firewall_deleted method. The delete_firewall method belongs to the FirewallAgentApi, which has no access to the firewall_deleted method normally because it's not responsible for deleting the firewall from the DB. However, it needs @@ -241,10 +242,10 @@ class TestAgentDriver(test_fwaas_plugin_v2.FirewallPluginV2TestCase, with self.firewall_policy(as_admin=True) as fwp: fwp_id = fwp['firewall_policy']['id'] with self.firewall_group( - name='test', - ingress_firewall_policy_id=fwp_id, - egress_firewall_policy_id=fwp_id, - admin_state_up=True) as fwg1: + name='test', + ingress_firewall_policy_id=fwp_id, + egress_firewall_policy_id=fwp_id, + admin_state_up=True) as fwg1: self.assertEqual(nl_constants.INACTIVE, fwg1['firewall_group']['status']) @@ -272,10 +273,10 @@ class TestAgentDriver(test_fwaas_plugin_v2.FirewallPluginV2TestCase, with self.firewall_policy(as_admin=True) as fwp: fwp_id = fwp['firewall_policy']['id'] with self.firewall_group( - name='test', - ingress_firewall_policy_id=fwp_id, - egress_firewall_policy_id=fwp_id, ports=fwg_ports, - admin_state_up=True) as fwg1: + name='test', + ingress_firewall_policy_id=fwp_id, + egress_firewall_policy_id=fwp_id, ports=fwg_ports, + admin_state_up=True) as fwg1: self.assertEqual(nl_constants.PENDING_CREATE, fwg1['firewall_group']['status']) @@ -313,11 +314,11 @@ class TestAgentDriver(test_fwaas_plugin_v2.FirewallPluginV2TestCase, with self.firewall_policy(as_admin=True) as fwp: fwp_id = fwp['firewall_policy']['id'] with self.firewall_group( - name='test', - ingress_firewall_policy_id=fwp_id, - egress_firewall_policy_id=fwp_id, - ports=fwg_ports, - admin_state_up=True) as fwg1: + name='test', + ingress_firewall_policy_id=fwp_id, + egress_firewall_policy_id=fwp_id, + ports=fwg_ports, + admin_state_up=True) as fwg1: self.assertEqual(nl_constants.PENDING_CREATE, fwg1['firewall_group']['status']) @@ -343,10 +344,10 @@ class TestAgentDriver(test_fwaas_plugin_v2.FirewallPluginV2TestCase, port_id2 = body['port_id'] fwg_ports = [port_id1, port_id2] with self.firewall_group( - name='test', - default_policy=False, - ports=fwg_ports, - admin_state_up=True) as fwg1: + name='test', + default_policy=False, + ports=fwg_ports, + admin_state_up=True) as fwg1: self.assertEqual(nl_constants.INACTIVE, fwg1['firewall_group']['status']) @@ -381,10 +382,10 @@ class TestAgentDriver(test_fwaas_plugin_v2.FirewallPluginV2TestCase, fwg_ports = [port_id1, port_id2] with self.firewall_group( - name='test', - default_policy=False, - ports=fwg_ports, - admin_state_up=True) as fwg1: + name='test', + default_policy=False, + ports=fwg_ports, + admin_state_up=True) as fwg1: self.assertEqual(nl_constants.INACTIVE, fwg1['firewall_group']['status']) data = {'firewall_group': {'ports': [port_id2, port_id3]}} @@ -433,10 +434,10 @@ class TestAgentDriver(test_fwaas_plugin_v2.FirewallPluginV2TestCase, with self.firewall_policy(as_admin=True) as fwp: fwp_id = fwp['firewall_policy']['id'] with self.firewall_group( - name='test', - ingress_firewall_policy_id=fwp_id, - egress_firewall_policy_id=fwp_id, ports=fwg_ports, - admin_state_up=True) as fwg1: + name='test', + ingress_firewall_policy_id=fwp_id, + egress_firewall_policy_id=fwp_id, ports=fwg_ports, + admin_state_up=True) as fwg1: self.assertEqual(nl_constants.PENDING_CREATE, fwg1['firewall_group']['status']) data = {'firewall_group': {'ports': [port_id2, port_id3]}} @@ -478,10 +479,10 @@ class TestAgentDriver(test_fwaas_plugin_v2.FirewallPluginV2TestCase, with self.firewall_policy(as_admin=True) as fwp: fwp_id = fwp['firewall_policy']['id'] with self.firewall_group( - name='test', - ingress_firewall_policy_id=fwp_id, - egress_firewall_policy_id=fwp_id, ports=fwg_ports, - admin_state_up=True) as fwg1: + name='test', + ingress_firewall_policy_id=fwp_id, + egress_firewall_policy_id=fwp_id, ports=fwg_ports, + admin_state_up=True) as fwg1: self.assertEqual(nl_constants.PENDING_CREATE, fwg1['firewall_group']['status']) @@ -516,10 +517,10 @@ class TestAgentDriver(test_fwaas_plugin_v2.FirewallPluginV2TestCase, as_admin=True) as fwp: fwp_id = fwp['firewall_policy']['id'] with self.firewall_group( - name='test', - ingress_firewall_policy_id=fwp_id, - egress_firewall_policy_id=fwp_id, ports=[port_id1], - admin_state_up=True) as fwg1: + name='test', + ingress_firewall_policy_id=fwp_id, + egress_firewall_policy_id=fwp_id, ports=[port_id1], + admin_state_up=True) as fwg1: self.assertEqual(nl_constants.PENDING_CREATE, fwg1['firewall_group']['status']) @@ -549,14 +550,14 @@ class TestAgentDriver(test_fwaas_plugin_v2.FirewallPluginV2TestCase, port_id1 = body['port_id'] with self.firewall_rule(as_admin=True) as fwr: with self.firewall_policy( - firewall_rules=[fwr['firewall_rule']['id']], - as_admin=True) as fwp: + firewall_rules=[fwr['firewall_rule']['id']], + as_admin=True) as fwp: fwp_id = fwp['firewall_policy']['id'] with self.firewall_group( - name='test', - ingress_firewall_policy_id=fwp_id, - egress_firewall_policy_id=fwp_id, ports=[port_id1], - admin_state_up=True) as fwg1: + name='test', + ingress_firewall_policy_id=fwp_id, + egress_firewall_policy_id=fwp_id, ports=[port_id1], + admin_state_up=True) as fwg1: self.assertEqual(nl_constants.PENDING_CREATE, fwg1['firewall_group']['status']) @@ -597,8 +598,8 @@ class TestAgentDriver(test_fwaas_plugin_v2.FirewallPluginV2TestCase, def test_update_firewall_group_with_ports_and_policy(self): """neutron firewall_group create test-policy """ with self.router(name='router1', admin_state_up=True, - tenant_id=self._tenant_id) as r,\ - self.subnet() as s1,\ + tenant_id=self._tenant_id) as r, \ + self.subnet() as s1, \ self.subnet(cidr='20.0.0.0/24') as s2: body = self._router_interface_action( diff --git a/neutron_fwaas/tests/unit/services/logapi/base.py b/neutron_fwaas/tests/unit/services/logapi/base.py index 0570da2a8..78f610e28 100644 --- a/neutron_fwaas/tests/unit/services/logapi/base.py +++ b/neutron_fwaas/tests/unit/services/logapi/base.py @@ -24,7 +24,7 @@ class BaseLogTestCase(testlib_api.SqlTestCase): with mock.patch.object( resource_manager.ResourceCallbacksManager, '_singleton', - new_callable=mock.PropertyMock(return_value=False)): + new_callable=mock.PropertyMock(return_value=False)): self.cons_mgr = resource_manager.ConsumerResourceCallbacksManager() self.prod_mgr = resource_manager.ProducerResourceCallbacksManager() diff --git a/requirements.txt b/requirements.txt index e8fd36ba2..4185da125 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,3 @@ -# Requirements lower bounds listed here are our best effort to keep them up to -# date but we do not test them so no guarantee of having them all correct. If -# you find any incorrect lower bounds, let us know or propose a fix. - -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. -pbr>=4.0.0 # Apache-2.0 - eventlet!=0.18.3,!=0.20.1,>=0.18.2 # MIT netaddr>=0.7.18 # BSD SQLAlchemy>=1.4.23 # MIT diff --git a/test-requirements.txt b/test-requirements.txt index d1c726983..bdb9dc3d5 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,10 +1,6 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. -hacking>=3.0.1,<3.1.0 # Apache-2.0 +hacking>=6.1.0,<6.2.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 -flake8-import-order==0.12 # LGPLv3 python-subunit>=1.0.0 # Apache-2.0/BSD requests-mock>=1.2.0 # Apache-2.0 oslo.concurrency>=3.26.0 # Apache-2.0 @@ -15,6 +11,7 @@ testscenarios>=0.4 # Apache-2.0/BSD WebOb>=1.8.2 # MIT WebTest>=2.0.27 # MIT oslotest>=3.2.0 # Apache-2.0 +pylint==2.17.4 # GPLv2 PyMySQL>=0.7.6 # MIT License psycopg2>=2.7.3 # LGPL/ZPL ddt>=1.0.1 # MIT diff --git a/tox.ini b/tox.ini index 08f3cf3f4..c0134d743 100644 --- a/tox.ini +++ b/tox.ini @@ -151,26 +151,20 @@ ignore = D000 ignore-path = .venv,.git,.tox,.tmp,*neutron_fwaas/locale*,*lib/python*,neutron_fwaas.egg*,doc/build,releasenotes/*,doc/source/contributor/api,requirements.txt,test-requirements.txt [flake8] -# E125 continuation line does not distinguish itself from next logical line +# N530 direct neutron imports not allowed +# W504 Line break occurred after a binary operator # E126 continuation line over-indented for hanging indent # E128 continuation line under-indented for visual indent -# E129 visually indented line with same indent as next logical line -# E265 block comment should start with '# ' -# H404 multi line docstring should start with a summary # H405 multi line docstring summary not separated with an empty line -# TODO(dougwig) -- uncomment this to test for remaining linkages -# N530 direct neutron imports not allowed -# TODO(ihrachys) -- reenable N537 when new neutron-lib release is available -# H106: Do not put vim configuration in source files +# I202 Additional newline in a group of imports +# E731 do not assign a lambda expression, use a def +# W504 line break after binary operator +ignore = E126,E128,E731,I202,H405,N530,W504 +# H106: Don't put vim configuration in source files # H203: Use assertIs(Not)None to check for None # H204: Use assert(Not)Equal to check for equality # H205: Use assert(Greater|Less)(Equal) for comparison # H904: Delay string interpolations at logging calls -# N521: jsonutils.loads must be used instead of json.loads -# W504 line break after binary operator -# (W503 and W504 are incompatible and we need to choose one of them. -# Existing codes follows W503, so we disable W504.) -ignore = E125,E126,E128,E129,E265,H404,H405,N530,N521,W504 enable-extensions=H106,H203,H204,H205,H904 show-source = true exclude = .venv,.git,.tox,dist,doc,*lib/python*,.tmp,*egg,build,tools,.ropeproject,rally-scenarios