Fix pep8 E128 warnings in non-test code

Reduces E128 warnings by ~260 to just ~900,
no way we're getting rid of all of them at once (or ever).
Files under neutron/tests still have a ton of E128 warnings.

Change-Id: I9137150ccf129bf443e33428267cd4bc9c323b54
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
This commit is contained in:
Brian Haley 2019-02-21 16:20:45 -05:00 committed by Brian Haley
parent 773489af62
commit eaf990b2bc
104 changed files with 422 additions and 354 deletions

View File

@ -468,7 +468,7 @@ class OVSBridge(BaseOVS):
if "cookie" in kwargs: if "cookie" in kwargs:
kwargs["cookie"] = check_cookie_mask(str(kwargs["cookie"])) kwargs["cookie"] = check_cookie_mask(str(kwargs["cookie"]))
flow_str = ",".join("=".join([key, str(val)]) flow_str = ",".join("=".join([key, str(val)])
for key, val in kwargs.items()) for key, val in kwargs.items())
flows = self.run_ofctl("dump-flows", [flow_str]) flows = self.run_ofctl("dump-flows", [flow_str])
if flows: if flows:

View File

@ -32,8 +32,8 @@ class L2AgentExtensionsManager(agent_ext_manager.AgentExtensionsManager):
""" """
def __init__(self, conf): def __init__(self, conf):
super(L2AgentExtensionsManager, self).__init__(conf, super(L2AgentExtensionsManager,
L2_AGENT_EXT_MANAGER_NAMESPACE) self).__init__(conf, L2_AGENT_EXT_MANAGER_NAMESPACE)
def handle_port(self, context, data): def handle_port(self, context, data):
"""Notify all agent extensions to handle port.""" """Notify all agent extensions to handle port."""

View File

@ -82,9 +82,9 @@ class DvrEdgeRouter(dvr_local_router.DvrLocalRouter):
else: else:
preserve_ips = self._list_centralized_floating_ip_cidrs() preserve_ips = self._list_centralized_floating_ip_cidrs()
self._external_gateway_added(ex_gw_port, self._external_gateway_added(ex_gw_port,
interface_name, interface_name,
self.snat_namespace.name, self.snat_namespace.name,
preserve_ips) preserve_ips)
def _external_gateway_removed(self, ex_gw_port, interface_name): def _external_gateway_removed(self, ex_gw_port, interface_name):
super(DvrEdgeRouter, self).external_gateway_removed(ex_gw_port, super(DvrEdgeRouter, self).external_gateway_removed(ex_gw_port,

View File

@ -330,7 +330,7 @@ class FipNamespace(namespaces.Namespace):
is_ipv6=False) is_ipv6=False)
def _update_gateway_route(self, agent_gateway_port, def _update_gateway_route(self, agent_gateway_port,
interface_name, tbl_index): interface_name, tbl_index):
ns_name = self.get_name() ns_name = self.get_name()
ipd = ip_lib.IPDevice(interface_name, namespace=ns_name) ipd = ip_lib.IPDevice(interface_name, namespace=ns_name)
# If the 'fg-' device doesn't exist in the namespace then trying # If the 'fg-' device doesn't exist in the namespace then trying

View File

@ -321,8 +321,7 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase):
def _delete_gateway_device_if_exists(self, ns_ip_device, gw_ip_addr, def _delete_gateway_device_if_exists(self, ns_ip_device, gw_ip_addr,
snat_idx): snat_idx):
try: try:
ns_ip_device.route.delete_gateway(gw_ip_addr, ns_ip_device.route.delete_gateway(gw_ip_addr, table=snat_idx)
table=snat_idx)
except exceptions.DeviceNotFoundError: except exceptions.DeviceNotFoundError:
pass pass

View File

@ -32,8 +32,8 @@ class L3AgentExtensionsManager(agent_ext_manager.AgentExtensionsManager):
"""Manage l3 agent extensions.""" """Manage l3 agent extensions."""
def __init__(self, conf): def __init__(self, conf):
super(L3AgentExtensionsManager, self).__init__(conf, super(L3AgentExtensionsManager,
L3_AGENT_EXT_MANAGER_NAMESPACE) self).__init__(conf, L3_AGENT_EXT_MANAGER_NAMESPACE)
def add_router(self, context, data): def add_router(self, context, data):
"""Notify all agent extensions to add router.""" """Notify all agent extensions to add router."""

View File

@ -374,7 +374,7 @@ class RouterInfo(object):
'new': fip['fixed_ip_address']}) 'new': fip['fixed_ip_address']})
fip_statuses[fip['id']] = self.move_floating_ip(fip) fip_statuses[fip['id']] = self.move_floating_ip(fip)
elif (ip_cidr in centralized_fip_cidrs and elif (ip_cidr in centralized_fip_cidrs and
fip.get('host') == self.host): fip.get('host') == self.host):
LOG.debug("Floating IP is migrating from centralized " LOG.debug("Floating IP is migrating from centralized "
"to distributed: %s", fip) "to distributed: %s", fip)
# TODO(dougwig) - remove this disable when fixing bug #1816874 # TODO(dougwig) - remove this disable when fixing bug #1816874
@ -586,8 +586,9 @@ class RouterInfo(object):
if ipv6_utils.is_ipv6_pd_enabled(subnet): if ipv6_utils.is_ipv6_pd_enabled(subnet):
interface_name = self.get_internal_device_name(p['id']) interface_name = self.get_internal_device_name(p['id'])
self.agent.pd.enable_subnet(self.router_id, subnet['id'], self.agent.pd.enable_subnet(self.router_id, subnet['id'],
subnet['cidr'], subnet['cidr'],
interface_name, p['mac_address']) interface_name,
p['mac_address'])
if (subnet['cidr'] != if (subnet['cidr'] !=
lib_constants.PROVISIONAL_IPV6_PD_PREFIX): lib_constants.PROVISIONAL_IPV6_PD_PREFIX):
self.pd_subnets[subnet['id']] = subnet['cidr'] self.pd_subnets[subnet['id']] = subnet['cidr']

View File

@ -718,8 +718,8 @@ class Dnsmasq(DhcpLocalProcess):
ip_address, 'set:', port.id)) ip_address, 'set:', port.id))
elif client_id and len(port.extra_dhcp_opts) == 1: elif client_id and len(port.extra_dhcp_opts) == 1:
buf.write('%s,%s%s,%s,%s\n' % buf.write('%s,%s%s,%s,%s\n' %
(port.mac_address, self._ID, client_id, name, (port.mac_address, self._ID, client_id, name,
ip_address)) ip_address))
else: else:
buf.write('%s,%s,%s,%s%s\n' % buf.write('%s,%s,%s,%s%s\n' %
(port.mac_address, name, ip_address, (port.mac_address, name, ip_address,

View File

@ -185,8 +185,8 @@ class IpConntrackManager(object):
r'.* -j CT --zone (?P<zone>\d+).*', rule) r'.* -j CT --zone (?P<zone>\d+).*', rule)
if match: if match:
# strip off any prefix that the interface is using # strip off any prefix that the interface is using
short_port_id = (match.group('dev') short_port_id = (
[n_const.LINUX_DEV_PREFIX_LEN:]) match.group('dev')[n_const.LINUX_DEV_PREFIX_LEN:])
self._device_zone_map[short_port_id] = int(match.group('zone')) self._device_zone_map[short_port_id] = int(match.group('zone'))
LOG.debug("Populated conntrack zone map: %s", self._device_zone_map) LOG.debug("Populated conntrack zone map: %s", self._device_zone_map)

View File

@ -119,7 +119,7 @@ class IpsetManager(object):
new_set_name = set_name + SWAP_SUFFIX new_set_name = set_name + SWAP_SUFFIX
set_type = self._get_ipset_set_type(ethertype) set_type = self._get_ipset_set_type(ethertype)
process_input = ["create %s hash:net family %s" % (new_set_name, process_input = ["create %s hash:net family %s" % (new_set_name,
set_type)] set_type)]
for ip in member_ips: for ip in member_ips:
process_input.append("add %s %s" % (new_set_name, ip)) process_input.append("add %s %s" % (new_set_name, ip))

View File

@ -72,7 +72,8 @@ class IptablesFirewallDriver(firewall.FirewallDriver):
CONNTRACK_ZONE_PER_PORT = False CONNTRACK_ZONE_PER_PORT = False
def __init__(self, namespace=None): def __init__(self, namespace=None):
self.iptables = iptables_manager.IptablesManager(state_less=True, self.iptables = iptables_manager.IptablesManager(
state_less=True,
use_ipv6=ipv6_utils.is_enabled_and_bind_by_default(), use_ipv6=ipv6_utils.is_enabled_and_bind_by_default(),
namespace=namespace) namespace=namespace)
# TODO(majopela, shihanzhang): refactor out ipset to a separate # TODO(majopela, shihanzhang): refactor out ipset to a separate
@ -722,8 +723,9 @@ class IptablesFirewallDriver(firewall.FirewallDriver):
if (is_port and rule_protocol in constants.IPTABLES_PROTOCOL_MAP): if (is_port and rule_protocol in constants.IPTABLES_PROTOCOL_MAP):
# iptables adds '-m protocol' when the port number is specified # iptables adds '-m protocol' when the port number is specified
iptables_rule += ['-m', iptables_rule += [
constants.IPTABLES_PROTOCOL_MAP[rule_protocol]] '-m', constants.IPTABLES_PROTOCOL_MAP[rule_protocol]
]
return iptables_rule return iptables_rule
def _port_arg(self, direction, protocol, port_range_min, port_range_max): def _port_arg(self, direction, protocol, port_range_min, port_range_max):

View File

@ -815,7 +815,7 @@ def _get_rules_by_chain(rules):
def _generate_chain_diff_iptables_commands(chain, old_chain_rules, def _generate_chain_diff_iptables_commands(chain, old_chain_rules,
new_chain_rules): new_chain_rules):
# keep track of the old index because we have to insert rules # keep track of the old index because we have to insert rules
# in the right position # in the right position
old_index = 1 old_index = 1

View File

@ -326,7 +326,8 @@ class ConjIPFlowManager(object):
# no address overlaps. # no address overlaps.
addr_to_conj = self._build_addr_conj_id_map( addr_to_conj = self._build_addr_conj_id_map(
ethertype, sg_conj_id_map) ethertype, sg_conj_id_map)
self._update_flows_for_vlan_subr(direction, ethertype, vlan_tag, self._update_flows_for_vlan_subr(
direction, ethertype, vlan_tag,
self.flow_state[vlan_tag][(direction, ethertype)], self.flow_state[vlan_tag][(direction, ethertype)],
addr_to_conj) addr_to_conj)
self.flow_state[vlan_tag][(direction, ethertype)] = addr_to_conj self.flow_state[vlan_tag][(direction, ethertype)] = addr_to_conj

View File

@ -98,20 +98,28 @@ class DaemonMonitor(object):
for p in router_ports: for p in router_ports:
subnets = p.get('subnets', []) subnets = p.get('subnets', [])
v6_subnets = [subnet for subnet in subnets if v6_subnets = [subnet for subnet in subnets if
netaddr.IPNetwork(subnet['cidr']).version == 6] netaddr.IPNetwork(subnet['cidr']).version == 6]
if not v6_subnets: if not v6_subnets:
continue continue
ra_modes = {subnet['ipv6_ra_mode'] for subnet in v6_subnets} ra_modes = {subnet['ipv6_ra_mode'] for subnet in v6_subnets}
auto_config_prefixes = [subnet['cidr'] for subnet in v6_subnets if auto_config_prefixes = [
subnet['ipv6_ra_mode'] == constants.IPV6_SLAAC or subnet['cidr'] for subnet in v6_subnets
subnet['ipv6_ra_mode'] == constants.DHCPV6_STATELESS] if (subnet['ipv6_ra_mode'] == constants.IPV6_SLAAC or
stateful_config_prefixes = [subnet['cidr'] for subnet in v6_subnets subnet['ipv6_ra_mode'] == constants.DHCPV6_STATELESS)
if subnet['ipv6_ra_mode'] == constants.DHCPV6_STATEFUL] ]
stateful_config_prefixes = [
subnet['cidr'] for subnet in v6_subnets
if subnet['ipv6_ra_mode'] == constants.DHCPV6_STATEFUL
]
interface_name = self._dev_name_helper(p['id']) interface_name = self._dev_name_helper(p['id'])
slaac_subnets = [subnet for subnet in v6_subnets if slaac_subnets = [
subnet['ipv6_ra_mode'] == constants.IPV6_SLAAC] subnet for subnet in v6_subnets
dns_servers = list(iter_chain(*[subnet['dns_nameservers'] for if subnet['ipv6_ra_mode'] == constants.IPV6_SLAAC
subnet in slaac_subnets if subnet.get('dns_nameservers')])) ]
dns_servers = list(iter_chain(*[
subnet['dns_nameservers'] for subnet in slaac_subnets
if subnet.get('dns_nameservers')
]))
network_mtu = p.get('mtu', 0) network_mtu = p.get('mtu', 0)
buf.write('%s' % CONFIG_TEMPLATE.render( buf.write('%s' % CONFIG_TEMPLATE.render(

View File

@ -162,9 +162,11 @@ class MetadataProxyHandler(object):
ports = self._get_ports(remote_address, network_id, router_id) ports = self._get_ports(remote_address, network_id, router_id)
LOG.debug("Gotten ports for remote_address %(remote_address)s, " LOG.debug("Gotten ports for remote_address %(remote_address)s, "
"network_id %(network_id)s, router_id %(router_id)s are: " "network_id %(network_id)s, router_id %(router_id)s are: "
"%(ports)s", {"remote_address": remote_address, "%(ports)s",
"network_id": network_id, "router_id": router_id, {"remote_address": remote_address,
"ports": ports}) "network_id": network_id,
"router_id": router_id,
"ports": ports})
if len(ports) == 1: if len(ports) == 1:
return ports[0]['device_id'], ports[0]['tenant_id'] return ports[0]['device_id'], ports[0]['tenant_id']

View File

@ -131,7 +131,7 @@ class ResourceConsumerTracker(object):
""" """
for resource_type, resource_version in versions.items(): for resource_type, resource_version in versions.items():
self._set_version(consumer, resource_type, self._set_version(consumer, resource_type,
resource_version) resource_version)
if versions: if versions:
self._cleanup_removed_versions(consumer, versions) self._cleanup_removed_versions(consumer, versions)

View File

@ -296,7 +296,7 @@ class DhcpRpcCallback(object):
old_port['device_id'] != old_port['device_id'] !=
utils.get_dhcp_agent_device_id(network_id, host) or utils.get_dhcp_agent_device_id(network_id, host) or
not self._is_dhcp_agent_hosting_network(plugin, context, host, not self._is_dhcp_agent_hosting_network(plugin, context, host,
network_id)): network_id)):
raise exceptions.DhcpPortInUse(port_id=port['id']) raise exceptions.DhcpPortInUse(port_id=port['id'])
LOG.debug('Update dhcp port %(port)s ' LOG.debug('Update dhcp port %(port)s '
'from %(host)s.', 'from %(host)s.',

View File

@ -102,8 +102,7 @@ class DVRServerRpcCallback(object):
host = kwargs.get('host') host = kwargs.get('host')
subnet = kwargs.get('subnet') subnet = kwargs.get('subnet')
LOG.debug("DVR Agent requests list of VM ports on host %s", host) LOG.debug("DVR Agent requests list of VM ports on host %s", host)
return self.plugin.get_ports_on_host_by_subnet(context, return self.plugin.get_ports_on_host_by_subnet(context, host, subnet)
host, subnet)
def get_subnet_for_dvr(self, context, **kwargs): def get_subnet_for_dvr(self, context, **kwargs):
fixed_ips = kwargs.get('fixed_ips') fixed_ips = kwargs.get('fixed_ips')

View File

@ -230,11 +230,10 @@ class L3RpcCallback(object):
# of hosts on which DVR router interfaces are spawned). Such # of hosts on which DVR router interfaces are spawned). Such
# bindings are created/updated here by invoking # bindings are created/updated here by invoking
# update_distributed_port_binding # update_distributed_port_binding
self.plugin.update_distributed_port_binding(context, port['id'], self.plugin.update_distributed_port_binding(
{'port': context, port['id'],
{portbindings.HOST_ID: host, {'port': {portbindings.HOST_ID: host,
'device_id': router_id} 'device_id': router_id}})
})
def get_external_network_id(self, context, **kwargs): def get_external_network_id(self, context, **kwargs):
"""Get one external network id for l3 agent. """Get one external network id for l3 agent.
@ -305,8 +304,9 @@ class L3RpcCallback(object):
admin_ctx, network_id, host) admin_ctx, network_id, host)
self._ensure_host_set_on_port(admin_ctx, host, agent_port) self._ensure_host_set_on_port(admin_ctx, host, agent_port)
LOG.debug('Agent Gateway port returned : %(agent_port)s with ' LOG.debug('Agent Gateway port returned : %(agent_port)s with '
'host %(host)s', {'agent_port': agent_port, 'host %(host)s',
'host': host}) {'agent_port': agent_port,
'host': host})
return agent_port return agent_port
@db_api.retry_db_errors @db_api.retry_db_errors

View File

@ -94,7 +94,8 @@ class ResourcesPullRpcApi(object):
def pull(self, context, resource_type, resource_id): def pull(self, context, resource_type, resource_id):
resource_type_cls = _resource_to_class(resource_type) resource_type_cls = _resource_to_class(resource_type)
cctxt = self.client.prepare() cctxt = self.client.prepare()
primitive = cctxt.call(context, 'pull', primitive = cctxt.call(
context, 'pull',
resource_type=resource_type, resource_type=resource_type,
version=resource_type_cls.VERSION, resource_id=resource_id) version=resource_type_cls.VERSION, resource_id=resource_id)
@ -107,7 +108,8 @@ class ResourcesPullRpcApi(object):
def bulk_pull(self, context, resource_type, filter_kwargs=None): def bulk_pull(self, context, resource_type, filter_kwargs=None):
resource_type_cls = _resource_to_class(resource_type) resource_type_cls = _resource_to_class(resource_type)
cctxt = self.client.prepare() cctxt = self.client.prepare()
primitives = cctxt.call(context, 'bulk_pull', primitives = cctxt.call(
context, 'bulk_pull',
resource_type=resource_type, resource_type=resource_type,
version=resource_type_cls.VERSION, filter_kwargs=filter_kwargs) version=resource_type_cls.VERSION, filter_kwargs=filter_kwargs)
return [resource_type_cls.clean_obj_from_primitive(primitive) return [resource_type_cls.clean_obj_from_primitive(primitive)

View File

@ -327,8 +327,8 @@ class Controller(object):
fields_to_strip += self._exclude_attributes_by_policy( fields_to_strip += self._exclude_attributes_by_policy(
request.context, obj_list[0]) request.context, obj_list[0])
collection = {self._collection: collection = {self._collection:
[self._filter_attributes(obj, [self._filter_attributes(
fields_to_strip=fields_to_strip) obj, fields_to_strip=fields_to_strip)
for obj in obj_list]} for obj in obj_list]}
pagination_links = pagination_helper.get_links(obj_list) pagination_links = pagination_helper.get_links(obj_list)
if pagination_links: if pagination_links:

View File

@ -289,7 +289,8 @@ class KeepalivedIPv6Test(object):
self.config_path = tempfile.mkdtemp() self.config_path = tempfile.mkdtemp()
# Instantiate keepalived manager with the IPv6 configuration. # Instantiate keepalived manager with the IPv6 configuration.
self.manager = keepalived.KeepalivedManager('router1', self.config, self.manager = keepalived.KeepalivedManager(
'router1', self.config,
namespace=self.nsname, process_monitor=self.pm, namespace=self.nsname, process_monitor=self.pm,
conf_path=self.config_path) conf_path=self.config_path)
self.manager.spawn() self.manager.spawn()

View File

@ -32,10 +32,11 @@ class CoreChecks(base.BaseChecks):
if cfg.CONF.api_workers and cfg.CONF.rpc_workers: if cfg.CONF.api_workers and cfg.CONF.rpc_workers:
return upgradecheck.Result( return upgradecheck.Result(
upgradecheck.Code.SUCCESS, _("Number of workers already " upgradecheck.Code.SUCCESS, _("Number of workers already "
"defined in config")) "defined in config"))
else: else:
return upgradecheck.Result( return upgradecheck.Result(
upgradecheck.Code.WARNING, _("The default number of workers " upgradecheck.Code.WARNING,
"has changed. Please see release notes for the new values, " _("The default number of workers "
"but it is strongly encouraged for deployers to manually set " "has changed. Please see release notes for the new values, "
"the values for api_workers and rpc_workers.")) "but it is strongly encouraged for deployers to manually "
"set the values for api_workers and rpc_workers."))

View File

@ -39,12 +39,14 @@ designate_opts = [
'context')), 'context')),
cfg.BoolOpt('allow_reverse_dns_lookup', default=True, cfg.BoolOpt('allow_reverse_dns_lookup', default=True,
help=_('Allow the creation of PTR records')), help=_('Allow the creation of PTR records')),
cfg.IntOpt('ipv4_ptr_zone_prefix_size', default=24, cfg.IntOpt(
'ipv4_ptr_zone_prefix_size', default=24,
help=_('Number of bits in an ipv4 PTR zone that will be considered ' help=_('Number of bits in an ipv4 PTR zone that will be considered '
'network prefix. It has to align to byte boundary. Minimum ' 'network prefix. It has to align to byte boundary. Minimum '
'value is 8. Maximum value is 24. As a consequence, range ' 'value is 8. Maximum value is 24. As a consequence, range '
'of values is 8, 16 and 24')), 'of values is 8, 16 and 24')),
cfg.IntOpt('ipv6_ptr_zone_prefix_size', default=120, cfg.IntOpt(
'ipv6_ptr_zone_prefix_size', default=120,
help=_('Number of bits in an ipv6 PTR zone that will be considered ' help=_('Number of bits in an ipv6 PTR zone that will be considered '
'network prefix. It has to align to nyble boundary. Minimum ' 'network prefix. It has to align to nyble boundary. Minimum '
'value is 4. Maximum value is 124. As a consequence, range ' 'value is 4. Maximum value is 124. As a consequence, range '
@ -59,6 +61,6 @@ designate_opts = [
def register_designate_opts(CONF=cfg.CONF): def register_designate_opts(CONF=cfg.CONF):
CONF.register_opts(designate_opts, 'designate') CONF.register_opts(designate_opts, 'designate')
loading.register_auth_conf_options(CONF, 'designate') loading.register_auth_conf_options(CONF, 'designate')
loading.register_session_conf_options(conf=CONF, loading.register_session_conf_options(
group='designate', conf=CONF, group='designate',
deprecated_opts={'cafile': [cfg.DeprecatedOpt('ca_cert')]}) deprecated_opts={'cafile': [cfg.DeprecatedOpt('ca_cert')]})

View File

@ -384,7 +384,7 @@ class DhcpAgentSchedulerDbMixin(dhcpagentscheduler
raise das_exc.NetworkHostedByDHCPAgent( raise das_exc.NetworkHostedByDHCPAgent(
network_id=network_id, agent_id=id) network_id=network_id, agent_id=id)
network.NetworkDhcpAgentBinding(context, dhcp_agent_id=id, network.NetworkDhcpAgentBinding(context, dhcp_agent_id=id,
network_id=network_id).create() network_id=network_id).create()
dhcp_notifier = self.agent_notifiers.get(constants.AGENT_TYPE_DHCP) dhcp_notifier = self.agent_notifiers.get(constants.AGENT_TYPE_DHCP)
if dhcp_notifier: if dhcp_notifier:
dhcp_notifier.network_added_to_agent( dhcp_notifier.network_added_to_agent(

View File

@ -24,7 +24,7 @@ from neutron_lib.objects import exceptions
from neutron.common import utils from neutron.common import utils
from neutron.objects.port.extensions import (allowedaddresspairs from neutron.objects.port.extensions import (allowedaddresspairs
as obj_addr_pair) as obj_addr_pair)
@resource_extend.has_resource_extenders @resource_extend.has_resource_extenders

View File

@ -21,7 +21,8 @@ class DataPlaneStatusMixin(object):
"""Mixin class to add data plane status to a port""" """Mixin class to add data plane status to a port"""
def _process_create_port_data_plane_status(self, context, data, res): def _process_create_port_data_plane_status(self, context, data, res):
obj = dps_obj.PortDataPlaneStatus(context, port_id=res['id'], obj = dps_obj.PortDataPlaneStatus(
context, port_id=res['id'],
data_plane_status=data[dps_lib.DATA_PLANE_STATUS]) data_plane_status=data[dps_lib.DATA_PLANE_STATUS])
obj.create() obj.create()
res[dps_lib.DATA_PLANE_STATUS] = data[dps_lib.DATA_PLANE_STATUS] res[dps_lib.DATA_PLANE_STATUS] = data[dps_lib.DATA_PLANE_STATUS]

View File

@ -153,7 +153,7 @@ class DbBasePluginCommon(common_db_mixin.CommonDbMixin):
for pool in subnet.allocation_pools] for pool in subnet.allocation_pools]
res['host_routes'] = [{'destination': str(route.destination), res['host_routes'] = [{'destination': str(route.destination),
'nexthop': str(route.nexthop)} 'nexthop': str(route.nexthop)}
for route in subnet.host_routes] for route in subnet.host_routes]
res['dns_nameservers'] = [str(dns.address) res['dns_nameservers'] = [str(dns.address)
for dns in subnet.dns_nameservers] for dns in subnet.dns_nameservers]
res['shared'] = subnet.shared res['shared'] = subnet.shared

View File

@ -681,7 +681,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
l3plugin = directory.get_plugin(plugin_constants.L3) l3plugin = directory.get_plugin(plugin_constants.L3)
if l3plugin: if l3plugin:
gw_ports = self._get_router_gw_ports_by_network(context, gw_ports = self._get_router_gw_ports_by_network(context,
network['id']) network['id'])
router_ids = [p.device_id for p in gw_ports] router_ids = [p.device_id for p in gw_ports]
for id in router_ids: for id in router_ids:
try: try:
@ -711,8 +711,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
return return
external_gateway_info['external_fixed_ips'].append( external_gateway_info['external_fixed_ips'].append(
{'subnet_id': subnet['id']}) {'subnet_id': subnet['id']})
info = {'router': {'external_gateway_info': info = {'router': {'external_gateway_info': external_gateway_info}}
external_gateway_info}}
l3plugin.update_router(context, router_id, info) l3plugin.update_router(context, router_id, info)
@db_api.retry_if_session_inactive() @db_api.retry_if_session_inactive()
@ -724,8 +723,8 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
# If this subnet supports auto-addressing, then update any # If this subnet supports auto-addressing, then update any
# internal ports on the network with addresses for this subnet. # internal ports on the network with addresses for this subnet.
if ipv6_utils.is_auto_address_subnet(result): if ipv6_utils.is_auto_address_subnet(result):
updated_ports = self.ipam.add_auto_addrs_on_network_ports(context, updated_ports = self.ipam.add_auto_addrs_on_network_ports(
result, ipam_subnet) context, result, ipam_subnet)
for port_id in updated_ports: for port_id in updated_ports:
port_info = {'port': {'id': port_id}} port_info = {'port': {'id': port_id}}
try: try:
@ -1336,7 +1335,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
with db_api.CONTEXT_WRITER.using(context): with db_api.CONTEXT_WRITER.using(context):
for port in port_data: for port in port_data:
raw_mac_address = port.pop('mac_address', raw_mac_address = port.pop('mac_address',
constants.ATTR_NOT_SPECIFIED) constants.ATTR_NOT_SPECIFIED)
if raw_mac_address is constants.ATTR_NOT_SPECIFIED: if raw_mac_address is constants.ATTR_NOT_SPECIFIED:
raw_mac_address = macs.pop() raw_mac_address = macs.pop()
eui_mac_address = netaddr.EUI(raw_mac_address, 48) eui_mac_address = netaddr.EUI(raw_mac_address, 48)
@ -1379,12 +1378,12 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
self._enforce_device_owner_not_router_intf_or_device_id( self._enforce_device_owner_not_router_intf_or_device_id(
context, pdata.get('device_owner'), context, pdata.get('device_owner'),
pdata.get('device_id'), pdata.get('tenant_id')) pdata.get('device_id'), pdata.get('tenant_id'))
bulk_port_data.append(dict(project_id=pdata.get('project_id'), bulk_port_data.append(dict(
project_id=pdata.get('project_id'),
name=pdata.get('name'), name=pdata.get('name'),
network_id=pdata.get('network_id'), network_id=pdata.get('network_id'),
admin_state_up=pdata.get('admin_state_up'), admin_state_up=pdata.get('admin_state_up'),
status=pdata.get('status', status=pdata.get('status', constants.PORT_STATUS_ACTIVE),
constants.PORT_STATUS_ACTIVE),
mac_address=pdata.get('mac_address'), mac_address=pdata.get('mac_address'),
device_id=pdata.get('device_id'), device_id=pdata.get('device_id'),
device_owner=pdata.get('device_owner'), device_owner=pdata.get('device_owner'),

View File

@ -92,7 +92,8 @@ class DNSDbMixin(object):
context, floatingip_data, req_data)) context, floatingip_data, req_data))
dns_actions_data = None dns_actions_data = None
if current_dns_name and current_dns_domain: if current_dns_name and current_dns_domain:
fip_obj.FloatingIPDNS(context, fip_obj.FloatingIPDNS(
context,
floatingip_id=floatingip_data['id'], floatingip_id=floatingip_data['id'],
dns_name=req_data[dns_apidef.DNSNAME], dns_name=req_data[dns_apidef.DNSNAME],
dns_domain=req_data[dns_apidef.DNSDOMAIN], dns_domain=req_data[dns_apidef.DNSDOMAIN],
@ -149,7 +150,8 @@ class DNSDbMixin(object):
else: else:
return return
if current_dns_name and current_dns_domain: if current_dns_name and current_dns_domain:
fip_obj.FloatingIPDNS(context, fip_obj.FloatingIPDNS(
context,
floatingip_id=floatingip_data['id'], floatingip_id=floatingip_data['id'],
dns_name='', dns_name='',
dns_domain='', dns_domain='',

View File

@ -143,7 +143,7 @@ class ExtraRoute_dbonly_mixin(l3_db.L3_NAT_dbonly_mixin):
def _confirm_router_interface_not_in_use(self, context, router_id, def _confirm_router_interface_not_in_use(self, context, router_id,
subnet_id): subnet_id):
super(ExtraRoute_dbonly_mixin, super(ExtraRoute_dbonly_mixin,
self)._confirm_router_interface_not_in_use( self)._confirm_router_interface_not_in_use(
context, router_id, subnet_id) context, router_id, subnet_id)
subnet = self._core_plugin.get_subnet(context, subnet_id) subnet = self._core_plugin.get_subnet(context, subnet_id)
subnet_cidr = netaddr.IPNetwork(subnet['cidr']) subnet_cidr = netaddr.IPNetwork(subnet['cidr'])

View File

@ -222,8 +222,8 @@ class FlavorsDbMixin(common_db_mixin.CommonDbMixin):
marker=None, page_reverse=False): marker=None, page_reverse=False):
"""From flavor, choose service profile and find provider for driver.""" """From flavor, choose service profile and find provider for driver."""
objs = obj_flavor.FlavorServiceProfileBinding.get_objects(context, objs = obj_flavor.FlavorServiceProfileBinding.get_objects(
flavor_id=flavor_id) context, flavor_id=flavor_id)
if not objs: if not objs:
raise flav_exc.FlavorServiceProfileBindingNotFound( raise flav_exc.FlavorServiceProfileBindingNotFound(
sp_id='', fl_id=flavor_id) sp_id='', fl_id=flavor_id)

View File

@ -125,7 +125,8 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
if _combine(route) == route_str: if _combine(route) == route_str:
route.delete() route.delete()
for route_str in new_route_set - old_route_set: for route_str in new_route_set - old_route_set:
route = subnet_obj.Route(context, route = subnet_obj.Route(
context,
destination=common_utils.AuthenticIPNetwork( destination=common_utils.AuthenticIPNetwork(
route_str.partition("_")[0]), route_str.partition("_")[0]),
nexthop=netaddr.IPAddress(route_str.partition("_")[2]), nexthop=netaddr.IPAddress(route_str.partition("_")[2]),

View File

@ -50,7 +50,7 @@ def get_ip_update_not_allowed_device_owner_list():
def is_neutron_built_in_router(context, router_id): def is_neutron_built_in_router(context, router_id):
l3plugin = directory.get_plugin(plugin_consts.L3) l3plugin = directory.get_plugin(plugin_consts.L3)
return bool(l3plugin and return bool(l3plugin and
l3plugin.router_supports_scheduling(context, router_id)) l3plugin.router_supports_scheduling(context, router_id))
class IpamPluggableBackend(ipam_backend_mixin.IpamBackendMixin): class IpamPluggableBackend(ipam_backend_mixin.IpamBackendMixin):
@ -437,8 +437,8 @@ class IpamPluggableBackend(ipam_backend_mixin.IpamBackendMixin):
port_copy = copy.deepcopy(original) port_copy = copy.deepcopy(original)
port_copy.update(new_port) port_copy.update(new_port)
port_copy['fixed_ips'] = auto_assign_subnets port_copy['fixed_ips'] = auto_assign_subnets
self.allocate_ips_for_port_and_store(context, self.allocate_ips_for_port_and_store(
{'port': port_copy}, port_copy['id']) context, {'port': port_copy}, port_copy['id'])
getattr(db_port, 'fixed_ips') # refresh relationship before return getattr(db_port, 'fixed_ips') # refresh relationship before return

View File

@ -121,7 +121,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
router_id = router['id'] router_id = router['id']
agent_id = agent['id'] agent_id = agent['id']
bindings = rb_obj.RouterL3AgentBinding.get_objects(context, bindings = rb_obj.RouterL3AgentBinding.get_objects(context,
router_id=router_id) router_id=router_id)
if not bindings: if not bindings:
return True return True
for binding in bindings: for binding in bindings:
@ -213,7 +213,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
# the routers should be retained. This flag will be used # the routers should be retained. This flag will be used
# to check if there are valid routers in this agent. # to check if there are valid routers in this agent.
retain_router = self._check_router_retain_needed(context, router, retain_router = self._check_router_retain_needed(context, router,
agent.host) agent.host)
if retain_router: if retain_router:
l3_notifier.routers_updated_on_host( l3_notifier.routers_updated_on_host(
context, [router_id], agent.host) context, [router_id], agent.host)
@ -262,8 +262,8 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
new_hosts = [agent['host'] for agent in new_agents] new_hosts = [agent['host'] for agent in new_agents]
router = self.get_router(context, router_id) router = self.get_router(context, router_id)
for host in set(old_hosts) - set(new_hosts): for host in set(old_hosts) - set(new_hosts):
retain_router = self._check_router_retain_needed(context, retain_router = self._check_router_retain_needed(
router, host) context, router, host)
if retain_router: if retain_router:
l3_notifier.routers_updated_on_host( l3_notifier.routers_updated_on_host(
context, [router_id], host) context, [router_id], host)
@ -362,9 +362,10 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
record_objs = rb_obj.RouterL3AgentBinding.get_objects( record_objs = rb_obj.RouterL3AgentBinding.get_objects(
context, router_id=router_ids) context, router_id=router_ids)
if admin_state_up is not None: if admin_state_up is not None:
l3_agents = ag_obj.Agent.get_objects(context, l3_agents = ag_obj.Agent.get_objects(
id=[obj.l3_agent_id for obj in record_objs], context,
admin_state_up=admin_state_up) id=[obj.l3_agent_id for obj in record_objs],
admin_state_up=admin_state_up)
else: else:
l3_agents = [ l3_agents = [
ag_obj.Agent.get_object(context, id=obj.l3_agent_id) ag_obj.Agent.get_object(context, id=obj.l3_agent_id)

View File

@ -471,8 +471,9 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
def _create_gw_port(self, context, router_id, router, new_network_id, def _create_gw_port(self, context, router_id, router, new_network_id,
ext_ips): ext_ips):
new_valid_gw_port_attachment = ( new_valid_gw_port_attachment = (
new_network_id and (not router.gw_port or new_network_id and
router.gw_port['network_id'] != new_network_id)) (not router.gw_port or
router.gw_port['network_id'] != new_network_id))
if new_valid_gw_port_attachment: if new_valid_gw_port_attachment:
subnets = self._core_plugin.get_subnets_by_network(context, subnets = self._core_plugin.get_subnets_by_network(context,
new_network_id) new_network_id)
@ -840,9 +841,11 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
if port: if port:
fixed_ips = list(map(dict, port['port']['fixed_ips'])) fixed_ips = list(map(dict, port['port']['fixed_ips']))
fixed_ips.append(fixed_ip) fixed_ips.append(fixed_ip)
return self._core_plugin.update_port(context, return (self._core_plugin.update_port(
port['port_id'], {'port': context, port['port_id'],
{'fixed_ips': fixed_ips}}), [subnet], False {'port': {'fixed_ips': fixed_ips}}),
[subnet],
False)
port_data = {'tenant_id': router.tenant_id, port_data = {'tenant_id': router.tenant_id,
'network_id': subnet['network_id'], 'network_id': subnet['network_id'],
@ -1041,9 +1044,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
# multiple prefix port - delete prefix from port # multiple prefix port - delete prefix from port
fixed_ips = [dict(fip) for fip in p['fixed_ips'] fixed_ips = [dict(fip) for fip in p['fixed_ips']
if fip['subnet_id'] != subnet_id] if fip['subnet_id'] != subnet_id]
self._core_plugin.update_port(context, p['id'], self._core_plugin.update_port(
{'port': context, p['id'], {'port': {'fixed_ips': fixed_ips}})
{'fixed_ips': fixed_ips}})
return (p, [subnet]) return (p, [subnet])
elif subnet_id in port_subnets: elif subnet_id in port_subnets:
# only one subnet on port - delete the port # only one subnet on port - delete the port
@ -1108,9 +1110,9 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
def _make_floatingip_dict(self, floatingip, fields=None, def _make_floatingip_dict(self, floatingip, fields=None,
process_extensions=True): process_extensions=True):
floating_ip_address = (str(floatingip.floating_ip_address) floating_ip_address = (str(floatingip.floating_ip_address)
if floatingip.floating_ip_address else None) if floatingip.floating_ip_address else None)
fixed_ip_address = (str(floatingip.fixed_ip_address) fixed_ip_address = (str(floatingip.fixed_ip_address)
if floatingip.fixed_ip_address else None) if floatingip.fixed_ip_address else None)
res = {'id': floatingip.id, res = {'id': floatingip.id,
'tenant_id': floatingip.project_id, 'tenant_id': floatingip.project_id,
'floating_ip_address': floating_ip_address, 'floating_ip_address': floating_ip_address,
@ -1133,8 +1135,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
internal_subnet_id, internal_subnet_id,
external_network_id): external_network_id):
subnet = self._core_plugin.get_subnet(context, internal_subnet_id) subnet = self._core_plugin.get_subnet(context, internal_subnet_id)
return self.get_router_for_floatingip(context, return self.get_router_for_floatingip(
internal_port, subnet, external_network_id) context, internal_port, subnet, external_network_id)
# NOTE(yamamoto): This method is an override point for plugins # NOTE(yamamoto): This method is an override point for plugins
# inheriting this class. Do not optimize this out. # inheriting this class. Do not optimize this out.
@ -1282,7 +1284,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
fixed_ip_address=netaddr.IPAddress(internal_ip_address)) fixed_ip_address=netaddr.IPAddress(internal_ip_address))
if fip_exists: if fip_exists:
floating_ip_address = (str(floatingip_obj.floating_ip_address) floating_ip_address = (str(floatingip_obj.floating_ip_address)
if floatingip_obj.floating_ip_address else None) if floatingip_obj.floating_ip_address
else None)
raise l3_exc.FloatingIPPortAlreadyAssociated( raise l3_exc.FloatingIPPortAlreadyAssociated(
port_id=fip['port_id'], port_id=fip['port_id'],
fip_id=floatingip_obj.id, fip_id=floatingip_obj.id,
@ -1319,7 +1322,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
if 'description' in fip: if 'description' in fip:
floatingip_obj.description = fip['description'] floatingip_obj.description = fip['description']
floating_ip_address = (str(floatingip_obj.floating_ip_address) floating_ip_address = (str(floatingip_obj.floating_ip_address)
if floatingip_obj.floating_ip_address else None) if floatingip_obj.floating_ip_address else None)
return {'fixed_ip_address': internal_ip_address, return {'fixed_ip_address': internal_ip_address,
'fixed_port_id': port_id, 'fixed_port_id': port_id,
'router_id': router_id, 'router_id': router_id,
@ -1334,7 +1337,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
return any(s.ip_version == 4 for s in net.subnets) return any(s.ip_version == 4 for s in net.subnets)
def _create_floatingip(self, context, floatingip, def _create_floatingip(self, context, floatingip,
initial_status=constants.FLOATINGIP_STATUS_ACTIVE): initial_status=constants.FLOATINGIP_STATUS_ACTIVE):
try: try:
registry.publish(resources.FLOATING_IP, events.BEFORE_CREATE, registry.publish(resources.FLOATING_IP, events.BEFORE_CREATE,
self, payload=events.DBEventPayload( self, payload=events.DBEventPayload(
@ -1444,7 +1447,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
@db_api.retry_if_session_inactive() @db_api.retry_if_session_inactive()
def create_floatingip(self, context, floatingip, def create_floatingip(self, context, floatingip,
initial_status=constants.FLOATINGIP_STATUS_ACTIVE): initial_status=constants.FLOATINGIP_STATUS_ACTIVE):
return self._create_floatingip(context, floatingip, initial_status) return self._create_floatingip(context, floatingip, initial_status)
def _update_floatingip(self, context, id, floatingip): def _update_floatingip(self, context, id, floatingip):
@ -2053,7 +2056,7 @@ class L3_NAT_db_mixin(L3_NAT_dbonly_mixin, L3RpcNotifierMixin):
return router_interface_info return router_interface_info
def create_floatingip(self, context, floatingip, def create_floatingip(self, context, floatingip,
initial_status=constants.FLOATINGIP_STATUS_ACTIVE): initial_status=constants.FLOATINGIP_STATUS_ACTIVE):
floatingip_dict = super(L3_NAT_db_mixin, self).create_floatingip( floatingip_dict = super(L3_NAT_db_mixin, self).create_floatingip(
context, floatingip, initial_status) context, floatingip, initial_status)
router_id = floatingip_dict['router_id'] router_id = floatingip_dict['router_id']

View File

@ -711,7 +711,7 @@ class _DVRAgentInterfaceMixin(object):
# Collect gw ports only if available # Collect gw ports only if available
if gw_port_id and gw_ports.get(gw_port_id): if gw_port_id and gw_ports.get(gw_port_id):
l3_agent = ag_obj.Agent.get_object(context, l3_agent = ag_obj.Agent.get_object(context,
id=binding_objs[0].l3_agent_id) id=binding_objs[0].l3_agent_id)
return l3_agent.host return l3_agent.host
def _build_routers_list(self, context, routers, gw_ports): def _build_routers_list(self, context, routers, gw_ports):
@ -810,7 +810,7 @@ class _DVRAgentInterfaceMixin(object):
@log_helper.log_method_call @log_helper.log_method_call
def _get_dvr_sync_data(self, context, host, agent, router_ids=None, def _get_dvr_sync_data(self, context, host, agent, router_ids=None,
active=None): active=None):
routers, interfaces, floating_ips = self._get_router_info_list( routers, interfaces, floating_ips = self._get_router_info_list(
context, router_ids=router_ids, active=active, context, router_ids=router_ids, active=active,
device_owners=const.ROUTER_INTERFACE_OWNERS) device_owners=const.ROUTER_INTERFACE_OWNERS)
@ -1098,7 +1098,7 @@ class _DVRAgentInterfaceMixin(object):
def _get_address_pair_active_port_with_fip( def _get_address_pair_active_port_with_fip(
self, context, port_dict, port_addr_pair_ip): self, context, port_dict, port_addr_pair_ip):
port_valid_state = (port_dict['admin_state_up'] or port_valid_state = (port_dict['admin_state_up'] or
(port_dict['status'] == const.PORT_STATUS_ACTIVE)) port_dict['status'] == const.PORT_STATUS_ACTIVE)
if not port_valid_state: if not port_valid_state:
return return
fips = l3_obj.FloatingIP.get_objects( fips = l3_obj.FloatingIP.get_objects(

View File

@ -125,7 +125,7 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
for agent in snat_agent_list: for agent in snat_agent_list:
LOG.debug('DVR: Handle new unbound migration port, ' LOG.debug('DVR: Handle new unbound migration port, '
'host %(host)s, router_ids %(router_ids)s', 'host %(host)s, router_ids %(router_ids)s',
{'host': agent.host, 'router_ids': router_ids}) {'host': agent.host, 'router_ids': router_ids})
self.l3_rpc_notifier.routers_updated_on_host( self.l3_rpc_notifier.routers_updated_on_host(
context, router_ids, agent.host) context, router_ids, agent.host)
if agent.host == port_host: if agent.host == port_host:
@ -400,7 +400,7 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
def _get_router_ids_for_agent(self, context, agent_db, router_ids): def _get_router_ids_for_agent(self, context, agent_db, router_ids):
result_set = set(super(L3_DVRsch_db_mixin, result_set = set(super(L3_DVRsch_db_mixin,
self)._get_router_ids_for_agent( self)._get_router_ids_for_agent(
context, agent_db, router_ids)) context, agent_db, router_ids))
router_ids = set(router_ids or []) router_ids = set(router_ids or [])
if router_ids and result_set == router_ids: if router_ids and result_set == router_ids:

View File

@ -63,7 +63,7 @@ class L3_NAT_dbonly_mixin(l3_db.L3_NAT_dbonly_mixin):
old_router = self._make_router_dict(router) old_router = self._make_router_dict(router)
router.enable_snat = self._get_enable_snat(info) router.enable_snat = self._get_enable_snat(info)
router_body = {l3_apidef.ROUTER: router_body = {l3_apidef.ROUTER:
{l3_apidef.EXTERNAL_GW_INFO: info}} {l3_apidef.EXTERNAL_GW_INFO: info}}
registry.publish(resources.ROUTER, events.PRECOMMIT_UPDATE, self, registry.publish(resources.ROUTER, events.PRECOMMIT_UPDATE, self,
payload=events.DBEventPayload( payload=events.DBEventPayload(
context, request_body=router_body, context, request_body=router_body,

View File

@ -144,8 +144,8 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
"%(ha_vr_id)d.", "%(ha_vr_id)d.",
{'router_id': router_id, 'ha_vr_id': allocation.vr_id}) {'router_id': router_id, 'ha_vr_id': allocation.vr_id})
router_body = {l3_apidef.ROUTER: router_body = {l3_apidef.ROUTER:
{l3_ext_ha_apidef.HA_INFO: True, {l3_ext_ha_apidef.HA_INFO: True,
'ha_vr_id': allocation.vr_id}} 'ha_vr_id': allocation.vr_id}}
registry.publish(resources.ROUTER, events.PRECOMMIT_UPDATE, registry.publish(resources.ROUTER, events.PRECOMMIT_UPDATE,
self, payload=events.DBEventPayload( self, payload=events.DBEventPayload(
context, request_body=router_body, context, request_body=router_body,
@ -234,9 +234,11 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
def get_number_of_agents_for_scheduling(self, context): def get_number_of_agents_for_scheduling(self, context):
"""Return number of agents on which the router will be scheduled.""" """Return number of agents on which the router will be scheduled."""
num_agents = len(self.get_l3_agents(context, active=True, num_agents = len(
filters={'agent_modes': [constants.L3_AGENT_MODE_LEGACY, self.get_l3_agents(
constants.L3_AGENT_MODE_DVR_SNAT]})) context, active=True,
filters={'agent_modes': [constants.L3_AGENT_MODE_LEGACY,
constants.L3_AGENT_MODE_DVR_SNAT]}))
max_agents = cfg.CONF.max_l3_agents_per_router max_agents = cfg.CONF.max_l3_agents_per_router
if max_agents: if max_agents:
if max_agents > num_agents: if max_agents > num_agents:
@ -257,8 +259,8 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
port_id=port_id, port_id=port_id,
router_id=router_id, router_id=router_id,
port_type=constants.DEVICE_OWNER_ROUTER_HA_INTF).create() port_type=constants.DEVICE_OWNER_ROUTER_HA_INTF).create()
portbinding = l3_hamode.L3HARouterAgentPortBinding(context, portbinding = l3_hamode.L3HARouterAgentPortBinding(
port_id=port_id, router_id=router_id) context, port_id=port_id, router_id=router_id)
portbinding.create() portbinding.create()
return portbinding return portbinding
@ -671,8 +673,8 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
sync_data = self._get_dvr_sync_data(context, host, agent, sync_data = self._get_dvr_sync_data(context, host, agent,
router_ids, active) router_ids, active)
else: else:
sync_data = super(L3_HA_NAT_db_mixin, self).get_sync_data(context, sync_data = super(L3_HA_NAT_db_mixin, self).get_sync_data(
router_ids, active) context, router_ids, active)
return self._process_sync_ha_data( return self._process_sync_ha_data(
context, sync_data, host, dvr_agent_mode) context, sync_data, host, dvr_agent_mode)
@ -703,7 +705,8 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
constants.DEVICE_OWNER_ROUTER_SNAT, constants.DEVICE_OWNER_ROUTER_SNAT,
constants.DEVICE_OWNER_ROUTER_GW]} constants.DEVICE_OWNER_ROUTER_GW]}
ports = self._core_plugin.get_ports(admin_ctx, filters=device_filter) ports = self._core_plugin.get_ports(admin_ctx, filters=device_filter)
active_ports = (port for port in ports active_ports = (
port for port in ports
if states[port['device_id']] == n_const.HA_ROUTER_STATE_ACTIVE) if states[port['device_id']] == n_const.HA_ROUTER_STATE_ACTIVE)
for port in active_ports: for port in active_ports:

View File

@ -196,7 +196,8 @@ def upgrade():
sa.ForeignKeyConstraint(['router_id'], ['routers.id']), sa.ForeignKeyConstraint(['router_id'], ['routers.id']),
sa.PrimaryKeyConstraint('router_id')) sa.PrimaryKeyConstraint('router_id'))
op.create_table('cisco_hosting_devices', op.create_table(
'cisco_hosting_devices',
sa.Column('tenant_id', sa.String(length=255), nullable=True, sa.Column('tenant_id', sa.String(length=255), nullable=True,
index=True), index=True),
sa.Column('id', sa.String(length=36), nullable=False), sa.Column('id', sa.String(length=36), nullable=False),
@ -213,7 +214,8 @@ def upgrade():
ondelete='SET NULL'), ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id') sa.PrimaryKeyConstraint('id')
) )
op.create_table('cisco_port_mappings', op.create_table(
'cisco_port_mappings',
sa.Column('logical_resource_id', sa.String(length=36), nullable=False), sa.Column('logical_resource_id', sa.String(length=36), nullable=False),
sa.Column('logical_port_id', sa.String(length=36), nullable=False), sa.Column('logical_port_id', sa.String(length=36), nullable=False),
sa.Column('port_type', sa.String(length=32), nullable=True), sa.Column('port_type', sa.String(length=32), nullable=True),
@ -227,7 +229,8 @@ def upgrade():
ondelete='CASCADE'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('logical_resource_id', 'logical_port_id') sa.PrimaryKeyConstraint('logical_resource_id', 'logical_port_id')
) )
op.create_table('cisco_router_mappings', op.create_table(
'cisco_router_mappings',
sa.Column('router_id', sa.String(length=36), nullable=False), sa.Column('router_id', sa.String(length=36), nullable=False),
sa.Column('auto_schedule', sa.Boolean(), nullable=False), sa.Column('auto_schedule', sa.Boolean(), nullable=False),
sa.Column('hosting_device_id', sa.String(length=36), nullable=True), sa.Column('hosting_device_id', sa.String(length=36), nullable=True),

View File

@ -138,7 +138,7 @@ def upgrade():
sa.Column('network_id', sa.String(length=36), nullable=False), sa.Column('network_id', sa.String(length=36), nullable=False),
sa.Column('dhcp_agent_id', sa.String(length=36), nullable=False), sa.Column('dhcp_agent_id', sa.String(length=36), nullable=False),
sa.ForeignKeyConstraint(['dhcp_agent_id'], ['agents.id'], sa.ForeignKeyConstraint(['dhcp_agent_id'], ['agents.id'],
ondelete='CASCADE'), ondelete='CASCADE'),
sa.ForeignKeyConstraint(['network_id'], ['networks.id'], sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
ondelete='CASCADE'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('network_id', 'dhcp_agent_id')) sa.PrimaryKeyConstraint('network_id', 'dhcp_agent_id'))

View File

@ -46,7 +46,7 @@ def contract_creation_exceptions():
def upgrade(): def upgrade():
op.add_column(ROUTER_L3_AGENT_BINDING, op.add_column(ROUTER_L3_AGENT_BINDING,
sa.Column('binding_index', sa.Integer(), nullable=False, sa.Column('binding_index', sa.Integer(), nullable=False,
server_default='1')) server_default='1'))
bindings_table = sa.Table( bindings_table = sa.Table(
ROUTER_L3_AGENT_BINDING, ROUTER_L3_AGENT_BINDING,

View File

@ -25,7 +25,7 @@ down_revision = '89ab9a816d70'
def upgrade(): def upgrade():
op.add_column('subnets', op.add_column('subnets',
sa.Column('segment_id', sa.String(length=36), nullable=True)) sa.Column('segment_id', sa.String(length=36), nullable=True))
op.create_foreign_key( op.create_foreign_key(
None, 'subnets', 'networksegments', ['segment_id'], ['id']) None, 'subnets', 'networksegments', ['segment_id'], ['id'])

View File

@ -43,6 +43,7 @@ def upgrade():
constants.INGRESS_DIRECTION, constants.INGRESS_DIRECTION,
name='directions'), name='directions'),
nullable=False, server_default=constants.EGRESS_DIRECTION), nullable=False, server_default=constants.EGRESS_DIRECTION),
sa.UniqueConstraint('qos_policy_id', 'direction', sa.UniqueConstraint(
'qos_policy_id', 'direction',
name='qos_minimum_bandwidth_rules0qos_policy_id0direction') name='qos_minimum_bandwidth_rules0qos_policy_id0direction')
) )

View File

@ -22,7 +22,8 @@ down_revision = '45f8dd33480b'
def upgrade(): def upgrade():
op.create_table('trunks', op.create_table(
'trunks',
sa.Column('admin_state_up', sa.Boolean(), sa.Column('admin_state_up', sa.Boolean(),
nullable=False, server_default=sql.true()), nullable=False, server_default=sql.true()),
sa.Column('tenant_id', sa.String(length=255), nullable=True, sa.Column('tenant_id', sa.String(length=255), nullable=True,
@ -42,7 +43,8 @@ def upgrade():
sa.UniqueConstraint('port_id'), sa.UniqueConstraint('port_id'),
sa.UniqueConstraint('standard_attr_id') sa.UniqueConstraint('standard_attr_id')
) )
op.create_table('subports', op.create_table(
'subports',
sa.Column('port_id', sa.String(length=36)), sa.Column('port_id', sa.String(length=36)),
sa.Column('trunk_id', sa.String(length=36), nullable=False), sa.Column('trunk_id', sa.String(length=36), nullable=False),
sa.Column('segmentation_type', sa.String(length=32), nullable=False), sa.Column('segmentation_type', sa.String(length=32), nullable=False),
@ -51,6 +53,7 @@ def upgrade():
sa.ForeignKeyConstraint(['trunk_id'], ['trunks.id'], sa.ForeignKeyConstraint(['trunk_id'], ['trunks.id'],
ondelete='CASCADE'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('port_id'), sa.PrimaryKeyConstraint('port_id'),
sa.UniqueConstraint('trunk_id', 'segmentation_type', 'segmentation_id', sa.UniqueConstraint(
'trunk_id', 'segmentation_type', 'segmentation_id',
name='uniq_subport0trunk_id0segmentation_type0segmentation_id') name='uniq_subport0trunk_id0segmentation_type0segmentation_id')
) )

View File

@ -30,7 +30,8 @@ down_revision = '030a959ceafa'
def upgrade(): def upgrade():
op.create_table('subnet_service_types', op.create_table(
'subnet_service_types',
sa.Column('subnet_id', sa.String(length=36)), sa.Column('subnet_id', sa.String(length=36)),
sa.Column('service_type', sa.String(length=255)), sa.Column('service_type', sa.String(length=255)),
sa.ForeignKeyConstraint(['subnet_id'], ['subnets.id'], sa.ForeignKeyConstraint(['subnet_id'], ['subnets.id'],

View File

@ -43,13 +43,13 @@ def upgrade():
op.add_column(ML2_PORT_BINDING, op.add_column(ML2_PORT_BINDING,
sa.Column('status', sa.Column('status',
sa.String(length=16), sa.String(length=16),
nullable=False, nullable=False,
server_default=constants.ACTIVE)) server_default=constants.ACTIVE))
if (engine.name == MYSQL_ENGINE): if (engine.name == MYSQL_ENGINE):
op.execute("ALTER TABLE ml2_port_bindings DROP PRIMARY KEY," op.execute("ALTER TABLE ml2_port_bindings DROP PRIMARY KEY,"
"ADD PRIMARY KEY(port_id, host);") "ADD PRIMARY KEY(port_id, host);")
else: else:
inspector = insp.from_engine(bind) inspector = insp.from_engine(bind)
pk_constraint = inspector.get_pk_constraint(ML2_PORT_BINDING) pk_constraint = inspector.get_pk_constraint(ML2_PORT_BINDING)

View File

@ -31,7 +31,8 @@ down_revision = '0ff9e3881597'
def upgrade(): def upgrade():
op.create_table('securitygrouprbacs', op.create_table(
'securitygrouprbacs',
sa.Column('project_id', sa.String(length=255), nullable=True), sa.Column('project_id', sa.String(length=255), nullable=True),
sa.Column('id', sa.String(length=36), nullable=False), sa.Column('id', sa.String(length=36), nullable=False),
sa.Column('target_tenant', sa.String(length=255), nullable=False), sa.Column('target_tenant', sa.String(length=255), nullable=False),

View File

@ -572,7 +572,7 @@ def get_alembic_version_table(config):
return [] return []
with environment.EnvironmentContext(config, script_dir, with environment.EnvironmentContext(config, script_dir,
fn=alembic_version_table_from_env): fn=alembic_version_table_from_env):
script_dir.run_env() script_dir.run_env()
return alembic_version_table[0] return alembic_version_table[0]

View File

@ -24,7 +24,8 @@ class Flavor(model_base.BASEV2, model_base.HasId):
# Make it True for multi-type flavors # Make it True for multi-type flavors
service_type = sa.Column(sa.String(36), nullable=True) service_type = sa.Column(sa.String(36), nullable=True)
service_profiles = orm.relationship("FlavorServiceProfileBinding", service_profiles = orm.relationship("FlavorServiceProfileBinding",
cascade="all, delete-orphan", lazy="subquery") cascade="all, delete-orphan",
lazy="subquery")
class ServiceProfile(model_base.BASEV2, model_base.HasId): class ServiceProfile(model_base.BASEV2, model_base.HasId):

View File

@ -105,7 +105,7 @@ class FloatingIP(standard_attr.HasStandardAttributes, model_base.BASEV2,
sa.UniqueConstraint( sa.UniqueConstraint(
floating_network_id, fixed_port_id, fixed_ip_address, floating_network_id, fixed_port_id, fixed_ip_address,
name=('uniq_floatingips0floatingnetworkid' name=('uniq_floatingips0floatingnetworkid'
'0fixedportid0fixedipaddress')), '0fixedportid0fixedipaddress')),
model_base.BASEV2.__table_args__,) model_base.BASEV2.__table_args__,)
api_collections = [l3_apidef.FLOATINGIPS] api_collections = [l3_apidef.FLOATINGIPS]
collection_resource_map = {l3_apidef.FLOATINGIPS: l3_apidef.FLOATINGIP} collection_resource_map = {l3_apidef.FLOATINGIPS: l3_apidef.FLOATINGIP}

View File

@ -21,7 +21,7 @@ class GeneveAllocation(model_base.BASEV2):
__tablename__ = 'ml2_geneve_allocations' __tablename__ = 'ml2_geneve_allocations'
geneve_vni = sa.Column(sa.Integer, nullable=False, primary_key=True, geneve_vni = sa.Column(sa.Integer, nullable=False, primary_key=True,
autoincrement=False) autoincrement=False)
allocated = sa.Column(sa.Boolean, nullable=False, default=False, allocated = sa.Column(sa.Boolean, nullable=False, default=False,
server_default=sql.false(), index=True) server_default=sql.false(), index=True)

View File

@ -188,8 +188,8 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase,
fields) fields)
if (fields is None or len(fields) == 0 or if (fields is None or len(fields) == 0 or
'security_group_rules' in fields): 'security_group_rules' in fields):
rules = self.get_security_group_rules(context, rules = self.get_security_group_rules(
{'security_group_id': [id]}) context, {'security_group_id': [id]})
ret['security_group_rules'] = rules ret['security_group_rules'] = rules
finally: finally:
@ -318,8 +318,8 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase,
def _create_port_security_group_binding(self, context, port_id, def _create_port_security_group_binding(self, context, port_id,
security_group_id): security_group_id):
with db_api.CONTEXT_WRITER.using(context): with db_api.CONTEXT_WRITER.using(context):
db = sg_models.SecurityGroupPortBinding(port_id=port_id, db = sg_models.SecurityGroupPortBinding(
security_group_id=security_group_id) port_id=port_id, security_group_id=security_group_id)
context.session.add(db) context.session.add(db)
def _get_port_security_group_bindings(self, context, def _get_port_security_group_bindings(self, context,
@ -427,9 +427,10 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase,
id=sg_rule.id) id=sg_rule.id)
res_rule_dict = self._make_security_group_rule_dict(sg_rule.db_obj) res_rule_dict = self._make_security_group_rule_dict(sg_rule.db_obj)
kwargs['security_group_rule'] = res_rule_dict kwargs['security_group_rule'] = res_rule_dict
self._registry_notify(resources.SECURITY_GROUP_RULE, self._registry_notify(
events.PRECOMMIT_CREATE, resources.SECURITY_GROUP_RULE,
exc_cls=ext_sg.SecurityGroupConflict, **kwargs) events.PRECOMMIT_CREATE,
exc_cls=ext_sg.SecurityGroupConflict, **kwargs)
return res_rule_dict return res_rule_dict
def _get_ip_proto_number(self, protocol): def _get_ip_proto_number(self, protocol):
@ -478,8 +479,8 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase,
if rule['port_range_min'] == 0 or rule['port_range_max'] == 0: if rule['port_range_min'] == 0 or rule['port_range_max'] == 0:
raise ext_sg.SecurityGroupInvalidPortValue(port=0) raise ext_sg.SecurityGroupInvalidPortValue(port=0)
elif (rule['port_range_min'] is not None and elif (rule['port_range_min'] is not None and
rule['port_range_max'] is not None and rule['port_range_max'] is not None and
rule['port_range_min'] <= rule['port_range_max']): rule['port_range_min'] <= rule['port_range_max']):
pass pass
else: else:
raise ext_sg.SecurityGroupInvalidPortRange() raise ext_sg.SecurityGroupInvalidPortRange()
@ -800,10 +801,12 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase,
sg_objs = sg_obj.SecurityGroup.get_objects(context, id=port_sg) sg_objs = sg_obj.SecurityGroup.get_objects(context, id=port_sg)
valid_groups = set(g.id for g in sg_objs valid_groups = set(
if not tenant_id or g.tenant_id == tenant_id or g.id for g in sg_objs
sg_obj.SecurityGroup.is_shared_with_tenant(context, if (not tenant_id or g.tenant_id == tenant_id or
g.id, tenant_id)) sg_obj.SecurityGroup.is_shared_with_tenant(
context, g.id, tenant_id))
)
requested_groups = set(port_sg) requested_groups = set(port_sg)
port_sg_missing = requested_groups - valid_groups port_sg_missing = requested_groups - valid_groups

View File

@ -44,11 +44,10 @@ class ServiceTypeManager(object):
def get_service_providers(self, context, filters=None, fields=None): def get_service_providers(self, context, filters=None, fields=None):
if filters and 'service_type' in filters: if filters and 'service_type' in filters:
return list( return list(chain.from_iterable(
chain.from_iterable(self.config[svc_type]. self.config[svc_type].get_service_providers(filters, fields)
get_service_providers(filters, fields) for svc_type in filters['service_type']
for svc_type in filters['service_type'] if svc_type in self.config)
if svc_type in self.config)
) )
return list( return list(
chain.from_iterable( chain.from_iterable(
@ -76,7 +75,8 @@ class ServiceTypeManager(object):
def add_resource_association(self, context, service_type, provider_name, def add_resource_association(self, context, service_type, provider_name,
resource_id): resource_id):
r = self.get_service_providers(context, r = self.get_service_providers(context,
filters={'service_type': [service_type], 'name': [provider_name]}) filters={'service_type': [service_type],
'name': [provider_name]})
if not r: if not r:
raise pconf.ServiceProviderNotFound(provider=provider_name, raise pconf.ServiceProviderNotFound(provider=provider_name,
service_type=service_type) service_type=service_type)

View File

@ -20,7 +20,8 @@ class UplinkStatusPropagationMixin(object):
"""Mixin class to add uplink propagation to a port""" """Mixin class to add uplink propagation to a port"""
def _process_create_port(self, context, data, res): def _process_create_port(self, context, data, res):
obj = usp_obj.PortUplinkStatusPropagation(context, port_id=res['id'], obj = usp_obj.PortUplinkStatusPropagation(
context, port_id=res['id'],
propagate_uplink_status=data[usp.PROPAGATE_UPLINK_STATUS]) propagate_uplink_status=data[usp.PROPAGATE_UPLINK_STATUS])
obj.create() obj.create()
res[usp.PROPAGATE_UPLINK_STATUS] = data[usp.PROPAGATE_UPLINK_STATUS] res[usp.PROPAGATE_UPLINK_STATUS] = data[usp.PROPAGATE_UPLINK_STATUS]

View File

@ -58,12 +58,13 @@ validators.add_validator('type:validate_subnet_service_types',
EXTENDED_ATTRIBUTES_2_0 = { EXTENDED_ATTRIBUTES_2_0 = {
subnet_def.COLLECTION_NAME: { subnet_def.COLLECTION_NAME: {
'service_types': {'allow_post': True, 'service_types': {
'allow_put': True, 'allow_post': True,
'default': constants.ATTR_NOT_SPECIFIED, 'allow_put': True,
'validate': {'type:validate_subnet_service_types': 'default': constants.ATTR_NOT_SPECIFIED,
None}, 'validate': {'type:validate_subnet_service_types': None},
'is_visible': True, }, 'is_visible': True,
},
}, },
} }

View File

@ -64,8 +64,8 @@ class IpamSubnetManager(object):
:param context: neutron api request context :param context: neutron api request context
:param neutron_subnet_id: neutron subnet id associated with ipam subnet :param neutron_subnet_id: neutron subnet id associated with ipam subnet
""" """
return ipam_objs.IpamSubnet.delete_objects(context, return ipam_objs.IpamSubnet.delete_objects(
neutron_subnet_id=neutron_subnet_id) context, neutron_subnet_id=neutron_subnet_id)
def create_pool(self, context, pool_start, pool_end): def create_pool(self, context, pool_start, pool_end):
"""Create an allocation pool for the subnet. """Create an allocation pool for the subnet.

View File

@ -187,8 +187,8 @@ class NeutronDbSubnet(ipam_base.Subnet):
allocated_num_addresses = requested_num_addresses allocated_num_addresses = requested_num_addresses
if prefer_next: if prefer_next:
allocated_ip_pool = list(itertools.islice(av_set, allocated_ip_pool = list(itertools.islice(
allocated_num_addresses)) av_set, allocated_num_addresses))
allocated_ips.extend([str(allocated_ip) allocated_ips.extend([str(allocated_ip)
for allocated_ip in allocated_ip_pool]) for allocated_ip in allocated_ip_pool])

View File

@ -313,8 +313,8 @@ class SubnetPoolReader(object):
self._sp_helper.validate_max_prefixlen(self.max_prefixlen, self._sp_helper.validate_max_prefixlen(self.max_prefixlen,
ip_version) ip_version)
self._sp_helper.validate_default_prefixlen(self.min_prefixlen, self._sp_helper.validate_default_prefixlen(self.min_prefixlen,
self.max_prefixlen, self.max_prefixlen,
self.default_prefixlen) self.default_prefixlen)
def _read_prefix_bound(self, type, subnetpool, default_bound=None): def _read_prefix_bound(self, type, subnetpool, default_bound=None):
prefixlen_attr = type + '_prefixlen' prefixlen_attr = type + '_prefixlen'
@ -372,15 +372,15 @@ class SubnetPoolReader(object):
class SubnetPoolHelper(object): class SubnetPoolHelper(object):
_PREFIX_VERSION_INFO = {4: {'max_prefixlen': constants.IPv4_BITS, _PREFIX_VERSION_INFO = {4: {'max_prefixlen': constants.IPv4_BITS,
'wildcard': '0.0.0.0', 'wildcard': '0.0.0.0',
'default_min_prefixlen': 8, 'default_min_prefixlen': 8,
# IPv4 quota measured in units of /32 # IPv4 quota measured in units of /32
'quota_units': 32}, 'quota_units': 32},
6: {'max_prefixlen': constants.IPv6_BITS, 6: {'max_prefixlen': constants.IPv6_BITS,
'wildcard': '::', 'wildcard': '::',
'default_min_prefixlen': 64, 'default_min_prefixlen': 64,
# IPv6 quota measured in units of /64 # IPv6 quota measured in units of /64
'quota_units': 64}} 'quota_units': 64}}
def validate_min_prefixlen(self, min_prefixlen, max_prefixlen): def validate_min_prefixlen(self, min_prefixlen, max_prefixlen):
if min_prefixlen < 0: if min_prefixlen < 0:

View File

@ -62,5 +62,5 @@ class RouterL3AgentBinding(base.NeutronDbObject):
l3_attrs.RouterExtraAttributes.ha == sql.false(), l3_attrs.RouterExtraAttributes.ha == sql.false(),
l3_attrs.RouterExtraAttributes.ha == sql.null()))) l3_attrs.RouterExtraAttributes.ha == sql.null())))
bindings = [cls._load_object(context, db_obj) for db_obj in bindings = [cls._load_object(context, db_obj) for db_obj in
query.all()] query.all()]
return bindings return bindings

View File

@ -292,8 +292,8 @@ class Network(rbac_db.NeutronRbacObject):
def _set_dns_domain(self, dns_domain): def _set_dns_domain(self, dns_domain):
NetworkDNSDomain.delete_objects(self.obj_context, network_id=self.id) NetworkDNSDomain.delete_objects(self.obj_context, network_id=self.id)
if dns_domain: if dns_domain:
NetworkDNSDomain(self.obj_context, NetworkDNSDomain(self.obj_context, network_id=self.id,
network_id=self.id, dns_domain=dns_domain).create() dns_domain=dns_domain).create()
self.dns_domain = dns_domain self.dns_domain = dns_domain
self.obj_reset_changes(['dns_domain']) self.obj_reset_changes(['dns_domain'])

View File

@ -198,14 +198,14 @@ class IPAllocation(base.NeutronDbObject):
# incorrect results # incorrect results
if exclude: if exclude:
alloc_db = (context.session.query(models_v2.IPAllocation). alloc_db = (context.session.query(models_v2.IPAllocation).
filter_by(subnet_id=subnet_id).join(models_v2.Port). filter_by(subnet_id=subnet_id).join(models_v2.Port).
filter(~models_v2.Port.device_owner. filter(~models_v2.Port.device_owner.
in_(device_owner)).first()) in_(device_owner)).first())
else: else:
alloc_db = (context.session.query(models_v2.IPAllocation). alloc_db = (context.session.query(models_v2.IPAllocation).
filter_by(subnet_id=subnet_id).join(models_v2.Port). filter_by(subnet_id=subnet_id).join(models_v2.Port).
filter(models_v2.Port.device_owner. filter(models_v2.Port.device_owner.
in_(device_owner)).first()) in_(device_owner)).first())
if exclude and alloc_db: if exclude and alloc_db:
return super(IPAllocation, cls)._load_object(context, alloc_db) return super(IPAllocation, cls)._load_object(context, alloc_db)
if alloc_db: if alloc_db:
@ -511,7 +511,7 @@ class Port(base.NeutronDbObject):
@classmethod @classmethod
def get_ports_ids_by_security_groups(cls, context, security_group_ids, def get_ports_ids_by_security_groups(cls, context, security_group_ids,
excluded_device_owners=None): excluded_device_owners=None):
query = context.session.query(sg_models.SecurityGroupPortBinding) query = context.session.query(sg_models.SecurityGroupPortBinding)
query = query.filter( query = query.filter(
sg_models.SecurityGroupPortBinding.security_group_id.in_( sg_models.SecurityGroupPortBinding.security_group_id.in_(

View File

@ -279,13 +279,16 @@ class FloatingIP(base.NeutronDbObject):
def get_scoped_floating_ips(cls, context, router_ids): def get_scoped_floating_ips(cls, context, router_ids):
query = context.session.query(l3.FloatingIP, query = context.session.query(l3.FloatingIP,
models_v2.SubnetPool.address_scope_id) models_v2.SubnetPool.address_scope_id)
query = query.join(models_v2.Port, query = query.join(
models_v2.Port,
l3.FloatingIP.fixed_port_id == models_v2.Port.id) l3.FloatingIP.fixed_port_id == models_v2.Port.id)
# Outer join of Subnet can cause each ip to have more than one row. # Outer join of Subnet can cause each ip to have more than one row.
query = query.outerjoin(models_v2.Subnet, query = query.outerjoin(
models_v2.Subnet,
models_v2.Subnet.network_id == models_v2.Port.network_id) models_v2.Subnet.network_id == models_v2.Port.network_id)
query = query.filter(models_v2.Subnet.ip_version == 4) query = query.filter(models_v2.Subnet.ip_version == 4)
query = query.outerjoin(models_v2.SubnetPool, query = query.outerjoin(
models_v2.SubnetPool,
models_v2.Subnet.subnetpool_id == models_v2.SubnetPool.id) models_v2.Subnet.subnetpool_id == models_v2.SubnetPool.id)
# Filter out on router_ids # Filter out on router_ids

View File

@ -60,19 +60,22 @@ def _apply_tag_filters(model, query, filters):
if 'tags' in filters: if 'tags' in filters:
tags = _get_tag_list(filters.pop('tags')) tags = _get_tag_list(filters.pop('tags'))
first_tag = tags.pop(0) first_tag = tags.pop(0)
query = query.join(tag_model.Tag, query = query.join(
tag_model.Tag,
model.standard_attr_id == tag_model.Tag.standard_attr_id) model.standard_attr_id == tag_model.Tag.standard_attr_id)
query = query.filter(tag_model.Tag.tag == first_tag) query = query.filter(tag_model.Tag.tag == first_tag)
for tag in tags: for tag in tags:
tag_alias = aliased(tag_model.Tag) tag_alias = aliased(tag_model.Tag)
query = query.join(tag_alias, query = query.join(
tag_alias,
model.standard_attr_id == tag_alias.standard_attr_id) model.standard_attr_id == tag_alias.standard_attr_id)
query = query.filter(tag_alias.tag == tag) query = query.filter(tag_alias.tag == tag)
if 'tags-any' in filters: if 'tags-any' in filters:
tags = _get_tag_list(filters.pop('tags-any')) tags = _get_tag_list(filters.pop('tags-any'))
query = query.join(tag_model.Tag, query = query.join(
tag_model.Tag,
model.standard_attr_id == tag_model.Tag.standard_attr_id) model.standard_attr_id == tag_model.Tag.standard_attr_id)
query = query.filter(tag_model.Tag.tag.in_(tags)) query = query.filter(tag_model.Tag.tag.in_(tags))
@ -84,7 +87,8 @@ def _apply_tag_filters(model, query, filters):
for tag in tags: for tag in tags:
tag_alias = aliased(tag_model.Tag) tag_alias = aliased(tag_model.Tag)
subq = subq.join(tag_alias, subq = subq.join(
tag_alias,
tag_model.Tag.standard_attr_id == tag_alias.standard_attr_id) tag_model.Tag.standard_attr_id == tag_alias.standard_attr_id)
subq = subq.filter(tag_alias.tag == tag) subq = subq.filter(tag_alias.tag == tag)

View File

@ -23,5 +23,5 @@ class ContextHook(hooks.PecanHook):
def before(self, state): def before(self, state):
ctx = (state.request.environ.get('neutron.context') or ctx = (state.request.environ.get('neutron.context') or
context.get_admin_context()) context.get_admin_context())
state.request.context['neutron_context'] = ctx state.request.context['neutron_context'] = ctx

View File

@ -29,8 +29,8 @@ class ExceptionTranslationHook(hooks.PecanHook):
language = None language = None
if state.request.accept_language: if state.request.accept_language:
all_languages = oslo_i18n.get_available_languages('neutron') all_languages = oslo_i18n.get_available_languages('neutron')
language = state.request.accept_language.lookup(all_languages, language = state.request.accept_language.lookup(
default='fake_LANG') all_languages, default='fake_LANG')
if language == 'fake_LANG': if language == 'fake_LANG':
language = None language = None
exc = api_common.convert_exception_to_http_exc(e, faults.FAULT_MAP, exc = api_common.convert_exception_to_http_exc(e, faults.FAULT_MAP,

View File

@ -264,7 +264,8 @@ def generate_distributed_port_status(context, port_id):
def get_distributed_port_binding_by_host(context, port_id, host): def get_distributed_port_binding_by_host(context, port_id, host):
with db_api.CONTEXT_READER.using(context): with db_api.CONTEXT_READER.using(context):
binding = (context.session.query(models.DistributedPortBinding). binding = (
context.session.query(models.DistributedPortBinding).
filter(models.DistributedPortBinding.port_id.startswith(port_id), filter(models.DistributedPortBinding.port_id.startswith(port_id),
models.DistributedPortBinding.host == host).first()) models.DistributedPortBinding.host == host).first())
if not binding: if not binding:

View File

@ -152,8 +152,8 @@ class SegmentTypeDriver(BaseTypeDriver):
if count: if count:
LOG.debug("%(type)s segment %(segment)s allocate " LOG.debug("%(type)s segment %(segment)s allocate "
"done ", "done ",
{"type": network_type, {"type": network_type,
"segment": raw_segment}) "segment": raw_segment})
return alloc return alloc
# Segment allocated or deleted since select # Segment allocated or deleted since select

View File

@ -74,7 +74,8 @@ def get_agent_by_host(context, agent_host):
def _get_active_network_ports(context, network_id): def _get_active_network_ports(context, network_id):
query = context.session.query(ml2_models.PortBinding, query = context.session.query(ml2_models.PortBinding,
agent_model.Agent) agent_model.Agent)
query = query.join(agent_model.Agent, query = query.join(
agent_model.Agent,
agent_model.Agent.host == ml2_models.PortBinding.host) agent_model.Agent.host == ml2_models.PortBinding.host)
query = query.join(models_v2.Port) query = query.join(models_v2.Port)
query = query.options(orm.subqueryload(ml2_models.PortBinding.port)) query = query.options(orm.subqueryload(ml2_models.PortBinding.port))
@ -85,7 +86,8 @@ def _get_active_network_ports(context, network_id):
def _ha_router_interfaces_on_network_query(context, network_id): def _ha_router_interfaces_on_network_query(context, network_id):
query = context.session.query(models_v2.Port) query = context.session.query(models_v2.Port)
query = query.join(l3ha_model.L3HARouterAgentPortBinding, query = query.join(
l3ha_model.L3HARouterAgentPortBinding,
l3ha_model.L3HARouterAgentPortBinding.router_id == l3ha_model.L3HARouterAgentPortBinding.router_id ==
models_v2.Port.device_id) models_v2.Port.device_id)
return query.filter( return query.filter(

View File

@ -90,7 +90,7 @@ class L2populationMechanismDriver(api.MechanismDriver):
fdb_entries[network_id]['ports'] = other_fdb_ports fdb_entries[network_id]['ports'] = other_fdb_ports
self.L2populationAgentNotify.remove_fdb_entries(self.rpc_ctx, self.L2populationAgentNotify.remove_fdb_entries(self.rpc_ctx,
fdb_entries) fdb_entries)
def filter_hosts_with_segment_access( def filter_hosts_with_segment_access(
self, context, segments, candidate_hosts, agent_getter): self, context, segments, candidate_hosts, agent_getter):

View File

@ -522,8 +522,9 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
ctx.reraise = False ctx.reraise = False
return False return False
def _add_tap_interface(self, network_id, network_type, physical_network, def _add_tap_interface(self, network_id,
segmentation_id, tap_device_name, device_owner, mtu): network_type, physical_network, segmentation_id,
tap_device_name, device_owner, mtu):
"""Add tap interface. """Add tap interface.
If a VIF has been plugged into a network, this function will If a VIF has been plugged into a network, this function will

View File

@ -380,7 +380,8 @@ class ESwitchManager(object):
# We don't know about this device at the moment, so add to the map. # We don't know about this device at the moment, so add to the map.
if PciOsWrapper.pf_device_exists(dev_name): if PciOsWrapper.pf_device_exists(dev_name):
self._create_emb_switch(phys_net, dev_name, self._create_emb_switch(
phys_net, dev_name,
exclude_devices.get(dev_name, set())) exclude_devices.get(dev_name, set()))
def discover_devices(self, device_mappings, exclude_devices): def discover_devices(self, device_mappings, exclude_devices):
@ -426,7 +427,8 @@ class ESwitchManager(object):
Clear the "rate" configuration from VF by setting it to 0. Clear the "rate" configuration from VF by setting it to 0.
@param pci_slot: VF PCI slot @param pci_slot: VF PCI slot
""" """
self._clear_rate(pci_slot, self._clear_rate(
pci_slot,
ip_link_support.IpLinkConstants.IP_LINK_CAPABILITY_RATE) ip_link_support.IpLinkConstants.IP_LINK_CAPABILITY_RATE)
def clear_min_tx_rate(self, pci_slot): def clear_min_tx_rate(self, pci_slot):
@ -435,7 +437,8 @@ class ESwitchManager(object):
Clear the "min_tx_rate" configuration from VF by setting it to 0. Clear the "min_tx_rate" configuration from VF by setting it to 0.
@param pci_slot: VF PCI slot @param pci_slot: VF PCI slot
""" """
self._clear_rate(pci_slot, self._clear_rate(
pci_slot,
ip_link_support.IpLinkConstants.IP_LINK_CAPABILITY_MIN_TX_RATE) ip_link_support.IpLinkConstants.IP_LINK_CAPABILITY_MIN_TX_RATE)
def _clear_rate(self, pci_slot, rate_type): def _clear_rate(self, pci_slot, rate_type):

View File

@ -153,8 +153,8 @@ class SriovNicSwitchAgent(object):
self.context = context.get_admin_context_without_session() self.context = context.get_admin_context_without_session()
self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN) self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
self.sg_agent = agent_sg_rpc.SecurityGroupAgentRpc(self.context, self.sg_agent = agent_sg_rpc.SecurityGroupAgentRpc(
self.sg_plugin_rpc) self.context, self.sg_plugin_rpc)
self._setup_rpc() self._setup_rpc()
self.ext_manager = self._create_agent_extension_manager( self.ext_manager = self._create_agent_extension_manager(
self.connection) self.connection)

View File

@ -35,16 +35,16 @@ class OVSDVRProcessMixin(object):
def install_dvr_process_ipv4(self, vlan_tag, gateway_ip): def install_dvr_process_ipv4(self, vlan_tag, gateway_ip):
# block ARP # block ARP
(_dp, ofp, ofpp) = self._get_dp() (_dp, ofp, ofpp) = self._get_dp()
match = self._dvr_process_ipv4_match(ofp, ofpp, match = self._dvr_process_ipv4_match(ofp, ofpp, vlan_tag=vlan_tag,
vlan_tag=vlan_tag, gateway_ip=gateway_ip) gateway_ip=gateway_ip)
self.install_drop(table_id=self.dvr_process_table_id, self.install_drop(table_id=self.dvr_process_table_id,
priority=3, priority=3,
match=match) match=match)
def delete_dvr_process_ipv4(self, vlan_tag, gateway_ip): def delete_dvr_process_ipv4(self, vlan_tag, gateway_ip):
(_dp, ofp, ofpp) = self._get_dp() (_dp, ofp, ofpp) = self._get_dp()
match = self._dvr_process_ipv4_match(ofp, ofpp, match = self._dvr_process_ipv4_match(ofp, ofpp, vlan_tag=vlan_tag,
vlan_tag=vlan_tag, gateway_ip=gateway_ip) gateway_ip=gateway_ip)
self.uninstall_flows(table_id=self.dvr_process_table_id, self.uninstall_flows(table_id=self.dvr_process_table_id,
match=match) match=match)
@ -59,15 +59,15 @@ class OVSDVRProcessMixin(object):
def install_dvr_process_ipv6(self, vlan_tag, gateway_mac): def install_dvr_process_ipv6(self, vlan_tag, gateway_mac):
# block RA # block RA
(_dp, ofp, ofpp) = self._get_dp() (_dp, ofp, ofpp) = self._get_dp()
match = self._dvr_process_ipv6_match(ofp, ofpp, match = self._dvr_process_ipv6_match(ofp, ofpp, vlan_tag=vlan_tag,
vlan_tag=vlan_tag, gateway_mac=gateway_mac) gateway_mac=gateway_mac)
self.install_drop(table_id=self.dvr_process_table_id, priority=3, self.install_drop(table_id=self.dvr_process_table_id, priority=3,
match=match) match=match)
def delete_dvr_process_ipv6(self, vlan_tag, gateway_mac): def delete_dvr_process_ipv6(self, vlan_tag, gateway_mac):
(_dp, ofp, ofpp) = self._get_dp() (_dp, ofp, ofpp) = self._get_dp()
match = self._dvr_process_ipv6_match(ofp, ofpp, match = self._dvr_process_ipv6_match(ofp, ofpp, vlan_tag=vlan_tag,
vlan_tag=vlan_tag, gateway_mac=gateway_mac) gateway_mac=gateway_mac)
self.uninstall_flows(table_id=self.dvr_process_table_id, self.uninstall_flows(table_id=self.dvr_process_table_id,
match=match) match=match)

View File

@ -58,9 +58,10 @@ class OVSPhysicalBridge(ovs_bridge.OVSAgentBridge,
def add_dvr_mac_vlan(self, mac, port): def add_dvr_mac_vlan(self, mac, port):
self.install_output(table_id=constants.DVR_NOT_LEARN_VLAN, self.install_output(table_id=constants.DVR_NOT_LEARN_VLAN,
priority=2, eth_src=mac, port=port) priority=2, eth_src=mac, port=port)
def remove_dvr_mac_vlan(self, mac): def remove_dvr_mac_vlan(self, mac):
# REVISIT(yamamoto): match in_port as well? # REVISIT(yamamoto): match in_port as well?
self.uninstall_flows(table_id=constants.DVR_NOT_LEARN_VLAN, self.uninstall_flows(
table_id=constants.DVR_NOT_LEARN_VLAN,
eth_src=mac) eth_src=mac)

View File

@ -52,7 +52,7 @@ class OVSPhysicalBridge(ovs_bridge.OVSAgentBridge,
def add_dvr_mac_vlan(self, mac, port): def add_dvr_mac_vlan(self, mac, port):
self.install_output(table_id=constants.DVR_NOT_LEARN_VLAN, self.install_output(table_id=constants.DVR_NOT_LEARN_VLAN,
priority=2, eth_src=mac, port=port) priority=2, eth_src=mac, port=port)
def remove_dvr_mac_vlan(self, mac): def remove_dvr_mac_vlan(self, mac):
# REVISIT(yamamoto): match in_port as well? # REVISIT(yamamoto): match in_port as well?

View File

@ -68,7 +68,7 @@ class OVSTunnelBridge(ovs_bridge.OVSAgentBridge,
proto='arp', proto='arp',
dl_dst="ff:ff:ff:ff:ff:ff", dl_dst="ff:ff:ff:ff:ff:ff",
actions=("resubmit(,%s)" % actions=("resubmit(,%s)" %
constants.ARP_RESPONDER)) constants.ARP_RESPONDER))
# PATCH_LV_TO_TUN table will handle packets coming from patch_int # PATCH_LV_TO_TUN table will handle packets coming from patch_int
# unicasts go to table UCAST_TO_TUN where remote addresses are # unicasts go to table UCAST_TO_TUN where remote addresses are
@ -77,7 +77,7 @@ class OVSTunnelBridge(ovs_bridge.OVSAgentBridge,
priority=0, priority=0,
dl_dst="00:00:00:00:00:00/01:00:00:00:00:00", dl_dst="00:00:00:00:00:00/01:00:00:00:00:00",
actions=("resubmit(,%s)" % actions=("resubmit(,%s)" %
constants.UCAST_TO_TUN)) constants.UCAST_TO_TUN))
# Broadcasts/multicasts go to table FLOOD_TO_TUN that handles # Broadcasts/multicasts go to table FLOOD_TO_TUN that handles
# flooding # flooding
@ -85,7 +85,7 @@ class OVSTunnelBridge(ovs_bridge.OVSAgentBridge,
priority=0, priority=0,
dl_dst="01:00:00:00:00:00/01:00:00:00:00:00", dl_dst="01:00:00:00:00:00/01:00:00:00:00:00",
actions=("resubmit(,%s)" % actions=("resubmit(,%s)" %
constants.FLOOD_TO_TUN)) constants.FLOOD_TO_TUN))
# Tables [tunnel_type]_TUN_TO_LV will set lvid depending on tun_id # Tables [tunnel_type]_TUN_TO_LV will set lvid depending on tun_id
# for each tunnel type, and resubmit to table LEARN_FROM_TUN where # for each tunnel type, and resubmit to table LEARN_FROM_TUN where

View File

@ -193,7 +193,7 @@ class OVSDVRNeutronAgent(object):
"plugin: %r", details) "plugin: %r", details)
self.dvr_mac_address = ( self.dvr_mac_address = (
netaddr.EUI(details['mac_address'], netaddr.EUI(details['mac_address'],
dialect=netaddr.mac_unix_expanded)) dialect=netaddr.mac_unix_expanded))
return return
def setup_dvr_flows_on_integ_br(self): def setup_dvr_flows_on_integ_br(self):
@ -396,7 +396,7 @@ class OVSDVRNeutronAgent(object):
# the compute port is discovered first here that its on # the compute port is discovered first here that its on
# a dvr routed subnet queue this subnet to that port # a dvr routed subnet queue this subnet to that port
comp_ovsport = OVSPort(vif.vif_id, vif.ofport, comp_ovsport = OVSPort(vif.vif_id, vif.ofport,
vif.vif_mac, local_port['device_owner']) vif.vif_mac, local_port['device_owner'])
comp_ovsport.add_subnet(subnet_uuid) comp_ovsport.add_subnet(subnet_uuid)
self.local_ports[vif.vif_id] = comp_ovsport self.local_ports[vif.vif_id] = comp_ovsport
# create rule for just this vm port # create rule for just this vm port

View File

@ -948,7 +948,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
self.context, devices_up, devices_down, self.agent_id, self.context, devices_up, devices_down, self.agent_id,
self.conf.host) self.conf.host)
failed_devices = (devices_set.get('failed_devices_up') + failed_devices = (devices_set.get('failed_devices_up') +
devices_set.get('failed_devices_down')) devices_set.get('failed_devices_down'))
if failed_devices: if failed_devices:
LOG.error("Configuration for devices %s failed!", LOG.error("Configuration for devices %s failed!",
failed_devices) failed_devices)
@ -995,8 +995,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
# Install protection only when prefix is not zero because a /0 # Install protection only when prefix is not zero because a /0
# prefix allows any address anyway and the nd_target can only # prefix allows any address anyway and the nd_target can only
# match on /1 or more. # match on /1 or more.
bridge.install_icmpv6_na_spoofing_protection(port=vif.ofport, bridge.install_icmpv6_na_spoofing_protection(
ip_addresses=ipv6_addresses) port=vif.ofport, ip_addresses=ipv6_addresses)
ipv4_addresses = {ip for ip in addresses ipv4_addresses = {ip for ip in addresses
if netaddr.IPNetwork(ip).version == 4} if netaddr.IPNetwork(ip).version == 4}
@ -1222,8 +1222,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
# be same, so check only one of them. # be same, so check only one of them.
# Not logging error here, as the interface may not exist yet. # Not logging error here, as the interface may not exist yet.
# Type check is done to cleanup wrong interface if any. # Type check is done to cleanup wrong interface if any.
int_type = self.int_br.db_get_val("Interface", int_type = self.int_br.db_get_val("Interface", int_if_name, "type",
int_if_name, "type", log_errors=False) log_errors=False)
if self.use_veth_interconnection: if self.use_veth_interconnection:
# Drop ports if the interface types doesn't match the # Drop ports if the interface types doesn't match the
# configuration value. # configuration value.
@ -1444,7 +1444,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
self._update_port_info_failed_devices_stats(port_info, failed_devices) self._update_port_info_failed_devices_stats(port_info, failed_devices)
self._update_port_info_failed_devices_stats(ancillary_port_info, self._update_port_info_failed_devices_stats(ancillary_port_info,
failed_ancillary_devices) failed_ancillary_devices)
if updated_ports is None: if updated_ports is None:
updated_ports = set() updated_ports = set()
@ -1974,9 +1974,9 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
bridge.cleanup_flows() bridge.cleanup_flows()
def process_port_info(self, start, polling_manager, sync, ovs_restarted, def process_port_info(self, start, polling_manager, sync, ovs_restarted,
ports, ancillary_ports, updated_ports_copy, ports, ancillary_ports, updated_ports_copy,
consecutive_resyncs, ports_not_ready_yet, consecutive_resyncs, ports_not_ready_yet,
failed_devices, failed_ancillary_devices): failed_devices, failed_ancillary_devices):
# There are polling managers that don't have get_events, e.g. # There are polling managers that don't have get_events, e.g.
# AlwaysPoll used by windows implementations # AlwaysPoll used by windows implementations
# REVISIT (rossella_s) This needs to be reworked to hide implementation # REVISIT (rossella_s) This needs to be reworked to hide implementation
@ -1999,7 +1999,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
# TODO(rossella_s): For implementations that use AlwaysPoll # TODO(rossella_s): For implementations that use AlwaysPoll
# resync if a device failed. This can be improved in future # resync if a device failed. This can be improved in future
sync = (any(failed_devices.values()) or sync = (any(failed_devices.values()) or
any(failed_ancillary_devices.values())) any(failed_ancillary_devices.values()))
# NOTE(rossella_s) don't empty the queue of events # NOTE(rossella_s) don't empty the queue of events
# calling polling_manager.get_events() since # calling polling_manager.get_events() since
@ -2109,9 +2109,9 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
self._report_state() self._report_state()
if self.enable_distributed_routing: if self.enable_distributed_routing:
self.dvr_agent.reset_ovs_parameters(self.int_br, self.dvr_agent.reset_ovs_parameters(self.int_br,
self.tun_br, self.tun_br,
self.patch_int_ofport, self.patch_int_ofport,
self.patch_tun_ofport) self.patch_tun_ofport)
self.dvr_agent.reset_dvr_parameters() self.dvr_agent.reset_dvr_parameters()
self.dvr_agent.setup_dvr_flows() self.dvr_agent.setup_dvr_flows()
# notify that OVS has restarted # notify that OVS has restarted
@ -2178,8 +2178,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
tunnel_sync = True tunnel_sync = True
ovs_restarted |= (ovs_status == constants.OVS_RESTARTED) ovs_restarted |= (ovs_status == constants.OVS_RESTARTED)
devices_need_retry = (any(failed_devices.values()) or devices_need_retry = (any(failed_devices.values()) or
any(failed_ancillary_devices.values()) or any(failed_ancillary_devices.values()) or
ports_not_ready_yet) ports_not_ready_yet)
if (self._agent_has_updates(polling_manager) or sync or if (self._agent_has_updates(polling_manager) or sync or
devices_need_retry): devices_need_retry):
try: try:

View File

@ -55,9 +55,11 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
def __init__(self): def __init__(self):
sg_enabled = securitygroups_rpc.is_firewall_enabled() sg_enabled = securitygroups_rpc.is_firewall_enabled()
hybrid_plug_required = (not cfg.CONF.SECURITYGROUP.firewall_driver or hybrid_plug_required = (
not cfg.CONF.SECURITYGROUP.firewall_driver or
cfg.CONF.SECURITYGROUP.firewall_driver in ( cfg.CONF.SECURITYGROUP.firewall_driver in (
IPTABLES_FW_DRIVER_FULL, 'iptables_hybrid')) and sg_enabled IPTABLES_FW_DRIVER_FULL, 'iptables_hybrid')
) and sg_enabled
vif_details = {portbindings.CAP_PORT_FILTER: sg_enabled, vif_details = {portbindings.CAP_PORT_FILTER: sg_enabled,
portbindings.OVS_HYBRID_PLUG: hybrid_plug_required} portbindings.OVS_HYBRID_PLUG: hybrid_plug_required}
# NOTE(moshele): Bind DIRECT (SR-IOV) port allows # NOTE(moshele): Bind DIRECT (SR-IOV) port allows
@ -163,9 +165,10 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
if bridge_name: if bridge_name:
vif_details[portbindings.VIF_DETAILS_BRIDGE_NAME] = bridge_name vif_details[portbindings.VIF_DETAILS_BRIDGE_NAME] = bridge_name
registry.publish(a_const.OVS_BRIDGE_NAME, events.BEFORE_READ, registry.publish(
set_bridge_name_inner, payload=events.EventPayload( a_const.OVS_BRIDGE_NAME, events.BEFORE_READ,
None, metadata={'port': port})) set_bridge_name_inner,
payload=events.EventPayload(None, metadata={'port': port}))
def _pre_get_vif_details(self, agent, context): def _pre_get_vif_details(self, agent, context):
a_config = agent['configurations'] a_config = agent['configurations']

View File

@ -550,8 +550,8 @@ class TunnelRpcCallbackMixin(object):
host, ip_endpoint.ip_address) host, ip_endpoint.ip_address)
elif (host_endpoint and host_endpoint.ip_address != tunnel_ip): elif (host_endpoint and host_endpoint.ip_address != tunnel_ip):
# Notify all other listening agents to delete stale tunnels # Notify all other listening agents to delete stale tunnels
self._notifier.tunnel_delete(rpc_context, self._notifier.tunnel_delete(
host_endpoint.ip_address, tunnel_type) rpc_context, host_endpoint.ip_address, tunnel_type)
driver.obj.delete_endpoint(host_endpoint.ip_address) driver.obj.delete_endpoint(host_endpoint.ip_address)
tunnel = driver.obj.add_endpoint(tunnel_ip, host) tunnel = driver.obj.add_endpoint(tunnel_ip, host)

View File

@ -139,9 +139,11 @@ class DNSExtensionDriver(api.ExtensionDriver):
plugin_context, plugin_context,
port_id=db_data['id']) port_id=db_data['id'])
if dns_data_db: if dns_data_db:
is_dns_name_changed = (dns_name is not None and is_dns_name_changed = (
dns_data_db[dns_apidef.DNSNAME] != dns_name) dns_name is not None and
is_dns_domain_changed = (dns_domain is not None and dns_data_db[dns_apidef.DNSNAME] != dns_name)
is_dns_domain_changed = (
dns_domain is not None and
dns_data_db[dns_apidef.DNSDOMAIN] != dns_domain) dns_data_db[dns_apidef.DNSDOMAIN] != dns_domain)
if (is_dns_name_changed or is_dns_domain_changed or if (is_dns_name_changed or is_dns_domain_changed or
(has_fixed_ips and dns_data_db['current_dns_name'])): (has_fixed_ips and dns_data_db['current_dns_name'])):
@ -159,8 +161,8 @@ class DNSExtensionDriver(api.ExtensionDriver):
dns_data_db.update() dns_data_db.update()
return dns_data_db return dns_data_db
if dns_name or dns_domain: if dns_name or dns_domain:
dns_data_db = self._create_port_dns_record(plugin_context, dns_data_db = self._create_port_dns_record(
request_data, db_data, network, dns_name or '') plugin_context, request_data, db_data, network, dns_name or '')
return dns_data_db return dns_data_db
def _populate_previous_external_dns_data(self, dns_data_db): def _populate_previous_external_dns_data(self, dns_data_db):

View File

@ -1371,8 +1371,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
if self._check_update_has_allowed_address_pairs(port): if self._check_update_has_allowed_address_pairs(port):
# has address pairs in request # has address pairs in request
raise addr_exc.AddressPairAndPortSecurityRequired() raise addr_exc.AddressPairAndPortSecurityRequired()
elif (not elif not self._check_update_deletes_allowed_address_pairs(port):
self._check_update_deletes_allowed_address_pairs(port)):
# not a request for deleting the address-pairs # not a request for deleting the address-pairs
updated_port[addr_apidef.ADDRESS_PAIRS] = ( updated_port[addr_apidef.ADDRESS_PAIRS] = (
self.get_allowed_address_pairs(context, id)) self.get_allowed_address_pairs(context, id))
@ -1386,8 +1385,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
# security groups, port security is set # security groups, port security is set
if self._check_update_has_security_groups(port): if self._check_update_has_security_groups(port):
raise psec_exc.PortSecurityAndIPRequiredForSecurityGroups() raise psec_exc.PortSecurityAndIPRequiredForSecurityGroups()
elif (not elif not self._check_update_deletes_security_groups(port):
self._check_update_deletes_security_groups(port)):
if not extensions.is_extension_supported(self, 'security-group'): if not extensions.is_extension_supported(self, 'security-group'):
return return
# Update did not have security groups passed in. Check # Update did not have security groups passed in. Check
@ -1578,7 +1576,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
id, host) id, host)
device_id = attrs and attrs.get('device_id') device_id = attrs and attrs.get('device_id')
router_id = binding and binding.get('router_id') router_id = binding and binding.get('router_id')
update_required = (not binding or update_required = (
not binding or
binding.vif_type == portbindings.VIF_TYPE_BINDING_FAILED or binding.vif_type == portbindings.VIF_TYPE_BINDING_FAILED or
router_id != device_id) router_id != device_id)
if update_required: if update_required:
@ -1591,8 +1590,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
network = self.get_network(context, network = self.get_network(context,
orig_port['network_id']) orig_port['network_id'])
levels = db.get_binding_level_objs(context, id, host) levels = db.get_binding_level_objs(context, id, host)
mech_context = driver_context.PortContext(self, mech_context = driver_context.PortContext(
context, orig_port, network, self, context, orig_port, network,
binding, levels, original_port=orig_port) binding, levels, original_port=orig_port)
self._process_distributed_port_binding( self._process_distributed_port_binding(
mech_context, context, attrs) mech_context, context, attrs)
@ -2059,7 +2058,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
# change in segments could affect resulting network mtu, so let's # change in segments could affect resulting network mtu, so let's
# recalculate it # recalculate it
network_db = self._get_network(context, network_id) network_db = self._get_network(context, network_id)
network_db.mtu = self._get_network_mtu(network_db, network_db.mtu = self._get_network_mtu(
network_db,
validate=(event != events.PRECOMMIT_DELETE)) validate=(event != events.PRECOMMIT_DELETE))
network_db.save(session=context.session) network_db.save(session=context.session)

View File

@ -95,7 +95,7 @@ ATTR_POSITIONS = {
'icmp': [('type', 6), ('code', 7), ('src', 4), ('dst', 5), ('id', 8), 'icmp': [('type', 6), ('code', 7), ('src', 4), ('dst', 5), ('id', 8),
('zone', 16)], ('zone', 16)],
'icmpv6': [('type', 6), ('code', 7), ('src', 4), ('dst', 5), ('id', 8), 'icmpv6': [('type', 6), ('code', 7), ('src', 4), ('dst', 5), ('id', 8),
('zone', 16)], ('zone', 16)],
'tcp': [('sport', 7), ('dport', 8), ('src', 5), ('dst', 6), ('zone', 15)], 'tcp': [('sport', 7), ('dport', 8), ('src', 5), ('dst', 6), ('zone', 15)],
'udp': [('sport', 6), ('dport', 7), ('src', 4), ('dst', 5), ('zone', 14)] 'udp': [('sport', 6), ('dport', 7), ('src', 4), ('dst', 5), ('zone', 14)]
} }

View File

@ -96,7 +96,7 @@ class ConfDriver(object):
if quotas[key] >= 0 and quotas[key] < val] if quotas[key] >= 0 and quotas[key] < val]
if overs: if overs:
raise exceptions.OverQuota(overs=sorted(overs), quotas=quotas, raise exceptions.OverQuota(overs=sorted(overs), quotas=quotas,
usages={}) usages={})
@staticmethod @staticmethod
def get_tenant_quotas(context, resources, tenant_id): def get_tenant_quotas(context, resources, tenant_id):

View File

@ -73,5 +73,5 @@ class BaseWeightScheduler(BaseScheduler):
def select(self, plugin, context, resource_hostable_agents, def select(self, plugin, context, resource_hostable_agents,
resource_hosted_agents, num_agents_needed): resource_hosted_agents, num_agents_needed):
chosen_agents = sorted(resource_hostable_agents, chosen_agents = sorted(resource_hostable_agents,
key=attrgetter('load'))[0:num_agents_needed] key=attrgetter('load'))[0:num_agents_needed]
return chosen_agents return chosen_agents

View File

@ -176,8 +176,9 @@ class DhcpFilter(base_resource_filter.BaseResourceFilter):
# DetachedInstanceError # DetachedInstanceError
agent_id = agent.id agent_id = agent.id
try: try:
network.NetworkDhcpAgentBinding(context, network.NetworkDhcpAgentBinding(
dhcp_agent_id=agent_id, network_id=network_id).create() context, dhcp_agent_id=agent_id,
network_id=network_id).create()
except exceptions.NeutronDbObjectDuplicateEntry: except exceptions.NeutronDbObjectDuplicateEntry:
# it's totally ok, someone just did our job! # it's totally ok, someone just did our job!
bound_agents.remove(agent) bound_agents.remove(agent)

View File

@ -66,8 +66,8 @@ def _ensure_external_network_default_value_callback(
if is_default: if is_default:
# ensure only one default external network at any given time # ensure only one default external network at any given time
pager = base_obj.Pager(limit=1) pager = base_obj.Pager(limit=1)
objs = net_obj.ExternalNetwork.get_objects(context, objs = net_obj.ExternalNetwork.get_objects(context, _pager=pager,
_pager=pager, is_default=True) is_default=True)
if objs: if objs:
if objs[0] and network['id'] != objs[0].network_id: if objs[0] and network['id'] != objs[0].network_id:
raise exceptions.DefaultExternalNetworkExists( raise exceptions.DefaultExternalNetworkExists(
@ -96,9 +96,9 @@ class AutoAllocatedTopologyMixin(common_db_mixin.CommonDbMixin):
new = super(AutoAllocatedTopologyMixin, cls).__new__(cls, *args, new = super(AutoAllocatedTopologyMixin, cls).__new__(cls, *args,
**kwargs) **kwargs)
registry.subscribe(_ensure_external_network_default_value_callback, registry.subscribe(_ensure_external_network_default_value_callback,
resources.NETWORK, events.PRECOMMIT_UPDATE) resources.NETWORK, events.PRECOMMIT_UPDATE)
registry.subscribe(_ensure_external_network_default_value_callback, registry.subscribe(_ensure_external_network_default_value_callback,
resources.NETWORK, events.PRECOMMIT_CREATE) resources.NETWORK, events.PRECOMMIT_CREATE)
return new return new
# TODO(armax): if a tenant modifies auto allocated resources under # TODO(armax): if a tenant modifies auto allocated resources under
@ -145,7 +145,7 @@ class AutoAllocatedTopologyMixin(common_db_mixin.CommonDbMixin):
return self._check_requirements(context, tenant_id) return self._check_requirements(context, tenant_id)
elif fields: elif fields:
raise n_exc.BadRequest(resource='auto_allocate', raise n_exc.BadRequest(resource='auto_allocate',
msg=_("Unrecognized field")) msg=_("Unrecognized field"))
# Check for an existent topology # Check for an existent topology
network_id = self._get_auto_allocated_network(context, tenant_id) network_id = self._get_auto_allocated_network(context, tenant_id)
@ -335,8 +335,8 @@ class AutoAllocatedTopologyMixin(common_db_mixin.CommonDbMixin):
{'tenant_id': tenant_id, 'reason': e}) {'tenant_id': tenant_id, 'reason': e})
router_id = router['id'] if router else None router_id = router['id'] if router else None
self._cleanup(context, self._cleanup(context,
network_id=subnets[0]['network_id'], network_id=subnets[0]['network_id'],
router_id=router_id, subnets=attached_subnets) router_id=router_id, subnets=attached_subnets)
raise exceptions.AutoAllocationFailure( raise exceptions.AutoAllocationFailure(
reason=_("Unable to provide external connectivity")) reason=_("Unable to provide external connectivity"))
except Exception as e: except Exception as e:

View File

@ -45,8 +45,9 @@ class NetworkIPAvailabilityPlugin(ip_availability_db.IpAvailabilityMixin,
def get_network_ip_availabilities(self, context, filters=None, def get_network_ip_availabilities(self, context, filters=None,
fields=None): fields=None):
"""Returns ip availability data for a collection of networks.""" """Returns ip availability data for a collection of networks."""
net_ip_availabilities = super(NetworkIPAvailabilityPlugin, net_ip_availabilities = super(
self).get_network_ip_availabilities(context, filters) NetworkIPAvailabilityPlugin, self
).get_network_ip_availabilities(context, filters)
return [db_utils.resource_fields(net_ip_availability, fields) return [db_utils.resource_fields(net_ip_availability, fields)
for net_ip_availability in net_ip_availabilities] for net_ip_availability in net_ip_availabilities]

View File

@ -214,7 +214,7 @@ class PlacementReporterAgents(object):
for driver in self._mechanism_drivers for driver in self._mechanism_drivers
if driver.obj.resource_provider_uuid5_namespace is not None] if driver.obj.resource_provider_uuid5_namespace is not None]
LOG.debug('agent types supporting placement reports: %s', LOG.debug('agent types supporting placement reports: %s',
', '.join(self._supported_agent_types)) ', '.join(self._supported_agent_types))
return self._supported_agent_types return self._supported_agent_types
def mechanism_driver_by_agent_type(self, agent_type): def mechanism_driver_by_agent_type(self, agent_type):

View File

@ -414,7 +414,7 @@ class QoSPlugin(qos.QoSPluginBase):
@db_base_plugin_common.convert_result_to_dict @db_base_plugin_common.convert_result_to_dict
def update_policy_rule(self, context, rule_cls, rule_id, policy_id, def update_policy_rule(self, context, rule_cls, rule_id, policy_id,
rule_data): rule_data):
"""Update a QoS policy rule. """Update a QoS policy rule.
:param context: neutron api request context :param context: neutron api request context

View File

@ -349,7 +349,7 @@ class NovaSegmentNotifier(object):
segment_id=current_segment_ids) segment_id=current_segment_ids)
segment_ids = {s.segment_id for s in subnets} segment_ids = {s.segment_id for s in subnets}
self.batch_notifier.queue_event(Event(self._add_host_to_aggregate, self.batch_notifier.queue_event(Event(self._add_host_to_aggregate,
segment_ids, host=host)) segment_ids, host=host))
def _add_host_to_aggregate(self, event): def _add_host_to_aggregate(self, event):
for segment_id in event.segment_ids: for segment_id in event.segment_ids:
@ -379,8 +379,9 @@ class NovaSegmentNotifier(object):
if segment_id: if segment_id:
if event == events.AFTER_DELETE: if event == events.AFTER_DELETE:
ipv4_subnets_number = -ipv4_subnets_number ipv4_subnets_number = -ipv4_subnets_number
self.batch_notifier.queue_event(Event(self._update_nova_inventory, self.batch_notifier.queue_event(
segment_id, reserved=ipv4_subnets_number)) Event(self._update_nova_inventory,
segment_id, reserved=ipv4_subnets_number))
@registry.receives(resources.PORT, [events.AFTER_UPDATE]) @registry.receives(resources.PORT, [events.AFTER_UPDATE])
def _notify_port_updated(self, resource, event, trigger, context, def _notify_port_updated(self, resource, event, trigger, context,
@ -407,7 +408,7 @@ class NovaSegmentNotifier(object):
update = port_ipv4_subnets_number - original_port_ipv4_subnets_number update = port_ipv4_subnets_number - original_port_ipv4_subnets_number
if update: if update:
self.batch_notifier.queue_event(Event(self._update_nova_inventory, self.batch_notifier.queue_event(Event(self._update_nova_inventory,
segment_id, reserved=update)) segment_id, reserved=update))
def _get_ipv4_subnets_number_and_segment_id(self, port, context): def _get_ipv4_subnets_number_and_segment_id(self, port, context):
ipv4_subnet_ids = self._get_ipv4_subnet_ids(port) ipv4_subnet_ids = self._get_ipv4_subnet_ids(port)

View File

@ -103,7 +103,7 @@ class TagPlugin(common_db_mixin.CommonDbMixin, tagging.TagPluginBase):
return return
try: try:
tag_obj.Tag(context, standard_attr_id=res.standard_attr_id, tag_obj.Tag(context, standard_attr_id=res.standard_attr_id,
tag=tag).create() tag=tag).create()
except obj_exc.NeutronDbObjectDuplicateEntry: except obj_exc.NeutronDbObjectDuplicateEntry:
pass pass
@ -116,6 +116,6 @@ class TagPlugin(common_db_mixin.CommonDbMixin, tagging.TagPluginBase):
@log_helpers.log_method_call @log_helpers.log_method_call
def delete_tag(self, context, resource, resource_id, tag): def delete_tag(self, context, resource, resource_id, tag):
res = self._get_resource(context, resource, resource_id) res = self._get_resource(context, resource, resource_id)
if not tag_obj.Tag.delete_objects(context, if not tag_obj.Tag.delete_objects(
tag=tag, standard_attr_id=res.standard_attr_id): context, tag=tag, standard_attr_id=res.standard_attr_id):
raise tagging.TagNotFound(tag=tag) raise tagging.TagNotFound(tag=tag)

View File

@ -49,7 +49,7 @@ def get_patch_peer_attrs(peer_name, port_mac=None, port_id=None):
if port_id: if port_id:
external_ids['iface-id'] = port_id external_ids['iface-id'] = port_id
attrs = [('type', 'patch'), attrs = [('type', 'patch'),
('options', {'peer': peer_name})] ('options', {'peer': peer_name})]
if external_ids: if external_ids:
attrs.append( attrs.append(
('external_ids', external_ids)) ('external_ids', external_ids))

View File

@ -266,7 +266,7 @@ def router_append_subnet(router, count=1,
if interface_id: if interface_id:
try: try:
interface = next(i for i in interfaces interface = next(i for i in interfaces
if i['id'] == interface_id) if i['id'] == interface_id)
except StopIteration: except StopIteration:
raise ValueError("interface_id not found") raise ValueError("interface_id not found")

View File

@ -117,18 +117,19 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
extra_routes = False extra_routes = False
return l3_test_common.prepare_router_data(ip_version=ip_version, return l3_test_common.prepare_router_data(ip_version=ip_version,
enable_snat=enable_snat, enable_snat=enable_snat,
num_internal_ports=( num_internal_ports=(
num_internal_ports), num_internal_ports),
enable_floating_ip=enable_fip, enable_floating_ip=(
enable_ha=enable_ha, enable_fip),
extra_routes=extra_routes, enable_ha=enable_ha,
dual_stack=dual_stack, extra_routes=extra_routes,
v6_ext_gw_with_sub=( dual_stack=dual_stack,
v6_ext_gw_with_sub), v6_ext_gw_with_sub=(
enable_pf_floating_ip=( v6_ext_gw_with_sub),
enable_pf_floating_ip), enable_pf_floating_ip=(
qos_policy_id=qos_policy_id) enable_pf_floating_ip),
qos_policy_id=qos_policy_id)
def _test_conntrack_disassociate_fip(self, ha): def _test_conntrack_disassociate_fip(self, ha):
'''Test that conntrack immediately drops stateful connection '''Test that conntrack immediately drops stateful connection
@ -375,7 +376,9 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
ipv6_subnet_modes=None, ipv6_subnet_modes=None,
interface_id=None): interface_id=None):
return l3_test_common.router_append_subnet(router, count, return l3_test_common.router_append_subnet(router, count,
ip_version, ipv6_subnet_modes, interface_id) ip_version,
ipv6_subnet_modes,
interface_id)
def _namespace_exists(self, namespace): def _namespace_exists(self, namespace):
return ip_lib.network_namespace_exists(namespace) return ip_lib.network_namespace_exists(namespace)

View File

@ -3277,7 +3277,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
ifname = ri.get_internal_device_name(intf['id']) ifname = ri.get_internal_device_name(intf['id'])
for subnet in intf['subnets']: for subnet in intf['subnets']:
return dibbler.PDDibbler(ri.router['id'], return dibbler.PDDibbler(ri.router['id'],
subnet['id'], ifname).requestor_id subnet['id'], ifname).requestor_id
def _pd_assert_dibbler_calls(self, expected, actual): def _pd_assert_dibbler_calls(self, expected, actual):
'''Check the external process calls for dibbler are expected '''Check the external process calls for dibbler are expected

View File

@ -334,7 +334,7 @@ class TestDvrFipNs(base.BaseTestCase):
@mock.patch.object(router_info.RouterInfo, 'get_router_cidrs') @mock.patch.object(router_info.RouterInfo, 'get_router_cidrs')
@mock.patch.object(ip_lib, 'IPDevice') @mock.patch.object(ip_lib, 'IPDevice')
def _test_scan_fip_ports(self, ri, ip_list, stale_list, IPDevice, def _test_scan_fip_ports(self, ri, ip_list, stale_list, IPDevice,
get_router_cidrs): get_router_cidrs):
IPDevice.return_value = device = mock.Mock() IPDevice.return_value = device = mock.Mock()
device.exists.return_value = True device.exists.return_value = True
ri.get_router_cidrs.return_value = ip_list ri.get_router_cidrs.return_value = ip_list

View File

@ -402,8 +402,7 @@ class KeepalivedTrackScriptTestCase(base.BaseTestCase):
keepalived.KeepalivedVirtualRoute('12.0.0.0/24', '10.0.0.1'), ] keepalived.KeepalivedVirtualRoute('12.0.0.0/24', '10.0.0.1'), ]
self.assertEqual(''' track_script { self.assertEqual(''' track_script {
ha_health_check_1 ha_health_check_1
}''', }''', ts.get_config_str())
ts.get_config_str())
def test_get_script_str(self): def test_get_script_str(self):
ts = keepalived.KeepalivedTrackScript( ts = keepalived.KeepalivedTrackScript(

Some files were not shown because too many files have changed in this diff Show More