summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Haley <bhaley@redhat.com>2018-04-10 16:17:36 -0400
committerBrian Haley <haleyb.dev@gmail.com>2018-04-17 14:22:58 +0000
commit90cd939047b448117a8fc50852721671221d6dc1 (patch)
tree39b427d2907445a93ece8b670025a5ac5cfaca09
parentc16d15fff2953c7427dc2671dc479d044d5b90c3 (diff)
Fix W503 pep8 warnings
Fix W503 (line break before binary operator) pep8 warnings and no longer ignore new failures. Trivialfix Change-Id: I7539f3b7187f2ad40681781f74b6e05a01bac474
Notes
Notes (review): Code-Review+2: Ihar Hrachyshka <ihrachys@redhat.com> Code-Review+1: Hongbin Lu <hongbin.lu@huawei.com> Code-Review+2: Slawek Kaplonski <skaplons@redhat.com> Code-Review+2: garyk <gkotton@vmware.com> Verified+1: Arista CI <arista-openstack-test@aristanetworks.com> Workflow+1: Ihar Hrachyshka <ihrachys@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 18 Apr 2018 05:58:39 +0000 Reviewed-on: https://review.openstack.org/560137 Project: openstack/neutron Branch: refs/heads/master
-rw-r--r--neutron/agent/dhcp/agent.py6
-rw-r--r--neutron/agent/l3/agent.py4
-rw-r--r--neutron/agent/l3/dvr_edge_ha_router.py3
-rw-r--r--neutron/agent/l3/router_info.py8
-rw-r--r--neutron/agent/linux/dhcp.py6
-rw-r--r--neutron/agent/linux/ip_lib.py4
-rw-r--r--neutron/agent/metadata/agent.py4
-rw-r--r--neutron/agent/ovsdb/impl_vsctl.py4
-rw-r--r--neutron/api/extensions.py4
-rw-r--r--neutron/api/rpc/handlers/dhcp_rpc.py5
-rw-r--r--neutron/common/ipv6_utils.py4
-rw-r--r--neutron/db/allowedaddresspairs_db.py5
-rw-r--r--neutron/db/extradhcpopt_db.py4
-rw-r--r--neutron/db/ipam_backend_mixin.py8
-rw-r--r--neutron/db/l3_db.py4
-rw-r--r--neutron/db/l3_hamode_db.py4
-rw-r--r--neutron/db/securitygroups_db.py5
-rw-r--r--neutron/ipam/utils.py6
-rw-r--r--neutron/notifiers/nova.py17
-rw-r--r--neutron/objects/qos/rule.py5
-rw-r--r--neutron/plugins/ml2/drivers/agent/_common_agent.py23
-rw-r--r--neutron/plugins/ml2/drivers/l2pop/mech_driver.py6
-rw-r--r--neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py4
-rw-r--r--neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py10
-rw-r--r--neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py4
-rw-r--r--neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py16
-rw-r--r--neutron/plugins/ml2/drivers/type_tunnel.py4
-rw-r--r--neutron/services/logapi/common/db_api.py6
-rw-r--r--neutron/services/segments/plugin.py4
-rw-r--r--neutron/services/timestamp/timestamp_db.py8
-rw-r--r--neutron/tests/functional/db/test_migrations.py9
-rw-r--r--neutron/tests/functional/test_server.py4
-rw-r--r--neutron/tests/unit/agent/l3/test_agent.py4
-rw-r--r--neutron/tests/unit/agent/linux/test_dhcp.py4
-rw-r--r--neutron/tests/unit/common/test_utils.py6
-rw-r--r--neutron/tests/unit/db/test_db_base_plugin_v2.py6
-rw-r--r--neutron/tests/unit/extensions/test_extra_dhcp_opt.py6
-rw-r--r--neutron/tests/unit/extensions/test_l3.py5
-rw-r--r--neutron/tests/unit/extensions/test_portsecurity.py4
-rw-r--r--neutron/tests/unit/extensions/test_securitygroup.py4
-rw-r--r--neutron/tests/unit/notifiers/test_nova.py6
-rw-r--r--neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py6
-rw-r--r--tox.ini3
43 files changed, 133 insertions, 129 deletions
diff --git a/neutron/agent/dhcp/agent.py b/neutron/agent/dhcp/agent.py
index faa27fa..790a60d 100644
--- a/neutron/agent/dhcp/agent.py
+++ b/neutron/agent/dhcp/agent.py
@@ -161,9 +161,9 @@ class DhcpAgent(manager.Manager):
161 # allocation pool or a port is deleted to free up an IP, this 161 # allocation pool or a port is deleted to free up an IP, this
162 # will automatically be retried on the notification 162 # will automatically be retried on the notification
163 self.schedule_resync(e, network.id) 163 self.schedule_resync(e, network.id)
164 if (isinstance(e, oslo_messaging.RemoteError) 164 if (isinstance(e, oslo_messaging.RemoteError) and
165 and e.exc_type == 'NetworkNotFound' 165 e.exc_type == 'NetworkNotFound' or
166 or isinstance(e, exceptions.NetworkNotFound)): 166 isinstance(e, exceptions.NetworkNotFound)):
167 LOG.debug("Network %s has been deleted.", network.id) 167 LOG.debug("Network %s has been deleted.", network.id)
168 else: 168 else:
169 LOG.exception('Unable to %(action)s dhcp for %(net_id)s.', 169 LOG.exception('Unable to %(action)s dhcp for %(net_id)s.',
diff --git a/neutron/agent/l3/agent.py b/neutron/agent/l3/agent.py
index 946a1c6..d9d28a3 100644
--- a/neutron/agent/l3/agent.py
+++ b/neutron/agent/l3/agent.py
@@ -335,8 +335,8 @@ class L3NATAgent(ha.AgentMixin,
335 # side of it, typically because it's landing on a node that needs 335 # side of it, typically because it's landing on a node that needs
336 # to provision a router namespace because of a DVR service port 336 # to provision a router namespace because of a DVR service port
337 # (e.g. DHCP). 337 # (e.g. DHCP).
338 if (self.conf.agent_mode == lib_const.L3_AGENT_MODE_DVR_SNAT 338 if (self.conf.agent_mode == lib_const.L3_AGENT_MODE_DVR_SNAT and
339 and router.get(lib_const.HA_INTERFACE_KEY) is not None): 339 router.get(lib_const.HA_INTERFACE_KEY) is not None):
340 kwargs['state_change_callback'] = self.enqueue_state_change 340 kwargs['state_change_callback'] = self.enqueue_state_change
341 return dvr_edge_ha_router.DvrEdgeHaRouter(*args, **kwargs) 341 return dvr_edge_ha_router.DvrEdgeHaRouter(*args, **kwargs)
342 342
diff --git a/neutron/agent/l3/dvr_edge_ha_router.py b/neutron/agent/l3/dvr_edge_ha_router.py
index d231c60..15d7a8d 100644
--- a/neutron/agent/l3/dvr_edge_ha_router.py
+++ b/neutron/agent/l3/dvr_edge_ha_router.py
@@ -115,8 +115,7 @@ class DvrEdgeHaRouter(dvr_edge_router.DvrEdgeRouter,
115 self._plug_external_gateway(ex_gw_port, interface_name, ns_name) 115 self._plug_external_gateway(ex_gw_port, interface_name, ns_name)
116 116
117 def _is_this_snat_host(self): 117 def _is_this_snat_host(self):
118 return (self.agent_conf.agent_mode 118 return self.agent_conf.agent_mode == constants.L3_AGENT_MODE_DVR_SNAT
119 == constants.L3_AGENT_MODE_DVR_SNAT)
120 119
121 def _dvr_internal_network_removed(self, port): 120 def _dvr_internal_network_removed(self, port):
122 super(DvrEdgeHaRouter, self)._dvr_internal_network_removed(port) 121 super(DvrEdgeHaRouter, self)._dvr_internal_network_removed(port)
diff --git a/neutron/agent/l3/router_info.py b/neutron/agent/l3/router_info.py
index 372045b..555bd09 100644
--- a/neutron/agent/l3/router_info.py
+++ b/neutron/agent/l3/router_info.py
@@ -772,8 +772,8 @@ class RouterInfo(object):
772 def _delete_stale_external_devices(self, interface_name): 772 def _delete_stale_external_devices(self, interface_name):
773 existing_devices = self._get_existing_devices() 773 existing_devices = self._get_existing_devices()
774 stale_devs = [dev for dev in existing_devices 774 stale_devs = [dev for dev in existing_devices
775 if dev.startswith(EXTERNAL_DEV_PREFIX) 775 if dev.startswith(EXTERNAL_DEV_PREFIX) and
776 and dev != interface_name] 776 dev != interface_name]
777 for stale_dev in stale_devs: 777 for stale_dev in stale_devs:
778 LOG.debug('Deleting stale external router device: %s', stale_dev) 778 LOG.debug('Deleting stale external router device: %s', stale_dev)
779 self.agent.pd.remove_gw_interface(self.router['id']) 779 self.agent.pd.remove_gw_interface(self.router['id'])
@@ -1053,8 +1053,8 @@ class RouterInfo(object):
1053 iptables = iptables_manager.get_tables(ip_version) 1053 iptables = iptables_manager.get_tables(ip_version)
1054 iptables['mangle'].empty_chain('scope') 1054 iptables['mangle'].empty_chain('scope')
1055 iptables['filter'].empty_chain('scope') 1055 iptables['filter'].empty_chain('scope')
1056 dont_block_external = (ip_version == lib_constants.IP_VERSION_4 1056 dont_block_external = (ip_version == lib_constants.IP_VERSION_4 and
1057 and self._snat_enabled and external_port) 1057 self._snat_enabled and external_port)
1058 for device_name, mark in scopemarks.items(): 1058 for device_name, mark in scopemarks.items():
1059 # Add address scope iptables rule 1059 # Add address scope iptables rule
1060 iptables['mangle'].add_rule( 1060 iptables['mangle'].add_rule(
diff --git a/neutron/agent/linux/dhcp.py b/neutron/agent/linux/dhcp.py
index 0060d66..aa0fd91 100644
--- a/neutron/agent/linux/dhcp.py
+++ b/neutron/agent/linux/dhcp.py
@@ -1155,9 +1155,9 @@ class DeviceManager(object):
1155 1155
1156 for subnet in network.subnets: 1156 for subnet in network.subnets:
1157 skip_subnet = ( 1157 skip_subnet = (
1158 subnet.ip_version != ip_version 1158 subnet.ip_version != ip_version or
1159 or not subnet.enable_dhcp 1159 not subnet.enable_dhcp or
1160 or subnet.gateway_ip is None) 1160 subnet.gateway_ip is None)
1161 1161
1162 if skip_subnet: 1162 if skip_subnet:
1163 continue 1163 continue
diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py
index 691b2c2..937dcb5 100644
--- a/neutron/agent/linux/ip_lib.py
+++ b/neutron/agent/linux/ip_lib.py
@@ -274,8 +274,8 @@ class IPDevice(SubProcessBase):
274 self.neigh = IpNeighCommand(self) 274 self.neigh = IpNeighCommand(self)
275 275
276 def __eq__(self, other): 276 def __eq__(self, other):
277 return (other is not None and self.name == other.name 277 return (other is not None and self.name == other.name and
278 and self.namespace == other.namespace) 278 self.namespace == other.namespace)
279 279
280 def __str__(self): 280 def __str__(self):
281 return self.name 281 return self.name
diff --git a/neutron/agent/metadata/agent.py b/neutron/agent/metadata/agent.py
index 6d4954c..ef44755 100644
--- a/neutron/agent/metadata/agent.py
+++ b/neutron/agent/metadata/agent.py
@@ -280,8 +280,8 @@ class UnixDomainMetadataProxy(object):
280 mode = self.conf.metadata_proxy_socket_mode 280 mode = self.conf.metadata_proxy_socket_mode
281 if mode == config.DEDUCE_MODE: 281 if mode == config.DEDUCE_MODE:
282 user = self.conf.metadata_proxy_user 282 user = self.conf.metadata_proxy_user
283 if (not user or user == '0' or user == 'root' 283 if (not user or user == '0' or user == 'root' or
284 or agent_utils.is_effective_user(user)): 284 agent_utils.is_effective_user(user)):
285 # user is agent effective user or root => USER_MODE 285 # user is agent effective user or root => USER_MODE
286 mode = config.USER_MODE 286 mode = config.USER_MODE
287 else: 287 else:
diff --git a/neutron/agent/ovsdb/impl_vsctl.py b/neutron/agent/ovsdb/impl_vsctl.py
index 514f377..07bd212 100644
--- a/neutron/agent/ovsdb/impl_vsctl.py
+++ b/neutron/agent/ovsdb/impl_vsctl.py
@@ -333,8 +333,8 @@ def _set_colval_args(*col_values):
333 if isinstance(val, collections.Mapping): 333 if isinstance(val, collections.Mapping):
334 args += ["%s:%s%s%s" % ( 334 args += ["%s:%s%s%s" % (
335 col, k, op, ovsdb.py_to_val(v)) for k, v in val.items()] 335 col, k, op, ovsdb.py_to_val(v)) for k, v in val.items()]
336 elif (isinstance(val, collections.Sequence) 336 elif (isinstance(val, collections.Sequence) and
337 and not isinstance(val, six.string_types)): 337 not isinstance(val, six.string_types)):
338 if len(val) == 0: 338 if len(val) == 0:
339 args.append("%s%s%s" % (col, op, "[]")) 339 args.append("%s%s%s" % (col, op, "[]"))
340 else: 340 else:
diff --git a/neutron/api/extensions.py b/neutron/api/extensions.py
index 8111b14..a57033b 100644
--- a/neutron/api/extensions.py
+++ b/neutron/api/extensions.py
@@ -138,8 +138,8 @@ class ExtensionMiddleware(base.ConfigurableMiddleware):
138 138
139 def __init__(self, application, 139 def __init__(self, application,
140 ext_mgr=None): 140 ext_mgr=None):
141 self.ext_mgr = (ext_mgr 141 self.ext_mgr = (ext_mgr or
142 or ExtensionManager(get_extensions_path())) 142 ExtensionManager(get_extensions_path()))
143 mapper = routes.Mapper() 143 mapper = routes.Mapper()
144 144
145 # extended resources 145 # extended resources
diff --git a/neutron/api/rpc/handlers/dhcp_rpc.py b/neutron/api/rpc/handlers/dhcp_rpc.py
index 20f9186..14269ac 100644
--- a/neutron/api/rpc/handlers/dhcp_rpc.py
+++ b/neutron/api/rpc/handlers/dhcp_rpc.py
@@ -282,8 +282,9 @@ class DhcpRpcCallback(object):
282 plugin = directory.get_plugin() 282 plugin = directory.get_plugin()
283 try: 283 try:
284 old_port = plugin.get_port(context, port['id']) 284 old_port = plugin.get_port(context, port['id'])
285 if (old_port['device_id'] != constants.DEVICE_ID_RESERVED_DHCP_PORT 285 if (old_port['device_id'] !=
286 and old_port['device_id'] != 286 constants.DEVICE_ID_RESERVED_DHCP_PORT and
287 old_port['device_id'] !=
287 utils.get_dhcp_agent_device_id(port['port']['network_id'], 288 utils.get_dhcp_agent_device_id(port['port']['network_id'],
288 host)): 289 host)):
289 raise n_exc.DhcpPortInUse(port_id=port['id']) 290 raise n_exc.DhcpPortInUse(port_id=port['id'])
diff --git a/neutron/common/ipv6_utils.py b/neutron/common/ipv6_utils.py
index 5b13654..bb4f170 100644
--- a/neutron/common/ipv6_utils.py
+++ b/neutron/common/ipv6_utils.py
@@ -52,8 +52,8 @@ def is_enabled_and_bind_by_default():
52def is_auto_address_subnet(subnet): 52def is_auto_address_subnet(subnet):
53 """Check if subnet is an auto address subnet.""" 53 """Check if subnet is an auto address subnet."""
54 modes = [const.IPV6_SLAAC, const.DHCPV6_STATELESS] 54 modes = [const.IPV6_SLAAC, const.DHCPV6_STATELESS]
55 return (subnet['ipv6_address_mode'] in modes 55 return (subnet['ipv6_address_mode'] in modes or
56 or subnet['ipv6_ra_mode'] in modes) 56 subnet['ipv6_ra_mode'] in modes)
57 57
58 58
59def is_eui64_address(ip_address): 59def is_eui64_address(ip_address):
diff --git a/neutron/db/allowedaddresspairs_db.py b/neutron/db/allowedaddresspairs_db.py
index 1bc1bdf..6b18490 100644
--- a/neutron/db/allowedaddresspairs_db.py
+++ b/neutron/db/allowedaddresspairs_db.py
@@ -90,8 +90,9 @@ class AllowedAddressPairsMixin(object):
90 return db_utils.resource_fields(res, fields) 90 return db_utils.resource_fields(res, fields)
91 91
92 def _has_address_pairs(self, port): 92 def _has_address_pairs(self, port):
93 return (validators.is_attr_set(port['port'][addr_apidef.ADDRESS_PAIRS]) 93 return (validators.is_attr_set(
94 and port['port'][addr_apidef.ADDRESS_PAIRS] != []) 94 port['port'][addr_apidef.ADDRESS_PAIRS]) and
95 port['port'][addr_apidef.ADDRESS_PAIRS] != [])
95 96
96 def _check_update_has_allowed_address_pairs(self, port): 97 def _check_update_has_allowed_address_pairs(self, port):
97 """Determine if request has an allowed address pair. 98 """Determine if request has an allowed address pair.
diff --git a/neutron/db/extradhcpopt_db.py b/neutron/db/extradhcpopt_db.py
index 5829b0c..bf69833 100644
--- a/neutron/db/extradhcpopt_db.py
+++ b/neutron/db/extradhcpopt_db.py
@@ -82,8 +82,8 @@ class ExtraDhcpOptMixin(object):
82 with db_api.context_manager.writer.using(context): 82 with db_api.context_manager.writer.using(context):
83 for upd_rec in dopts: 83 for upd_rec in dopts:
84 for opt in opts: 84 for opt in opts:
85 if (opt['opt_name'] == upd_rec['opt_name'] 85 if (opt['opt_name'] == upd_rec['opt_name'] and
86 and opt['ip_version'] == upd_rec.get( 86 opt['ip_version'] == upd_rec.get(
87 'ip_version', 4)): 87 'ip_version', 4)):
88 # to handle deleting of a opt from the port. 88 # to handle deleting of a opt from the port.
89 if upd_rec['opt_value'] is None: 89 if upd_rec['opt_value'] is None:
diff --git a/neutron/db/ipam_backend_mixin.py b/neutron/db/ipam_backend_mixin.py
index 892ae1f..1f535bf 100644
--- a/neutron/db/ipam_backend_mixin.py
+++ b/neutron/db/ipam_backend_mixin.py
@@ -765,10 +765,10 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
765 old_ips = old_port.get('fixed_ips') 765 old_ips = old_port.get('fixed_ips')
766 deferred_ip_allocation = ( 766 deferred_ip_allocation = (
767 old_port.get('ip_allocation') == 767 old_port.get('ip_allocation') ==
768 ipalloc_apidef.IP_ALLOCATION_DEFERRED 768 ipalloc_apidef.IP_ALLOCATION_DEFERRED and
769 and host and not old_host 769 host and not old_host and
770 and not old_ips 770 not old_ips and
771 and not fixed_ips_requested) 771 not fixed_ips_requested)
772 if not deferred_ip_allocation: 772 if not deferred_ip_allocation:
773 # Check that any existing IPs are valid on the new segment 773 # Check that any existing IPs are valid on the new segment
774 new_host_requested = host and host != old_host 774 new_host_requested = host and host != old_host
diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py
index 78e7e65..0b53fcc 100644
--- a/neutron/db/l3_db.py
+++ b/neutron/db/l3_db.py
@@ -788,8 +788,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
788 if not subnet['gateway_ip']: 788 if not subnet['gateway_ip']:
789 msg = _('Subnet for router interface must have a gateway IP') 789 msg = _('Subnet for router interface must have a gateway IP')
790 raise n_exc.BadRequest(resource='router', msg=msg) 790 raise n_exc.BadRequest(resource='router', msg=msg)
791 if (subnet['ip_version'] == 6 and subnet['ipv6_ra_mode'] is None 791 if (subnet['ip_version'] == 6 and subnet['ipv6_ra_mode'] is None and
792 and subnet['ipv6_address_mode'] is not None): 792 subnet['ipv6_address_mode'] is not None):
793 msg = (_('IPv6 subnet %s configured to receive RAs from an ' 793 msg = (_('IPv6 subnet %s configured to receive RAs from an '
794 'external router cannot be added to Neutron Router.') % 794 'external router cannot be added to Neutron Router.') %
795 subnet['id']) 795 subnet['id'])
diff --git a/neutron/db/l3_hamode_db.py b/neutron/db/l3_hamode_db.py
index e9eacc0..0badefb 100644
--- a/neutron/db/l3_hamode_db.py
+++ b/neutron/db/l3_hamode_db.py
@@ -552,8 +552,8 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
552 # List agents where router is active and agent is dead 552 # List agents where router is active and agent is dead
553 # and agents where router is standby and agent is dead 553 # and agents where router is standby and agent is dead
554 for binding in bindings: 554 for binding in bindings:
555 if not (binding.agent.is_active 555 if not (binding.agent.is_active and
556 and binding.agent.admin_state_up): 556 binding.agent.admin_state_up):
557 if binding.state == n_const.HA_ROUTER_STATE_ACTIVE: 557 if binding.state == n_const.HA_ROUTER_STATE_ACTIVE:
558 router_active_agents_dead.append(binding.agent) 558 router_active_agents_dead.append(binding.agent)
559 elif binding.state == n_const.HA_ROUTER_STATE_STANDBY: 559 elif binding.state == n_const.HA_ROUTER_STATE_STANDBY:
diff --git a/neutron/db/securitygroups_db.py b/neutron/db/securitygroups_db.py
index 8bc6e94..d09b1e6 100644
--- a/neutron/db/securitygroups_db.py
+++ b/neutron/db/securitygroups_db.py
@@ -827,8 +827,9 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
827 is either [] or not is_attr_set, otherwise return False 827 is either [] or not is_attr_set, otherwise return False
828 """ 828 """
829 if (ext_sg.SECURITYGROUPS in port['port'] and 829 if (ext_sg.SECURITYGROUPS in port['port'] and
830 not (validators.is_attr_set(port['port'][ext_sg.SECURITYGROUPS]) 830 not (validators.is_attr_set(
831 and port['port'][ext_sg.SECURITYGROUPS] != [])): 831 port['port'][ext_sg.SECURITYGROUPS]) and
832 port['port'][ext_sg.SECURITYGROUPS] != [])):
832 return True 833 return True
833 return False 834 return False
834 835
diff --git a/neutron/ipam/utils.py b/neutron/ipam/utils.py
index 1c062d7..c3097ab 100644
--- a/neutron/ipam/utils.py
+++ b/neutron/ipam/utils.py
@@ -23,9 +23,9 @@ def check_subnet_ip(cidr, ip_address):
23 net = netaddr.IPNetwork(cidr) 23 net = netaddr.IPNetwork(cidr)
24 # Check that the IP is valid on subnet. This cannot be the 24 # Check that the IP is valid on subnet. This cannot be the
25 # network or the broadcast address (which exists only in IPv4) 25 # network or the broadcast address (which exists only in IPv4)
26 return (ip != net.network 26 return (ip != net.network and
27 and (net.version == 6 or ip != net[-1]) 27 (net.version == 6 or ip != net[-1]) and
28 and net.netmask & ip == net.network) 28 net.netmask & ip == net.network)
29 29
30 30
31def check_gateway_invalid_in_subnet(cidr, gateway): 31def check_gateway_invalid_in_subnet(cidr, gateway):
diff --git a/neutron/notifiers/nova.py b/neutron/notifiers/nova.py
index 29d00ae..b3b9963 100644
--- a/neutron/notifiers/nova.py
+++ b/neutron/notifiers/nova.py
@@ -76,8 +76,9 @@ class Notifier(object):
76 76
77 def _is_compute_port(self, port): 77 def _is_compute_port(self, port):
78 try: 78 try:
79 if (port['device_id'] and uuidutils.is_uuid_like(port['device_id']) 79 if (port['device_id'] and
80 and port['device_owner'].startswith( 80 uuidutils.is_uuid_like(port['device_id']) and
81 port['device_owner'].startswith(
81 constants.DEVICE_OWNER_COMPUTE_PREFIX)): 82 constants.DEVICE_OWNER_COMPUTE_PREFIX)):
82 return True 83 return True
83 except (KeyError, AttributeError): 84 except (KeyError, AttributeError):
@@ -116,9 +117,9 @@ class Notifier(object):
116 # port to a new instance port without disassociate it first, an 117 # port to a new instance port without disassociate it first, an
117 # event should be sent for original instance, that will make nova 118 # event should be sent for original instance, that will make nova
118 # know original instance's info, and update database for it. 119 # know original instance's info, and update database for it.
119 if (action == 'update_floatingip' 120 if (action == 'update_floatingip' and
120 and returned_obj['floatingip'].get('port_id') 121 returned_obj['floatingip'].get('port_id') and
121 and original_obj.get('port_id')): 122 original_obj.get('port_id')):
122 disassociate_returned_obj = {'floatingip': {'port_id': None}} 123 disassociate_returned_obj = {'floatingip': {'port_id': None}}
123 event = self.create_port_changed_event(action, original_obj, 124 event = self.create_port_changed_event(action, original_obj,
124 disassociate_returned_obj) 125 disassociate_returned_obj)
@@ -194,9 +195,9 @@ class Notifier(object):
194 # NO_VALUE/DOWN/BUILD -> ACTIVE/ERROR. 195 # NO_VALUE/DOWN/BUILD -> ACTIVE/ERROR.
195 elif (previous_port_status in [sql_attr.NO_VALUE, 196 elif (previous_port_status in [sql_attr.NO_VALUE,
196 constants.PORT_STATUS_DOWN, 197 constants.PORT_STATUS_DOWN,
197 constants.PORT_STATUS_BUILD] 198 constants.PORT_STATUS_BUILD] and
198 and current_port_status in [constants.PORT_STATUS_ACTIVE, 199 current_port_status in [constants.PORT_STATUS_ACTIVE,
199 constants.PORT_STATUS_ERROR]): 200 constants.PORT_STATUS_ERROR]):
200 event_name = VIF_PLUGGED 201 event_name = VIF_PLUGGED
201 # All the remaining state transitions are of no interest to nova 202 # All the remaining state transitions are of no interest to nova
202 else: 203 else:
diff --git a/neutron/objects/qos/rule.py b/neutron/objects/qos/rule.py
index 8a84f83..76d90b1 100644
--- a/neutron/objects/qos/rule.py
+++ b/neutron/objects/qos/rule.py
@@ -113,8 +113,9 @@ class QosRule(base.NeutronDbObject):
113 # - Is a port QoS policy (not a network QoS policy) 113 # - Is a port QoS policy (not a network QoS policy)
114 # - Is not an internal network device (e.g. router) and is a network 114 # - Is not an internal network device (e.g. router) and is a network
115 # QoS policy and there is no port QoS policy 115 # QoS policy and there is no port QoS policy
116 return (is_port_policy or ((is_router_gw or not is_network_device_port) 116 return (is_port_policy or
117 and is_network_policy_only)) 117 ((is_router_gw or not is_network_device_port) and
118 is_network_policy_only))
118 119
119 120
120@base.NeutronObjectRegistry.register 121@base.NeutronObjectRegistry.register
diff --git a/neutron/plugins/ml2/drivers/agent/_common_agent.py b/neutron/plugins/ml2/drivers/agent/_common_agent.py
index cb27aab..b03ebbf 100644
--- a/neutron/plugins/ml2/drivers/agent/_common_agent.py
+++ b/neutron/plugins/ml2/drivers/agent/_common_agent.py
@@ -202,8 +202,8 @@ class CommonAgentLoop(service.Service):
202 # Updated devices are processed the same as new ones, as their 202 # Updated devices are processed the same as new ones, as their
203 # admin_state_up may have changed. The set union prevents duplicating 203 # admin_state_up may have changed. The set union prevents duplicating
204 # work when a device is new and updated in the same polling iteration. 204 # work when a device is new and updated in the same polling iteration.
205 devices_added_updated = (set(device_info.get('added')) 205 devices_added_updated = (set(device_info.get('added')) |
206 | set(device_info.get('updated'))) 206 set(device_info.get('updated')))
207 if devices_added_updated: 207 if devices_added_updated:
208 resync_a = self.treat_devices_added_updated(devices_added_updated) 208 resync_a = self.treat_devices_added_updated(devices_added_updated)
209 209
@@ -408,14 +408,15 @@ class CommonAgentLoop(service.Service):
408 408
409 # Retry cleaning devices that may not have been cleaned properly. 409 # Retry cleaning devices that may not have been cleaned properly.
410 # And clean any that disappeared since the previous iteration. 410 # And clean any that disappeared since the previous iteration.
411 device_info['removed'] = (previous['removed'] | previous['current'] 411 device_info['removed'] = (previous['removed'] |
412 - current_devices) 412 previous['current'] -
413 current_devices)
413 414
414 # Retry updating devices that may not have been updated properly. 415 # Retry updating devices that may not have been updated properly.
415 # And any that were updated since the previous iteration. 416 # And any that were updated since the previous iteration.
416 # Only update devices that currently exist. 417 # Only update devices that currently exist.
417 device_info['updated'] = (previous['updated'] | updated_devices 418 device_info['updated'] = (previous['updated'] | updated_devices &
418 & current_devices) 419 current_devices)
419 else: 420 else:
420 device_info['added'] = current_devices - previous['current'] 421 device_info['added'] = current_devices - previous['current']
421 device_info['removed'] = previous['current'] - current_devices 422 device_info['removed'] = previous['current'] - current_devices
@@ -424,9 +425,9 @@ class CommonAgentLoop(service.Service):
424 return device_info 425 return device_info
425 426
426 def _device_info_has_changes(self, device_info): 427 def _device_info_has_changes(self, device_info):
427 return (device_info.get('added') 428 return (device_info.get('added') or
428 or device_info.get('updated') 429 device_info.get('updated') or
429 or device_info.get('removed')) 430 device_info.get('removed'))
430 431
431 def daemon_loop(self): 432 def daemon_loop(self):
432 LOG.info("%s Agent RPC Daemon Started!", self.agent_type) 433 LOG.info("%s Agent RPC Daemon Started!", self.agent_type)
@@ -447,8 +448,8 @@ class CommonAgentLoop(service.Service):
447 device_info = self.scan_devices(previous=device_info, sync=sync) 448 device_info = self.scan_devices(previous=device_info, sync=sync)
448 sync = False 449 sync = False
449 450
450 if (self._device_info_has_changes(device_info) 451 if (self._device_info_has_changes(device_info) or
451 or self.sg_agent.firewall_refresh_needed()): 452 self.sg_agent.firewall_refresh_needed()):
452 LOG.debug("Agent loop found changes! %s", device_info) 453 LOG.debug("Agent loop found changes! %s", device_info)
453 try: 454 try:
454 sync = self.process_network_devices(device_info) 455 sync = self.process_network_devices(device_info)
diff --git a/neutron/plugins/ml2/drivers/l2pop/mech_driver.py b/neutron/plugins/ml2/drivers/l2pop/mech_driver.py
index ce71001..7a97c0b 100644
--- a/neutron/plugins/ml2/drivers/l2pop/mech_driver.py
+++ b/neutron/plugins/ml2/drivers/l2pop/mech_driver.py
@@ -166,9 +166,9 @@ class L2populationMechanismDriver(api.MechanismDriver):
166 agent_host) 166 agent_host)
167 self.L2populationAgentNotify.remove_fdb_entries( 167 self.L2populationAgentNotify.remove_fdb_entries(
168 self.rpc_ctx, fdb_entries) 168 self.rpc_ctx, fdb_entries)
169 elif (context.host != context.original_host 169 elif (context.host != context.original_host and
170 and context.original_status == const.PORT_STATUS_ACTIVE 170 context.original_status == const.PORT_STATUS_ACTIVE and
171 and context.status == const.PORT_STATUS_DOWN): 171 context.status == const.PORT_STATUS_DOWN):
172 # The port has been migrated. Send notification about port 172 # The port has been migrated. Send notification about port
173 # removal from old host. 173 # removal from old host.
174 fdb_entries = self._get_agent_fdb( 174 fdb_entries = self._get_agent_fdb(
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 e078b0a..6c5438b 100644
--- a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py
+++ b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py
@@ -696,8 +696,8 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
696 696
697 test_iface = None 697 test_iface = None
698 for seg_id in moves.range(1, constants.MAX_VXLAN_VNI + 1): 698 for seg_id in moves.range(1, constants.MAX_VXLAN_VNI + 1):
699 if (ip_lib.device_exists(self.get_vxlan_device_name(seg_id)) 699 if (ip_lib.device_exists(self.get_vxlan_device_name(seg_id)) or
700 or ip_lib.vxlan_in_use(seg_id)): 700 ip_lib.vxlan_in_use(seg_id)):
701 continue 701 continue
702 test_iface = self.ensure_vxlan(seg_id) 702 test_iface = self.ensure_vxlan(seg_id)
703 break 703 break
diff --git a/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py b/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py
index dc17960..3d3dee8 100644
--- a/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py
+++ b/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py
@@ -210,9 +210,9 @@ class SriovNicSwitchAgent(object):
210 return device_info 210 return device_info
211 211
212 def _device_info_has_changes(self, device_info): 212 def _device_info_has_changes(self, device_info):
213 return (device_info.get('added') 213 return (device_info.get('added') or
214 or device_info.get('updated') 214 device_info.get('updated') or
215 or device_info.get('removed')) 215 device_info.get('removed'))
216 216
217 def process_network_devices(self, device_info): 217 def process_network_devices(self, device_info):
218 resync_a = False 218 resync_a = False
@@ -225,8 +225,8 @@ class SriovNicSwitchAgent(object):
225 # Updated devices are processed the same as new ones, as their 225 # Updated devices are processed the same as new ones, as their
226 # admin_state_up may have changed. The set union prevents duplicating 226 # admin_state_up may have changed. The set union prevents duplicating
227 # work when a device is new and updated in the same polling iteration. 227 # work when a device is new and updated in the same polling iteration.
228 devices_added_updated = (set(device_info.get('added')) 228 devices_added_updated = (set(device_info.get('added')) |
229 | set(device_info.get('updated'))) 229 set(device_info.get('updated')))
230 if devices_added_updated: 230 if devices_added_updated:
231 resync_a = self.treat_devices_added_updated(devices_added_updated) 231 resync_a = self.treat_devices_added_updated(devices_added_updated)
232 232
diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py
index 48167a1..180f97d 100644
--- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py
+++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py
@@ -575,8 +575,8 @@ class OVSDVRNeutronAgent(object):
575 if not self.in_distributed_mode(): 575 if not self.in_distributed_mode():
576 return 576 return
577 577
578 if local_vlan_map.network_type not in (constants.TUNNEL_NETWORK_TYPES 578 if local_vlan_map.network_type not in (constants.TUNNEL_NETWORK_TYPES +
579 + [n_const.TYPE_VLAN]): 579 [n_const.TYPE_VLAN]):
580 LOG.debug("DVR: Port %s is with network_type %s not supported" 580 LOG.debug("DVR: Port %s is with network_type %s not supported"
581 " for dvr plumbing", port.vif_id, 581 " for dvr plumbing", port.vif_id,
582 local_vlan_map.network_type) 582 local_vlan_map.network_type)
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 2773f01..b05346e 100644
--- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
+++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
@@ -351,8 +351,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
351 if not local_vlan: 351 if not local_vlan:
352 continue 352 continue
353 net_uuid = local_vlan_map.get('net_uuid') 353 net_uuid = local_vlan_map.get('net_uuid')
354 if (net_uuid and net_uuid not in self._local_vlan_hints 354 if (net_uuid and net_uuid not in self._local_vlan_hints and
355 and local_vlan != constants.DEAD_VLAN_TAG): 355 local_vlan != constants.DEAD_VLAN_TAG):
356 self.available_local_vlans.remove(local_vlan) 356 self.available_local_vlans.remove(local_vlan)
357 self._local_vlan_hints[local_vlan_map['net_uuid']] = \ 357 self._local_vlan_hints[local_vlan_map['net_uuid']] = \
358 local_vlan 358 local_vlan
@@ -1367,8 +1367,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
1367 for lvm in self.vlan_manager: 1367 for lvm in self.vlan_manager:
1368 for port in lvm.vif_ports.values(): 1368 for port in lvm.vif_ports.values():
1369 if ( 1369 if (
1370 port.port_name in port_tags 1370 port.port_name in port_tags and
1371 and port_tags[port.port_name] != lvm.vlan 1371 port_tags[port.port_name] != lvm.vlan
1372 ): 1372 ):
1373 LOG.info( 1373 LOG.info(
1374 "Port '%(port_name)s' has lost " 1374 "Port '%(port_name)s' has lost "
@@ -2029,8 +2029,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
2029 devices_need_retry = (any(failed_devices.values()) or 2029 devices_need_retry = (any(failed_devices.values()) or
2030 any(failed_ancillary_devices.values()) or 2030 any(failed_ancillary_devices.values()) or
2031 ports_not_ready_yet) 2031 ports_not_ready_yet)
2032 if (self._agent_has_updates(polling_manager) or sync 2032 if (self._agent_has_updates(polling_manager) or sync or
2033 or devices_need_retry): 2033 devices_need_retry):
2034 try: 2034 try:
2035 LOG.debug("Agent rpc_loop - iteration:%(iter_num)d - " 2035 LOG.debug("Agent rpc_loop - iteration:%(iter_num)d - "
2036 "starting polling. Elapsed:%(elapsed).3f", 2036 "starting polling. Elapsed:%(elapsed).3f",
@@ -2149,8 +2149,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
2149 rpc_api.client.set_max_timeout(timeout) 2149 rpc_api.client.set_max_timeout(timeout)
2150 2150
2151 def _check_agent_configurations(self): 2151 def _check_agent_configurations(self):
2152 if (self.enable_distributed_routing and self.enable_tunneling 2152 if (self.enable_distributed_routing and self.enable_tunneling and
2153 and not self.l2_pop): 2153 not self.l2_pop):
2154 2154
2155 raise ValueError(_("DVR deployments for VXLAN/GRE/Geneve " 2155 raise ValueError(_("DVR deployments for VXLAN/GRE/Geneve "
2156 "underlays require L2-pop to be enabled, " 2156 "underlays require L2-pop to be enabled, "
diff --git a/neutron/plugins/ml2/drivers/type_tunnel.py b/neutron/plugins/ml2/drivers/type_tunnel.py
index 57c64f9..94742c5 100644
--- a/neutron/plugins/ml2/drivers/type_tunnel.py
+++ b/neutron/plugins/ml2/drivers/type_tunnel.py
@@ -445,8 +445,8 @@ class TunnelRpcCallbackMixin(object):
445 host_endpoint = driver.obj.get_endpoint_by_host(host) 445 host_endpoint = driver.obj.get_endpoint_by_host(host)
446 ip_endpoint = driver.obj.get_endpoint_by_ip(tunnel_ip) 446 ip_endpoint = driver.obj.get_endpoint_by_ip(tunnel_ip)
447 447
448 if (ip_endpoint and ip_endpoint.host is None 448 if (ip_endpoint and ip_endpoint.host is None and
449 and host_endpoint is None): 449 host_endpoint is None):
450 driver.obj.delete_endpoint(ip_endpoint.ip_address) 450 driver.obj.delete_endpoint(ip_endpoint.ip_address)
451 elif (ip_endpoint and ip_endpoint.host != host): 451 elif (ip_endpoint and ip_endpoint.host != host):
452 LOG.info( 452 LOG.info(
diff --git a/neutron/services/logapi/common/db_api.py b/neutron/services/logapi/common/db_api.py
index 4a855c9..e4f0bd5 100644
--- a/neutron/services/logapi/common/db_api.py
+++ b/neutron/services/logapi/common/db_api.py
@@ -172,9 +172,9 @@ def get_logs_bound_port(context, port_id):
172 project_id = port['project_id'] 172 project_id = port['project_id']
173 logs = log_object.Log.get_objects( 173 logs = log_object.Log.get_objects(
174 context, project_id=project_id, enabled=True) 174 context, project_id=project_id, enabled=True)
175 is_bound = lambda log: (log.resource_id in port.security_group_ids 175 is_bound = lambda log: (log.resource_id in port.security_group_ids or
176 or log.target_id == port.id 176 log.target_id == port.id or
177 or (not log.target_id and not log.resource_id)) 177 (not log.target_id and not log.resource_id))
178 return [log for log in logs if is_bound(log)] 178 return [log for log in logs if is_bound(log)]
179 179
180 180
diff --git a/neutron/services/segments/plugin.py b/neutron/services/segments/plugin.py
index 35e494e..a9f3416 100644
--- a/neutron/services/segments/plugin.py
+++ b/neutron/services/segments/plugin.py
@@ -72,8 +72,8 @@ class Plugin(db.SegmentDbMixin, segment.SegmentPluginBase):
72 72
73 # TODO(carl_baldwin) Make this work with service subnets when 73 # TODO(carl_baldwin) Make this work with service subnets when
74 # it's a thing. 74 # it's a thing.
75 is_adjacent = (not network_db.subnets 75 is_adjacent = (not network_db.subnets or
76 or not network_db.subnets[0].segment_id) 76 not network_db.subnets[0].segment_id)
77 network_res[l2adj_apidef.L2_ADJACENCY] = is_adjacent 77 network_res[l2adj_apidef.L2_ADJACENCY] = is_adjacent
78 78
79 @staticmethod 79 @staticmethod
diff --git a/neutron/services/timestamp/timestamp_db.py b/neutron/services/timestamp/timestamp_db.py
index d1dd417..b824a9c 100644
--- a/neutron/services/timestamp/timestamp_db.py
+++ b/neutron/services/timestamp/timestamp_db.py
@@ -47,8 +47,8 @@ def _change_since_result_filter_hook(query, filters):
47 query = query.join(standard_attr.StandardAttribute, 47 query = query.join(standard_attr.StandardAttribute,
48 target_model_class.standard_attr_id == 48 target_model_class.standard_attr_id ==
49 standard_attr.StandardAttribute.id).filter( 49 standard_attr.StandardAttribute.id).filter(
50 standard_attr.StandardAttribute.updated_at 50 standard_attr.StandardAttribute.updated_at >=
51 >= changed_since) 51 changed_since)
52 return query 52 return query
53 53
54 54
@@ -57,8 +57,8 @@ def _update_timestamp(session, context, instances):
57 57
58 while objs_list: 58 while objs_list:
59 obj = objs_list.pop() 59 obj = objs_list.pop()
60 if (isinstance(obj, standard_attr.HasStandardAttributes) 60 if (isinstance(obj, standard_attr.HasStandardAttributes) and
61 and obj.standard_attr_id): 61 obj.standard_attr_id):
62 obj.updated_at = timeutils.utcnow() 62 obj.updated_at = timeutils.utcnow()
63 63
64 64
diff --git a/neutron/tests/functional/db/test_migrations.py b/neutron/tests/functional/db/test_migrations.py
index 714000f..02314c7 100644
--- a/neutron/tests/functional/db/test_migrations.py
+++ b/neutron/tests/functional/db/test_migrations.py
@@ -153,8 +153,8 @@ class _TestModelsMigrations(test_migrations.ModelsMigrationsSync):
153 return head_models.get_metadata() 153 return head_models.get_metadata()
154 154
155 def include_object(self, object_, name, type_, reflected, compare_to): 155 def include_object(self, object_, name, type_, reflected, compare_to):
156 if type_ == 'table' and (name == 'alembic_version' 156 if type_ == 'table' and (name == 'alembic_version' or
157 or name in external.TABLES): 157 name in external.TABLES):
158 return False 158 return False
159 159
160 return super(_TestModelsMigrations, self).include_object( 160 return super(_TestModelsMigrations, self).include_object(
@@ -363,8 +363,9 @@ class TestModelsMigrationsMysql(testlib_api.MySQLTestCaseMixin,
363 self.assertGreater(len(tables), 0, 363 self.assertGreater(len(tables), 0,
364 "No tables found. Wrong schema?") 364 "No tables found. Wrong schema?")
365 res = [table for table in tables if 365 res = [table for table in tables if
366 insp.get_table_options(table)['mysql_engine'] != 'InnoDB' 366 insp.get_table_options(table)['mysql_engine'] !=
367 and table != 'alembic_version'] 367 'InnoDB' and
368 table != 'alembic_version']
368 self.assertEqual(0, len(res), "%s non InnoDB tables created" % res) 369 self.assertEqual(0, len(res), "%s non InnoDB tables created" % res)
369 370
370 371
diff --git a/neutron/tests/functional/test_server.py b/neutron/tests/functional/test_server.py
index 43110f7..8adc6ba 100644
--- a/neutron/tests/functional/test_server.py
+++ b/neutron/tests/functional/test_server.py
@@ -146,8 +146,8 @@ class TestNeutronServer(base.BaseTestCase):
146 # Wait for temp file to be created and its size reaching the expected 146 # Wait for temp file to be created and its size reaching the expected
147 # value 147 # value
148 expected_size = len(expected_msg) 148 expected_size = len(expected_msg)
149 condition = lambda: (os.path.isfile(self.temp_file) 149 condition = lambda: (os.path.isfile(self.temp_file) and
150 and os.stat(self.temp_file).st_size == 150 os.stat(self.temp_file).st_size ==
151 expected_size) 151 expected_size)
152 152
153 utils.wait_until_true( 153 utils.wait_until_true(
diff --git a/neutron/tests/unit/agent/l3/test_agent.py b/neutron/tests/unit/agent/l3/test_agent.py
index 4c8816f..d7f0a60 100644
--- a/neutron/tests/unit/agent/l3/test_agent.py
+++ b/neutron/tests/unit/agent/l3/test_agent.py
@@ -1864,8 +1864,8 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
1864 l3_test_common.router_append_subnet( 1864 l3_test_common.router_append_subnet(
1865 router, count=2, ip_version=6, 1865 router, count=2, ip_version=6,
1866 ipv6_subnet_modes=([{'ra_mode': lib_constants.IPV6_SLAAC, 1866 ipv6_subnet_modes=([{'ra_mode': lib_constants.IPV6_SLAAC,
1867 'address_mode': lib_constants.IPV6_SLAAC}] 1867 'address_mode': lib_constants.IPV6_SLAAC}] *
1868 * 2)) 1868 2))
1869 self._process_router_instance_for_agent(agent, ri, router) 1869 self._process_router_instance_for_agent(agent, ri, router)
1870 self._assert_ri_process_enabled(ri) 1870 self._assert_ri_process_enabled(ri)
1871 # Reset mocks to check for modified radvd config 1871 # Reset mocks to check for modified radvd config
diff --git a/neutron/tests/unit/agent/linux/test_dhcp.py b/neutron/tests/unit/agent/linux/test_dhcp.py
index cab5711..a0c5ad5 100644
--- a/neutron/tests/unit/agent/linux/test_dhcp.py
+++ b/neutron/tests/unit/agent/linux/test_dhcp.py
@@ -1219,8 +1219,8 @@ class TestDnsmasq(TestBase):
1219 prefix6 = '--dhcp-range=set:tag%d,%s,%s,%s%s' 1219 prefix6 = '--dhcp-range=set:tag%d,%s,%s,%s%s'
1220 possible_leases = 0 1220 possible_leases = 0
1221 for i, s in enumerate(network.subnets): 1221 for i, s in enumerate(network.subnets):
1222 if (s.ip_version != 6 1222 if (s.ip_version != 6 or
1223 or s.ipv6_address_mode == constants.DHCPV6_STATEFUL): 1223 s.ipv6_address_mode == constants.DHCPV6_STATEFUL):
1224 if s.ip_version == 4: 1224 if s.ip_version == 4:
1225 expected.extend([prefix % ( 1225 expected.extend([prefix % (
1226 i, s.cidr.split('/')[0], 1226 i, s.cidr.split('/')[0],
diff --git a/neutron/tests/unit/common/test_utils.py b/neutron/tests/unit/common/test_utils.py
index 97e7786..cba844d 100644
--- a/neutron/tests/unit/common/test_utils.py
+++ b/neutron/tests/unit/common/test_utils.py
@@ -50,9 +50,9 @@ class _PortRange(object):
50 50
51 @property 51 @property
52 def can_merge(self): 52 def can_merge(self):
53 return (self.prev_ref 53 return (self.prev_ref and
54 and self.possible_mask_base == self.prev_ref.possible_mask_base 54 self.possible_mask_base == self.prev_ref.possible_mask_base and
55 and self.mask == self.prev_ref.mask) 55 self.mask == self.prev_ref.mask)
56 56
57 def shake(self): 57 def shake(self):
58 """Try to merge ranges created earlier. 58 """Try to merge ranges created earlier.
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 f6240cb..434ea04 100644
--- a/neutron/tests/unit/db/test_db_base_plugin_v2.py
+++ b/neutron/tests/unit/db/test_db_base_plugin_v2.py
@@ -4318,9 +4318,9 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
4318 'fe80::/64', ip_version=6, 4318 'fe80::/64', ip_version=6,
4319 ipv6_ra_mode=addr_mode, 4319 ipv6_ra_mode=addr_mode,
4320 ipv6_address_mode=addr_mode) 4320 ipv6_address_mode=addr_mode)
4321 if (insert_db_reference_error or insert_address_allocated 4321 if (insert_db_reference_error or insert_address_allocated or
4322 or device_owner == constants.DEVICE_OWNER_ROUTER_SNAT 4322 device_owner == constants.DEVICE_OWNER_ROUTER_SNAT or
4323 or device_owner in constants.ROUTER_INTERFACE_OWNERS): 4323 device_owner in constants.ROUTER_INTERFACE_OWNERS):
4324 # DVR SNAT, router interfaces and DHCP ports should not have 4324 # DVR SNAT, router interfaces and DHCP ports should not have
4325 # been updated with addresses from the new auto-address subnet 4325 # been updated with addresses from the new auto-address subnet
4326 self.assertEqual(1, len(port['port']['fixed_ips'])) 4326 self.assertEqual(1, len(port['port']['fixed_ips']))
diff --git a/neutron/tests/unit/extensions/test_extra_dhcp_opt.py b/neutron/tests/unit/extensions/test_extra_dhcp_opt.py
index 60a28db..2a79691 100644
--- a/neutron/tests/unit/extensions/test_extra_dhcp_opt.py
+++ b/neutron/tests/unit/extensions/test_extra_dhcp_opt.py
@@ -63,9 +63,9 @@ class TestExtraDhcpOpt(ExtraDhcpOptDBTestCase):
63 for opt in returned: 63 for opt in returned:
64 name = opt['opt_name'] 64 name = opt['opt_name']
65 for exp in expected: 65 for exp in expected:
66 if (name == exp['opt_name'] 66 if (name == exp['opt_name'] and
67 and opt['ip_version'] == exp.get( 67 opt['ip_version'] == exp.get(
68 'ip_version', 4)): 68 'ip_version', 4)):
69 val = exp['opt_value'] 69 val = exp['opt_value']
70 break 70 break
71 self.assertEqual(val, opt['opt_value']) 71 self.assertEqual(val, opt['opt_value'])
diff --git a/neutron/tests/unit/extensions/test_l3.py b/neutron/tests/unit/extensions/test_l3.py
index 3cc7be2..032f2aa 100644
--- a/neutron/tests/unit/extensions/test_l3.py
+++ b/neutron/tests/unit/extensions/test_l3.py
@@ -350,8 +350,9 @@ class L3NatTestCaseMixin(object):
350 data['router']['name'] = name 350 data['router']['name'] = name
351 if admin_state_up is not None: 351 if admin_state_up is not None:
352 data['router']['admin_state_up'] = admin_state_up 352 data['router']['admin_state_up'] = admin_state_up
353 for arg in (('admin_state_up', 'tenant_id', 'availability_zone_hints') 353 for arg in (('admin_state_up', 'tenant_id',
354 + (arg_list or ())): 354 'availability_zone_hints') +
355 (arg_list or ())):
355 # Arg must be present and not empty 356 # Arg must be present and not empty
356 if arg in kwargs: 357 if arg in kwargs:
357 data['router'][arg] = kwargs[arg] 358 data['router'][arg] = kwargs[arg]
diff --git a/neutron/tests/unit/extensions/test_portsecurity.py b/neutron/tests/unit/extensions/test_portsecurity.py
index 3e49bae..b398292 100644
--- a/neutron/tests/unit/extensions/test_portsecurity.py
+++ b/neutron/tests/unit/extensions/test_portsecurity.py
@@ -136,8 +136,8 @@ class PortSecurityTestPlugin(db_base_plugin_v2.NeutronDbPluginV2,
136 has_ip = self._ip_on_port(ret_port) 136 has_ip = self._ip_on_port(ret_port)
137 # checks if security groups were updated adding/modifying 137 # checks if security groups were updated adding/modifying
138 # security groups, port security is set and port has ip 138 # security groups, port security is set and port has ip
139 if (has_security_groups and (not ret_port[psec.PORTSECURITY] 139 if (has_security_groups and (not ret_port[psec.PORTSECURITY] or
140 or not has_ip)): 140 not has_ip)):
141 raise psec_exc.PortSecurityAndIPRequiredForSecurityGroups() 141 raise psec_exc.PortSecurityAndIPRequiredForSecurityGroups()
142 142
143 # Port security/IP was updated off. Need to check that no security 143 # Port security/IP was updated off. Need to check that no security
diff --git a/neutron/tests/unit/extensions/test_securitygroup.py b/neutron/tests/unit/extensions/test_securitygroup.py
index 6a5265e..a8bd399 100644
--- a/neutron/tests/unit/extensions/test_securitygroup.py
+++ b/neutron/tests/unit/extensions/test_securitygroup.py
@@ -172,8 +172,8 @@ class SecurityGroupsTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
172 172
173 for r in res['security_group_rules']: 173 for r in res['security_group_rules']:
174 if (r['direction'] == 'egress' and not r['port_range_max'] and 174 if (r['direction'] == 'egress' and not r['port_range_max'] and
175 not r['port_range_min'] and not r['protocol'] 175 not r['port_range_min'] and not r['protocol'] and
176 and not r['remote_ip_prefix']): 176 not r['remote_ip_prefix']):
177 self._delete('security-group-rules', r['id']) 177 self._delete('security-group-rules', r['id'])
178 178
179 def _assert_sg_rule_has_kvs(self, security_group_rule, expected_kvs): 179 def _assert_sg_rule_has_kvs(self, security_group_rule, expected_kvs):
diff --git a/neutron/tests/unit/notifiers/test_nova.py b/neutron/tests/unit/notifiers/test_nova.py
index 4319f58..f07bc77 100644
--- a/neutron/tests/unit/notifiers/test_nova.py
+++ b/neutron/tests/unit/notifiers/test_nova.py
@@ -117,9 +117,9 @@ class TestNovaNotify(base.BaseTestCase):
117 117
118 elif (previous_port_status in [sql_attr.NO_VALUE, 118 elif (previous_port_status in [sql_attr.NO_VALUE,
119 n_const.PORT_STATUS_DOWN, 119 n_const.PORT_STATUS_DOWN,
120 n_const.PORT_STATUS_BUILD] 120 n_const.PORT_STATUS_BUILD] and
121 and current_port_status in [n_const.PORT_STATUS_ACTIVE, 121 current_port_status in [n_const.PORT_STATUS_ACTIVE,
122 n_const.PORT_STATUS_ERROR]): 122 n_const.PORT_STATUS_ERROR]):
123 event_name = nova.VIF_PLUGGED 123 event_name = nova.VIF_PLUGGED
124 124
125 else: 125 else:
diff --git a/neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py b/neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py
index 95b0cdd..71dfca6 100644
--- a/neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py
+++ b/neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py
@@ -170,11 +170,9 @@ class DNSIntegrationTestCase(test_plugin.Ml2PluginV2TestCase):
170 else: 170 else:
171 self.assertFalse(dns_data_db['current_dns_domain']) 171 self.assertFalse(dns_data_db['current_dns_domain'])
172 records_v4 = [ip['ip_address'] for ip in port['fixed_ips'] 172 records_v4 = [ip['ip_address'] for ip in port['fixed_ips']
173 if netaddr.IPAddress(ip['ip_address']).version 173 if netaddr.IPAddress(ip['ip_address']).version == 4]
174 == 4]
175 records_v6 = [ip['ip_address'] for ip in port['fixed_ips'] 174 records_v6 = [ip['ip_address'] for ip in port['fixed_ips']
176 if netaddr.IPAddress(ip['ip_address']).version 175 if netaddr.IPAddress(ip['ip_address']).version == 6]
177 == 6]
178 expected = [] 176 expected = []
179 expected_delete = [] 177 expected_delete = []
180 if records_v4: 178 if records_v4:
diff --git a/tox.ini b/tox.ini
index 84981f6..9e603bb 100644
--- a/tox.ini
+++ b/tox.ini
@@ -148,8 +148,7 @@ commands = sphinx-build -W -b linkcheck doc/source doc/build/linkcheck
148# TODO(amotoki) check the following new rules should be fixed or ignored 148# TODO(amotoki) check the following new rules should be fixed or ignored
149# E402 module level import not at top of file 149# E402 module level import not at top of file
150# E731 do not assign a lambda expression, use a def 150# E731 do not assign a lambda expression, use a def
151# W503 line break before binary operator 151ignore = E125,E126,E128,E129,E265,E402,E731,H404,H405,N530,N534,N536
152ignore = E125,E126,E128,E129,E265,E402,E731,W503,H404,H405,N530,N534,N536
153# H106: Don't put vim configuration in source files 152# H106: Don't put vim configuration in source files
154# H203: Use assertIs(Not)None to check for None 153# H203: Use assertIs(Not)None to check for None
155# H204: Use assert(Not)Equal to check for equality 154# H204: Use assert(Not)Equal to check for equality