use PROVISIONAL_IPV6_PD_PREFIX from neutron-lib

Commit I9642ed9b513a43c5558f9611f43227299707284a rehomed the
PROVISIONAL_IPV6_PD_PREFIX constant into neutron-lib. This patch
consumes it removing the constant in neutron and using lib's version
of it instead.

NeutronLibImpact

Change-Id: I107cb5e0ff2f3e2c5bb9dc501f420d0be08735a0
changes/27/519727/1
Boden R 5 years ago
parent d505e3eeb7
commit 502e99bca9

@ -422,7 +422,7 @@ class RouterInfo(object):
def _internal_network_updated(self, port, subnet_id, prefix, old_prefix,
updated_cidrs):
interface_name = self.get_internal_device_name(port['id'])
if prefix != n_const.PROVISIONAL_IPV6_PD_PREFIX:
if prefix != lib_constants.PROVISIONAL_IPV6_PD_PREFIX:
fixed_ips = port['fixed_ips']
for fixed_ip in fixed_ips:
if fixed_ip['subnet_id'] == subnet_id:
@ -505,7 +505,8 @@ class RouterInfo(object):
if 'subnets' in port:
for subnet in port['subnets']:
if (netaddr.IPNetwork(subnet['cidr']).version == 6 and
subnet['cidr'] != n_const.PROVISIONAL_IPV6_PD_PREFIX):
subnet['cidr'] !=
lib_constants.PROVISIONAL_IPV6_PD_PREFIX):
return True
def enable_radvd(self, internal_ports=None):
@ -1048,7 +1049,7 @@ class RouterInfo(object):
'scope',
self.address_scope_filter_rule(device_name, mark))
for subnet_id, prefix in self.pd_subnets.items():
if prefix != n_const.PROVISIONAL_IPV6_PD_PREFIX:
if prefix != lib_constants.PROVISIONAL_IPV6_PD_PREFIX:
self._process_pd_iptables_rules(prefix, subnet_id)
def process_ports_address_scope_iptables(self):

@ -17,6 +17,7 @@ import os
import shutil
import jinja2
from neutron_lib import constants as lib_const
from neutron_lib.utils import file as file_utils
from oslo_config import cfg
from oslo_log import log as logging
@ -26,7 +27,6 @@ from neutron.agent.linux import external_process
from neutron.agent.linux import pd
from neutron.agent.linux import pd_driver
from neutron.agent.linux import utils
from neutron.common import constants
LOG = logging.getLogger(__name__)
@ -167,7 +167,7 @@ class PDDibbler(pd_driver.PDDriverBase):
def get_prefix(self):
prefix = utils.get_value_from_file(self.prefix_path)
if not prefix:
prefix = constants.PROVISIONAL_IPV6_PD_PREFIX
prefix = lib_const.PROVISIONAL_IPV6_PD_PREFIX
return prefix
@staticmethod

@ -97,7 +97,7 @@ class PrefixDelegation(object):
return
self._delete_pd(router, pd_info)
if self._is_pd_master_router(router):
prefix_update[subnet_id] = l3_constants.PROVISIONAL_IPV6_PD_PREFIX
prefix_update[subnet_id] = n_const.PROVISIONAL_IPV6_PD_PREFIX
LOG.debug("Update server with prefixes: %s", prefix_update)
self.notifier(self.context, prefix_update)
del router['subnets'][subnet_id]
@ -152,7 +152,7 @@ class PrefixDelegation(object):
pd_info.driver.disable(self.pmon, router['ns_name'])
pd_info.prefix = None
pd_info.client_started = False
prefix = l3_constants.PROVISIONAL_IPV6_PD_PREFIX
prefix = n_const.PROVISIONAL_IPV6_PD_PREFIX
prefix_update[subnet_id] = prefix
if prefix_update:
LOG.debug("Update server with prefixes: %s", prefix_update)
@ -310,7 +310,7 @@ class PrefixDelegation(object):
router_id, subnet_id, pd_info.ri_ifname)
prefix = None
if (pd_info.prefix !=
l3_constants.PROVISIONAL_IPV6_PD_PREFIX):
n_const.PROVISIONAL_IPV6_PD_PREFIX):
prefix = pd_info.prefix
pd_info.driver.enable(self.pmon, router['ns_name'],
@ -397,8 +397,8 @@ class PDInfo(object):
"""
def __init__(self, pd_info=None, ri_ifname=None, mac=None):
if pd_info is None:
self.prefix = l3_constants.PROVISIONAL_IPV6_PD_PREFIX
self.old_prefix = l3_constants.PROVISIONAL_IPV6_PD_PREFIX
self.prefix = n_const.PROVISIONAL_IPV6_PD_PREFIX
self.old_prefix = n_const.PROVISIONAL_IPV6_PD_PREFIX
self.ri_ifname = ri_ifname
self.mac = mac
self.bind_lla = None

@ -45,7 +45,7 @@ class PDDriverBase(object):
def get_prefix(self):
"""Get the current assigned prefix for this PDDriver from the PD agent.
If no prefix is currently assigned, return
constants.PROVISIONAL_IPV6_PD_PREFIX
neutron_lib.constants.PROVISIONAL_IPV6_PD_PREFIX
"""
@staticmethod

@ -109,10 +109,6 @@ IPTABLES_PROTOCOL_MAP = {lib_constants.PROTO_NAME_DCCP: 'dccp',
lib_constants.PROTO_NAME_TCP: 'tcp',
lib_constants.PROTO_NAME_UDP: 'udp'}
# TODO(boden): consume with I9642ed9b513a43c5558f9611f43227299707284a
# Special provisional prefix for IPv6 Prefix Delegation
PROVISIONAL_IPV6_PD_PREFIX = '::/64'
# Timeout in seconds for getting an IPv6 LLA
LLA_TASK_TIMEOUT = 40

@ -40,7 +40,6 @@ from sqlalchemy import not_
from neutron._i18n import _
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
from neutron.common import constants as n_const
from neutron.common import exceptions as n_exc
from neutron.common import ipv6_utils
from neutron.common import utils
@ -777,7 +776,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
subnetpool_id = None
self._validate_subnet(context, s)
else:
prefix = n_const.PROVISIONAL_IPV6_PD_PREFIX
prefix = constants.PROVISIONAL_IPV6_PD_PREFIX
subnet['subnet']['cidr'] = prefix
self._validate_subnet_for_pd(s)
else:

@ -30,7 +30,6 @@ from sqlalchemy import and_, or_
from sqlalchemy.orm import exc as orm_exc
from neutron._i18n import _
from neutron.common import constants
from neutron.common import exceptions as n_exc
from neutron.common import ipv6_utils
from neutron.common import utils as common_utils
@ -239,7 +238,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
subnet_list = self._get_all_subnets(context)
for subnet in subnet_list:
if ((netaddr.IPSet([subnet.cidr]) & new_subnet_ipset) and
subnet.cidr != constants.PROVISIONAL_IPV6_PD_PREFIX):
subnet.cidr != const.PROVISIONAL_IPV6_PD_PREFIX):
# don't give out details of the overlapping subnet
err_msg = ("Requested subnet with cidr: %(cidr)s for "
"network: %(network_id)s overlaps with another "

@ -24,7 +24,6 @@ from oslo_log import log as logging
from oslo_utils import excutils
from sqlalchemy import and_
from neutron.common import constants as n_const
from neutron.common import ipv6_utils
from neutron.db import api as db_api
from neutron.db import ipam_backend_mixin
@ -263,7 +262,7 @@ class IpamPluggableBackend(ipam_backend_mixin.IpamBackendMixin):
is_auto_addr_subnet = ipv6_utils.is_auto_address_subnet(subnet)
if ('ip_address' in fixed and
subnet['cidr'] != n_const.PROVISIONAL_IPV6_PD_PREFIX):
subnet['cidr'] != constants.PROVISIONAL_IPV6_PD_PREFIX):
if (is_auto_addr_subnet and device_owner not in
constants.ROUTER_INTERFACE_OWNERS):
raise ipam_exc.AllocationOnAutoAddressSubnet(

@ -37,7 +37,6 @@ from sqlalchemy.orm import exc
from neutron._i18n import _
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
from neutron.common import constants as n_const
from neutron.common import ipv6_utils
from neutron.common import rpc as n_rpc
from neutron.common import utils
@ -609,7 +608,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
# Ignore temporary Prefix Delegation CIDRs
new_subnets = [s for s in new_subnets
if s['cidr'] != n_const.PROVISIONAL_IPV6_PD_PREFIX]
if s['cidr'] != constants.PROVISIONAL_IPV6_PD_PREFIX]
id_filter = {'id': router_subnets}
subnets = self._core_plugin.get_subnets(context.elevated(),
filters=id_filter)

@ -19,7 +19,6 @@ from neutron_lib import constants as lib_constants
from oslo_utils import uuidutils
from six import moves
from neutron.common import constants as n_const
from neutron.common import ipv6_utils
_uuid = uuidutils.generate_uuid
@ -285,7 +284,7 @@ def router_append_pd_enabled_subnet(router, count=1):
'subnet_id': subnet_id}],
'mac_address': str(mac_address),
'subnets': [{'id': subnet_id,
'cidr': n_const.PROVISIONAL_IPV6_PD_PREFIX,
'cidr': lib_constants.PROVISIONAL_IPV6_PD_PREFIX,
'gateway_ip': '::1',
'ipv6_ra_mode': lib_constants.IPV6_SLAAC,
'subnetpool_id': lib_constants.IPV6_PD_POOL_ID}]}
@ -299,7 +298,7 @@ def get_unassigned_pd_interfaces(router):
for intf in router[lib_constants.INTERFACE_KEY]:
for subnet in intf['subnets']:
if (ipv6_utils.is_ipv6_pd_enabled(subnet) and
subnet['cidr'] == n_const.PROVISIONAL_IPV6_PD_PREFIX):
subnet['cidr'] == lib_constants.PROVISIONAL_IPV6_PD_PREFIX):
pd_intfs.append(intf)
return pd_intfs
@ -309,7 +308,7 @@ def assign_prefix_for_pd_interfaces(router):
for ifno, intf in enumerate(router[lib_constants.INTERFACE_KEY]):
for subnet in intf['subnets']:
if (ipv6_utils.is_ipv6_pd_enabled(subnet) and
subnet['cidr'] == n_const.PROVISIONAL_IPV6_PD_PREFIX):
subnet['cidr'] == lib_constants.PROVISIONAL_IPV6_PD_PREFIX):
subnet['cidr'] = "2001:db8:%d::/64" % ifno
pd_intfs.append(intf)
return pd_intfs

@ -2945,7 +2945,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
requestor_id, ri, False))
for subnet in intf['subnets']:
expected_pd_update[subnet['id']] = (
n_const.PROVISIONAL_IPV6_PD_PREFIX)
lib_constants.PROVISIONAL_IPV6_PD_PREFIX)
# Implement the prefix update notifier
# Keep track of the updated prefix
@ -2980,7 +2980,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
requestor_id, ri, False))
for subnet in intf['subnets']:
expected_pd_update += [{subnet['id']:
n_const.PROVISIONAL_IPV6_PD_PREFIX}]
lib_constants.PROVISIONAL_IPV6_PD_PREFIX}]
# Implement the prefix update notifier
# Keep track of the updated prefix

@ -43,7 +43,6 @@ import neutron
from neutron.api import api_common
from neutron.api import extensions
from neutron.api.v2 import router
from neutron.common import constants as n_const
from neutron.common import exceptions as n_exc
from neutron.common import ipv6_utils
from neutron.common import test_lib
@ -3755,7 +3754,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
@testtools.skipIf(tools.is_bsd(), 'bug/1484837')
def test_create_subnet_ipv6_pd_gw_values(self):
cidr = n_const.PROVISIONAL_IPV6_PD_PREFIX
cidr = constants.PROVISIONAL_IPV6_PD_PREFIX
# Gateway is last IP in IPv6 DHCPv6 Stateless subnet
gateway = '::ffff:ffff:ffff:ffff'
allocation_pools = [{'start': '::1',
@ -3899,7 +3898,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
@testtools.skipIf(tools.is_bsd(), 'bug/1484837')
def test_create_subnet_with_v6_pd_allocation_pool(self):
gateway_ip = '::1'
cidr = n_const.PROVISIONAL_IPV6_PD_PREFIX
cidr = constants.PROVISIONAL_IPV6_PD_PREFIX
allocation_pools = [{'start': '::2',
'end': '::ffff:ffff:ffff:fffe'}]
self._test_create_subnet(gateway_ip=gateway_ip,
@ -4108,7 +4107,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
plugin = directory.get_plugin()
ctx = context.get_admin_context()
new_subnet = {'ip_version': 6,
'cidr': n_const.PROVISIONAL_IPV6_PD_PREFIX,
'cidr': constants.PROVISIONAL_IPV6_PD_PREFIX,
'enable_dhcp': True,
'ipv6_address_mode': None,
'ipv6_ra_mode': None}

@ -26,7 +26,6 @@ from oslo_utils import netutils
from oslo_utils import uuidutils
import webob.exc
from neutron.common import constants as n_const
from neutron.db import ipam_backend_mixin
from neutron.db import ipam_pluggable_backend
from neutron.db import models_v2
@ -343,7 +342,7 @@ class TestDbBasePluginIpam(test_db_base.NeutronDbPluginV2TestCase):
def test_test_fixed_ips_for_port_pd_gateway(self):
context = mock.Mock()
pluggable_backend = ipam_pluggable_backend.IpamPluggableBackend()
with self.subnet(cidr=n_const.PROVISIONAL_IPV6_PD_PREFIX,
with self.subnet(cidr=constants.PROVISIONAL_IPV6_PD_PREFIX,
ip_version=6) as subnet:
subnet = subnet['subnet']
fixed_ips = [{'subnet_id': subnet['id'],
@ -378,7 +377,7 @@ class TestDbBasePluginIpam(test_db_base.NeutronDbPluginV2TestCase):
def test_create_ipv6_pd_subnet_over_ipam(self, pool_mock):
mocks = self._prepare_mocks_with_pool_mock(pool_mock)
cfg.CONF.set_override('ipv6_pd_enabled', True)
cidr = n_const.PROVISIONAL_IPV6_PD_PREFIX
cidr = constants.PROVISIONAL_IPV6_PD_PREFIX
allocation_pools = [netaddr.IPRange('::2', '::ffff:ffff:ffff:ffff')]
with self.subnet(cidr=None, ip_version=6,
subnetpool_id=constants.IPV6_PD_POOL_ID,

Loading…
Cancel
Save