Fix W503 pep8 warnings

Fix W503 (line break before binary operator) pep8 warnings
and no longer ignore new failures.

Trivialfix

Change-Id: I7539f3b7187f2ad40681781f74b6e05a01bac474
This commit is contained in:
Brian Haley 2018-04-10 16:17:36 -04:00 committed by Brian Haley
parent c16d15fff2
commit 90cd939047
43 changed files with 133 additions and 129 deletions

View File

@ -161,9 +161,9 @@ class DhcpAgent(manager.Manager):
# allocation pool or a port is deleted to free up an IP, this
# 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)):
if (isinstance(e, oslo_messaging.RemoteError) and
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.',

View File

@ -335,8 +335,8 @@ class L3NATAgent(ha.AgentMixin,
# side of it, typically because it's landing on a node that needs
# to provision a router namespace because of a DVR service port
# (e.g. DHCP).
if (self.conf.agent_mode == lib_const.L3_AGENT_MODE_DVR_SNAT
and router.get(lib_const.HA_INTERFACE_KEY) is not None):
if (self.conf.agent_mode == lib_const.L3_AGENT_MODE_DVR_SNAT and
router.get(lib_const.HA_INTERFACE_KEY) is not None):
kwargs['state_change_callback'] = self.enqueue_state_change
return dvr_edge_ha_router.DvrEdgeHaRouter(*args, **kwargs)

View File

@ -115,8 +115,7 @@ class DvrEdgeHaRouter(dvr_edge_router.DvrEdgeRouter,
self._plug_external_gateway(ex_gw_port, interface_name, ns_name)
def _is_this_snat_host(self):
return (self.agent_conf.agent_mode
== constants.L3_AGENT_MODE_DVR_SNAT)
return self.agent_conf.agent_mode == constants.L3_AGENT_MODE_DVR_SNAT
def _dvr_internal_network_removed(self, port):
super(DvrEdgeHaRouter, self)._dvr_internal_network_removed(port)

View File

@ -772,8 +772,8 @@ class RouterInfo(object):
def _delete_stale_external_devices(self, interface_name):
existing_devices = self._get_existing_devices()
stale_devs = [dev for dev in existing_devices
if dev.startswith(EXTERNAL_DEV_PREFIX)
and dev != interface_name]
if dev.startswith(EXTERNAL_DEV_PREFIX) and
dev != interface_name]
for stale_dev in stale_devs:
LOG.debug('Deleting stale external router device: %s', stale_dev)
self.agent.pd.remove_gw_interface(self.router['id'])
@ -1053,8 +1053,8 @@ class RouterInfo(object):
iptables = iptables_manager.get_tables(ip_version)
iptables['mangle'].empty_chain('scope')
iptables['filter'].empty_chain('scope')
dont_block_external = (ip_version == lib_constants.IP_VERSION_4
and self._snat_enabled and external_port)
dont_block_external = (ip_version == lib_constants.IP_VERSION_4 and
self._snat_enabled and external_port)
for device_name, mark in scopemarks.items():
# Add address scope iptables rule
iptables['mangle'].add_rule(

View File

@ -1155,9 +1155,9 @@ class DeviceManager(object):
for subnet in network.subnets:
skip_subnet = (
subnet.ip_version != ip_version
or not subnet.enable_dhcp
or subnet.gateway_ip is None)
subnet.ip_version != ip_version or
not subnet.enable_dhcp or
subnet.gateway_ip is None)
if skip_subnet:
continue

View File

@ -274,8 +274,8 @@ class IPDevice(SubProcessBase):
self.neigh = IpNeighCommand(self)
def __eq__(self, other):
return (other is not None and self.name == other.name
and self.namespace == other.namespace)
return (other is not None and self.name == other.name and
self.namespace == other.namespace)
def __str__(self):
return self.name

View File

@ -280,8 +280,8 @@ class UnixDomainMetadataProxy(object):
mode = self.conf.metadata_proxy_socket_mode
if mode == config.DEDUCE_MODE:
user = self.conf.metadata_proxy_user
if (not user or user == '0' or user == 'root'
or agent_utils.is_effective_user(user)):
if (not user or user == '0' or user == 'root' or
agent_utils.is_effective_user(user)):
# user is agent effective user or root => USER_MODE
mode = config.USER_MODE
else:

View File

@ -333,8 +333,8 @@ def _set_colval_args(*col_values):
if isinstance(val, collections.Mapping):
args += ["%s:%s%s%s" % (
col, k, op, ovsdb.py_to_val(v)) for k, v in val.items()]
elif (isinstance(val, collections.Sequence)
and not isinstance(val, six.string_types)):
elif (isinstance(val, collections.Sequence) and
not isinstance(val, six.string_types)):
if len(val) == 0:
args.append("%s%s%s" % (col, op, "[]"))
else:

View File

@ -138,8 +138,8 @@ class ExtensionMiddleware(base.ConfigurableMiddleware):
def __init__(self, application,
ext_mgr=None):
self.ext_mgr = (ext_mgr
or ExtensionManager(get_extensions_path()))
self.ext_mgr = (ext_mgr or
ExtensionManager(get_extensions_path()))
mapper = routes.Mapper()
# extended resources

View File

@ -282,8 +282,9 @@ class DhcpRpcCallback(object):
plugin = directory.get_plugin()
try:
old_port = plugin.get_port(context, port['id'])
if (old_port['device_id'] != constants.DEVICE_ID_RESERVED_DHCP_PORT
and old_port['device_id'] !=
if (old_port['device_id'] !=
constants.DEVICE_ID_RESERVED_DHCP_PORT and
old_port['device_id'] !=
utils.get_dhcp_agent_device_id(port['port']['network_id'],
host)):
raise n_exc.DhcpPortInUse(port_id=port['id'])

View File

@ -52,8 +52,8 @@ def is_enabled_and_bind_by_default():
def is_auto_address_subnet(subnet):
"""Check if subnet is an auto address subnet."""
modes = [const.IPV6_SLAAC, const.DHCPV6_STATELESS]
return (subnet['ipv6_address_mode'] in modes
or subnet['ipv6_ra_mode'] in modes)
return (subnet['ipv6_address_mode'] in modes or
subnet['ipv6_ra_mode'] in modes)
def is_eui64_address(ip_address):

View File

@ -90,8 +90,9 @@ class AllowedAddressPairsMixin(object):
return db_utils.resource_fields(res, fields)
def _has_address_pairs(self, port):
return (validators.is_attr_set(port['port'][addr_apidef.ADDRESS_PAIRS])
and port['port'][addr_apidef.ADDRESS_PAIRS] != [])
return (validators.is_attr_set(
port['port'][addr_apidef.ADDRESS_PAIRS]) and
port['port'][addr_apidef.ADDRESS_PAIRS] != [])
def _check_update_has_allowed_address_pairs(self, port):
"""Determine if request has an allowed address pair.

View File

@ -82,8 +82,8 @@ class ExtraDhcpOptMixin(object):
with db_api.context_manager.writer.using(context):
for upd_rec in dopts:
for opt in opts:
if (opt['opt_name'] == upd_rec['opt_name']
and opt['ip_version'] == upd_rec.get(
if (opt['opt_name'] == upd_rec['opt_name'] and
opt['ip_version'] == upd_rec.get(
'ip_version', 4)):
# to handle deleting of a opt from the port.
if upd_rec['opt_value'] is None:

View File

@ -765,10 +765,10 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
old_ips = old_port.get('fixed_ips')
deferred_ip_allocation = (
old_port.get('ip_allocation') ==
ipalloc_apidef.IP_ALLOCATION_DEFERRED
and host and not old_host
and not old_ips
and not fixed_ips_requested)
ipalloc_apidef.IP_ALLOCATION_DEFERRED and
host and not old_host and
not old_ips and
not fixed_ips_requested)
if not deferred_ip_allocation:
# Check that any existing IPs are valid on the new segment
new_host_requested = host and host != old_host

View File

@ -788,8 +788,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
if not subnet['gateway_ip']:
msg = _('Subnet for router interface must have a gateway IP')
raise n_exc.BadRequest(resource='router', msg=msg)
if (subnet['ip_version'] == 6 and subnet['ipv6_ra_mode'] is None
and subnet['ipv6_address_mode'] is not None):
if (subnet['ip_version'] == 6 and subnet['ipv6_ra_mode'] is None and
subnet['ipv6_address_mode'] is not None):
msg = (_('IPv6 subnet %s configured to receive RAs from an '
'external router cannot be added to Neutron Router.') %
subnet['id'])

View File

@ -552,8 +552,8 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
# List agents where router is active and agent is dead
# and agents where router is standby and agent is dead
for binding in bindings:
if not (binding.agent.is_active
and binding.agent.admin_state_up):
if not (binding.agent.is_active and
binding.agent.admin_state_up):
if binding.state == n_const.HA_ROUTER_STATE_ACTIVE:
router_active_agents_dead.append(binding.agent)
elif binding.state == n_const.HA_ROUTER_STATE_STANDBY:

View File

@ -827,8 +827,9 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
is either [] or not is_attr_set, otherwise return False
"""
if (ext_sg.SECURITYGROUPS in port['port'] and
not (validators.is_attr_set(port['port'][ext_sg.SECURITYGROUPS])
and port['port'][ext_sg.SECURITYGROUPS] != [])):
not (validators.is_attr_set(
port['port'][ext_sg.SECURITYGROUPS]) and
port['port'][ext_sg.SECURITYGROUPS] != [])):
return True
return False

View File

@ -23,9 +23,9 @@ def check_subnet_ip(cidr, ip_address):
net = netaddr.IPNetwork(cidr)
# Check that the IP is valid on subnet. This cannot be the
# network or the broadcast address (which exists only in IPv4)
return (ip != net.network
and (net.version == 6 or ip != net[-1])
and net.netmask & ip == net.network)
return (ip != net.network and
(net.version == 6 or ip != net[-1]) and
net.netmask & ip == net.network)
def check_gateway_invalid_in_subnet(cidr, gateway):

View File

@ -76,8 +76,9 @@ class Notifier(object):
def _is_compute_port(self, port):
try:
if (port['device_id'] and uuidutils.is_uuid_like(port['device_id'])
and port['device_owner'].startswith(
if (port['device_id'] and
uuidutils.is_uuid_like(port['device_id']) and
port['device_owner'].startswith(
constants.DEVICE_OWNER_COMPUTE_PREFIX)):
return True
except (KeyError, AttributeError):
@ -116,9 +117,9 @@ class Notifier(object):
# port to a new instance port without disassociate it first, an
# event should be sent for original instance, that will make nova
# know original instance's info, and update database for it.
if (action == 'update_floatingip'
and returned_obj['floatingip'].get('port_id')
and original_obj.get('port_id')):
if (action == 'update_floatingip' and
returned_obj['floatingip'].get('port_id') and
original_obj.get('port_id')):
disassociate_returned_obj = {'floatingip': {'port_id': None}}
event = self.create_port_changed_event(action, original_obj,
disassociate_returned_obj)
@ -194,9 +195,9 @@ class Notifier(object):
# NO_VALUE/DOWN/BUILD -> ACTIVE/ERROR.
elif (previous_port_status in [sql_attr.NO_VALUE,
constants.PORT_STATUS_DOWN,
constants.PORT_STATUS_BUILD]
and current_port_status in [constants.PORT_STATUS_ACTIVE,
constants.PORT_STATUS_ERROR]):
constants.PORT_STATUS_BUILD] and
current_port_status in [constants.PORT_STATUS_ACTIVE,
constants.PORT_STATUS_ERROR]):
event_name = VIF_PLUGGED
# All the remaining state transitions are of no interest to nova
else:

View File

@ -113,8 +113,9 @@ class QosRule(base.NeutronDbObject):
# - Is a port QoS policy (not a network QoS policy)
# - Is not an internal network device (e.g. router) and is a network
# QoS policy and there is no port QoS policy
return (is_port_policy or ((is_router_gw or not is_network_device_port)
and is_network_policy_only))
return (is_port_policy or
((is_router_gw or not is_network_device_port) and
is_network_policy_only))
@base.NeutronObjectRegistry.register

View File

@ -202,8 +202,8 @@ class CommonAgentLoop(service.Service):
# Updated devices are processed the same as new ones, as their
# admin_state_up may have changed. The set union prevents duplicating
# work when a device is new and updated in the same polling iteration.
devices_added_updated = (set(device_info.get('added'))
| set(device_info.get('updated')))
devices_added_updated = (set(device_info.get('added')) |
set(device_info.get('updated')))
if devices_added_updated:
resync_a = self.treat_devices_added_updated(devices_added_updated)
@ -408,14 +408,15 @@ class CommonAgentLoop(service.Service):
# Retry cleaning devices that may not have been cleaned properly.
# And clean any that disappeared since the previous iteration.
device_info['removed'] = (previous['removed'] | previous['current']
- current_devices)
device_info['removed'] = (previous['removed'] |
previous['current'] -
current_devices)
# Retry updating devices that may not have been updated properly.
# And any that were updated since the previous iteration.
# Only update devices that currently exist.
device_info['updated'] = (previous['updated'] | updated_devices
& current_devices)
device_info['updated'] = (previous['updated'] | updated_devices &
current_devices)
else:
device_info['added'] = current_devices - previous['current']
device_info['removed'] = previous['current'] - current_devices
@ -424,9 +425,9 @@ class CommonAgentLoop(service.Service):
return device_info
def _device_info_has_changes(self, device_info):
return (device_info.get('added')
or device_info.get('updated')
or device_info.get('removed'))
return (device_info.get('added') or
device_info.get('updated') or
device_info.get('removed'))
def daemon_loop(self):
LOG.info("%s Agent RPC Daemon Started!", self.agent_type)
@ -447,8 +448,8 @@ class CommonAgentLoop(service.Service):
device_info = self.scan_devices(previous=device_info, sync=sync)
sync = False
if (self._device_info_has_changes(device_info)
or self.sg_agent.firewall_refresh_needed()):
if (self._device_info_has_changes(device_info) or
self.sg_agent.firewall_refresh_needed()):
LOG.debug("Agent loop found changes! %s", device_info)
try:
sync = self.process_network_devices(device_info)

View File

@ -166,9 +166,9 @@ class L2populationMechanismDriver(api.MechanismDriver):
agent_host)
self.L2populationAgentNotify.remove_fdb_entries(
self.rpc_ctx, fdb_entries)
elif (context.host != context.original_host
and context.original_status == const.PORT_STATUS_ACTIVE
and context.status == const.PORT_STATUS_DOWN):
elif (context.host != context.original_host and
context.original_status == const.PORT_STATUS_ACTIVE and
context.status == const.PORT_STATUS_DOWN):
# The port has been migrated. Send notification about port
# removal from old host.
fdb_entries = self._get_agent_fdb(

View File

@ -696,8 +696,8 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
test_iface = None
for seg_id in moves.range(1, constants.MAX_VXLAN_VNI + 1):
if (ip_lib.device_exists(self.get_vxlan_device_name(seg_id))
or ip_lib.vxlan_in_use(seg_id)):
if (ip_lib.device_exists(self.get_vxlan_device_name(seg_id)) or
ip_lib.vxlan_in_use(seg_id)):
continue
test_iface = self.ensure_vxlan(seg_id)
break

View File

@ -210,9 +210,9 @@ class SriovNicSwitchAgent(object):
return device_info
def _device_info_has_changes(self, device_info):
return (device_info.get('added')
or device_info.get('updated')
or device_info.get('removed'))
return (device_info.get('added') or
device_info.get('updated') or
device_info.get('removed'))
def process_network_devices(self, device_info):
resync_a = False
@ -225,8 +225,8 @@ class SriovNicSwitchAgent(object):
# Updated devices are processed the same as new ones, as their
# admin_state_up may have changed. The set union prevents duplicating
# work when a device is new and updated in the same polling iteration.
devices_added_updated = (set(device_info.get('added'))
| set(device_info.get('updated')))
devices_added_updated = (set(device_info.get('added')) |
set(device_info.get('updated')))
if devices_added_updated:
resync_a = self.treat_devices_added_updated(devices_added_updated)

View File

@ -575,8 +575,8 @@ class OVSDVRNeutronAgent(object):
if not self.in_distributed_mode():
return
if local_vlan_map.network_type not in (constants.TUNNEL_NETWORK_TYPES
+ [n_const.TYPE_VLAN]):
if local_vlan_map.network_type not in (constants.TUNNEL_NETWORK_TYPES +
[n_const.TYPE_VLAN]):
LOG.debug("DVR: Port %s is with network_type %s not supported"
" for dvr plumbing", port.vif_id,
local_vlan_map.network_type)

View File

@ -351,8 +351,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
if not local_vlan:
continue
net_uuid = local_vlan_map.get('net_uuid')
if (net_uuid and net_uuid not in self._local_vlan_hints
and local_vlan != constants.DEAD_VLAN_TAG):
if (net_uuid and net_uuid not in self._local_vlan_hints and
local_vlan != constants.DEAD_VLAN_TAG):
self.available_local_vlans.remove(local_vlan)
self._local_vlan_hints[local_vlan_map['net_uuid']] = \
local_vlan
@ -1367,8 +1367,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
for lvm in self.vlan_manager:
for port in lvm.vif_ports.values():
if (
port.port_name in port_tags
and port_tags[port.port_name] != lvm.vlan
port.port_name in port_tags and
port_tags[port.port_name] != lvm.vlan
):
LOG.info(
"Port '%(port_name)s' has lost "
@ -2029,8 +2029,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
devices_need_retry = (any(failed_devices.values()) or
any(failed_ancillary_devices.values()) or
ports_not_ready_yet)
if (self._agent_has_updates(polling_manager) or sync
or devices_need_retry):
if (self._agent_has_updates(polling_manager) or sync or
devices_need_retry):
try:
LOG.debug("Agent rpc_loop - iteration:%(iter_num)d - "
"starting polling. Elapsed:%(elapsed).3f",
@ -2149,8 +2149,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
rpc_api.client.set_max_timeout(timeout)
def _check_agent_configurations(self):
if (self.enable_distributed_routing and self.enable_tunneling
and not self.l2_pop):
if (self.enable_distributed_routing and self.enable_tunneling and
not self.l2_pop):
raise ValueError(_("DVR deployments for VXLAN/GRE/Geneve "
"underlays require L2-pop to be enabled, "

View File

@ -445,8 +445,8 @@ class TunnelRpcCallbackMixin(object):
host_endpoint = driver.obj.get_endpoint_by_host(host)
ip_endpoint = driver.obj.get_endpoint_by_ip(tunnel_ip)
if (ip_endpoint and ip_endpoint.host is None
and host_endpoint is None):
if (ip_endpoint and ip_endpoint.host is None and
host_endpoint is None):
driver.obj.delete_endpoint(ip_endpoint.ip_address)
elif (ip_endpoint and ip_endpoint.host != host):
LOG.info(

View File

@ -172,9 +172,9 @@ def get_logs_bound_port(context, port_id):
project_id = port['project_id']
logs = log_object.Log.get_objects(
context, project_id=project_id, enabled=True)
is_bound = lambda log: (log.resource_id in port.security_group_ids
or log.target_id == port.id
or (not log.target_id and not log.resource_id))
is_bound = lambda log: (log.resource_id in port.security_group_ids or
log.target_id == port.id or
(not log.target_id and not log.resource_id))
return [log for log in logs if is_bound(log)]

View File

@ -72,8 +72,8 @@ class Plugin(db.SegmentDbMixin, segment.SegmentPluginBase):
# TODO(carl_baldwin) Make this work with service subnets when
# it's a thing.
is_adjacent = (not network_db.subnets
or not network_db.subnets[0].segment_id)
is_adjacent = (not network_db.subnets or
not network_db.subnets[0].segment_id)
network_res[l2adj_apidef.L2_ADJACENCY] = is_adjacent
@staticmethod

View File

@ -47,8 +47,8 @@ def _change_since_result_filter_hook(query, filters):
query = query.join(standard_attr.StandardAttribute,
target_model_class.standard_attr_id ==
standard_attr.StandardAttribute.id).filter(
standard_attr.StandardAttribute.updated_at
>= changed_since)
standard_attr.StandardAttribute.updated_at >=
changed_since)
return query
@ -57,8 +57,8 @@ def _update_timestamp(session, context, instances):
while objs_list:
obj = objs_list.pop()
if (isinstance(obj, standard_attr.HasStandardAttributes)
and obj.standard_attr_id):
if (isinstance(obj, standard_attr.HasStandardAttributes) and
obj.standard_attr_id):
obj.updated_at = timeutils.utcnow()

View File

@ -153,8 +153,8 @@ class _TestModelsMigrations(test_migrations.ModelsMigrationsSync):
return head_models.get_metadata()
def include_object(self, object_, name, type_, reflected, compare_to):
if type_ == 'table' and (name == 'alembic_version'
or name in external.TABLES):
if type_ == 'table' and (name == 'alembic_version' or
name in external.TABLES):
return False
return super(_TestModelsMigrations, self).include_object(
@ -363,8 +363,9 @@ class TestModelsMigrationsMysql(testlib_api.MySQLTestCaseMixin,
self.assertGreater(len(tables), 0,
"No tables found. Wrong schema?")
res = [table for table in tables if
insp.get_table_options(table)['mysql_engine'] != 'InnoDB'
and table != 'alembic_version']
insp.get_table_options(table)['mysql_engine'] !=
'InnoDB' and
table != 'alembic_version']
self.assertEqual(0, len(res), "%s non InnoDB tables created" % res)

View File

@ -146,8 +146,8 @@ class TestNeutronServer(base.BaseTestCase):
# Wait for temp file to be created and its size reaching the expected
# value
expected_size = len(expected_msg)
condition = lambda: (os.path.isfile(self.temp_file)
and os.stat(self.temp_file).st_size ==
condition = lambda: (os.path.isfile(self.temp_file) and
os.stat(self.temp_file).st_size ==
expected_size)
utils.wait_until_true(

View File

@ -1864,8 +1864,8 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
l3_test_common.router_append_subnet(
router, count=2, ip_version=6,
ipv6_subnet_modes=([{'ra_mode': lib_constants.IPV6_SLAAC,
'address_mode': lib_constants.IPV6_SLAAC}]
* 2))
'address_mode': lib_constants.IPV6_SLAAC}] *
2))
self._process_router_instance_for_agent(agent, ri, router)
self._assert_ri_process_enabled(ri)
# Reset mocks to check for modified radvd config

View File

@ -1219,8 +1219,8 @@ class TestDnsmasq(TestBase):
prefix6 = '--dhcp-range=set:tag%d,%s,%s,%s%s'
possible_leases = 0
for i, s in enumerate(network.subnets):
if (s.ip_version != 6
or s.ipv6_address_mode == constants.DHCPV6_STATEFUL):
if (s.ip_version != 6 or
s.ipv6_address_mode == constants.DHCPV6_STATEFUL):
if s.ip_version == 4:
expected.extend([prefix % (
i, s.cidr.split('/')[0],

View File

@ -50,9 +50,9 @@ class _PortRange(object):
@property
def can_merge(self):
return (self.prev_ref
and self.possible_mask_base == self.prev_ref.possible_mask_base
and self.mask == self.prev_ref.mask)
return (self.prev_ref and
self.possible_mask_base == self.prev_ref.possible_mask_base and
self.mask == self.prev_ref.mask)
def shake(self):
"""Try to merge ranges created earlier.

View File

@ -4318,9 +4318,9 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
'fe80::/64', ip_version=6,
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):
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):
# 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']))

View File

@ -63,9 +63,9 @@ class TestExtraDhcpOpt(ExtraDhcpOptDBTestCase):
for opt in returned:
name = opt['opt_name']
for exp in expected:
if (name == exp['opt_name']
and opt['ip_version'] == exp.get(
'ip_version', 4)):
if (name == exp['opt_name'] and
opt['ip_version'] == exp.get(
'ip_version', 4)):
val = exp['opt_value']
break
self.assertEqual(val, opt['opt_value'])

View File

@ -350,8 +350,9 @@ class L3NatTestCaseMixin(object):
data['router']['name'] = name
if admin_state_up is not None:
data['router']['admin_state_up'] = admin_state_up
for arg in (('admin_state_up', 'tenant_id', 'availability_zone_hints')
+ (arg_list or ())):
for arg in (('admin_state_up', 'tenant_id',
'availability_zone_hints') +
(arg_list or ())):
# Arg must be present and not empty
if arg in kwargs:
data['router'][arg] = kwargs[arg]

View File

@ -136,8 +136,8 @@ class PortSecurityTestPlugin(db_base_plugin_v2.NeutronDbPluginV2,
has_ip = self._ip_on_port(ret_port)
# checks if security groups were updated adding/modifying
# security groups, port security is set and port has ip
if (has_security_groups and (not ret_port[psec.PORTSECURITY]
or not has_ip)):
if (has_security_groups and (not ret_port[psec.PORTSECURITY] or
not has_ip)):
raise psec_exc.PortSecurityAndIPRequiredForSecurityGroups()
# Port security/IP was updated off. Need to check that no security

View File

@ -172,8 +172,8 @@ class SecurityGroupsTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
for r in res['security_group_rules']:
if (r['direction'] == 'egress' and not r['port_range_max'] and
not r['port_range_min'] and not r['protocol']
and not r['remote_ip_prefix']):
not r['port_range_min'] and not r['protocol'] and
not r['remote_ip_prefix']):
self._delete('security-group-rules', r['id'])
def _assert_sg_rule_has_kvs(self, security_group_rule, expected_kvs):

View File

@ -117,9 +117,9 @@ class TestNovaNotify(base.BaseTestCase):
elif (previous_port_status in [sql_attr.NO_VALUE,
n_const.PORT_STATUS_DOWN,
n_const.PORT_STATUS_BUILD]
and current_port_status in [n_const.PORT_STATUS_ACTIVE,
n_const.PORT_STATUS_ERROR]):
n_const.PORT_STATUS_BUILD] and
current_port_status in [n_const.PORT_STATUS_ACTIVE,
n_const.PORT_STATUS_ERROR]):
event_name = nova.VIF_PLUGGED
else:

View File

@ -170,11 +170,9 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
else:
self.assertFalse(dns_data_db['current_dns_domain'])
records_v4 = [ip['ip_address'] for ip in port['fixed_ips']
if netaddr.IPAddress(ip['ip_address']).version
== 4]
if netaddr.IPAddress(ip['ip_address']).version == 4]
records_v6 = [ip['ip_address'] for ip in port['fixed_ips']
if netaddr.IPAddress(ip['ip_address']).version
== 6]
if netaddr.IPAddress(ip['ip_address']).version == 6]
expected = []
expected_delete = []
if records_v4:

View File

@ -148,8 +148,7 @@ commands = sphinx-build -W -b linkcheck doc/source doc/build/linkcheck
# TODO(amotoki) check the following new rules should be fixed or ignored
# E402 module level import not at top of file
# E731 do not assign a lambda expression, use a def
# W503 line break before binary operator
ignore = E125,E126,E128,E129,E265,E402,E731,W503,H404,H405,N530,N534,N536
ignore = E125,E126,E128,E129,E265,E402,E731,H404,H405,N530,N534,N536
# 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