From 58b1df699d2aff234aace1df2c8dca609ca7352c Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Fri, 1 Jul 2022 17:41:59 -0400 Subject: [PATCH] Fix some pylint indentation warnings Running with a stricter .pylintrc generates a lot of C0330 warnings (hanging/continued indentation). Fix some of them, about 10%. Feel free to reject if we think it will cause too much trouble with cherry-picks, else I'll slowly work my way through the rest of the tree. Trivialfix Change-Id: I3d484d11e273cb8ee617f9445a069887e7b2b89f --- neutron/cmd/eventlet/agents/dhcp.py | 2 +- neutron/cmd/eventlet/agents/l3.py | 2 +- neutron/cmd/eventlet/agents/metadata.py | 2 +- neutron/cmd/eventlet/agents/ovn_metadata.py | 2 +- .../plugins/linuxbridge_neutron_agent.py | 2 +- .../eventlet/plugins/macvtap_neutron_agent.py | 2 +- .../cmd/eventlet/plugins/ovs_neutron_agent.py | 2 +- .../plugins/sriov_nic_neutron_agent.py | 2 +- .../cmd/eventlet/services/metering_agent.py | 2 +- neutron/cmd/sanity/checks.py | 8 +++--- neutron/cmd/sanity_check.py | 12 ++++----- neutron/cmd/upgrade_checks/checks.py | 3 +-- .../extensions/floating_ip_port_forwarding.py | 10 +++---- neutron/extensions/floatingip_pools.py | 10 +++---- neutron/extensions/l3_conntrack_helper.py | 10 +++---- neutron/extensions/l3_ndp_proxy.py | 10 +++---- neutron/extensions/logging.py | 10 +++---- neutron/extensions/qos.py | 26 +++++++++---------- neutron/extensions/qos_pps_minimum_rule.py | 2 +- .../extensions/qos_pps_minimum_rule_alias.py | 2 +- neutron/extensions/qos_rules_alias.py | 2 +- neutron/extensions/quotasv2.py | 9 ++++--- neutron/opts.py | 4 +-- neutron/quota/resource.py | 4 +-- neutron/wsgi.py | 2 +- 25 files changed, 71 insertions(+), 71 deletions(-) diff --git a/neutron/cmd/eventlet/agents/dhcp.py b/neutron/cmd/eventlet/agents/dhcp.py index 168cf3603b2..17f30aab0ca 100644 --- a/neutron/cmd/eventlet/agents/dhcp.py +++ b/neutron/cmd/eventlet/agents/dhcp.py @@ -18,7 +18,7 @@ from neutron_lib import constants def main(): proctitle = "%s (%s)" % ( - constants.AGENT_PROCESS_DHCP, setproctitle.getproctitle()) + constants.AGENT_PROCESS_DHCP, setproctitle.getproctitle()) setproctitle.setproctitle(proctitle) dhcp_agent.main() diff --git a/neutron/cmd/eventlet/agents/l3.py b/neutron/cmd/eventlet/agents/l3.py index d090c427ace..29f0db73de0 100644 --- a/neutron/cmd/eventlet/agents/l3.py +++ b/neutron/cmd/eventlet/agents/l3.py @@ -18,7 +18,7 @@ from neutron_lib import constants def main(): proctitle = "%s (%s)" % ( - constants.AGENT_PROCESS_L3, setproctitle.getproctitle()) + constants.AGENT_PROCESS_L3, setproctitle.getproctitle()) setproctitle.setproctitle(proctitle) l3_agent.main() diff --git a/neutron/cmd/eventlet/agents/metadata.py b/neutron/cmd/eventlet/agents/metadata.py index 1ae8be5bad4..58d49f0315d 100644 --- a/neutron/cmd/eventlet/agents/metadata.py +++ b/neutron/cmd/eventlet/agents/metadata.py @@ -18,7 +18,7 @@ from neutron_lib import constants def main(): proctitle = "%s (%s)" % ( - constants.AGENT_PROCESS_METADATA, setproctitle.getproctitle()) + constants.AGENT_PROCESS_METADATA, setproctitle.getproctitle()) setproctitle.setproctitle(proctitle) metadata_agent.main() diff --git a/neutron/cmd/eventlet/agents/ovn_metadata.py b/neutron/cmd/eventlet/agents/ovn_metadata.py index 7e122081163..284829c5852 100644 --- a/neutron/cmd/eventlet/agents/ovn_metadata.py +++ b/neutron/cmd/eventlet/agents/ovn_metadata.py @@ -18,7 +18,7 @@ from neutron_lib import constants def main(): proctitle = "%s (%s)" % ( - constants.AGENT_PROCESS_OVN_METADATA, setproctitle.getproctitle()) + constants.AGENT_PROCESS_OVN_METADATA, setproctitle.getproctitle()) setproctitle.setproctitle(proctitle) metadata_agent.main() diff --git a/neutron/cmd/eventlet/plugins/linuxbridge_neutron_agent.py b/neutron/cmd/eventlet/plugins/linuxbridge_neutron_agent.py index 4d77983296f..04baac62d5c 100644 --- a/neutron/cmd/eventlet/plugins/linuxbridge_neutron_agent.py +++ b/neutron/cmd/eventlet/plugins/linuxbridge_neutron_agent.py @@ -22,7 +22,7 @@ from neutron_lib import constants def main(): proctitle = "%s (%s)" % ( - constants.AGENT_PROCESS_LINUXBRIDGE, setproctitle.getproctitle()) + constants.AGENT_PROCESS_LINUXBRIDGE, setproctitle.getproctitle()) setproctitle.setproctitle(proctitle) agent_main.main() diff --git a/neutron/cmd/eventlet/plugins/macvtap_neutron_agent.py b/neutron/cmd/eventlet/plugins/macvtap_neutron_agent.py index ea84d0a002e..61b46df1960 100644 --- a/neutron/cmd/eventlet/plugins/macvtap_neutron_agent.py +++ b/neutron/cmd/eventlet/plugins/macvtap_neutron_agent.py @@ -21,7 +21,7 @@ from neutron_lib import constants def main(): proctitle = "%s (%s)" % ( - constants.AGENT_PROCESS_MACVTAP, setproctitle.getproctitle()) + constants.AGENT_PROCESS_MACVTAP, setproctitle.getproctitle()) setproctitle.setproctitle(proctitle) agent_main.main() diff --git a/neutron/cmd/eventlet/plugins/ovs_neutron_agent.py b/neutron/cmd/eventlet/plugins/ovs_neutron_agent.py index 6851d60152d..2e68fecb6ef 100644 --- a/neutron/cmd/eventlet/plugins/ovs_neutron_agent.py +++ b/neutron/cmd/eventlet/plugins/ovs_neutron_agent.py @@ -21,7 +21,7 @@ from neutron_lib import constants def main(): proctitle = "%s (%s)" % ( - constants.AGENT_PROCESS_OVS, setproctitle.getproctitle()) + constants.AGENT_PROCESS_OVS, setproctitle.getproctitle()) setproctitle.setproctitle(proctitle) agent_main.main() diff --git a/neutron/cmd/eventlet/plugins/sriov_nic_neutron_agent.py b/neutron/cmd/eventlet/plugins/sriov_nic_neutron_agent.py index 4d7cc623ae1..a56ac24ef30 100644 --- a/neutron/cmd/eventlet/plugins/sriov_nic_neutron_agent.py +++ b/neutron/cmd/eventlet/plugins/sriov_nic_neutron_agent.py @@ -21,7 +21,7 @@ from neutron_lib import constants def main(): proctitle = "%s (%s)" % ( - constants.AGENT_PROCESS_NIC_SWITCH, setproctitle.getproctitle()) + constants.AGENT_PROCESS_NIC_SWITCH, setproctitle.getproctitle()) setproctitle.setproctitle(proctitle) agent_main.main() diff --git a/neutron/cmd/eventlet/services/metering_agent.py b/neutron/cmd/eventlet/services/metering_agent.py index 4813a5735f2..caa64422d4c 100644 --- a/neutron/cmd/eventlet/services/metering_agent.py +++ b/neutron/cmd/eventlet/services/metering_agent.py @@ -18,7 +18,7 @@ from neutron_lib import constants def main(): proctitle = "%s (%s)" % ( - constants.AGENT_PROCESS_METERING, setproctitle.getproctitle()) + constants.AGENT_PROCESS_METERING, setproctitle.getproctitle()) setproctitle.setproctitle(proctitle) metering_agent.main() diff --git a/neutron/cmd/sanity/checks.py b/neutron/cmd/sanity/checks.py index ba6b14fd84b..901f469efaf 100644 --- a/neutron/cmd/sanity/checks.py +++ b/neutron/cmd/sanity/checks.py @@ -274,7 +274,7 @@ def ovs_qos_direct_port_supported(): ver = versionutils.convert_version_to_tuple(matched_version.group(1) if matched_version else '0.0') minver = versionutils.convert_version_to_tuple( - DIRECT_PORT_QOS_MIN_OVS_VERSION) + DIRECT_PORT_QOS_MIN_OVS_VERSION) if ver < minver: return False except (OSError, RuntimeError, ValueError) as e: @@ -590,7 +590,7 @@ def ovn_nb_db_schema_port_group_supported(): try: ver = _get_ovn_version(OVNCheckType.nb_db_schema) minver = versionutils.convert_version_to_tuple( - OVN_NB_DB_SCHEMA_PORT_GROUP) + OVN_NB_DB_SCHEMA_PORT_GROUP) if ver < minver: return False except (OSError, RuntimeError, ValueError) as e: @@ -604,7 +604,7 @@ def ovn_nb_db_schema_stateless_nat_supported(): try: ver = _get_ovn_version(OVNCheckType.nb_db_schema) minver = versionutils.convert_version_to_tuple( - OVN_NB_DB_SCHEMA_STATELESS_NAT) + OVN_NB_DB_SCHEMA_STATELESS_NAT) if ver < minver: return False except (OSError, RuntimeError, ValueError) as e: @@ -618,7 +618,7 @@ def ovn_sb_db_schema_virtual_port_supported(): try: ver = _get_ovn_version(OVNCheckType.sb_db_schema) minver = versionutils.convert_version_to_tuple( - OVN_SB_DB_SCHEMA_VIRTUAL_PORT) + OVN_SB_DB_SCHEMA_VIRTUAL_PORT) if ver < minver: return False except (OSError, RuntimeError, ValueError) as e: diff --git a/neutron/cmd/sanity_check.py b/neutron/cmd/sanity_check.py index 69af3f5a501..c396bbc88dd 100644 --- a/neutron/cmd/sanity_check.py +++ b/neutron/cmd/sanity_check.py @@ -440,12 +440,12 @@ def enable_tests_from_config(): if cfg.CONF.SECURITYGROUP.enable_security_group: cfg.CONF.set_default('ip6tables_installed', True) if cfg.CONF.SECURITYGROUP.firewall_driver in ( - 'iptables', - 'iptables_hybrid', - ('neutron.agent.linux.iptables_firewall.' - 'IptablesFirewallDriver'), - ('neutron.agent.linux.iptables_firewall.' - 'OVSHybridIptablesFirewallDriver'), + 'iptables', + 'iptables_hybrid', + ('neutron.agent.linux.iptables_firewall.' + 'IptablesFirewallDriver'), + ('neutron.agent.linux.iptables_firewall.' + 'OVSHybridIptablesFirewallDriver'), ): cfg.CONF.set_default('bridge_firewalling', True) if cfg.CONF.SRIOV_NIC.physical_device_mappings: diff --git a/neutron/cmd/upgrade_checks/checks.py b/neutron/cmd/upgrade_checks/checks.py index 33178e209de..d367a370981 100644 --- a/neutron/cmd/upgrade_checks/checks.py +++ b/neutron/cmd/upgrade_checks/checks.py @@ -145,8 +145,7 @@ def get_fip_per_network_without_qos_policies(network_id): query = query.filter(and_( ~exists().where(qos_models.QosFIPPolicyBinding.fip_id == l3_models.FloatingIP.id), - l3_models.FloatingIP.floating_network_id == network_id) - ) + l3_models.FloatingIP.floating_network_id == network_id)) return query.count() diff --git a/neutron/extensions/floating_ip_port_forwarding.py b/neutron/extensions/floating_ip_port_forwarding.py index c46f562f480..14c47c440c9 100644 --- a/neutron/extensions/floating_ip_port_forwarding.py +++ b/neutron/extensions/floating_ip_port_forwarding.py @@ -46,11 +46,11 @@ class Floating_ip_port_forwarding(api_extensions.APIExtensionDescriptor): apidef.SUB_RESOURCE_ATTRIBUTE_MAP)) resources = resource_helper.build_resource_info( - plural_mappings, - apidef.RESOURCE_ATTRIBUTE_MAP, - plugin_consts.PORTFORWARDING, - translate_name=True, - allow_bulk=True) + plural_mappings, + apidef.RESOURCE_ATTRIBUTE_MAP, + plugin_consts.PORTFORWARDING, + translate_name=True, + allow_bulk=True) plugin = directory.get_plugin(plugin_consts.PORTFORWARDING) diff --git a/neutron/extensions/floatingip_pools.py b/neutron/extensions/floatingip_pools.py index 337c83c2aa3..93f607c72df 100644 --- a/neutron/extensions/floatingip_pools.py +++ b/neutron/extensions/floatingip_pools.py @@ -32,11 +32,11 @@ class Floatingip_pools(api_extensions.APIExtensionDescriptor): {}, itertools.chain(apidef.RESOURCE_ATTRIBUTE_MAP)) resources = resource_helper.build_resource_info( - plural_mappings, - apidef.RESOURCE_ATTRIBUTE_MAP, - constants.L3, - translate_name=True, - allow_bulk=True) + plural_mappings, + apidef.RESOURCE_ATTRIBUTE_MAP, + constants.L3, + translate_name=True, + allow_bulk=True) return resources diff --git a/neutron/extensions/l3_conntrack_helper.py b/neutron/extensions/l3_conntrack_helper.py index bd6319ef631..76dba410f36 100644 --- a/neutron/extensions/l3_conntrack_helper.py +++ b/neutron/extensions/l3_conntrack_helper.py @@ -50,11 +50,11 @@ class L3_conntrack_helper(api_extensions.APIExtensionDescriptor): apidef.SUB_RESOURCE_ATTRIBUTE_MAP)) resources = resource_helper.build_resource_info( - plural_mappings, - apidef.RESOURCE_ATTRIBUTE_MAP, - plugin_consts.CONNTRACKHELPER, - translate_name=True, - allow_bulk=True) + plural_mappings, + apidef.RESOURCE_ATTRIBUTE_MAP, + plugin_consts.CONNTRACKHELPER, + translate_name=True, + allow_bulk=True) plugin = directory.get_plugin(plugin_consts.CONNTRACKHELPER) diff --git a/neutron/extensions/l3_ndp_proxy.py b/neutron/extensions/l3_ndp_proxy.py index 2cfa6f340d5..5d3c7f335df 100644 --- a/neutron/extensions/l3_ndp_proxy.py +++ b/neutron/extensions/l3_ndp_proxy.py @@ -35,11 +35,11 @@ class L3_ndp_proxy(api_extensions.APIExtensionDescriptor): plural_mappings = resource_helper.build_plural_mappings( special_mappings, apidef.RESOURCE_ATTRIBUTE_MAP) return resource_helper.build_resource_info( - plural_mappings, - apidef.RESOURCE_ATTRIBUTE_MAP, - plugin_consts.NDPPROXY, - translate_name=True, - allow_bulk=True) + plural_mappings, + apidef.RESOURCE_ATTRIBUTE_MAP, + plugin_consts.NDPPROXY, + translate_name=True, + allow_bulk=True) class NDPProxyBase(service_base.ServicePluginBase): diff --git a/neutron/extensions/logging.py b/neutron/extensions/logging.py index 249b0a2e29b..4b676cdc8ce 100644 --- a/neutron/extensions/logging.py +++ b/neutron/extensions/logging.py @@ -40,11 +40,11 @@ class Logging(api_extensions.APIExtensionDescriptor): {}, itertools.chain(apidef.RESOURCE_ATTRIBUTE_MAP)) resources = resource_helper.build_resource_info( - plural_mappings, - apidef.RESOURCE_ATTRIBUTE_MAP, - plugin_const.LOG_API, - translate_name=True, - allow_bulk=True) + plural_mappings, + apidef.RESOURCE_ATTRIBUTE_MAP, + plugin_const.LOG_API, + translate_name=True, + allow_bulk=True) return resources diff --git a/neutron/extensions/qos.py b/neutron/extensions/qos.py index 843f686d84f..ccb2c8be6f5 100644 --- a/neutron/extensions/qos.py +++ b/neutron/extensions/qos.py @@ -48,11 +48,11 @@ class Qos(api_extensions.APIExtensionDescriptor): apidef.SUB_RESOURCE_ATTRIBUTE_MAP)) resources = resource_helper.build_resource_info( - plural_mappings, - apidef.RESOURCE_ATTRIBUTE_MAP, - constants.QOS, - translate_name=True, - allow_bulk=True) + plural_mappings, + apidef.RESOURCE_ATTRIBUTE_MAP, + constants.QOS, + translate_name=True, + allow_bulk=True) plugin = directory.get_plugin(constants.QOS) for collection_name in apidef.SUB_RESOURCE_ATTRIBUTE_MAP: @@ -95,14 +95,14 @@ class QoSPluginBase(service_base.ServicePluginBase, metaclass=abc.ABCMeta): # Patterns used to call method proxies for all policy-rule-specific # method calls (see __getattr__ docstring, below). qos_rule_method_patterns = [ - re.compile( - r"^((create|update|delete)_policy_(?P.*)_rule)$"), - re.compile( - r"^(get_policy_(?P.*)_(rules|rule))$"), - # The following entry handles rule alias calls - re.compile( - r"^((update|delete|get)_alias_(?P.*)_rule)$"), - ] + re.compile( + r"^((create|update|delete)_policy_(?P.*)_rule)$"), + re.compile( + r"^(get_policy_(?P.*)_(rules|rule))$"), + # The following entry handles rule alias calls + re.compile( + r"^((update|delete|get)_alias_(?P.*)_rule)$"), + ] def __getattr__(self, attrib): """Implement method proxies for all policy-rule-specific requests. For diff --git a/neutron/extensions/qos_pps_minimum_rule.py b/neutron/extensions/qos_pps_minimum_rule.py index ae74bd49600..d00485bbb24 100644 --- a/neutron/extensions/qos_pps_minimum_rule.py +++ b/neutron/extensions/qos_pps_minimum_rule.py @@ -25,7 +25,7 @@ class Qos_pps_minimum_rule(api_extensions.APIExtensionDescriptor): @classmethod def get_resources(cls): plural_mappings = resource_helper.build_plural_mappings( - {}, apidef.SUB_RESOURCE_ATTRIBUTE_MAP) + {}, apidef.SUB_RESOURCE_ATTRIBUTE_MAP) return resource_helper.build_resource_info( plural_mappings, diff --git a/neutron/extensions/qos_pps_minimum_rule_alias.py b/neutron/extensions/qos_pps_minimum_rule_alias.py index 37f2cee0643..0ea706d6ed4 100644 --- a/neutron/extensions/qos_pps_minimum_rule_alias.py +++ b/neutron/extensions/qos_pps_minimum_rule_alias.py @@ -25,7 +25,7 @@ class Qos_pps_minimum_rule_alias(api_extensions.APIExtensionDescriptor): @classmethod def get_resources(cls): plural_mappings = resource_helper.build_plural_mappings( - {}, apidef.RESOURCE_ATTRIBUTE_MAP) + {}, apidef.RESOURCE_ATTRIBUTE_MAP) return resource_helper.build_resource_info( plural_mappings, diff --git a/neutron/extensions/qos_rules_alias.py b/neutron/extensions/qos_rules_alias.py index 99dd53a1d94..79af4bff560 100644 --- a/neutron/extensions/qos_rules_alias.py +++ b/neutron/extensions/qos_rules_alias.py @@ -27,7 +27,7 @@ class Qos_rules_alias(api_extensions.APIExtensionDescriptor): def get_resources(cls): """Returns Ext Resources.""" plural_mappings = resource_helper.build_plural_mappings( - {}, apidef.RESOURCE_ATTRIBUTE_MAP) + {}, apidef.RESOURCE_ATTRIBUTE_MAP) return resource_helper.build_resource_info( plural_mappings, diff --git a/neutron/extensions/quotasv2.py b/neutron/extensions/quotasv2.py index f84eae0e37c..250a6fa9b4f 100644 --- a/neutron/extensions/quotasv2.py +++ b/neutron/extensions/quotasv2.py @@ -86,10 +86,11 @@ class QuotaSetsController(wsgi.Controller): context = request.context if id != context.project_id: validate_policy(context, "get_quota") - return {self._resource_name: self._driver.get_default_quotas( - context=context, - resources=resource_registry.get_all_resources(), - project_id=id)} + return {self._resource_name: + self._driver.get_default_quotas( + context=context, + resources=resource_registry.get_all_resources(), + project_id=id)} def create(self, request, body=None): msg = _('POST requests are not supported on this resource.') diff --git a/neutron/opts.py b/neutron/opts.py index 31f8fa88dcf..8df86423c21 100644 --- a/neutron/opts.py +++ b/neutron/opts.py @@ -157,7 +157,7 @@ def list_db_opts(): neutron.conf.db.extraroute_db.EXTRA_ROUTE_OPTS, neutron.conf.db.l3_gwmode_db.L3GWMODE_OPTS, neutron.conf.agent.database.agentschedulers_db - .AGENTS_SCHEDULER_OPTS, + .AGENTS_SCHEDULER_OPTS, neutron.conf.db.dvr_mac_db.DVR_MAC_ADDRESS_OPTS, neutron.conf.db.l3_dvr_db.ROUTER_DISTRIBUTED_OPTS, neutron.conf.db.l3_agentschedulers_db.L3_AGENTS_SCHEDULER_OPTS, @@ -180,7 +180,7 @@ def list_opts(): ), (neutron.conf.common.NOVA_CONF_SECTION, itertools.chain( - neutron.conf.common.nova_opts) + neutron.conf.common.nova_opts) ), (neutron.conf.common.IRONIC_CONF_SECTION, itertools.chain( diff --git a/neutron/quota/resource.py b/neutron/quota/resource.py index d5bb523304d..1d00adeefdf 100644 --- a/neutron/quota/resource.py +++ b/neutron/quota/resource.py @@ -264,7 +264,7 @@ class TrackedResource(BaseResource): {'project_id': project_id, 'resource': self.name}) in_use = context.session.query( self._model_class.project_id).filter_by( - project_id=project_id).count() + project_id=project_id).count() # Update quota usage return self._resync(context, project_id, in_use) @@ -295,7 +295,7 @@ class TrackedResource(BaseResource): 'project_id': project_id}) in_use = context.session.query( self._model_class.project_id).filter_by( - project_id=project_id).count() + project_id=project_id).count() # Update quota usage, if requested (by default do not do that, as # typically one counts before adding a record, and that would mark diff --git a/neutron/wsgi.py b/neutron/wsgi.py index 9c07bda4782..df1c6d6951c 100644 --- a/neutron/wsgi.py +++ b/neutron/wsgi.py @@ -148,7 +148,7 @@ class Server(object): eventlet.sleep(0.1) if not sock: raise RuntimeError(_("Could not bind to %(host)s:%(port)s " - "after trying for %(time)d seconds") % + "after trying for %(time)d seconds") % {'host': host, 'port': port, 'time': CONF.retry_until_window})