Browse Source

Start enforcing E125 flake8 directive

Removed E125 (continuation line does not distinguish itself
from next logical line) from the ignore list and fixed all
the indentation issues.  Didn't think it was going to be
close to 100 files when I started.

Change-Id: I0a6f5efec4b7d8d3632dd9dbb43e0ab58af9dff3
changes/81/671881/1
Brian Haley 2 years ago
parent
commit
b79842f289
100 changed files with 385 additions and 424 deletions
  1. +1
    -1
      neutron/agent/l3/dvr_edge_router.py
  2. +5
    -5
      neutron/agent/l3/dvr_local_router.py
  3. +2
    -2
      neutron/agent/linux/utils.py
  4. +1
    -1
      neutron/api/rpc/agentnotifiers/metering_rpc_agent_api.py
  5. +1
    -1
      neutron/api/rpc/handlers/dhcp_rpc.py
  6. +3
    -3
      neutron/api/rpc/handlers/l3_rpc.py
  7. +2
    -2
      neutron/db/external_net_db.py
  8. +1
    -2
      neutron/db/l3_db.py
  9. +26
    -27
      neutron/db/l3_dvr_db.py
  10. +1
    -1
      neutron/db/metering/metering_rpc.py
  11. +10
    -12
      neutron/db/portsecurity_db_common.py
  12. +1
    -1
      neutron/db/provisioning_blocks.py
  13. +1
    -1
      neutron/db/quota/api.py
  14. +1
    -2
      neutron/db/quota/driver.py
  15. +3
    -2
      neutron/plugins/ml2/drivers/l2pop/mech_driver.py
  16. +4
    -5
      neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py
  17. +2
    -3
      neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
  18. +3
    -3
      neutron/plugins/ml2/drivers/type_vlan.py
  19. +1
    -1
      neutron/plugins/ml2/extensions/dns_integration.py
  20. +2
    -2
      neutron/plugins/ml2/plugin.py
  21. +1
    -2
      neutron/scheduler/dhcp_agent_scheduler.py
  22. +3
    -2
      neutron/services/auto_allocate/db.py
  23. +1
    -1
      neutron/services/l3_router/service_providers/driver_controller.py
  24. +2
    -2
      neutron/services/metering/drivers/iptables/iptables_driver.py
  25. +1
    -2
      neutron/services/segments/exceptions.py
  26. +1
    -1
      neutron/services/tag/tag_plugin.py
  27. +1
    -2
      neutron/services/trunk/drivers/openvswitch/agent/driver.py
  28. +2
    -2
      neutron/services/trunk/rules.py
  29. +2
    -2
      neutron/tests/common/agents/l2_extensions.py
  30. +4
    -4
      neutron/tests/functional/agent/l3/framework.py
  31. +32
    -31
      neutron/tests/functional/agent/l3/test_dvr_router.py
  32. +1
    -1
      neutron/tests/functional/scheduler/test_dhcp_agent_scheduler.py
  33. +10
    -10
      neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py
  34. +1
    -1
      neutron/tests/unit/agent/common/test_async_process.py
  35. +4
    -4
      neutron/tests/unit/agent/dhcp/test_agent.py
  36. +4
    -4
      neutron/tests/unit/agent/l2/extensions/test_qos.py
  37. +1
    -1
      neutron/tests/unit/agent/l3/extensions/test_port_forwarding.py
  38. +12
    -16
      neutron/tests/unit/agent/l3/test_agent.py
  39. +4
    -4
      neutron/tests/unit/agent/l3/test_dvr_fip_ns.py
  40. +1
    -1
      neutron/tests/unit/agent/l3/test_dvr_local_router.py
  41. +2
    -1
      neutron/tests/unit/agent/l3/test_router_info.py
  42. +2
    -1
      neutron/tests/unit/agent/linux/test_dhcp.py
  43. +4
    -4
      neutron/tests/unit/agent/linux/test_iptables_firewall.py
  44. +1
    -2
      neutron/tests/unit/agent/metadata/test_agent.py
  45. +2
    -2
      neutron/tests/unit/agent/test_rpc.py
  46. +3
    -4
      neutron/tests/unit/agent/test_securitygroups_rpc.py
  47. +3
    -2
      neutron/tests/unit/api/rpc/agentnotifiers/test_dhcp_rpc_agent_api.py
  48. +3
    -4
      neutron/tests/unit/api/rpc/callbacks/test_resource_manager.py
  49. +16
    -17
      neutron/tests/unit/db/test_db_base_plugin_v2.py
  50. +10
    -9
      neutron/tests/unit/db/test_l3_db.py
  51. +8
    -9
      neutron/tests/unit/db/test_l3_dvr_db.py
  52. +5
    -5
      neutron/tests/unit/db/test_migration.py
  53. +14
    -15
      neutron/tests/unit/db/test_securitygroups_db.py
  54. +1
    -1
      neutron/tests/unit/extensions/test_data_plane_status.py
  55. +9
    -11
      neutron/tests/unit/extensions/test_dns.py
  56. +2
    -2
      neutron/tests/unit/extensions/test_extraroute.py
  57. +21
    -21
      neutron/tests/unit/extensions/test_l3.py
  58. +3
    -3
      neutron/tests/unit/extensions/test_l3_ext_gw_mode.py
  59. +2
    -3
      neutron/tests/unit/extensions/test_portsecurity.py
  60. +7
    -10
      neutron/tests/unit/extensions/test_subnet_onboard.py
  61. +4
    -8
      neutron/tests/unit/extensions/test_subnetpool_prefix_ops.py
  62. +3
    -3
      neutron/tests/unit/ipam/drivers/neutrondb_ipam/test_driver.py
  63. +2
    -3
      neutron/tests/unit/notifiers/test_nova.py
  64. +2
    -3
      neutron/tests/unit/objects/port/extensions/test_uplink_status_propagation.py
  65. +2
    -3
      neutron/tests/unit/objects/qos/test_policy.py
  66. +1
    -1
      neutron/tests/unit/objects/test_auto_allocate.py
  67. +3
    -4
      neutron/tests/unit/objects/test_base.py
  68. +2
    -2
      neutron/tests/unit/objects/test_flavor.py
  69. +1
    -1
      neutron/tests/unit/objects/test_ipam.py
  70. +2
    -2
      neutron/tests/unit/objects/test_l3_hamode.py
  71. +4
    -4
      neutron/tests/unit/objects/test_network.py
  72. +1
    -1
      neutron/tests/unit/objects/test_provisioning_blocks.py
  73. +2
    -4
      neutron/tests/unit/objects/test_quota.py
  74. +1
    -2
      neutron/tests/unit/objects/test_router.py
  75. +2
    -3
      neutron/tests/unit/objects/test_servicetype.py
  76. +2
    -2
      neutron/tests/unit/objects/test_subnet.py
  77. +2
    -1
      neutron/tests/unit/plugins/ml2/drivers/agent/test__common_agent.py
  78. +5
    -5
      neutron/tests/unit/plugins/ml2/drivers/l2pop/rpc_manager/test_l2population_rpc.py
  79. +8
    -8
      neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/extension_drivers/test_qos_driver.py
  80. +8
    -9
      neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py
  81. +8
    -8
      neutron/tests/unit/plugins/ml2/drivers/macvtap/agent/test_macvtap_neutron_agent.py
  82. +3
    -4
      neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/test_eswitch_manager.py
  83. +3
    -3
      neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py
  84. +4
    -4
      neutron/tests/unit/plugins/ml2/drivers/openvswitch/mech_driver/test_mech_openvswitch.py
  85. +1
    -1
      neutron/tests/unit/plugins/ml2/extensions/test_dns_integration.py
  86. +3
    -3
      neutron/tests/unit/plugins/ml2/test_agent_scheduler.py
  87. +6
    -8
      neutron/tests/unit/plugins/ml2/test_plugin.py
  88. +1
    -1
      neutron/tests/unit/plugins/ml2/test_rpc.py
  89. +2
    -3
      neutron/tests/unit/plugins/ml2/test_security_group.py
  90. +3
    -5
      neutron/tests/unit/scheduler/test_dhcp_agent_scheduler.py
  91. +1
    -1
      neutron/tests/unit/scheduler/test_l3_agent_scheduler.py
  92. +4
    -4
      neutron/tests/unit/services/l3_router/service_providers/test_driver_controller.py
  93. +2
    -2
      neutron/tests/unit/services/logapi/base.py
  94. +2
    -2
      neutron/tests/unit/services/portforwarding/test_pf_plugin.py
  95. +2
    -2
      neutron/tests/unit/services/qos/base.py
  96. +1
    -1
      neutron/tests/unit/services/trunk/drivers/openvswitch/agent/test_ovsdb_handler.py
  97. +1
    -1
      neutron/tests/unit/services/trunk/test_plugin.py
  98. +1
    -1
      neutron/tests/unit/test_wsgi.py
  99. +2
    -3
      neutron/tests/unit/tests/common/test_net_helpers.py
  100. +1
    -2
      tox.ini

+ 1
- 1
neutron/agent/l3/dvr_edge_router.py View File

@ -355,7 +355,7 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
fixed = fip['fixed_ip_address']
fip_ip = fip['floating_ip_address']
for chain, rule in self._centralized_floating_forward_rules(
fip_ip, fixed):
fip_ip, fixed):
self.snat_iptables_manager.ipv4['nat'].add_rule(
chain, rule, tag='floating_ip')


+ 5
- 5
neutron/agent/l3/dvr_local_router.py View File

@ -622,7 +622,7 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase):
def process_external(self):
if self.agent_conf.agent_mode != (
lib_constants.L3_AGENT_MODE_DVR_NO_EXTERNAL):
lib_constants.L3_AGENT_MODE_DVR_NO_EXTERNAL):
ex_gw_port = self.get_ex_gw_port()
if ex_gw_port:
self.create_dvr_external_gateway_on_agent(ex_gw_port)
@ -756,8 +756,8 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase):
operation, route, fip_ns_name, tbl_index)
super(DvrLocalRouter, self).update_routing_table(operation, route)
def _update_fip_route_table_with_next_hop_routes(
self, operation, route, fip_ns_name, tbl_index):
def _update_fip_route_table_with_next_hop_routes(self, operation, route,
fip_ns_name, tbl_index):
cmd = ['ip', 'route', operation, 'to', route['destination'],
'via', route['nexthop'], 'table', tbl_index]
ip_wrapper = ip_lib.IPWrapper(namespace=fip_ns_name)
@ -768,8 +768,8 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase):
"router %(id)s",
{'ns': fip_ns_name, 'id': self.router_id})
def _check_if_route_applicable_to_fip_namespace(
self, route, agent_gateway_port):
def _check_if_route_applicable_to_fip_namespace(self, route,
agent_gateway_port):
ip_cidrs = common_utils.fixed_ip_cidrs(agent_gateway_port['fixed_ips'])
nexthop_cidr = netaddr.IPAddress(route['nexthop'])
for gw_cidr in ip_cidrs:


+ 2
- 2
neutron/agent/linux/utils.py View File

@ -56,8 +56,8 @@ class RootwrapDaemonHelper(object):
def get_client(cls):
with cls.__lock:
if cls.__client is None:
if xenapi_root_helper.ROOT_HELPER_DAEMON_TOKEN == \
cfg.CONF.AGENT.root_helper_daemon:
if (xenapi_root_helper.ROOT_HELPER_DAEMON_TOKEN ==
cfg.CONF.AGENT.root_helper_daemon):
cls.__client = xenapi_root_helper.XenAPIClient()
else:
cls.__client = client.Client(


+ 1
- 1
neutron/api/rpc/agentnotifiers/metering_rpc_agent_api.py View File

@ -82,7 +82,7 @@ class MeteringAgentNotifyAPI(object):
"""Notify all the agents that are hosting the routers."""
plugin = directory.get_plugin(plugin_constants.L3)
if extensions.is_extension_supported(
plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
self._agent_notification(context, method, routers)
else:
cctxt = self.client.prepare(fanout=True)


+ 1
- 1
neutron/api/rpc/handlers/dhcp_rpc.py View File

@ -80,7 +80,7 @@ class DhcpRpcCallback(object):
host = kwargs.get('host')
plugin = directory.get_plugin()
if extensions.is_extension_supported(
plugin, constants.DHCP_AGENT_SCHEDULER_EXT_ALIAS):
plugin, constants.DHCP_AGENT_SCHEDULER_EXT_ALIAS):
if cfg.CONF.network_auto_schedule:
plugin.auto_schedule_networks(context, host)
nets = plugin.list_active_networks_on_active_dhcp_agent(


+ 3
- 3
neutron/api/rpc/handlers/l3_rpc.py View File

@ -74,7 +74,7 @@ class L3RpcCallback(object):
calling update_device_up.
"""
if not extensions.is_extension_supported(
self.plugin, constants.PORT_BINDING_EXT_ALIAS):
self.plugin, constants.PORT_BINDING_EXT_ALIAS):
return
device_filter = {
'device_owner': [constants.DEVICE_OWNER_ROUTER_HA_INTF],
@ -117,7 +117,7 @@ class L3RpcCallback(object):
context = neutron_context.get_admin_context()
routers = self._routers_to_sync(context, router_ids, host)
if extensions.is_extension_supported(
self.plugin, constants.PORT_BINDING_EXT_ALIAS):
self.plugin, constants.PORT_BINDING_EXT_ALIAS):
self._ensure_host_set_on_ports(context, host, routers)
# refresh the data structure after ports are bound
routers = self._routers_to_sync(context, router_ids, host)
@ -128,7 +128,7 @@ class L3RpcCallback(object):
def _routers_to_sync(self, context, router_ids, host=None):
if extensions.is_extension_supported(
self.l3plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
self.l3plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
routers = (
self.l3plugin.list_active_sync_routers_on_active_l3_agent(
context, host, router_ids))


+ 2
- 2
neutron/db/external_net_db.py View File

@ -128,8 +128,8 @@ class External_net_db_mixin(object):
# (and thus, possible floating IPs) on this network before
# allow it to be update to external=False
if context.session.query(models_v2.Port.id).filter_by(
device_owner=constants.DEVICE_OWNER_ROUTER_GW,
network_id=net_data['id']).first():
device_owner=constants.DEVICE_OWNER_ROUTER_GW,
network_id=net_data['id']).first():
raise extnet_exc.ExternalNetworkInUse(net_id=net_id)
net_obj.ExternalNetwork.delete_objects(


+ 1
- 2
neutron/db/l3_db.py View File

@ -2091,8 +2091,7 @@ class L3_NAT_db_mixin(L3_NAT_dbonly_mixin, L3RpcNotifierMixin):
super(L3_NAT_db_mixin, self).notify_routers_updated(
context, list(router_ids), 'disassociate_floatingips', {})
def _migrate_router_ports(
self, context, router_db, old_owner, new_owner):
def _migrate_router_ports(self, context, router_db, old_owner, new_owner):
"""Update the model to support the dvr case of a router."""
for rp in router_db.attached_ports:
if rp.port_type == old_owner:


+ 26
- 27
neutron/db/l3_dvr_db.py View File

@ -186,8 +186,8 @@ class DVRResourceOperationHandler(object):
not old_router.get(l3_apidef.EXTERNAL_GW_INFO))
if not do_create:
return
if not self._create_snat_intf_ports_if_not_exists(
context.elevated(), router_db):
if not self._create_snat_intf_ports_if_not_exists(context.elevated(),
router_db):
LOG.debug("SNAT interface ports not created: %s",
router_db['id'])
return router_db
@ -220,8 +220,9 @@ class DVRResourceOperationHandler(object):
msg = _("Unable to create the SNAT Interface Port")
raise n_exc.BadRequest(resource='router', msg=msg)
with plugin_utils.delete_port_on_error(
self.l3plugin._core_plugin, context.elevated(), snat_port['id']):
with plugin_utils.delete_port_on_error(self.l3plugin._core_plugin,
context.elevated(),
snat_port['id']):
l3_obj.RouterPort(
context,
port_id=snat_port['id'],
@ -313,8 +314,8 @@ class DVRResourceOperationHandler(object):
self.l3plugin.l3_rpc_notifier.delete_fipnamespace_for_ext_net(
context, network_id)
def delete_floatingip_agent_gateway_port(
self, context, host_id, ext_net_id):
def delete_floatingip_agent_gateway_port(self, context, host_id,
ext_net_id):
"""Function to delete FIP gateway port with given ext_net_id."""
# delete any fip agent gw port
device_filter = {'device_owner': [const.DEVICE_OWNER_AGENT_GW],
@ -327,8 +328,8 @@ class DVRResourceOperationHandler(object):
if host_id:
return
def _get_ports_for_allowed_address_pair_ip(
self, context, network_id, fixed_ip):
def _get_ports_for_allowed_address_pair_ip(self, context, network_id,
fixed_ip):
"""Return all active ports associated with the allowed_addr_pair ip."""
query = context.session.query(
models_v2.Port).filter(
@ -391,8 +392,7 @@ class DVRResourceOperationHandler(object):
self._inherit_service_port_and_arp_update(
context, addr_pair_active_service_port_list[0])
def _inherit_service_port_and_arp_update(
self, context, service_port):
def _inherit_service_port_and_arp_update(self, context, service_port):
"""Function inherits port host bindings for allowed_address_pair."""
service_port_dict = self.l3plugin._core_plugin._make_port_dict(
service_port)
@ -473,8 +473,8 @@ class DVRResourceOperationHandler(object):
port['id'])
LOG.debug("CSNAT port updated for IPv6 subnet: %s", updated_port)
def _find_v6_router_port_by_network_and_device_owner(
self, router, net_id, device_owner):
def _find_v6_router_port_by_network_and_device_owner(self, router, net_id,
device_owner):
for port in router.attached_ports:
p = port['port']
if (p['network_id'] == net_id and
@ -482,8 +482,8 @@ class DVRResourceOperationHandler(object):
self.l3plugin._port_has_ipv6_address(p)):
return self.l3plugin._core_plugin._make_port_dict(p)
def _check_for_multiprefix_csnat_port_and_update(
self, context, router, network_id, subnet_id):
def _check_for_multiprefix_csnat_port_and_update(self, context, router,
network_id, subnet_id):
"""Checks if the csnat port contains multiple ipv6 prefixes.
If the csnat port contains multiple ipv6 prefixes for the given
@ -764,7 +764,7 @@ class _DVRAgentInterfaceMixin(object):
if router:
if router['distributed']:
if self._skip_floating_ip_for_mismatched_agent_or_host(
floating_ip, agent, host):
floating_ip, agent, host):
continue
router_floatingips = router.get(const.FLOATINGIP_KEY, [])
router_floatingips.append(floating_ip)
@ -889,8 +889,8 @@ class _DVRAgentInterfaceMixin(object):
self._get_dvr_migrating_service_port_hostid(
context, fip['port_id'], port=vm_port))
vm_port_agent_mode = vm_port.get('agent', None)
if vm_port_agent_mode != (
const.L3_AGENT_MODE_DVR_NO_EXTERNAL):
if (vm_port_agent_mode !=
const.L3_AGENT_MODE_DVR_NO_EXTERNAL):
# For floatingip configured on ports that do not
# reside on a 'dvr_no_external' agent, add the
# fip host binding, else it will be created
@ -926,8 +926,8 @@ class _DVRAgentInterfaceMixin(object):
port_db = port or self._core_plugin.get_port(context, port_id)
return port_db[portbindings.HOST_ID] or None
def _get_dvr_migrating_service_port_hostid(
self, context, port_id, port=None):
def _get_dvr_migrating_service_port_hostid(self, context, port_id,
port=None):
"""Returns the migrating host_id from the migrating profile."""
port_db = port or self._core_plugin.get_port(context, port_id)
port_profile = port_db.get(portbindings.PROFILE)
@ -963,8 +963,8 @@ class _DVRAgentInterfaceMixin(object):
self.create_fip_agent_gw_port_if_not_exists(
context.elevated(), network_id, host)
def create_fip_agent_gw_port_if_not_exists(
self, context, network_id, host):
def create_fip_agent_gw_port_if_not_exists(self, context, network_id,
host):
"""Function to return the FIP Agent GW port.
This function will create a FIP Agent GW port
@ -1010,8 +1010,8 @@ class _DVRAgentInterfaceMixin(object):
self._populate_mtu_and_subnets_for_ports(context, [agent_port])
return agent_port
def _generate_arp_table_and_notify_agent(
self, context, fixed_ip, mac_address, notifier):
def _generate_arp_table_and_notify_agent(self, context, fixed_ip,
mac_address, notifier):
"""Generates the arp table entry and notifies the l3 agent."""
ip_address = fixed_ip['ip_address']
subnet = fixed_ip['subnet_id']
@ -1025,8 +1025,7 @@ class _DVRAgentInterfaceMixin(object):
for router_id in routers:
notifier(context, router_id, arp_table)
def _get_subnet_id_for_given_fixed_ip(
self, context, fixed_ip, port_dict):
def _get_subnet_id_for_given_fixed_ip(self, context, fixed_ip, port_dict):
"""Returns the subnet_id that matches the fixedip on a network."""
filters = {'network_id': [port_dict['network_id']]}
subnets = self._core_plugin.get_subnets(context, filters)
@ -1072,8 +1071,8 @@ class _DVRAgentInterfaceMixin(object):
context, fixed_ip, port_dict['mac_address'],
self.l3_rpc_notifier.add_arp_entry)
def delete_arp_entry_for_dvr_service_port(
self, context, port_dict, fixed_ips_to_delete=None):
def delete_arp_entry_for_dvr_service_port(self, context, port_dict,
fixed_ips_to_delete=None):
"""Notify L3 agents of ARP table entry for dvr service port.
When a dvr service port goes down, look for the DVR


+ 1
- 1
neutron/db/metering/metering_rpc.py View File

@ -38,7 +38,7 @@ class MeteringRpcCallbacks(object):
metering_data = self.meter_plugin.get_sync_data_metering(context)
host = kwargs.get('host')
if not extensions.is_extension_supported(
l3_plugin, consts.L3_AGENT_SCHEDULER_EXT_ALIAS) or not host:
l3_plugin, consts.L3_AGENT_SCHEDULER_EXT_ALIAS) or not host:
return metering_data
else:
agents = l3_plugin.get_l3_agents(context, filters={'host': [host]})


+ 10
- 12
neutron/db/portsecurity_db_common.py View File

@ -30,8 +30,8 @@ class PortSecurityDbCommon(object):
response_data[psec.PORTSECURITY] = (
db_data['port_security'][psec.PORTSECURITY])
def _process_port_security_create(
self, context, obj_cls, res_name, req, res):
def _process_port_security_create(self, context, obj_cls, res_name, req,
res):
obj = obj_cls(
context,
id=res['id'],
@ -41,14 +41,13 @@ class PortSecurityDbCommon(object):
res[psec.PORTSECURITY] = req[psec.PORTSECURITY]
return self._make_port_security_dict(obj, res_name)
def _process_port_port_security_create(
self, context, port_req, port_res):
def _process_port_port_security_create(self, context, port_req, port_res):
self._process_port_security_create(
context, p_ps.PortSecurity, 'port',
port_req, port_res)
def _process_network_port_security_create(
self, context, network_req, network_res):
def _process_network_port_security_create(self, context, network_req,
network_res):
self._process_port_security_create(
context, network.NetworkPortSecurity, 'network',
network_req, network_res)
@ -66,19 +65,18 @@ class PortSecurityDbCommon(object):
def _get_port_security_binding(self, context, port_id):
return self._get_security_binding(context, p_ps.PortSecurity, port_id)
def _process_port_port_security_update(
self, context, port_req, port_res):
def _process_port_port_security_update(self, context, port_req, port_res):
self._process_port_security_update(
context, p_ps.PortSecurity, 'port', port_req, port_res)
def _process_network_port_security_update(
self, context, network_req, network_res):
def _process_network_port_security_update(self, context, network_req,
network_res):
self._process_port_security_update(
context, network.NetworkPortSecurity, 'network',
network_req, network_res)
def _process_port_security_update(
self, context, obj_cls, res_name, req, res):
def _process_port_security_update(self, context, obj_cls, res_name, req,
res):
if psec.PORTSECURITY not in req:
return
port_security_enabled = req[psec.PORTSECURITY]


+ 1
- 1
neutron/db/provisioning_blocks.py View File

@ -97,7 +97,7 @@ def remove_provisioning_component(context, object_id, object_type, entity,
if not standard_attr_id:
return False
if pb_obj.ProvisioningBlock.delete_objects(
context, standard_attr_id=standard_attr_id, entity=entity):
context, standard_attr_id=standard_attr_id, entity=entity):
return True
else:
return False


+ 1
- 1
neutron/db/quota/api.py View File

@ -26,7 +26,7 @@ def utcnow():
class QuotaUsageInfo(collections.namedtuple(
'QuotaUsageInfo', ['resource', 'tenant_id', 'used', 'dirty'])):
'QuotaUsageInfo', ['resource', 'tenant_id', 'used', 'dirty'])):
"""Information about resource quota usage."""


+ 1
- 2
neutron/db/quota/driver.py View File

@ -118,8 +118,7 @@ class DbQuotaDriver(object):
Raise a "not found" error if the quota for the given tenant was
never defined.
"""
if quota_obj.Quota.delete_objects(
context, project_id=tenant_id) < 1:
if quota_obj.Quota.delete_objects(context, project_id=tenant_id) < 1:
# No record deleted means the quota was not found
raise exceptions.TenantQuotaNotFound(tenant_id=tenant_id)


+ 3
- 2
neutron/plugins/ml2/drivers/l2pop/mech_driver.py View File

@ -254,8 +254,9 @@ class L2populationMechanismDriver(api.MechanismDriver):
agent_host = context.host
l3plugin = directory.get_plugin(plugin_constants.L3)
# when agent transitions to backup, don't remove flood flows
if agent_host and l3plugin and getattr(
l3plugin, "list_router_ids_on_host", None):
if agent_host and l3plugin and getattr(l3plugin,
"list_router_ids_on_host",
None):
admin_context = n_context.get_admin_context()
port_context = context._plugin_context
fdb_entries = self._get_agent_fdb(


+ 4
- 5
neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py View File

@ -557,7 +557,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
if not device_owner.startswith(constants.DEVICE_OWNER_COMPUTE_PREFIX):
# Check if device needs to be added to bridge
if not bridge_lib.BridgeDevice.get_interface_bridge(
tap_device_name):
tap_device_name):
data = {'tap_device_name': tap_device_name,
'bridge_name': bridge_name}
LOG.debug("Adding device %(tap_device_name)s to bridge "
@ -874,10 +874,9 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
return lconst.EXTENSION_DRIVER_TYPE
class LinuxBridgeRpcCallbacks(
sg_rpc.SecurityGroupAgentRpcCallbackMixin,
l2pop_rpc.L2populationRpcCallBackMixin,
amb.CommonAgentManagerRpcCallBackBase):
class LinuxBridgeRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
l2pop_rpc.L2populationRpcCallBackMixin,
amb.CommonAgentManagerRpcCallBackBase):
# Set RPC API version to 1.0 by default.
# history


+ 2
- 3
neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py View File

@ -1133,7 +1133,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
bridge.set_allowed_macs_for_port(port=vif.ofport, allow_all=True)
return
if port_details['device_owner'].startswith(
n_const.DEVICE_OWNER_NETWORK_PREFIX):
n_const.DEVICE_OWNER_NETWORK_PREFIX):
LOG.debug("Skipping ARP spoofing rules for network owned port "
"'%s'.", vif.port_name)
bridge.delete_arp_spoofing_protection(port=vif.ofport)
@ -2300,8 +2300,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
# REVISIT (rossella_s) Define a method "reset" in
# BasePollingManager that will be implemented by AlwaysPoll as
# no action and by InterfacePollingMinimizer as start/stop
if isinstance(
polling_manager, polling.InterfacePollingMinimizer):
if isinstance(polling_manager, polling.InterfacePollingMinimizer):
polling_manager.stop()
polling_manager.start()


+ 3
- 3
neutron/plugins/ml2/drivers/type_vlan.py View File

@ -147,9 +147,9 @@ class VlanTypeDriver(helpers.SegmentTypeDriver):
# allocated, update_objects will return 0 so we
# don't delete.
if vlanalloc.VlanAllocation.update_objects(
ctx, values={'allocated': False},
allocated=False, vlan_id=alloc.vlan_id,
physical_network=physical_network):
ctx, values={'allocated': False},
allocated=False, vlan_id=alloc.vlan_id,
physical_network=physical_network):
alloc.delete()
del allocations[physical_network]


+ 1
- 1
neutron/plugins/ml2/extensions/dns_integration.py View File

@ -491,7 +491,7 @@ def _update_port_in_external_dns_service(resource, event, trigger, **kwargs):
dns_data_db = port_obj.PortDNS.get_object(
context, port_id=updated_port['id'])
if not (dns_data_db and (dns_data_db['previous_dns_name'] or dns_data_db[
'current_dns_name'])):
'current_dns_name'])):
return
if dns_data_db['previous_dns_name']:
_remove_data_from_external_dns_service(


+ 2
- 2
neutron/plugins/ml2/plugin.py View File

@ -1933,8 +1933,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
self._post_delete_port(
context, port, router_ids, bound_mech_contexts)
def _post_delete_port(
self, context, port, router_ids, bound_mech_contexts):
def _post_delete_port(self, context, port, router_ids,
bound_mech_contexts):
kwargs = {
'context': context,
'port': port,


+ 1
- 2
neutron/scheduler/dhcp_agent_scheduler.py View File

@ -68,8 +68,7 @@ class AutoScheduler(object):
segments_on_host = {s.segment_id for s in segment_host_mapping}
for dhcp_agent in dhcp_agents:
if agent_utils.is_agent_down(
dhcp_agent.heartbeat_timestamp):
if agent_utils.is_agent_down(dhcp_agent.heartbeat_timestamp):
LOG.warning('DHCP agent %s is not active', dhcp_agent.id)
continue
for net_id, is_routed_network in net_ids.items():


+ 3
- 2
neutron/services/auto_allocate/db.py View File

@ -307,8 +307,9 @@ class AutoAllocatedTopologyMixin(object):
network_id = network['id'] if network else None
raise exceptions.UnknownProvisioningError(e, network_id=network_id)
def _provision_external_connectivity(
self, context, default_external_network, subnets, tenant_id):
def _provision_external_connectivity(self, context,
default_external_network, subnets,
tenant_id):
"""Uplink tenant subnet(s) to external network."""
router_args = {
'name': 'auto_allocated_router',


+ 1
- 1
neutron/services/l3_router/service_providers/driver_controller.py View File

@ -243,7 +243,7 @@ class DriverController(object):
class _LegacyPlusProviderConfiguration(
provider_configuration.ProviderConfiguration):
provider_configuration.ProviderConfiguration):
def __init__(self):
# loads up ha, dvr, and single_node service providers automatically.


+ 2
- 2
neutron/services/metering/drivers/iptables/iptables_driver.py View File

@ -346,8 +346,8 @@ class IptablesMeteringDriver(abstract_driver.MeteringAbstractDriver):
rm.iptables_manager.ipv4['filter'].add_rule(
label_chain, '', wrap=False)
def _process_metering_rule_action_based_on_ns(
self, router, action, ext_dev, im):
def _process_metering_rule_action_based_on_ns(self, router, action,
ext_dev, im):
'''Process metering rule actions based specific namespaces.'''
rm = self.routers.get(router['id'])
with IptablesManagerTransaction(im):


+ 1
- 2
neutron/services/segments/exceptions.py View File

@ -23,8 +23,7 @@ class SegmentNotFound(exceptions.NotFound):
message = _("Segment %(segment_id)s could not be found.")
class NoUpdateSubnetWhenMultipleSegmentsOnNetwork(
exceptions.BadRequest):
class NoUpdateSubnetWhenMultipleSegmentsOnNetwork(exceptions.BadRequest):
message = _("The network '%(network_id)s' has multiple segments, it is "
"only possible to associate an existing subnet with a segment "
"on networks with a single segment.")


+ 1
- 1
neutron/services/tag/tag_plugin.py View File

@ -116,5 +116,5 @@ class TagPlugin(tagging.TagPluginBase):
def delete_tag(self, context, resource, resource_id, tag):
res = self._get_resource(context, resource, resource_id)
if not tag_obj.Tag.delete_objects(
context, tag=tag, standard_attr_id=res.standard_attr_id):
context, tag=tag, standard_attr_id=res.standard_attr_id):
raise tagging.TagNotFound(tag=tag)

+ 1
- 2
neutron/services/trunk/drivers/openvswitch/agent/driver.py View File

@ -75,8 +75,7 @@ class OVSTrunkSkeleton(agent.TrunkSkeleton):
{'event': event_type, 'subports': subports, 'err': e})
@local_registry.receives(resources.TRUNK, [local_events.BEFORE_CREATE])
def check_trunk_dependencies(
self, resource, event, trigger, **kwargs):
def check_trunk_dependencies(self, resource, event, trigger, **kwargs):
# The OVS trunk driver does not work with iptables firewall and QoS.
# We should validate the environment configuration and signal that
# something might be wrong.


+ 2
- 2
neutron/services/trunk/rules.py View File

@ -256,8 +256,8 @@ class SubPortsValidator(object):
if subport['port_id'] == self.trunk_port_id:
raise trunk_exc.ParentPortInUse(port_id=subport['port_id'])
def _raise_subport_invalid_mtu(
self, context, subport, trunk_port_mtu, subport_mtus):
def _raise_subport_invalid_mtu(self, context, subport, trunk_port_mtu,
subport_mtus):
# Check MTU sanity - subport MTU must not exceed trunk MTU.
# If for whatever reason trunk_port_mtu is not available,
# the MTU sanity check cannot be enforced.


+ 2
- 2
neutron/tests/common/agents/l2_extensions.py View File

@ -88,8 +88,8 @@ def wait_until_dscp_marking_rule_applied_ovs(bridge, port_vif, rule):
common_utils.wait_until_true(_dscp_marking_rule_applied)
def wait_until_dscp_marking_rule_applied_linuxbridge(
namespace, port_vif, expected_rule):
def wait_until_dscp_marking_rule_applied_linuxbridge(namespace, port_vif,
expected_rule):
iptables = iptables_manager.IptablesManager(
namespace=namespace)


+ 4
- 4
neutron/tests/functional/agent/l3/framework.py View File

@ -680,8 +680,8 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
self._assert_ip_address_on_interface(namespace, interface,
ip_address)
def _assert_ip_address_not_on_interface(
self, namespace, interface, ip_address):
def _assert_ip_address_not_on_interface(self,
namespace, interface, ip_address):
self.assertNotIn(
ip_address, self._get_addresses_on_device(namespace, interface))
@ -690,8 +690,8 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
self.assertIn(
ip_address, self._get_addresses_on_device(namespace, interface))
def _assert_ping_reply_from_expected_address(
self, ping_result, expected_address):
def _assert_ping_reply_from_expected_address(self, ping_result,
expected_address):
ping_results = ping_result.split('\n')
self.assertGreater(
len(ping_results), 1,


+ 32
- 31
neutron/tests/functional/agent/l3/test_dvr_router.py View File

@ -128,7 +128,7 @@ class TestDvrRouter(framework.L3AgentTestFramework):
self.assertEqual(2, interface_rules_list_count)
def test_dvr_update_gateway_port_no_fip_fg_port_recovers_itself_with_fpr(
self):
self):
self.agent.conf.agent_mode = 'dvr'
# Create the router with external net
router_info = self.generate_dvr_router_info()
@ -232,8 +232,8 @@ class TestDvrRouter(framework.L3AgentTestFramework):
self._assert_fip_namespace_deleted(external_gw_port)
@mock.patch.object(dvr_fip_ns.FipNamespace, 'subscribe')
def test_dvr_process_fips_with_no_gw_port_in_namespace(
self, fip_subscribe):
def test_dvr_process_fips_with_no_gw_port_in_namespace(self,
fip_subscribe):
self.agent.conf.agent_mode = 'dvr'
# Create the router with external net
@ -584,8 +584,7 @@ class TestDvrRouter(framework.L3AgentTestFramework):
self.agent._register_router_cls(self.agent.router_factory)
return router
def _get_fip_agent_gw_port_for_router(
self, external_gw_port):
def _get_fip_agent_gw_port_for_router(self, external_gw_port):
# Add fip agent gateway port information to the router_info
if external_gw_port:
# Get values from external gateway port
@ -915,16 +914,16 @@ class TestDvrRouter(framework.L3AgentTestFramework):
self.assertFalse(self._fixed_ip_rule_exists(router_ns, fixed_ip))
self.assertTrue(self._fixed_ip_rule_exists(router_ns, new_fixed_ip))
def _assert_iptables_rules_exist(
self, router_iptables_manager, table_name, expected_rules):
def _assert_iptables_rules_exist(self, router_iptables_manager,
table_name, expected_rules):
rules = router_iptables_manager.get_rules_for_table(table_name)
for rule in expected_rules:
self.assertIn(
str(iptables_manager.IptablesRule(rule[0], rule[1])), rules)
return True
def _assert_iptables_rules_not_exist(
self, router_iptables_manager, table_name, expected_rules):
def _assert_iptables_rules_not_exist(self, router_iptables_manager,
table_name, expected_rules):
rules = router_iptables_manager.get_rules_for_table(table_name)
for rule in expected_rules:
self.assertNotIn(
@ -1092,8 +1091,8 @@ class TestDvrRouter(framework.L3AgentTestFramework):
router.router_id)
self.assertTrue(self._namespace_exists(namespace))
def _get_dvr_snat_namespace_device_status(
self, router, internal_dev_name=None):
def _get_dvr_snat_namespace_device_status(self, router,
internal_dev_name=None):
"""Function returns the internal and external device status."""
snat_ns = dvr_snat_ns.SnatNamespace.get_snat_ns_name(
router.router_id)
@ -1451,7 +1450,7 @@ class TestDvrRouter(framework.L3AgentTestFramework):
@mock.patch.object(
dvr_ha_router.DvrEdgeHaRouter, 'get_centralized_fip_cidr_set')
def test_dvr_ha_router_with_centralized_fip_calls_keepalived_cidr(
self, connect_rtr_2_fip_mock, fip_cidr_centralized_mock):
self, connect_rtr_2_fip_mock, fip_cidr_centralized_mock):
self._setup_dvr_ha_agents()
self._setup_dvr_ha_bridges()
@ -1470,7 +1469,7 @@ class TestDvrRouter(framework.L3AgentTestFramework):
@mock.patch.object(
dvr_edge_router.DvrEdgeRouter, 'get_centralized_fip_cidr_set')
def test_dvr_router_with_centralized_fip_calls_keepalived_cidr(
self, connect_rtr_2_fip_mock, fip_cidr_centralized_mock):
self, connect_rtr_2_fip_mock, fip_cidr_centralized_mock):
router_info = self.generate_dvr_router_info(
enable_gw=True, enable_centralized_fip=True, snat_bound_fip=True)
@ -1626,9 +1625,9 @@ class TestDvrRouter(framework.L3AgentTestFramework):
self.failover_agent._process_updated_router(router2.router)
self.assertFalse(r2_chsfr.called)
def _setup_dvr_router_static_routes(
self, router_namespace=True,
check_fpr_int_rule_delete=False, enable_ha=False):
def _setup_dvr_router_static_routes(self, router_namespace=True,
check_fpr_int_rule_delete=False,
enable_ha=False):
"""Test to validate the extra routes on dvr routers."""
self.agent.conf.agent_mode = 'dvr_snat'
router_info = self.generate_dvr_router_info(
@ -1739,20 +1738,20 @@ class TestDvrRouter(framework.L3AgentTestFramework):
self._setup_dvr_router_static_routes(router_namespace=False)
def test_dvr_router_static_routes_in_snat_namespace_and_router_namespace(
self):
self):
self._setup_dvr_router_static_routes()
def test_dvr_ha_rtr_static_routes_in_rtr_namespace(self):
self._setup_dvr_router_static_routes(enable_ha=True)
def test_dvr_router_rule_and_route_table_cleared_when_fip_removed(
self):
def test_dvr_router_rule_and_route_table_cleared_when_fip_removed(self):
self._setup_dvr_router_static_routes(
router_namespace=False, check_fpr_int_rule_delete=True)
def _assert_fip_namespace_interface_static_routes(
self, address_scopes, fpr_device,
router_info, rtr_2_fip, fpr_device_name):
def _assert_fip_namespace_interface_static_routes(self, address_scopes,
fpr_device, router_info,
rtr_2_fip,
fpr_device_name):
fixed_ips_1 = router_info[lib_constants.INTERFACE_KEY][0]['fixed_ips']
fixed_ips_2 = router_info[lib_constants.INTERFACE_KEY][1]['fixed_ips']
actual_routes = fpr_device.route.list_routes(
@ -1790,9 +1789,11 @@ class TestDvrRouter(framework.L3AgentTestFramework):
else:
self.assertEqual([], actual_routes)
def _assert_interface_rules_on_gateway_remove(
self, router, agent, address_scopes, agent_gw_port,
rfp_device, fpr_device, no_external=False):
def _assert_interface_rules_on_gateway_remove(self, router, agent,
address_scopes,
agent_gw_port, rfp_device,
fpr_device,
no_external=False):
router.router[lib_constants.SNAT_ROUTER_INTF_KEY] = []
router.router['gw_port'] = ""
@ -1889,11 +1890,11 @@ class TestDvrRouter(framework.L3AgentTestFramework):
rfp_device, fpr_device)
def test_dvr_fip_and_router_namespace_rules_with_address_scopes_match(
self):
self):
self._setup_dvr_router_for_fast_path_exit(address_scopes=True)
def test_dvr_fip_and_router_namespace_rules_with_address_scopes_mismatch(
self):
self):
self._setup_dvr_router_for_fast_path_exit(address_scopes=False)
@mock.patch.object(dvr_local_router.DvrLocalRouter,
@ -1901,8 +1902,8 @@ class TestDvrRouter(framework.L3AgentTestFramework):
@mock.patch.object(dvr_local_router.DvrLocalRouter,
'_add_interface_route_to_fip_ns')
def test_dvr_no_external_router_namespace_rules_with_address_scopes_match(
self, mock_add_interface_route_rule,
mock_add_fip_interface_route_rule):
self, mock_add_interface_route_rule,
mock_add_fip_interface_route_rule):
"""Test to validate the router namespace routes.
This test validates the router namespace routes
@ -1978,8 +1979,8 @@ class TestDvrRouter(framework.L3AgentTestFramework):
self.assertIsNone(ex_gw_device.route.get_gateway())
self.assertIsNone(fg_device.route.get_gateway())
def _assert_fip_namespace_deleted(
self, ext_gateway_port, assert_ovs_interface=True):
def _assert_fip_namespace_deleted(self, ext_gateway_port,
assert_ovs_interface=True):
ext_net_id = ext_gateway_port['network_id']
fip_ns = self.agent.get_fip_ns(ext_net_id)
fip_ns.unsubscribe = mock.Mock()


+ 1
- 1
neutron/tests/functional/scheduler/test_dhcp_agent_scheduler.py View File

@ -570,7 +570,7 @@ class TestAZAwareWeightScheduler(test_dhcp_sch.TestDhcpSchedulerBaseTestCase,
class TestDHCPSchedulerWithNetworkAccessibility(
test_plugin.Ml2PluginV2TestCase):
test_plugin.Ml2PluginV2TestCase):
_mechanism_drivers = ['openvswitch']


+ 10
- 10
neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py View File

@ -328,7 +328,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
test_agent_mode=None)
def _test_create_floating_ip_agent_notification(
self, dvr=True, test_agent_mode=constants.L3_AGENT_MODE_DVR):
self, dvr=True, test_agent_mode=constants.L3_AGENT_MODE_DVR):
with self.subnet() as ext_subnet,\
self.subnet(cidr='20.0.0.0/24') as int_subnet,\
self.port(subnet=int_subnet,
@ -369,8 +369,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
self.l3_plugin.create_floatingip(
self.context, {'floatingip': floating_ip})
if dvr:
if test_agent_mode == (
constants.L3_AGENT_MODE_DVR_NO_EXTERNAL):
if (test_agent_mode ==
constants.L3_AGENT_MODE_DVR_NO_EXTERNAL):
if router['ha']:
expected_calls = [
mock.call(self.context,
@ -400,7 +400,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
self._test_create_floating_ip_agent_notification()
def test_create_floating_ip_agent_notification_for_dvr_no_external_agent(
self):
self):
agent_mode = constants.L3_AGENT_MODE_DVR_NO_EXTERNAL
self._test_create_floating_ip_agent_notification(
test_agent_mode=agent_mode)
@ -409,7 +409,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
self._test_create_floating_ip_agent_notification(dvr=False)
def _test_update_floating_ip_agent_notification(
self, dvr=True, test_agent_mode=constants.L3_AGENT_MODE_DVR):
self, dvr=True, test_agent_mode=constants.L3_AGENT_MODE_DVR):
with self.subnet() as ext_subnet,\
self.subnet(cidr='20.0.0.0/24') as int_subnet1,\
self.subnet(cidr='30.0.0.0/24') as int_subnet2,\
@ -465,8 +465,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
self.context, floating_ip['id'],
{'floatingip': updated_floating_ip})
if dvr:
if test_agent_mode == (
constants.L3_AGENT_MODE_DVR_NO_EXTERNAL):
if (test_agent_mode ==
constants.L3_AGENT_MODE_DVR_NO_EXTERNAL):
if router1['ha'] and router2['ha']:
self.assertEqual(
4,
@ -518,7 +518,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
self._test_update_floating_ip_agent_notification()
def test_update_floating_ip_agent_notification_with_dvr_no_external_agents(
self):
self):
agent_mode = constants.L3_AGENT_MODE_DVR_NO_EXTERNAL
self._test_update_floating_ip_agent_notification(
test_agent_mode=agent_mode)
@ -531,7 +531,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
test_agent_mode=None)
def _test_delete_floating_ip_agent_notification(
self, dvr=True, test_agent_mode=constants.L3_AGENT_MODE_DVR):
self, dvr=True, test_agent_mode=constants.L3_AGENT_MODE_DVR):
with self.subnet() as ext_subnet,\
self.subnet(cidr='20.0.0.0/24') as int_subnet,\
self.port(subnet=int_subnet,
@ -611,7 +611,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
self._test_delete_floating_ip_agent_notification()
def test_delete_floating_ip_agent_notification_with_dvr_no_external_agents(
self):
self):
agent_mode = constants.L3_AGENT_MODE_DVR_NO_EXTERNAL
self._test_delete_floating_ip_agent_notification(
test_agent_mode=agent_mode)


+ 1
- 1
neutron/tests/unit/agent/common/test_async_process.py View File

@ -282,7 +282,7 @@ class TestAsyncProcessLogging(base.BaseTestCase):
def _test__read_stdout_logging(self, enable):
proc = async_process.AsyncProcess(['fakecmd'], log_output=enable)
with mock.patch.object(proc, '_read', return_value='fakedata'),\
mock.patch.object(proc, '_process'):
mock.patch.object(proc, '_process'):
proc._read_stdout()
self.assertEqual(enable, self.log_mock.debug.called)


+ 4
- 4
neutron/tests/unit/agent/dhcp/test_agent.py View File

@ -262,7 +262,7 @@ class TestDhcpAgent(base.BaseTestCase):
# message.
with mock.patch.object(dhcp_agent.LOG, 'exception') as log:
with testtools.ExpectedException(
exceptions.InvalidConfigurationOption):
exceptions.InvalidConfigurationOption):
dhcp_agent.DhcpAgent(HOSTNAME)
log.assert_any_call("DHCP agent must have resync_throttle <= "
"resync_interval")
@ -534,7 +534,7 @@ class TestDhcpAgent(base.BaseTestCase):
dhcp = dhcp_agent.DhcpAgentWithStateReport(HOSTNAME)
with mock.patch.object(dhcp.state_rpc,
'report_state') as report_state,\
mock.patch.object(dhcp, "run"):
mock.patch.object(dhcp, "run"):
report_state.return_value = agent_consts.AGENT_ALIVE
dhcp._report_state()
self.assertEqual({}, dhcp.needs_resync_reasons)
@ -793,8 +793,8 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
self.plugin.get_network_info.return_value = fake_network_ipv6_ipv4
self.call_driver.return_value = False
cfg.CONF.set_override('enable_isolated_metadata', True)
with mock.patch.object(
self.dhcp, 'enable_isolated_metadata_proxy') as enable_metadata:
with mock.patch.object(self.dhcp,
'enable_isolated_metadata_proxy') as enable_metadata:
self.dhcp.enable_dhcp_helper(fake_network_ipv6_ipv4.id)
self.plugin.assert_has_calls(
[mock.call.get_network_info(fake_network_ipv6_ipv4.id)])


+ 4
- 4
neutron/tests/unit/agent/l2/extensions/test_qos.py View File

@ -370,8 +370,8 @@ class QosExtensionRpcTestCase(QosExtensionBaseTestCase):
self.assertIsNone(self.qos_ext.policy_map.get_port_policy(port))
def test__handle_notification_ignores_all_event_types_except_updated(self):
with mock.patch.object(
self.qos_ext, '_process_update_policy') as update_mock:
with mock.patch.object(self.qos_ext,
'_process_update_policy') as update_mock:
for event_type in set(events.VALID) - {events.UPDATED}:
self.qos_ext._handle_notification(mock.Mock(), 'QOS',
@ -379,8 +379,8 @@ class QosExtensionRpcTestCase(QosExtensionBaseTestCase):
self.assertFalse(update_mock.called)
def test__handle_notification_passes_update_events(self):
with mock.patch.object(
self.qos_ext, '_process_update_policy') as update_mock:
with mock.patch.object(self.qos_ext,
'_process_update_policy') as update_mock:
policy_obj = mock.Mock()
self.qos_ext._handle_notification(mock.Mock(), 'QOS',


+ 1
- 1
neutron/tests/unit/agent/l3/extensions/test_port_forwarding.py View File

@ -41,7 +41,7 @@ HOSTNAME = 'testhost'
class PortForwardingExtensionBaseTestCase(
test_agent.BasicRouterOperationsFramework):
test_agent.BasicRouterOperationsFramework):
def setUp(self):
super(PortForwardingExtensionBaseTestCase, self).setUp()


+ 12
- 16
neutron/tests/unit/agent/l3/test_agent.py View File

@ -958,8 +958,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
self.assertIsNotNone(ri.snat_namespace)
self.assertEqual(ri.snat_namespace.name, ri.get_gw_ns_name())
def test_ext_gw_updated_calling_snat_ns_delete_if_gw_port_host_none(
self):
def test_ext_gw_updated_calling_snat_ns_delete_if_gw_port_host_none(self):
"""Test to check the impact of snat_namespace object.
This function specifically checks the impact of the snat
@ -982,7 +981,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
@mock.patch.object(namespaces.Namespace, 'delete')
def test_snat_ns_delete_not_called_when_snat_namespace_does_not_exist(
self, mock_ns_del):
self, mock_ns_del):
"""Test to check the impact of snat_namespace object.
This function specifically checks the impact of the snat
@ -1409,8 +1408,8 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
self.assertEqual(1, ri.fip_ns.create_rtr_2_fip_link.call_count)
@mock.patch.object(lla.LinkLocalAllocator, '_write')
def test_floating_ip_not_configured_if_no_host_or_dest_host(
self, lla_write):
def test_floating_ip_not_configured_if_no_host_or_dest_host(self,
lla_write):
fake_network_id = _uuid()
subnet_id = _uuid()
fake_floatingips = {'floatingips': [
@ -2269,9 +2268,8 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
def test_process_router_floatingip_disabled(self):
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
with mock.patch.object(
agent.plugin_rpc,
'update_floatingip_statuses') as mock_update_fip_status:
with mock.patch.object(agent.plugin_rpc,
'update_floatingip_statuses') as mock_update_fip_status:
fip_id = _uuid()
router = l3_test_common.prepare_router_data(num_internal_ports=1)
router[lib_constants.FLOATINGIP_KEY] = [
@ -2302,9 +2300,8 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
def test_process_router_floatingip_exception(self):
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
with mock.patch.object(
agent.plugin_rpc,
'update_floatingip_statuses') as mock_update_fip_status:
with mock.patch.object(agent.plugin_rpc,
'update_floatingip_statuses') as mock_update_fip_status:
fip_id = _uuid()
router = l3_test_common.prepare_router_data(num_internal_ports=1)
router[lib_constants.FLOATINGIP_KEY] = [
@ -2327,9 +2324,8 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
def test_process_external_iptables_exception(self):
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
with mock.patch.object(
agent.plugin_rpc,
'update_floatingip_statuses') as mock_update_fip_status:
with mock.patch.object(agent.plugin_rpc,
'update_floatingip_statuses') as mock_update_fip_status:
fip_id = _uuid()
router = l3_test_common.prepare_router_data(num_internal_ports=1)
router[lib_constants.FLOATINGIP_KEY] = [
@ -2628,9 +2624,9 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
'distributed': False}
driver = metadata_driver.MetadataDriver
with mock.patch.object(
driver, 'destroy_monitored_metadata_proxy') as destroy_proxy:
driver, 'destroy_monitored_metadata_proxy') as destroy_proxy:
with mock.patch.object(
driver, 'spawn_monitored_metadata_proxy') as spawn_proxy:
driver, 'spawn_monitored_metadata_proxy') as spawn_proxy:
agent._process_added_router(router)
if enableflag:
spawn_proxy.assert_called_with(


+ 4
- 4
neutron/tests/unit/agent/l3/test_dvr_fip_ns.py View File

@ -119,8 +119,8 @@ class TestDvrFipNs(base.BaseTestCase):
@mock.patch.object(ip_lib, 'send_ip_addr_adv_notif')
@mock.patch.object(dvr_fip_ns.FipNamespace, 'subscribe')
@mock.patch.object(dvr_fip_ns.FipNamespace, '_add_default_gateway_for_fip')
def test_update_gateway_port(
self, def_gw, fip_sub, send_adv_notif, IPDevice):
def test_update_gateway_port(self, def_gw, fip_sub, send_adv_notif,
IPDevice):
fip_sub.return_value = False
self.fip_ns._check_for_gateway_ip_change = mock.Mock(return_value=True)
agent_gw_port = self._get_agent_gw_port()
@ -142,8 +142,8 @@ class TestDvrFipNs(base.BaseTestCase):
@mock.patch.object(dvr_fip_ns.FipNamespace, 'subscribe')
@mock.patch.object(dvr_fip_ns.FipNamespace, 'delete')
@mock.patch.object(dvr_fip_ns.FipNamespace, 'unsubscribe')
def test_update_gateway_port_raises_exception(
self, fip_unsub, fip_delete, fip_sub, exists):
def test_update_gateway_port_raises_exception(self, fip_unsub, fip_delete,
fip_sub, exists):
agent_gw_port = self._get_agent_gw_port()
self.fip_ns._create_gateway_port = mock.Mock()
self.fip_ns.create_or_update_gateway_port(agent_gw_port)


+ 1
- 1
neutron/tests/unit/agent/l3/test_dvr_local_router.py View File

@ -187,7 +187,7 @@ class TestDvrRouterOperations(base.BaseTestCase):
self._setup_create_dvr_fip_interfaces_for_setting_routing_rules()
def _setup_create_dvr_fip_interfaces_for_setting_routing_rules(
self, address_scopes_match=False):
self, address_scopes_match=False):
ri = self._create_router()
ri.get_floating_agent_gw_interface = mock.Mock()
ri.fip_ns = mock.Mock()


+ 2
- 1
neutron/tests/unit/agent/l3/test_router_info.py View File

@ -196,7 +196,8 @@ class TestRouterInfo(base.BaseTestCase):
ri = router_info.RouterInfo(mock.Mock(), _uuid(), {}, **self.ri_kwargs)
ri.router = {'id': _uuid()}
with mock.patch.object(ri, '_process_internal_ports') as p_i_p,\
mock.patch.object(ri, '_process_external_on_delete') as p_e_o_d:
mock.patch.object(ri,
'_process_external_on_delete') as p_e_o_d:
self.mock_ip.netns.exists.return_value = False
ri.process_delete()
self.assertFalse(p_i_p.called)


+ 2
- 1
neutron/tests/unit/agent/linux/test_dhcp.py View File

@ -2739,7 +2739,8 @@ class TestDnsmasq(TestBase):
self.conf, FakeDualNetworkDualDHCP()))
def _test__generate_opts_per_subnet_helper(
self, config_opts, expected_mdt_ip, network_class=FakeNetworkDhcpPort):
self, config_opts, expected_mdt_ip,
network_class=FakeNetworkDhcpPort):
for key, value in config_opts.items():
self.conf.set_override(key, value)
dm = self._get_dnsmasq(network_class())


+ 4
- 4
neutron/tests/unit/agent/linux/test_iptables_firewall.py View File

@ -1447,7 +1447,7 @@ class IptablesFirewallTestCase(BaseIptablesFirewallTestCase):
ct_zone=10)
def test_remove_conntrack_entries_for_port_sec_group_change_no_ct_zone(
self):
self):
self._test_remove_conntrack_entries_for_port_sec_group_change(
ct_zone=None)
@ -1497,7 +1497,7 @@ class IptablesFirewallTestCase(BaseIptablesFirewallTestCase):
'IPv4', direction, ct_zone=10)
def test_remove_conntrack_entries_for_sg_member_changed_ipv4_no_ct_zone(
self):
self):
for direction in ['ingress', 'egress']:
self._test_remove_conntrack_entries_sg_member_changed(
'IPv4', direction, ct_zone=None)
@ -1508,7 +1508,7 @@ class IptablesFirewallTestCase(BaseIptablesFirewallTestCase):
'IPv6', direction, ct_zone=10)
def test_remove_conntrack_entries_for_sg_member_changed_ipv6_no_ct_zone(
self):
self):
for direction in ['ingress', 'egress']:
self._test_remove_conntrack_entries_sg_member_changed(
'IPv6', direction, ct_zone=None)
@ -2375,7 +2375,7 @@ class OVSHybridIptablesFirewallTestCase(BaseIptablesFirewallTestCase):
# fill it up and then make sure an extra throws an error
for i in range(ip_conntrack.ZONE_START,
ip_conntrack.MAX_CONNTRACK_ZONES):
ip_conntrack.MAX_CONNTRACK_ZONES):
self.firewall.ipconntrack._device_zone_map['dev-%s' % i] = i
with testtools.ExpectedException(exceptions.CTZoneExhaustedError):
self.firewall.ipconntrack._find_open_zone()


+ 1
- 2
neutron/tests/unit/agent/metadata/test_agent.py View File

@ -149,8 +149,7 @@ class _TestMetadataProxyHandlerCacheMixin(object):
router_id = 'router-id'
ports = [{'network_id': 'network_id1', 'something': 42}]
expected_networks = ('network_id1',)
with mock.patch(
'oslo_utils.timeutils.utcnow_ts', return_value=0):
with mock.patch('oslo_utils.timeutils.utcnow_ts', return_value=0):
mock_get_ports = self.handler.plugin_rpc.get_ports
mock_get_ports.return_value = ports
networks = self.handler._get_router_networks(router_id)


+ 2
- 2
neutron/tests/unit/agent/test_rpc.py View File

@ -134,8 +134,8 @@ class AgentPluginReportState(base.BaseTestCase):
class AgentRPCMethods(base.BaseTestCase):
def _test_create_consumers(
self, endpoints, method, expected, topics, listen):
def _test_create_consumers(self, endpoints, method, expected, topics,
listen):
with mock.patch.object(n_rpc, 'Connection') as create_connection:
rpc.create_consumers(
endpoints, method, topics, start_listening=listen)


+ 3
- 4
neutron/tests/unit/agent/test_securitygroups_rpc.py View File

@ -966,8 +966,7 @@ class SecurityGroupAgentRpcTestCase(BaseSecurityGroupAgentRpcTestCase):
self.assertFalse(self.agent.firewall.defer_apply.called)
class SecurityGroupAgentEnhancedRpcTestCase(
<