]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add new config option for IPv6 Prefix Delegation
authorJohn Davidge <jodavidg@cisco.com>
Thu, 1 Oct 2015 17:32:53 +0000 (18:32 +0100)
committerJohn Davidge <jodavidg@cisco.com>
Fri, 6 Nov 2015 16:35:02 +0000 (16:35 +0000)
With the impending deprecation of the default subnetpool configuration
options, IPv6 PD needs to be enabled with a new config option.

This patch adds the 'ipv6_pd_enabled' option to neutron.conf, and makes
all of the necessary changes for its use.

DocImpact

Change-Id: I43486c5a13ee2ff0097355afe7e1f3ef8794b185
Closes-Bug: 1501835

etc/neutron.conf
neutron/common/config.py
neutron/common/constants.py
neutron/db/db_base_plugin_v2.py
neutron/tests/unit/api/rpc/handlers/test_l3_rpc.py
neutron/tests/unit/db/test_db_base_plugin_v2.py
neutron/tests/unit/db/test_ipam_pluggable_backend.py

index 3ec158584a8ed91406f3b30cec07cb34577d48a5..0575c03b6e47cc602953a26393620c2aa861d3dc 100644 (file)
 
 # Default Subnet Pool to be used for IPv6 subnet-allocation.
 # Specifies by UUID the pool to be used in case of subnet-create being
-# called without a subnet-pool ID.  Set to "prefix_delegation"
-# to enable IPv6 Prefix Delegation in a PD-capable environment.
-# See the description for default_ipv4_subnet_pool for more information.
+# called without a subnet-pool ID. See the description for
+# default_ipv4_subnet_pool for more information.
 # default_ipv6_subnet_pool =
 
+# Set to True to enable IPv6 Prefix Delegation for subnet-allocation in a
+# PD-capable environment. Users making subnet-create requests for v6 subnets
+# without providing a cidr or subnetpool ID will be given a cidr via the Prefix
+# Delegation mechanism. Note that enabling PD will override the behavior of
+# the default IPv6 subnetpool.
+# ipv6_pd_enabled =
+
 # =========== items for MTU selection and advertisement =============
 # Advertise MTU.  If True, effort is made to advertise MTU
 # settings to VMs via network methods (ie. DHCP and RA MTU options)
index a598f73f427b34753d266adef27aeaa1f302ec6d..1f07ba00a0da966acff926db62d9288831db81f4 100644 (file)
@@ -78,6 +78,9 @@ core_opts = [
     cfg.StrOpt('default_ipv6_subnet_pool',
                help=_("Default IPv6 subnet-pool to be used for automatic "
                       "subnet CIDR allocation")),
+    cfg.BoolOpt('ipv6_pd_enabled', default=False,
+                help=_("Enables IPv6 Prefix Delegation for automatic subnet "
+                       "CIDR allocation")),
     cfg.IntOpt('dhcp_lease_duration', default=86400,
                deprecated_name='dhcp_lease_time',
                help=_("DHCP lease duration (in seconds). Use -1 to tell "
index a5f34ee9d2d864e18fedd54f1993c21e38e7ed06..8d468d3b8584bc8496b34fad4df72703d98cd33f 100644 (file)
@@ -142,8 +142,8 @@ IPV6_MODES = [DHCPV6_STATEFUL, DHCPV6_STATELESS, IPV6_SLAAC]
 
 IPV6_LLA_PREFIX = 'fe80::/64'
 
-# Human-readable ID to which default_ipv6_subnet_pool should be set to
-# indicate that IPv6 Prefix Delegation should be used to allocate subnet CIDRs
+# Human-readable ID to which the subnetpool ID should be set to
+# indicate that IPv6 Prefix Delegation is enabled for a given subnet
 IPV6_PD_POOL_ID = 'prefix_delegation'
 
 # Special provisional prefix for IPv6 Prefix Delegation
index 5ea921c348977d72ee069cb1d70aa14df4e31c81..bf032ada4c959ec36f5afcf7e2086863bc7a7fc9 100644 (file)
@@ -632,6 +632,8 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
 
         if ip_version == 4:
             return cfg.CONF.default_ipv4_subnet_pool
+        if cfg.CONF.ipv6_pd_enabled:
+            return constants.IPV6_PD_POOL_ID
         return cfg.CONF.default_ipv6_subnet_pool
 
     def create_subnet(self, context, subnet):
index 68ec79d141b6e2b1eb27cc6bbe2aaf74512d1cc5..341436af0459b390eae0646236ccb4cee13e481c 100644 (file)
@@ -30,8 +30,7 @@ class TestL3RpcCallback(testlib_api.SqlTestCase):
         self.setup_coreplugin(test_db_base_plugin_v2.DB_PLUGIN_KLASS)
         self.plugin = manager.NeutronManager.get_plugin()
         self.ctx = context.get_admin_context()
-        cfg.CONF.set_override('default_ipv6_subnet_pool',
-                              constants.IPV6_PD_POOL_ID)
+        cfg.CONF.set_override('ipv6_pd_enabled', True)
         self.callbacks = l3_rpc.L3RpcCallback()
         self.network = self._prepare_network()
 
index 6354c1274e05e2d0b24cd04b79b2f003e6dd8d9f..cc87fc1bf0f0fc5c092145d430fdf963866d8f02 100644 (file)
@@ -1713,8 +1713,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
         if ipv6_pd:
             cidr = None
             gateway = None
-            cfg.CONF.set_override('default_ipv6_subnet_pool',
-                                  constants.IPV6_PD_POOL_ID)
+            cfg.CONF.set_override('ipv6_pd_enabled', True)
         return (self._make_subnet(self.fmt, network, gateway=gateway,
                                   cidr=cidr, ip_version=6,
                                   ipv6_ra_mode=ra_addr_mode,
@@ -2814,6 +2813,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
     def test_create_subnet_only_ip_version_v6_no_pool(self):
         with self.network() as network:
             tenant_id = network['network']['tenant_id']
+            cfg.CONF.set_override('ipv6_pd_enabled', False)
             cfg.CONF.set_override('default_ipv6_subnet_pool', None)
             data = {'subnet': {'network_id': network['network']['id'],
                     'ip_version': '6',
@@ -2856,6 +2856,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
                                  tenant_id=tenant_id,
                                  min_prefixlen='64') as subnetpool:
                 subnetpool_id = subnetpool['subnetpool']['id']
+                cfg.CONF.set_override('ipv6_pd_enabled', False)
                 cfg.CONF.set_override('default_ipv6_subnet_pool',
                                       subnetpool_id)
                 data = {'subnet': {'network_id': network['network']['id'],
index 97e79f561cf8d5a0e7357bb568397e3a707c1bf4..5ca13cc0f0562cc933f65690afb93bc2a39ab2c8 100644 (file)
@@ -290,8 +290,7 @@ class TestDbBasePluginIpam(test_db_base.NeutronDbPluginV2TestCase):
     @mock.patch('neutron.ipam.driver.Pool')
     def test_create_ipv6_pd_subnet_over_ipam(self, pool_mock):
         mocks = self._prepare_mocks_with_pool_mock(pool_mock)
-        cfg.CONF.set_override('default_ipv6_subnet_pool',
-                              constants.IPV6_PD_POOL_ID)
+        cfg.CONF.set_override('ipv6_pd_enabled', True)
         cidr = constants.PROVISIONAL_IPV6_PD_PREFIX
         allocation_pools = [netaddr.IPRange('::2', '::ffff:ffff:ffff:ffff')]
         with self.subnet(cidr=None, ip_version=6,