diff --git a/config.yaml b/config.yaml index b3bf50da..b4938fc3 100755 --- a/config.yaml +++ b/config.yaml @@ -267,6 +267,15 @@ options: when using an overlay/tunnel protocol. This option allows specifying a physical network MTU value that differs from the default global-physnet-mtu value. + physical-network-mtus: + type: string + default: + description: | + Space-delimited list of : pairs specifying MTU for + individual physical networks. + . + Use this if a subset of your flat or VLAN provider networks have a MTU + that differ with what is set in global-physnet-mtu. dns-domain: type: string default: openstack.example. diff --git a/hooks/neutron_api_context.py b/hooks/neutron_api_context.py index 4b7ae3fe..5eec6324 100644 --- a/hooks/neutron_api_context.py +++ b/hooks/neutron_api_context.py @@ -432,6 +432,10 @@ class NeutronCCContext(context.NeutronContext): ctxt['path_mtu'] = config('path-mtu') else: ctxt['path_mtu'] = config('global-physnet-mtu') + physical_network_mtus = config('physical-network-mtus') + if physical_network_mtus: + ctxt['physical_network_mtus'] = ','.join( + physical_network_mtus.split()) if 'kilo' <= cmp_release <= 'mitaka': pci_vendor_devs = config('supported-pci-vendor-devs') diff --git a/templates/mitaka/ml2_conf.ini b/templates/mitaka/ml2_conf.ini index f1252526..bb5a2848 100644 --- a/templates/mitaka/ml2_conf.ini +++ b/templates/mitaka/ml2_conf.ini @@ -16,6 +16,9 @@ type_drivers = {{ tenant_network_types }} tenant_network_types = {{ tenant_network_types }} mechanism_drivers = {{ mechanism_drivers }} +{% if physical_network_mtus -%} +physical_network_mtus = {{ physical_network_mtus }} +{% endif -%} {% if path_mtu -%} path_mtu = {{ path_mtu }} {% endif -%} diff --git a/unit_tests/test_neutron_api_context.py b/unit_tests/test_neutron_api_context.py index 1ed65a71..a9b0e14a 100644 --- a/unit_tests/test_neutron_api_context.py +++ b/unit_tests/test_neutron_api_context.py @@ -450,6 +450,48 @@ class NeutronCCContextTest(CharmTestCase): with patch.object(napi_ctxt, '_ensure_packages'): self.assertEqual(ctxt_data, napi_ctxt()) + @patch.object(context.NeutronCCContext, 'network_manager') + @patch.object(context.NeutronCCContext, 'plugin') + @patch('builtins.__import__') + def test_neutroncc_context_no_setting_mitaka(self, _import, plugin, nm): + plugin.return_value = None + ctxt_data = { + 'debug': True, + 'enable_dvr': False, + 'l3_ha': False, + 'mechanism_drivers': 'openvswitch,hyperv,l2population', + 'dhcp_agents_per_network': 3, + 'enable_sriov': False, + 'external_network': 'bob', + 'global_physnet_mtu': 1500, + 'neutron_bind_port': self.api_port, + 'verbose': True, + 'l2_population': True, + 'overlay_network_type': 'gre', + 'path_mtu': 1500, + 'tenant_network_types': 'gre,vlan,flat,local', + 'quota_floatingip': 50, + 'quota_health_monitors': -1, + 'quota_member': -1, + 'quota_network': 10, + 'quota_pool': 10, + 'quota_port': 50, + 'quota_router': 10, + 'quota_security_group': 10, + 'quota_security_group_rule': 100, + 'quota_subnet': 10, + 'quota_vip': 10, + 'vlan_ranges': 'physnet1:1000:2000', + 'vni_ranges': '1001:2000', + 'extension_drivers': 'port_security', + 'service_plugins': 'router,firewall,lbaas,vpnaas,metering', + } + napi_ctxt = context.NeutronCCContext() + self.maxDiff = None + self.os_release.return_value = 'mitaka' + with patch.object(napi_ctxt, '_ensure_packages'): + self.assertEqual(ctxt_data, napi_ctxt()) + @patch.object(context.NeutronCCContext, 'network_manager') @patch.object(context.NeutronCCContext, 'plugin') def test_neutroncc_context_dns_setting(self, plugin, nm): @@ -810,6 +852,30 @@ class NeutronCCContextTest(CharmTestCase): self.assertEqual(context.NeutronCCContext()()['service_plugins'], service_plugins) + @patch.object(context.NeutronCCContext, 'network_manager') + @patch.object(context.NeutronCCContext, 'plugin') + def test_neutroncc_context_physical_network_mtus(self, plugin, nm): + plugin.return_value = None + self.test_config.set('physical-network-mtus', 'provider1:4000') + self.os_release.return_value = 'mitaka' + napi_ctxt = context.NeutronCCContext() + with patch.object(napi_ctxt, '_ensure_packages'): + ctxt = napi_ctxt() + self.assertEqual(ctxt['physical_network_mtus'], 'provider1:4000') + + @patch.object(context.NeutronCCContext, 'network_manager') + @patch.object(context.NeutronCCContext, 'plugin') + def test_neutroncc_context_physical_network_mtus_multi(self, plugin, nm): + plugin.return_value = None + self.test_config.set('physical-network-mtus', + 'provider1:4000 provider2:5000') + self.os_release.return_value = 'mitaka' + napi_ctxt = context.NeutronCCContext() + with patch.object(napi_ctxt, '_ensure_packages'): + ctxt = napi_ctxt() + self.assertEqual(ctxt['physical_network_mtus'], + 'provider1:4000,provider2:5000') + class EtcdContextTest(CharmTestCase):