diff --git a/neutron/agent/dhcp/agent.py b/neutron/agent/dhcp/agent.py index 790a60dee5a..3d398ec8f6c 100644 --- a/neutron/agent/dhcp/agent.py +++ b/neutron/agent/dhcp/agent.py @@ -162,8 +162,8 @@ class DhcpAgent(manager.Manager): # will automatically be retried on the notification self.schedule_resync(e, network.id) if (isinstance(e, oslo_messaging.RemoteError) and - e.exc_type == 'NetworkNotFound' or - isinstance(e, exceptions.NetworkNotFound)): + e.exc_type == 'NetworkNotFound' or + isinstance(e, exceptions.NetworkNotFound)): LOG.debug("Network %s has been deleted.", network.id) else: LOG.exception('Unable to %(action)s dhcp for %(net_id)s.', @@ -521,7 +521,7 @@ class DhcpAgent(manager.Manager): def disable_isolated_metadata_proxy(self, network): if (self.conf.enable_metadata_network and - network.id in self._metadata_routers): + network.id in self._metadata_routers): uuid = self._metadata_routers[network.id] is_router_id = True else: diff --git a/neutron/agent/l3/agent.py b/neutron/agent/l3/agent.py index 7607c241374..9bfb4d36a18 100644 --- a/neutron/agent/l3/agent.py +++ b/neutron/agent/l3/agent.py @@ -456,7 +456,7 @@ class L3NATAgent(ha.AgentMixin, def _process_router_if_compatible(self, router): if (self.conf.external_network_bridge and - not ip_lib.device_exists(self.conf.external_network_bridge)): + not ip_lib.device_exists(self.conf.external_network_bridge)): LOG.error("The external network bridge '%s' does not exist", self.conf.external_network_bridge) return diff --git a/neutron/agent/l3/dvr_fip_ns.py b/neutron/agent/l3/dvr_fip_ns.py index 21879b78426..01d2163ac0c 100644 --- a/neutron/agent/l3/dvr_fip_ns.py +++ b/neutron/agent/l3/dvr_fip_ns.py @@ -309,8 +309,8 @@ class FipNamespace(namespaces.Namespace): def _update_gateway_port(self, agent_gateway_port, interface_name): if (self.agent_gateway_port and - not self._check_for_gateway_ip_change(agent_gateway_port)): - return + not self._check_for_gateway_ip_change(agent_gateway_port)): + return # Caller already holding lock self._update_gateway_route( agent_gateway_port, interface_name, tbl_index=None) diff --git a/neutron/agent/l3/dvr_local_router.py b/neutron/agent/l3/dvr_local_router.py index 7eace9e2ab7..9ac73b82545 100644 --- a/neutron/agent/l3/dvr_local_router.py +++ b/neutron/agent/l3/dvr_local_router.py @@ -625,8 +625,8 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase): if int_port_addr_value is None: return False if ((key != lib_constants.IP_VERSION_6) and - int_port_addr_scopes.get(str(key)) in - ext_port_addr_scopes.values()): + int_port_addr_scopes.get(str(key)) in + ext_port_addr_scopes.values()): return True return False diff --git a/neutron/agent/linux/dhcp.py b/neutron/agent/linux/dhcp.py index a1c44a4997e..55ba783fde5 100644 --- a/neutron/agent/linux/dhcp.py +++ b/neutron/agent/linux/dhcp.py @@ -813,7 +813,7 @@ class Dnsmasq(DhcpLocalProcess): (iaid, ip, client_id) = parts[1], parts[2], parts[4] ip = ip.strip('[]') if (ip_version and - netaddr.IPAddress(ip).version != ip_version): + netaddr.IPAddress(ip).version != ip_version): continue leases[ip] = {'iaid': iaid, 'client_id': client_id, @@ -1122,7 +1122,8 @@ class Dnsmasq(DhcpLocalProcess): continue for alloc in port.fixed_ips: if (alloc.subnet_id in subnets and - subnets[alloc.subnet_id].gateway_ip == alloc.ip_address): + subnets[alloc.subnet_id].gateway_ip == + alloc.ip_address): isolated_subnets[alloc.subnet_id] = False return isolated_subnets @@ -1165,7 +1166,7 @@ class Dnsmasq(DhcpLocalProcess): return False if (conf.enable_metadata_network and - cls.has_metadata_subnet(all_subnets)): + cls.has_metadata_subnet(all_subnets)): return True isolated_subnets = cls.get_isolated_subnets(network) diff --git a/neutron/agent/linux/iptables_manager.py b/neutron/agent/linux/iptables_manager.py index e0ef2aaf6bc..01ac80e0c83 100644 --- a/neutron/agent/linux/iptables_manager.py +++ b/neutron/agent/linux/iptables_manager.py @@ -499,7 +499,7 @@ class IptablesManager(object): err = self._do_run_restore(args, commands) if (isinstance(err, linux_utils.ProcessExecutionError) and - err.returncode == XTABLES_RESOURCE_PROBLEM_CODE): + err.returncode == XTABLES_RESOURCE_PROBLEM_CODE): # maybe we run on a platform that includes iptables commit # 999eaa241212d3952ddff39a99d0d55a74e3639e (for example, latest # RHEL) and failed because of xlock acquired by another diff --git a/neutron/agent/linux/openvswitch_firewall/firewall.py b/neutron/agent/linux/openvswitch_firewall/firewall.py index 87e487dd68b..d6a1e684221 100644 --- a/neutron/agent/linux/openvswitch_firewall/firewall.py +++ b/neutron/agent/linux/openvswitch_firewall/firewall.py @@ -364,7 +364,7 @@ class ConjIPFlowManager(object): for sg_conj_id_map in vlan_conj_id_map.values(): for remote_sg_id, unused in unused_dict.items(): if (remote_sg_id in sg_conj_id_map and - sg_conj_id_map[remote_sg_id] & unused): + sg_conj_id_map[remote_sg_id] & unused): sg_conj_id_map[remote_sg_id] -= unused if not sg_conj_id_map[remote_sg_id]: del sg_conj_id_map[remote_sg_id] diff --git a/neutron/agent/linux/openvswitch_firewall/rules.py b/neutron/agent/linux/openvswitch_firewall/rules.py index f7bdf8b6a02..2c13e89f42b 100644 --- a/neutron/agent/linux/openvswitch_firewall/rules.py +++ b/neutron/agent/linux/openvswitch_firewall/rules.py @@ -142,7 +142,7 @@ def merge_port_ranges(rule_conj_list): cur_conj.remove(conj_id) if (len(result) == 1 and result[0][0]['port_range_min'] == 1 and - result[0][0]['port_range_max'] == 65535): + result[0][0]['port_range_max'] == 65535): del result[0][0]['port_range_min'] del result[0][0]['port_range_max'] return result diff --git a/neutron/agent/linux/xenapi_root_helper.py b/neutron/agent/linux/xenapi_root_helper.py index 4dacc1e4d80..67f6d506d4d 100644 --- a/neutron/agent/linux/xenapi_root_helper.py +++ b/neutron/agent/linux/xenapi_root_helper.py @@ -62,7 +62,7 @@ class XenAPIClient(object): # [XENAPI_PLUGIN_FAILURE_ID, methodname, except_class_name, message] # We can distinguish the error type by checking the message string. if (len(failure_details) == 4 and - XENAPI_PLUGIN_FAILURE_ID == failure_details[0]): + XENAPI_PLUGIN_FAILURE_ID == failure_details[0]): if (MSG_UNAUTHORIZED == failure_details[3]): return oslo_rootwrap_cmd.RC_UNAUTHORIZED elif (MSG_NOT_FOUND == failure_details[3]): diff --git a/neutron/agent/securitygroups_rpc.py b/neutron/agent/securitygroups_rpc.py index b7a061e44e9..9ad65e44182 100644 --- a/neutron/agent/securitygroups_rpc.py +++ b/neutron/agent/securitygroups_rpc.py @@ -113,7 +113,7 @@ class SecurityGroupAgentRpc(object): @functools.wraps(func) def decorated_function(self, *args, **kwargs): if (isinstance(self.firewall, firewall.NoopFirewallDriver) or - not is_firewall_enabled()): + not is_firewall_enabled()): LOG.info("Skipping method %s as firewall is disabled " "or configured as NoopFirewallDriver.", func.__name__) diff --git a/neutron/api/api_common.py b/neutron/api/api_common.py index aac92bf368c..6a5fee0f3f6 100644 --- a/neutron/api/api_common.py +++ b/neutron/api/api_common.py @@ -147,7 +147,7 @@ def get_limit_and_marker(request): def _get_pagination_max_limit(): max_limit = -1 if (cfg.CONF.pagination_max_limit.lower() != - constants.PAGINATION_INFINITE): + constants.PAGINATION_INFINITE): try: max_limit = int(cfg.CONF.pagination_max_limit) if max_limit == 0: diff --git a/neutron/api/rpc/callbacks/producer/registry.py b/neutron/api/rpc/callbacks/producer/registry.py index 92124c54bcf..970fee4cd89 100644 --- a/neutron/api/rpc/callbacks/producer/registry.py +++ b/neutron/api/rpc/callbacks/producer/registry.py @@ -51,7 +51,7 @@ def pull(resource_type, resource_id, **kwargs): obj = callback(resource_type, resource_id, **kwargs) if obj: if (not isinstance(obj, base.NeutronObject) or - resource_type != obj.obj_name()): + resource_type != obj.obj_name()): raise exceptions.CallbackWrongResourceType( resource_type=resource_type) return obj diff --git a/neutron/api/v2/base.py b/neutron/api/v2/base.py index ff8232644ee..2f6ca1c230e 100644 --- a/neutron/api/v2/base.py +++ b/neutron/api/v2/base.py @@ -169,11 +169,12 @@ class Controller(object): attr_data = self._attr_info.get(attr_name) if attr_data and attr_data['is_visible']: if policy.check( - context, - '%s:%s' % (self._plugin_handlers[self.SHOW], attr_name), - data, - might_not_exist=True, - pluralized=self._collection): + context, + '%s:%s' % (self._plugin_handlers[self.SHOW], + attr_name), + data, + might_not_exist=True, + pluralized=self._collection): # this attribute is visible, check next one continue # if the code reaches this point then either the policy check diff --git a/neutron/cmd/sanity_check.py b/neutron/cmd/sanity_check.py index c92fa970bf9..e6f2e81fa63 100644 --- a/neutron/cmd/sanity_check.py +++ b/neutron/cmd/sanity_check.py @@ -375,7 +375,7 @@ def enable_tests_from_config(): if cfg.CONF.SECURITYGROUP.enable_security_group: cfg.CONF.set_default('ip6tables_installed', True) if ('sriovnicswitch' in cfg.CONF.ml2.mechanism_drivers and - 'qos' in cfg.CONF.ml2.extension_drivers): + 'qos' in cfg.CONF.ml2.extension_drivers): cfg.CONF.set_default('vf_extended_management', True) if cfg.CONF.SECURITYGROUP.firewall_driver in ( 'iptables', diff --git a/neutron/db/agentschedulers_db.py b/neutron/db/agentschedulers_db.py index 73859b24580..a30f23382bf 100644 --- a/neutron/db/agentschedulers_db.py +++ b/neutron/db/agentschedulers_db.py @@ -73,8 +73,9 @@ class AgentSchedulerDbMixin(agents_db.AgentDbMixin): agent_data = agent['agent'] agent_notifier = self.agent_notifiers.get(original_agent['agent_type']) if (agent_notifier and - 'admin_state_up' in agent_data and - original_agent['admin_state_up'] != agent_data['admin_state_up']): + 'admin_state_up' in agent_data and + original_agent['admin_state_up'] != + agent_data['admin_state_up']): agent_notifier.agent_updated(context, agent_data['admin_state_up'], original_agent['host']) diff --git a/neutron/db/db_base_plugin_v2.py b/neutron/db/db_base_plugin_v2.py index 0d913c61fce..db9242e54c1 100644 --- a/neutron/db/db_base_plugin_v2.py +++ b/neutron/db/db_base_plugin_v2.py @@ -278,7 +278,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, # raise if multiple tenants found or if the only tenant found # is not the owner of the network if (len(tenant_ids) > 1 or len(tenant_ids) == 1 and - original.tenant_id not in tenant_ids): + original.tenant_id not in tenant_ids): self._validate_projects_have_access_to_network( original, tenant_ids) @@ -570,7 +570,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, error_message = _("Subnet has a prefix length that is " "incompatible with DHCP service enabled") if ((ip_ver == 4 and subnet_prefixlen > 30) or - (ip_ver == 6 and subnet_prefixlen > 126)): + (ip_ver == 6 and subnet_prefixlen > 126)): raise exc.InvalidInput(error_message=error_message) net = netaddr.IPNetwork(s['cidr']) @@ -937,7 +937,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, for ip in port['fixed_ips']: if ip['subnet_id'] == result['id']: if (port['device_owner'] in - constants.ROUTER_INTERFACE_OWNERS): + constants.ROUTER_INTERFACE_OWNERS): routers.append(port['device_id']) ip['ip_address'] = result['gateway_ip'] else: @@ -1244,7 +1244,8 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, def _check_mac_addr_update(self, context, port, new_mac, device_owner): if (device_owner and - device_owner.startswith(constants.DEVICE_OWNER_NETWORK_PREFIX)): + device_owner.startswith( + constants.DEVICE_OWNER_NETWORK_PREFIX)): raise n_exc.UnsupportedPortDeviceOwner( op=_("mac address update"), port_id=id, device_owner=device_owner) diff --git a/neutron/db/dns_db.py b/neutron/db/dns_db.py index d1e887815bf..57b14164fae 100644 --- a/neutron/db/dns_db.py +++ b/neutron/db/dns_db.py @@ -134,7 +134,7 @@ class DNSDbMixin(object): context, floatingip_data)) if dns_data_db: if (dns_data_db['published_dns_name'] != current_dns_name or - dns_data_db['published_dns_domain'] != current_dns_domain): + dns_data_db['published_dns_domain'] != current_dns_domain): dns_actions_data = DNSActionsData( previous_dns_name=dns_data_db['published_dns_name'], previous_dns_domain=dns_data_db['published_dns_domain']) diff --git a/neutron/db/ipam_backend_mixin.py b/neutron/db/ipam_backend_mixin.py index 1f535bf6523..26fc6ac526d 100644 --- a/neutron/db/ipam_backend_mixin.py +++ b/neutron/db/ipam_backend_mixin.py @@ -238,7 +238,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon): subnet_list = self._get_subnets(context) for subnet in subnet_list: if ((netaddr.IPSet([subnet.cidr]) & new_subnet_ipset) and - str(subnet.cidr) != const.PROVISIONAL_IPV6_PD_PREFIX): + str(subnet.cidr) != const.PROVISIONAL_IPV6_PD_PREFIX): # don't give out details of the overlapping subnet err_msg = ("Requested subnet with cidr: %(cidr)s for " "network: %(network_id)s overlaps with another " diff --git a/neutron/db/l3_agentschedulers_db.py b/neutron/db/l3_agentschedulers_db.py index 08a8afb1591..91011541713 100644 --- a/neutron/db/l3_agentschedulers_db.py +++ b/neutron/db/l3_agentschedulers_db.py @@ -99,7 +99,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase, raise l3agentscheduler.DVRL3CannotAssignToDvrAgent() if (agent_mode == constants.L3_AGENT_MODE_LEGACY and - router.get('distributed')): + router.get('distributed')): raise l3agentscheduler.RouterL3AgentMismatch( router_id=router['id'], agent_id=agent['id']) diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py index e3757472ce3..81c4f068a56 100644 --- a/neutron/db/l3_db.py +++ b/neutron/db/l3_db.py @@ -333,7 +333,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase, if (not extensions.is_extension_supported( l3_plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS) or - l3_plugin.router_scheduler is None): + l3_plugin.router_scheduler is None): # that might mean that we are dealing with non-agent-based # implementation of l3 services return @@ -801,7 +801,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase, 'subnet_id': subnet['id']} if (subnet['ip_version'] == 6 and not - ipv6_utils.is_ipv6_pd_enabled(subnet)): + ipv6_utils.is_ipv6_pd_enabled(subnet)): # Add new prefix to an existing ipv6 port with the same network id # if one exists port = self._find_ipv6_router_port_by_network(context, router, diff --git a/neutron/db/l3_dvr_db.py b/neutron/db/l3_dvr_db.py index ab77cc67fec..db4cca68b1b 100644 --- a/neutron/db/l3_dvr_db.py +++ b/neutron/db/l3_dvr_db.py @@ -361,7 +361,7 @@ class DVRResourceOperationHandler(object): # dvr service ports except for the compute port and # dhcp port. if (port['device_owner'] == "" or - port['device_owner'] in allowed_device_owners): + port['device_owner'] in allowed_device_owners): addr_pair_active_service_port_list = ( self._get_ports_for_allowed_address_pair_ip( admin_ctx, port['network_id'], @@ -458,8 +458,8 @@ class DVRResourceOperationHandler(object): for port in router.attached_ports: p = port['port'] if (p['network_id'] == net_id and - p['device_owner'] == device_owner and - self.l3plugin._port_has_ipv6_address(p)): + p['device_owner'] == device_owner and + self.l3plugin._port_has_ipv6_address(p)): return self.l3plugin._core_plugin._make_port_dict(p) def _check_for_multiprefix_csnat_port_and_update( @@ -678,7 +678,7 @@ class _DVRAgentInterfaceMixin(object): # Skip if it is bound, but not to the given host fip_dest_host = floating_ip.get('dest_host') if (fip_host != l3_const.FLOATING_IP_HOST_NEEDS_BINDING and - fip_host != host and fip_dest_host is None): + fip_host != host and fip_dest_host is None): return True # not being skipped, log host @@ -721,8 +721,7 @@ class _DVRAgentInterfaceMixin(object): # All unbound ports with floatingip irrespective of # the device owner should be included as valid ports # and updated. - if (port_in_migration or - self._is_unbound_port(port)): + if port_in_migration or self._is_unbound_port(port): port_dict.update({port['id']: port}) continue port_host = port[portbindings.HOST_ID] diff --git a/neutron/db/l3_hascheduler_db.py b/neutron/db/l3_hascheduler_db.py index e9a6b2e164c..864191da091 100644 --- a/neutron/db/l3_hascheduler_db.py +++ b/neutron/db/l3_hascheduler_db.py @@ -63,8 +63,8 @@ def _notify_l3_agent_ha_port_update(resource, event, trigger, **kwargs): if new_port and original_port and host: new_device_owner = new_port.get('device_owner', '') if (new_device_owner == constants.DEVICE_OWNER_ROUTER_HA_INTF and - new_port['status'] == constants.PORT_STATUS_ACTIVE and - original_port['status'] != new_port['status']): + new_port['status'] == constants.PORT_STATUS_ACTIVE and + original_port['status'] != new_port['status']): l3plugin = directory.get_plugin(plugin_constants.L3) l3plugin.l3_rpc_notifier.routers_updated_on_host( context, [new_port['device_id']], host) diff --git a/neutron/db/migration/cli.py b/neutron/db/migration/cli.py index 875007e0df8..101054f3c9c 100644 --- a/neutron/db/migration/cli.py +++ b/neutron/db/migration/cli.py @@ -122,7 +122,7 @@ def do_upgrade(config, cmd): branch = None if ((CONF.command.revision or CONF.command.delta) and - (CONF.command.expand or CONF.command.contract)): + (CONF.command.expand or CONF.command.contract)): raise SystemExit(_( 'Phase upgrade options do not accept revision specification')) diff --git a/neutron/db/securitygroups_db.py b/neutron/db/securitygroups_db.py index 41bf16dd202..d83a7d249b7 100644 --- a/neutron/db/securitygroups_db.py +++ b/neutron/db/securitygroups_db.py @@ -440,8 +440,7 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase): def _validate_port_range(self, rule): """Check that port_range is valid.""" - if (rule['port_range_min'] is None and - rule['port_range_max'] is None): + if rule['port_range_min'] is None and rule['port_range_max'] is None: return if not rule['protocol']: raise ext_sg.SecurityGroupProtocolRequiredWithPorts() @@ -474,8 +473,8 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase): # Only the protocols above support port ranges, raise otherwise. # When min/max are the same it is just a single port. if (rule['port_range_min'] is not None and - rule['port_range_max'] is not None and - rule['port_range_min'] != rule['port_range_max']): + rule['port_range_max'] is not None and + rule['port_range_min'] != rule['port_range_max']): raise ext_sg.SecurityGroupInvalidProtocolForPortRange( protocol=ip_proto) diff --git a/neutron/db/securitygroups_rpc_base.py b/neutron/db/securitygroups_rpc_base.py index 647b9d86b4a..7fa998e15c8 100644 --- a/neutron/db/securitygroups_rpc_base.py +++ b/neutron/db/securitygroups_rpc_base.py @@ -117,7 +117,7 @@ class SecurityGroupServerNotifierRpcMixin(sg_db.SecurityGroupDbMixin): # since it includes the legacy router interface device owners # and DVR router interface device owners. if (port['device_owner'] not in - [const.DEVICE_OWNER_DHCP, const.ROUTER_INTERFACE_OWNERS]): + [const.DEVICE_OWNER_DHCP, const.ROUTER_INTERFACE_OWNERS]): sec_groups |= set(port.get(ext_sg.SECURITYGROUPS)) if sec_groups: @@ -172,7 +172,7 @@ class SecurityGroupInfoAPIMixin(object): security_group_id = rule_in_db.get('security_group_id') ethertype = rule_in_db['ethertype'] if ('security_group_source_groups' - not in sg_info['devices'][port_id]): + not in sg_info['devices'][port_id]): sg_info['devices'][port_id][ 'security_group_source_groups'] = [] diff --git a/neutron/manager.py b/neutron/manager.py index 3b2ce67b4a2..d1bff0f03e0 100644 --- a/neutron/manager.py +++ b/neutron/manager.py @@ -79,7 +79,7 @@ def validate_post_plugin_load(): message. If all is OK then it will return None. """ if ('dhcp_agents_per_network' in cfg.CONF and - cfg.CONF.dhcp_agents_per_network <= 0): + cfg.CONF.dhcp_agents_per_network <= 0): msg = _("dhcp_agents_per_network must be >= 1. '%s' " "is invalid.") % cfg.CONF.dhcp_agents_per_network return msg diff --git a/neutron/objects/qos/policy.py b/neutron/objects/qos/policy.py index 86d03729dd1..85302e75185 100644 --- a/neutron/objects/qos/policy.py +++ b/neutron/objects/qos/policy.py @@ -134,7 +134,7 @@ class QosPolicy(rbac_db.NeutronRbacObject): policy_obj = super(QosPolicy, cls).get_object(admin_context, **kwargs) if (not policy_obj or - not cls.is_accessible(context, policy_obj)): + not cls.is_accessible(context, policy_obj)): return policy_obj.obj_load_attr('rules') diff --git a/neutron/pecan_wsgi/hooks/policy_enforcement.py b/neutron/pecan_wsgi/hooks/policy_enforcement.py index b649c16e243..3d1b86d677b 100644 --- a/neutron/pecan_wsgi/hooks/policy_enforcement.py +++ b/neutron/pecan_wsgi/hooks/policy_enforcement.py @@ -234,13 +234,13 @@ class PolicyHook(hooks.PecanHook): attr_data = controller.resource_info.get(attr_name) if attr_data and attr_data['is_visible']: if policy.check( - context, - # NOTE(kevinbenton): this used to reference a - # _plugin_handlers dict, why? - 'get_%s:%s' % (resource, attr_name), - data, - might_not_exist=True, - pluralized=collection): + context, + # NOTE(kevinbenton): this used to reference a + # _plugin_handlers dict, why? + 'get_%s:%s' % (resource, attr_name), + data, + might_not_exist=True, + pluralized=collection): # this attribute is visible, check next one continue # if the code reaches this point then either the policy check diff --git a/neutron/plugins/ml2/drivers/l2pop/mech_driver.py b/neutron/plugins/ml2/drivers/l2pop/mech_driver.py index 7a97c0bdd0f..d1259d9fd20 100644 --- a/neutron/plugins/ml2/drivers/l2pop/mech_driver.py +++ b/neutron/plugins/ml2/drivers/l2pop/mech_driver.py @@ -141,7 +141,7 @@ class L2populationMechanismDriver(api.MechanismDriver): orig = context.original if (orig['mac_address'] != port['mac_address'] and - context.status == const.PORT_STATUS_ACTIVE): + context.status == const.PORT_STATUS_ACTIVE): msg = _("unable to modify mac_address of ACTIVE port " "%s") % port['id'] raise exceptions.InvalidInput(error_message=msg) diff --git a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py index 2631d595c7a..be0ffb34eaf 100644 --- a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py @@ -196,7 +196,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase): # prefix = mix_interface.1 (backward compatible) # prefix = mix_iHASHED.1111 if (len(physical_interface) + len(vlan_postfix) > - constants.DEVICE_NAME_MAX_LEN): + constants.DEVICE_NAME_MAX_LEN): physical_interface = plugin_utils.get_interface_name( physical_interface, max_len=(constants.DEVICE_NAME_MAX_LEN - MAX_VLAN_POSTFIX_LEN)) diff --git a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py index 7075236ccc4..77ecb00bb17 100644 --- a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py +++ b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py @@ -82,7 +82,7 @@ class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): if profile: capabilities = profile.get('capabilities', []) if (vnic_type == portbindings.VNIC_DIRECT and - 'switchdev' in capabilities): + 'switchdev' in capabilities): LOG.debug("Refusing to bind due to unsupported vnic_type: %s " "with switchdev capability", portbindings.VNIC_DIRECT) return diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py index 3d4aff59b1a..a132ef41816 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -1425,7 +1425,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, def _setup_tunnel_port(self, br, port_name, remote_ip, tunnel_type): try: if (netaddr.IPAddress(self.local_ip).version != - netaddr.IPAddress(remote_ip).version): + netaddr.IPAddress(remote_ip).version): LOG.error("IP version mismatch, cannot create tunnel: " "local_ip=%(lip)s remote_ip=%(rip)s", {'lip': self.local_ip, 'rip': remote_ip}) @@ -2065,8 +2065,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, # Secure and wire/unwire VIFs and update their status # on Neutron server if (self._port_info_has_changes(port_info) or - self.sg_agent.firewall_refresh_needed() or - ovs_restarted): + self.sg_agent.firewall_refresh_needed() or + ovs_restarted): LOG.debug("Starting to process devices in:%s", port_info) failed_devices = self.process_network_ports( @@ -2153,7 +2153,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, def _check_agent_configurations(self): if (self.enable_distributed_routing and self.enable_tunneling and - not self.l2_pop): + not self.l2_pop): raise ValueError(_("DVR deployments for VXLAN/GRE/Geneve " "underlays require L2-pop to be enabled, " diff --git a/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py b/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py index e1ad9a55fdc..70122a9ef96 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py +++ b/neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py @@ -85,7 +85,7 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): if profile: capabilities = profile.get('capabilities', []) if (vnic_type == portbindings.VNIC_DIRECT and - 'switchdev' not in capabilities): + 'switchdev' not in capabilities): LOG.debug("Refusing to bind due to unsupported vnic_type: %s with " "no switchdev capability", portbindings.VNIC_DIRECT) return @@ -96,8 +96,8 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): if (any(x in caps.get('iface_types', []) for x in [a_const.OVS_DPDK_VHOST_USER, a_const.OVS_DPDK_VHOST_USER_CLIENT]) and - agent['configurations'].get('datapath_type') == - a_const.OVS_DATAPATH_NETDEV): + agent['configurations'].get('datapath_type') == + a_const.OVS_DATAPATH_NETDEV): return portbindings.VIF_TYPE_VHOST_USER return self.vif_type diff --git a/neutron/plugins/ml2/extensions/dns_integration.py b/neutron/plugins/ml2/extensions/dns_integration.py index 0834e5cbaaf..d9577189074 100644 --- a/neutron/plugins/ml2/extensions/dns_integration.py +++ b/neutron/plugins/ml2/extensions/dns_integration.py @@ -143,7 +143,7 @@ class DNSExtensionDriver(api.ExtensionDriver): is_dns_domain_changed = (dns_domain is not None and dns_data_db[dns_apidef.DNSDOMAIN] != dns_domain) if (is_dns_name_changed or is_dns_domain_changed or - (has_fixed_ips and dns_data_db['current_dns_name'])): + (has_fixed_ips and dns_data_db['current_dns_name'])): dns_data_db = self._populate_previous_external_dns_data( dns_data_db) dns_data_db = self._populate_current_external_dns_data( diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index e89591aee1c..c0cd99bd626 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -329,14 +329,13 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, host = attrs.get(portbindings.HOST_ID) or '' original_host = binding.host - if (validators.is_attr_set(host) and - original_host != host): + if validators.is_attr_set(host) and original_host != host: binding.host = host changes = True vnic_type = attrs and attrs.get(portbindings.VNIC_TYPE) if (validators.is_attr_set(vnic_type) and - binding.vnic_type != vnic_type): + binding.vnic_type != vnic_type): binding.vnic_type = vnic_type changes = True @@ -564,7 +563,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, # Update the port status if requested by the bound driver. if (bind_context._binding_levels and - bind_context._new_port_status): + bind_context._new_port_status): port_db.status = bind_context._new_port_status port['status'] = bind_context._new_port_status @@ -886,13 +885,12 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, # relationship can be updated. context.session.expire(db_network) - if ( - mtuw_apidef.MTU in net_data or + if (mtuw_apidef.MTU in net_data or # NOTE(ihrachys) mtu may be null for existing networks, # calculate and update it as needed; the conditional can be # removed in Queens when we populate all mtu attributes and # enforce it's not nullable on database level - db_network.mtu is None): + db_network.mtu is None): db_network.mtu = self._get_network_mtu(db_network, validate=False) # agents should now update all ports to reflect new MTU @@ -1747,7 +1745,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, port_id = port.id if ((port.status != status and port['device_owner'] != const.DEVICE_OWNER_DVR_INTERFACE) or - port['device_owner'] == const.DEVICE_OWNER_DVR_INTERFACE): + port['device_owner'] == const.DEVICE_OWNER_DVR_INTERFACE): attr = { 'id': port.id, portbindings.HOST_ID: host, @@ -1759,7 +1757,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, with db_api.context_manager.writer.using(context): context.session.add(port) # bring port into writer session if (port.status != status and - port['device_owner'] != const.DEVICE_OWNER_DVR_INTERFACE): + port['device_owner'] != const.DEVICE_OWNER_DVR_INTERFACE): original_port = self._make_port_dict(port) port.status = status # explicit flush before _make_port_dict to ensure extensions @@ -1783,7 +1781,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, updated = True if (updated and - port['device_owner'] == const.DEVICE_OWNER_DVR_INTERFACE): + port['device_owner'] == const.DEVICE_OWNER_DVR_INTERFACE): with db_api.context_manager.writer.using(context): port = db.get_port(context, port_id) if not port: @@ -1915,7 +1913,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, events.AFTER_DELETE)) def _handle_segment_change(self, rtype, event, trigger, context, segment): if (event == events.PRECOMMIT_CREATE and - not isinstance(trigger, segments_plugin.Plugin)): + not isinstance(trigger, segments_plugin.Plugin)): # TODO(xiaohhui): Now, when create network, ml2 will reserve # segment and trigger this event handler. This event handler # will reserve segment again, which will lead to error as the @@ -1957,7 +1955,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, self, context, network_with_segments, original_network=network_with_segments) if (event == events.PRECOMMIT_CREATE or - event == events.PRECOMMIT_DELETE): + event == events.PRECOMMIT_DELETE): self.mechanism_manager.update_network_precommit(mech_context) elif event == events.AFTER_CREATE or event == events.AFTER_DELETE: self.mechanism_manager.update_network_postcommit(mech_context) diff --git a/neutron/quota/resource.py b/neutron/quota/resource.py index b7751994798..a23c1521e6c 100644 --- a/neutron/quota/resource.py +++ b/neutron/quota/resource.py @@ -264,7 +264,7 @@ class TrackedResource(BaseResource): # or if data migrations do not take care of usage counters, the # assumption will not hold anymore if (tenant_id in self._dirty_tenants or - not usage_info or usage_info.dirty): + not usage_info or usage_info.dirty): LOG.debug(("Usage tracker for resource:%(resource)s and tenant:" "%(tenant_id)s is out of sync, need to count used " "quota"), {'resource': self.name, diff --git a/neutron/quota/resource_registry.py b/neutron/quota/resource_registry.py index 9a666545d87..56fc43244b4 100644 --- a/neutron/quota/resource_registry.py +++ b/neutron/quota/resource_registry.py @@ -171,7 +171,7 @@ class ResourceRegistry(object): """ if (not cfg.CONF.QUOTAS.track_quota_usage or - resource_name not in self._tracked_resource_mappings): + resource_name not in self._tracked_resource_mappings): LOG.info("Creating instance of CountableResource for " "resource:%s", resource_name) return resource.CountableResource( diff --git a/neutron/scheduler/dhcp_agent_scheduler.py b/neutron/scheduler/dhcp_agent_scheduler.py index cab0cc41fdd..d9e90ce96c7 100644 --- a/neutron/scheduler/dhcp_agent_scheduler.py +++ b/neutron/scheduler/dhcp_agent_scheduler.py @@ -85,7 +85,7 @@ class AutoScheduler(object): az_hints = (net.get(az_def.AZ_HINTS) or cfg.CONF.default_availability_zones) if (az_hints and - dhcp_agent['availability_zone'] not in az_hints): + dhcp_agent['availability_zone'] not in az_hints): continue bindings_to_add.append((dhcp_agent, net_id)) # do it outside transaction so particular scheduling results don't diff --git a/neutron/scheduler/l3_agent_scheduler.py b/neutron/scheduler/l3_agent_scheduler.py index cb805e197ba..50b10cce326 100644 --- a/neutron/scheduler/l3_agent_scheduler.py +++ b/neutron/scheduler/l3_agent_scheduler.py @@ -106,7 +106,7 @@ class L3Scheduler(object): for router, count in plugin.get_routers_l3_agents_count(context): if (count < 1 or - router.get('ha', False) and count < max_agents_for_ha): + router.get('ha', False) and count < max_agents_for_ha): # Either the router was un-scheduled (scheduled to 0 agents), # or it's an HA router and it was under-scheduled (scheduled to # less than max_agents_for_ha). Either way, it should be added diff --git a/neutron/services/externaldns/drivers/designate/driver.py b/neutron/services/externaldns/drivers/designate/driver.py index 66ae88d91bd..48a6ea0c105 100644 --- a/neutron/services/externaldns/drivers/designate/driver.py +++ b/neutron/services/externaldns/drivers/designate/driver.py @@ -69,16 +69,16 @@ class Designate(driver.ExternalDNSService): ipv6_ptr_zone_size = CONF.designate.ipv6_ptr_zone_prefix_size if (ipv4_ptr_zone_size < IPV4_PTR_ZONE_PREFIX_MIN_SIZE or - ipv4_ptr_zone_size > IPV4_PTR_ZONE_PREFIX_MAX_SIZE or - (ipv4_ptr_zone_size % 8) != 0): + ipv4_ptr_zone_size > IPV4_PTR_ZONE_PREFIX_MAX_SIZE or + (ipv4_ptr_zone_size % 8) != 0): raise dns_exc.InvalidPTRZoneConfiguration( parameter='ipv4_ptr_zone_size', number='8', maximum=str(IPV4_PTR_ZONE_PREFIX_MAX_SIZE), minimum=str(IPV4_PTR_ZONE_PREFIX_MIN_SIZE)) if (ipv6_ptr_zone_size < IPV6_PTR_ZONE_PREFIX_MIN_SIZE or - ipv6_ptr_zone_size > IPV6_PTR_ZONE_PREFIX_MAX_SIZE or - (ipv6_ptr_zone_size % 4) != 0): + ipv6_ptr_zone_size > IPV6_PTR_ZONE_PREFIX_MAX_SIZE or + (ipv6_ptr_zone_size % 4) != 0): raise dns_exc.InvalidPTRZoneConfiguration( parameter='ipv6_ptr_zone_size', number='4', maximum=str(IPV6_PTR_ZONE_PREFIX_MAX_SIZE), diff --git a/neutron/services/segments/plugin.py b/neutron/services/segments/plugin.py index 87b9add42f5..53716124f47 100644 --- a/neutron/services/segments/plugin.py +++ b/neutron/services/segments/plugin.py @@ -407,7 +407,7 @@ class NovaSegmentNotifier(object): def _does_port_require_nova_inventory_update(self, port): device_owner = port.get('device_owner') if (device_owner.startswith(constants.DEVICE_OWNER_COMPUTE_PREFIX) or - device_owner == constants.DEVICE_OWNER_DHCP): + device_owner == constants.DEVICE_OWNER_DHCP): return False return True diff --git a/neutron/services/timestamp/timestamp_db.py b/neutron/services/timestamp/timestamp_db.py index b824a9c2dfb..1e6e23736ea 100644 --- a/neutron/services/timestamp/timestamp_db.py +++ b/neutron/services/timestamp/timestamp_db.py @@ -58,7 +58,7 @@ def _update_timestamp(session, context, instances): while objs_list: obj = objs_list.pop() if (isinstance(obj, standard_attr.HasStandardAttributes) and - obj.standard_attr_id): + obj.standard_attr_id): obj.updated_at = timeutils.utcnow() diff --git a/neutron/tests/common/l3_test_common.py b/neutron/tests/common/l3_test_common.py index 0afd5730674..b70eb9ecf1c 100644 --- a/neutron/tests/common/l3_test_common.py +++ b/neutron/tests/common/l3_test_common.py @@ -302,7 +302,8 @@ def get_unassigned_pd_interfaces(router): for intf in router[lib_constants.INTERFACE_KEY]: for subnet in intf['subnets']: if (ipv6_utils.is_ipv6_pd_enabled(subnet) and - subnet['cidr'] == lib_constants.PROVISIONAL_IPV6_PD_PREFIX): + subnet['cidr'] == + lib_constants.PROVISIONAL_IPV6_PD_PREFIX): pd_intfs.append(intf) return pd_intfs @@ -312,7 +313,8 @@ def assign_prefix_for_pd_interfaces(router): for ifno, intf in enumerate(router[lib_constants.INTERFACE_KEY]): for subnet in intf['subnets']: if (ipv6_utils.is_ipv6_pd_enabled(subnet) and - subnet['cidr'] == lib_constants.PROVISIONAL_IPV6_PD_PREFIX): + subnet['cidr'] == + lib_constants.PROVISIONAL_IPV6_PD_PREFIX): subnet['cidr'] = "2001:db8:%d::/64" % ifno pd_intfs.append(intf) return pd_intfs diff --git a/neutron/tests/common/net_helpers.py b/neutron/tests/common/net_helpers.py index 303d1ca7a00..28cc0191058 100644 --- a/neutron/tests/common/net_helpers.py +++ b/neutron/tests/common/net_helpers.py @@ -595,7 +595,7 @@ class VethFixture(fixtures.Fixture): for port in self.ports: ip_wrapper = ip_lib.IPWrapper(port.namespace) if (ip_wrapper.netns.exists(port.namespace) or - port.namespace is None): + port.namespace is None): try: ip_wrapper.del_veth(port.name) break @@ -666,7 +666,7 @@ class MacvtapFixture(fixtures.Fixture): def destroy(self): if (ip_lib.network_namespace_exists(self.ip_dev.namespace) or - self.ip_dev.namespace is None): + self.ip_dev.namespace is None): try: self.ip_dev.link.delete() except RuntimeError: diff --git a/neutron/tests/fullstack/resources/machine.py b/neutron/tests/fullstack/resources/machine.py index 4a4f254657c..bce26186281 100644 --- a/neutron/tests/fullstack/resources/machine.py +++ b/neutron/tests/fullstack/resources/machine.py @@ -109,7 +109,7 @@ class FakeFullstackMachine(machine_fixtures.FakeMachineBase): subnet_id = fixed_ip['subnet_id'] subnet = self.safe_client.client.show_subnet(subnet_id) 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'] self.gateway_ipv6 = subnet['subnet']['gateway_ip'] diff --git a/neutron/tests/fullstack/test_securitygroup.py b/neutron/tests/fullstack/test_securitygroup.py index e363d68d15e..0bf0dc5a415 100644 --- a/neutron/tests/fullstack/test_securitygroup.py +++ b/neutron/tests/fullstack/test_securitygroup.py @@ -55,7 +55,7 @@ class BaseSecurityGroupsSameNetworkTest(base.BaseFullStackTestCase): super(BaseSecurityGroupsSameNetworkTest, self).setUp(env) if (self.firewall_driver == 'openvswitch' and - not OVSVersionChecker.supports_ovsfirewall()): + not OVSVersionChecker.supports_ovsfirewall()): self.skipTest("Open vSwitch firewall_driver doesn't work " "with this version of ovs.") diff --git a/neutron/tests/unit/agent/linux/test_dhcp.py b/neutron/tests/unit/agent/linux/test_dhcp.py index 18ad230eb81..1773166bedf 100644 --- a/neutron/tests/unit/agent/linux/test_dhcp.py +++ b/neutron/tests/unit/agent/linux/test_dhcp.py @@ -1220,7 +1220,7 @@ class TestDnsmasq(TestBase): possible_leases = 0 for i, s in enumerate(network.subnets): if (s.ip_version != 6 or - s.ipv6_address_mode == constants.DHCPV6_STATEFUL): + s.ipv6_address_mode == constants.DHCPV6_STATEFUL): if s.ip_version == 4: expected.extend([prefix % ( i, s.cidr.split('/')[0], diff --git a/neutron/tests/unit/agent/test_securitygroups_rpc.py b/neutron/tests/unit/agent/test_securitygroups_rpc.py index 60b6c7be3b4..61fcb85ab79 100644 --- a/neutron/tests/unit/agent/test_securitygroups_rpc.py +++ b/neutron/tests/unit/agent/test_securitygroups_rpc.py @@ -275,7 +275,7 @@ class SGServerRpcCallBackTestCase(test_sg.SecurityGroupDBTestCase): def _port_with_addr_pairs_and_security_group(self): plugin_obj = directory.get_plugin() if ('allowed-address-pairs' - not in plugin_obj.supported_extension_aliases): + not in plugin_obj.supported_extension_aliases): self.skipTest("Test depends on allowed-address-pairs extension") fake_prefix = FAKE_PREFIX['IPv4'] with self.network() as n,\ diff --git a/neutron/tests/unit/db/test_agentschedulers_db.py b/neutron/tests/unit/db/test_agentschedulers_db.py index 850c865b02a..1a24319dc49 100644 --- a/neutron/tests/unit/db/test_agentschedulers_db.py +++ b/neutron/tests/unit/db/test_agentschedulers_db.py @@ -215,7 +215,7 @@ class AgentSchedulerTestMixIn(object): agents = self._list_agents() for agent_data in agents['agents']: if (agent_data['agent_type'] == agent_type and - agent_data['host'] == host): + agent_data['host'] == host): return agent_data['id'] @@ -1139,7 +1139,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase): default = l3agents['agents'][0]['id'] for com in agents['agents']: if (com['id'] != default and - com['agent_type'] == constants.AGENT_TYPE_L3): + com['agent_type'] == constants.AGENT_TYPE_L3): another_l3_agent_id = com['id'] another_l3_agent_host = com['host'] break diff --git a/neutron/tests/unit/db/test_db_base_plugin_v2.py b/neutron/tests/unit/db/test_db_base_plugin_v2.py index 56699945dee..3ff9c0477b3 100644 --- a/neutron/tests/unit/db/test_db_base_plugin_v2.py +++ b/neutron/tests/unit/db/test_db_base_plugin_v2.py @@ -341,7 +341,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase): data['subnet'][arg] = kwargs[arg] if ('gateway_ip' in kwargs and - kwargs['gateway_ip'] is not constants.ATTR_NOT_SPECIFIED): + kwargs['gateway_ip'] is not constants.ATTR_NOT_SPECIFIED): data['subnet']['gateway_ip'] = kwargs['gateway_ip'] subnet_req = self.new_create_request('subnets', data, fmt) @@ -401,9 +401,9 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase): data['port'][arg] = kwargs[arg] # create a dhcp port device id if one hasn't been supplied if ('device_owner' in kwargs and - kwargs['device_owner'] == constants.DEVICE_OWNER_DHCP and - 'host' in kwargs and - 'device_id' not in kwargs): + kwargs['device_owner'] == constants.DEVICE_OWNER_DHCP and + 'host' in kwargs and + 'device_id' not in kwargs): device_id = utils.get_dhcp_agent_device_id(net_id, kwargs['host']) data['port']['device_id'] = device_id port_req = self.new_create_request('ports', data, fmt) @@ -4351,8 +4351,8 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): ipv6_ra_mode=addr_mode, ipv6_address_mode=addr_mode) if (insert_db_reference_error or insert_address_allocated or - device_owner == constants.DEVICE_OWNER_ROUTER_SNAT or - device_owner in constants.ROUTER_INTERFACE_OWNERS): + device_owner == constants.DEVICE_OWNER_ROUTER_SNAT or + device_owner in constants.ROUTER_INTERFACE_OWNERS): # DVR SNAT, router interfaces and DHCP ports should not have # been updated with addresses from the new auto-address subnet self.assertEqual(1, len(port['port']['fixed_ips'])) diff --git a/neutron/tests/unit/extensions/test_dns.py b/neutron/tests/unit/extensions/test_dns.py index d90a6480db5..c2fd43110ae 100644 --- a/neutron/tests/unit/extensions/test_dns.py +++ b/neutron/tests/unit/extensions/test_dns.py @@ -91,9 +91,9 @@ class DnsExtensionTestCase(test_plugin.Ml2PluginV2TestCase): data['port'][arg] = kwargs[arg] # create a dhcp port device id if one hasn't been supplied if ('device_owner' in kwargs and - kwargs['device_owner'] == constants.DEVICE_OWNER_DHCP and - 'host' in kwargs and - 'device_id' not in kwargs): + kwargs['device_owner'] == constants.DEVICE_OWNER_DHCP and + 'host' in kwargs and + 'device_id' not in kwargs): device_id = utils.get_dhcp_agent_device_id(net_id, kwargs['host']) data['port']['device_id'] = device_id port_req = self.new_create_request('ports', data, fmt) diff --git a/neutron/tests/unit/extensions/test_l3.py b/neutron/tests/unit/extensions/test_l3.py index e73b55cc12f..0d7aa3bf4bd 100644 --- a/neutron/tests/unit/extensions/test_l3.py +++ b/neutron/tests/unit/extensions/test_l3.py @@ -2114,7 +2114,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin): self.assertEqual(400, res.status_int) for p in self._list('ports')['ports']: if (p['device_owner'] == - lib_constants.DEVICE_OWNER_FLOATINGIP): + lib_constants.DEVICE_OWNER_FLOATINGIP): self.fail('garbage port is not deleted') def test_floatingip_with_assoc_fails(self): diff --git a/neutron/tests/unit/extensions/test_portsecurity.py b/neutron/tests/unit/extensions/test_portsecurity.py index b3982929216..15c24c43df9 100644 --- a/neutron/tests/unit/extensions/test_portsecurity.py +++ b/neutron/tests/unit/extensions/test_portsecurity.py @@ -105,7 +105,7 @@ class PortSecurityTestPlugin(db_base_plugin_v2.NeutronDbPluginV2, self._process_port_port_security_create(context, p, neutron_db) if (validators.is_attr_set(p.get(ext_sg.SECURITYGROUPS)) and - not (port_security and has_ip)): + not (port_security and has_ip)): raise psec_exc.PortSecurityAndIPRequiredForSecurityGroups() # Port requires ip and port_security enabled for security group diff --git a/neutron/tests/unit/objects/qos/test_policy.py b/neutron/tests/unit/objects/qos/test_policy.py index 0dd5324582f..b0e9f7660ef 100644 --- a/neutron/tests/unit/objects/qos/test_policy.py +++ b/neutron/tests/unit/objects/qos/test_policy.py @@ -90,9 +90,9 @@ class QosPolicyObjectTestCase(test_base.BaseObjectIfaceTestCase): return_value=[self.db_objs[0]]) as get_objects_mock: with mock.patch.object( - self.context, - 'elevated', - return_value=admin_context) as context_mock: + self.context, + 'elevated', + return_value=admin_context) as context_mock: objs = self._test_class.get_objects( self.context, diff --git a/neutron/tests/unit/objects/test_base.py b/neutron/tests/unit/objects/test_base.py index f882dd1ca18..2f55a64770c 100644 --- a/neutron/tests/unit/objects/test_base.py +++ b/neutron/tests/unit/objects/test_base.py @@ -1152,10 +1152,10 @@ class BaseObjectIfaceTestCase(_BaseObjectTestCase, test_base.BaseTestCase): return_value={'a': 'a', 'b': 'b', 'c': 'c'}) def test_update_changes_forbidden(self, *mocks): with mock.patch.object( - self._test_class, - 'fields_no_update', - new_callable=mock.PropertyMock(return_value=['a', 'c']), - create=True): + self._test_class, + 'fields_no_update', + new_callable=mock.PropertyMock(return_value=['a', 'c']), + create=True): obj = self._test_class(self.context, **self.obj_fields[0]) self.assertRaises(o_exc.NeutronObjectUpdateForbidden, obj.update) diff --git a/neutron/tests/unit/plugins/ml2/drivers/mechanism_test.py b/neutron/tests/unit/plugins/ml2/drivers/mechanism_test.py index eece0f68159..ac632b665ce 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/mechanism_test.py +++ b/neutron/tests/unit/plugins/ml2/drivers/mechanism_test.py @@ -92,7 +92,7 @@ class TestMechanismDriver(api.MechanismDriver): if context.vif_type in (portbindings.VIF_TYPE_UNBOUND, portbindings.VIF_TYPE_BINDING_FAILED): if (context.segments_to_bind and - context.segments_to_bind[0][api.NETWORK_TYPE] == 'vlan'): + context.segments_to_bind[0][api.NETWORK_TYPE] == 'vlan'): # Partially bound. self._check_bound(context.binding_levels, context.top_bound_segment, @@ -188,7 +188,7 @@ class TestMechanismDriver(api.MechanismDriver): def update_port_precommit(self, context): if ((context.original_top_bound_segment and not context.top_bound_segment) or - (context.host == "host-fail")): + (context.host == "host-fail")): self.bound_ports.remove((context.original['id'], context.original_host)) self._check_port_context(context, True) diff --git a/neutron/tests/unit/scheduler/test_dhcp_agent_scheduler.py b/neutron/tests/unit/scheduler/test_dhcp_agent_scheduler.py index a4070093e07..931650aff3c 100644 --- a/neutron/tests/unit/scheduler/test_dhcp_agent_scheduler.py +++ b/neutron/tests/unit/scheduler/test_dhcp_agent_scheduler.py @@ -282,7 +282,7 @@ class TestAutoScheduleNetworks(TestDhcpSchedulerBaseTestCase): expected_hosted_agents = (1 if expected_result and self.valid_host else 0) if (self.az_hints and - agents[0]['availability_zone'] not in self.az_hints): + agents[0]['availability_zone'] not in self.az_hints): expected_hosted_agents = 0 host = "host-a" if self.valid_host else "host-b" observed_ret_value = scheduler.auto_schedule_networks( diff --git a/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py b/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py index a36a512b5d2..8bcf3192fbb 100644 --- a/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py +++ b/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py @@ -1243,8 +1243,8 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase): } with mock.patch( - 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2' '.get_ports', - return_value=[dvr_port]): + 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2' '.get_ports', + return_value=[dvr_port]): sub_ids = self.dut.get_subnet_ids_on_router(self.adminContext, r1['id']) self.assertEqual(sub_ids.pop(), diff --git a/neutron/tests/unit/services/qos/test_qos_plugin.py b/neutron/tests/unit/services/qos/test_qos_plugin.py index a010da53598..d6e68e9af42 100644 --- a/neutron/tests/unit/services/qos/test_qos_plugin.py +++ b/neutron/tests/unit/services/qos/test_qos_plugin.py @@ -524,8 +524,8 @@ class TestQosPlugin(base.BaseQosTestCase): setattr(_policy, "rules", [self.rule]) with mock.patch('neutron.objects.qos.rule.get_rules', return_value=[self.rule]), mock.patch( - 'neutron.objects.qos.policy.QosPolicy.get_object', - return_value=_policy): + 'neutron.objects.qos.policy.QosPolicy.get_object', + return_value=_policy): self.rule_data['bandwidth_limit_rule']['max_kbps'] = 1 self.qos_plugin.update_policy_bandwidth_limit_rule( self.ctxt, self.rule.id, self.policy.id, self.rule_data) diff --git a/tox.ini b/tox.ini index 51e5aedfe3e..66d7731ceb9 100644 --- a/tox.ini +++ b/tox.ini @@ -137,7 +137,6 @@ commands = sphinx-build -W -b linkcheck doc/source doc/build/linkcheck # E125 continuation line does not distinguish itself from next logical line # 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 # H404 multi line docstring should start with a summary # H405 multi line docstring summary not separated with an empty line # N530 direct neutron imports not allowed @@ -145,7 +144,7 @@ commands = sphinx-build -W -b linkcheck doc/source doc/build/linkcheck # N534 Untranslated exception message # TODO(amotoki) check the following new rules should be fixed or ignored # E731 do not assign a lambda expression, use a def -ignore = E125,E126,E128,E129,E731,H404,H405,N530,N534 +ignore = E125,E126,E128,E731,H404,H405,N530,N534 # 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