From 9e1018bcfb2e84ec9f84b97dbfb685c0f81fc76b Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Wed, 20 Jun 2018 15:13:25 +0100 Subject: [PATCH] Add instance-mtu config opt This brings this charm inline with the neutron-gateway charm in terms of configurability when using a local dhcp agent. Change-Id: Idc4f7735aaa9236d8a476fd3bae6aaf52b9dc043 Closes-Bug: 1777888 --- config.yaml | 8 ++++++++ hooks/neutron_ovs_context.py | 2 ++ templates/dnsmasq.conf | 3 +++ unit_tests/test_neutron_ovs_context.py | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/config.yaml b/config.yaml index 59b91a05..4bfedc99 100644 --- a/config.yaml +++ b/config.yaml @@ -127,6 +127,14 @@ options: Comma-separated list of key=value config flags with the additional dhcp options for neutron dnsmasq. Note, this option is only valid when enable-local-dhcp-and-metadata option is set to True. + instance-mtu: + type: int + default: + description: | + Configure DHCP services to provide MTU configuration to instances + within the cloud. This is useful in deployments where its not + possible to increase MTU on switches and physical servers to + accommodate the packet overhead of using GRE tunnels. dns-servers: type: string default: diff --git a/hooks/neutron_ovs_context.py b/hooks/neutron_ovs_context.py index 498b8e1f..a9519483 100644 --- a/hooks/neutron_ovs_context.py +++ b/hooks/neutron_ovs_context.py @@ -222,6 +222,8 @@ class DHCPAgentContext(OSContextGenerator): if neutron_api_settings.get('dns_domain'): ctxt['dns_domain'] = neutron_api_settings.get('dns_domain') + ctxt['instance_mtu'] = config('instance-mtu') + return ctxt diff --git a/templates/dnsmasq.conf b/templates/dnsmasq.conf index a7d8e928..48a5c032 100644 --- a/templates/dnsmasq.conf +++ b/templates/dnsmasq.conf @@ -1,3 +1,6 @@ +{%- if instance_mtu -%} +dhcp-option=26,{{ instance_mtu }} +{% endif -%} {% if dnsmasq_flags -%} {% for key, value in dnsmasq_flags.items() -%} {{ key }} = {{ value }} diff --git a/unit_tests/test_neutron_ovs_context.py b/unit_tests/test_neutron_ovs_context.py index caa09fb0..bcabd33b 100644 --- a/unit_tests/test_neutron_ovs_context.py +++ b/unit_tests/test_neutron_ovs_context.py @@ -294,6 +294,7 @@ class DHCPAgentContextTest(CharmTestCase): self.assertEqual( context.DHCPAgentContext()(), {'dns_domain': 'openstack.example.', + 'instance_mtu': None, 'dns_servers': None} ) self.relation_ids.assert_called_with('neutron-plugin') @@ -325,6 +326,7 @@ class DHCPAgentContextTest(CharmTestCase): context.DHCPAgentContext()(), {'availability_zone': 'nova', 'dns_domain': 'openstack.example.', + 'instance_mtu': None, 'dns_servers': '8.8.8.8,4.4.4.4'} ) self.relation_ids.assert_called_with('neutron-plugin') @@ -354,6 +356,7 @@ class DHCPAgentContextTest(CharmTestCase): self.assertEqual( context.DHCPAgentContext()(), {'availability_zone': 'nova', + 'instance_mtu': None, 'dns_servers': '8.8.8.8'} ) self.relation_ids.assert_called_with('neutron-plugin') @@ -390,6 +393,7 @@ class DHCPAgentContextTest(CharmTestCase): 'dhcp-match': 'set:ipxe,175', 'server': '1.2.3.4', }, + 'instance_mtu': None, 'dns_servers': None, } )