diff --git a/neutron/conf/plugins/ml2/config.py b/neutron/conf/plugins/ml2/config.py index cd56ee6794a..651ec614b9b 100644 --- a/neutron/conf/plugins/ml2/config.py +++ b/neutron/conf/plugins/ml2/config.py @@ -51,13 +51,13 @@ ml2_opts = [ 'This option allows specifying a physical network MTU ' 'value that differs from the default global_physnet_mtu ' 'value.')), - cfg.ListOpt('physical_network_mtus', - default=[], - help=_("A list of mappings of physical networks to MTU " - "values. The format of the mapping is " - ":. This mapping allows " - "specifying a physical network MTU value that " - "differs from the default global_physnet_mtu value.")), + cfg.DictOpt('physical_network_mtus', + default={}, + help=_("Mappings of physical networks to MTU values. " + "The format of the mapping is :. " + "This mapping allows specifying a physical network MTU " + "value that differs from " + "the default global_physnet_mtu value.")), cfg.StrOpt('external_network_type', help=_("Default network type for external networks when no " "provider attributes are specified. By default it is " diff --git a/neutron/plugins/ml2/drivers/helpers.py b/neutron/plugins/ml2/drivers/helpers.py index 276665f8e1b..c5cd3c339cd 100644 --- a/neutron/plugins/ml2/drivers/helpers.py +++ b/neutron/plugins/ml2/drivers/helpers.py @@ -22,7 +22,6 @@ from neutron_lib.plugins import constants as plugin_constants from neutron_lib.plugins import directory from neutron_lib.plugins.ml2 import api from neutron_lib.plugins import utils as p_utils -from neutron_lib.utils import helpers from oslo_config import cfg from oslo_db import exception as db_exc from oslo_log import log @@ -37,13 +36,7 @@ class BaseTypeDriver(api.ML2TypeDriver): """BaseTypeDriver for functions common to Segment and flat.""" def __init__(self): - try: - self.physnet_mtus = helpers.parse_mappings( - cfg.CONF.ml2.physical_network_mtus, unique_values=False - ) - except Exception as e: - LOG.error("Failed to parse physical_network_mtus: %s", e) - self.physnet_mtus = [] + self.physnet_mtus = cfg.CONF.ml2.physical_network_mtus def get_mtu(self, physical_network=None): return p_utils.get_deployment_physnet_mtu() diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py index 89f4d17038b..0a9bccf4a44 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py @@ -38,7 +38,7 @@ class FlatTypeTest(testlib_api.SqlTestCase): group='ml2_type_flat') self.driver = type_flat.FlatTypeDriver() self.context = context.Context() - self.driver.physnet_mtus = [] + self.driver.physnet_mtus = {} def _get_allocation(self, context, segment): return flat_obj.FlatAllocation.get_object( @@ -145,23 +145,13 @@ class FlatTypeTest(testlib_api.SqlTestCase): self.driver.physnet_mtus = {} self.assertEqual(0, self.driver.get_mtu('physnet1')) - def test_parse_physical_network_mtus(self): - cfg.CONF.set_override( - 'physical_network_mtus', - ['physnet1:1500', 'physnet2:1500', 'physnet3:9000'], - group='ml2') - driver = type_flat.FlatTypeDriver() - self.assertEqual('1500', driver.physnet_mtus['physnet1']) - self.assertEqual('1500', driver.physnet_mtus['physnet2']) - self.assertEqual('9000', driver.physnet_mtus['physnet3']) - class FlatTypeDefaultTest(base.BaseTestCase): def setUp(self): super().setUp() self.driver = type_flat.FlatTypeDriver() - self.driver.physnet_mtus = [] + self.driver.physnet_mtus = {} def test_validate_provider_segment_default(self): segment = {api.NETWORK_TYPE: p_const.TYPE_FLAT, diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py index 6fa0ffe3ca5..9a7349617df 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py @@ -66,7 +66,7 @@ class VlanTypeTest(testlib_api.SqlTestCase): self.driver = type_vlan.VlanTypeDriver() self.driver._sync_vlan_allocations() self.context = context.Context() - self.driver.physnet_mtus = [] + self.driver.physnet_mtus = {} self.setup_coreplugin(CORE_PLUGIN) def test_parse_network_exception_handling(self): @@ -328,7 +328,7 @@ class VlanTypeAllocationTest(testlib_api.SqlTestCase): ranges, group='ml2_type_vlan') driver = type_vlan.VlanTypeDriver() - driver.physnet_mtus = [] + driver.physnet_mtus = {} driver._sync_vlan_allocations() # swap config order from DB order after sync has happened to # ensure config order is followed and not DB order