From ebec1a4119c78858649542509c77fd4999124a59 Mon Sep 17 00:00:00 2001 From: Ionut Balutoiu Date: Tue, 17 Nov 2015 15:46:49 +0200 Subject: [PATCH] Added config option for the additional dnsmasq flags --- config.yaml | 6 ++++++ hooks/neutron_contexts.py | 5 +++++ templates/havana/dnsmasq.conf | 5 +++++ unit_tests/test_neutron_contexts.py | 11 +++++++++++ 4 files changed, 27 insertions(+) diff --git a/config.yaml b/config.yaml index 4de70d87..b43a5db6 100644 --- a/config.yaml +++ b/config.yaml @@ -128,6 +128,12 @@ options: 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. + dnsmasq-flags: + type: string + default: + description: | + Comma-separated list of key=value config flags with the additional + dhcp options for neutron dnsmasq. enable-l3-agent: type: boolean default: True diff --git a/hooks/neutron_contexts.py b/hooks/neutron_contexts.py index f6501d7f..4d449952 100644 --- a/hooks/neutron_contexts.py +++ b/hooks/neutron_contexts.py @@ -13,6 +13,7 @@ from charmhelpers.fetch import ( from charmhelpers.contrib.openstack.context import ( OSContextGenerator, NeutronAPIContext, + config_flags_parser ) from charmhelpers.contrib.openstack.utils import ( get_os_codename_install_source @@ -154,6 +155,10 @@ class NeutronGatewayContext(NeutronAPIContext): if vlan_ranges: ctxt['vlan_ranges'] = ','.join(vlan_ranges.split()) + dnsmasq_flags = config('dnsmasq-flags') + if dnsmasq_flags: + ctxt['dnsmasq_flags'] = config_flags_parser(dnsmasq_flags) + net_dev_mtu = api_settings['network_device_mtu'] if net_dev_mtu: ctxt['network_device_mtu'] = net_dev_mtu diff --git a/templates/havana/dnsmasq.conf b/templates/havana/dnsmasq.conf index 0ee10c05..f67aa11f 100644 --- a/templates/havana/dnsmasq.conf +++ b/templates/havana/dnsmasq.conf @@ -1,3 +1,8 @@ {%- if instance_mtu -%} dhcp-option=26,{{ instance_mtu }} {% endif -%} +{% if dnsmasq_flags -%} +{% for key, value in dnsmasq_flags.iteritems() -%} +{{ key }} = {{ value }} +{% endfor -%} +{% endif -%} diff --git a/unit_tests/test_neutron_contexts.py b/unit_tests/test_neutron_contexts.py index 2fb55a9c..e19ab236 100644 --- a/unit_tests/test_neutron_contexts.py +++ b/unit_tests/test_neutron_contexts.py @@ -17,6 +17,7 @@ TO_PATCH = [ 'eligible_leader', 'get_os_codename_install_source', 'unit_get', + 'config_flags_parser' ] @@ -123,6 +124,8 @@ class TestNeutronGatewayContext(CharmTestCase): self.test_config.set('debug', False) self.test_config.set('verbose', True) self.test_config.set('instance-mtu', 1420) + self.test_config.set('dnsmasq-flags', 'dhcp-userclass=set:ipxe,iPXE,' + 'dhcp-match=set:ipxe,175') self.test_config.set('vlan-ranges', 'physnet1:1000:2000 physnet2:2001:3000') self.test_config.set('flat-network-providers', 'physnet3 physnet4') @@ -131,6 +134,10 @@ class TestNeutronGatewayContext(CharmTestCase): _runits.return_value = ['neutron-api/0'] _rget.side_effect = lambda *args, **kwargs: rdata self.get_os_codename_install_source.return_value = 'folsom' + self.config_flags_parser.return_value = { + 'dhcp-userclass': 'set:ipxe,iPXE', + 'dhcp-match': 'set:ipxe,175' + } _host_ip.return_value = '10.5.0.1' _secret.return_value = 'testsecret' ctxt = neutron_contexts.NeutronGatewayContext()() @@ -152,6 +159,10 @@ class TestNeutronGatewayContext(CharmTestCase): 'vlan_ranges': 'physnet1:1000:2000,physnet2:2001:3000', 'network_device_mtu': 9000, 'veth_mtu': 9000, + 'dnsmasq_flags': { + 'dhcp-userclass': 'set:ipxe,iPXE', + 'dhcp-match': 'set:ipxe,175' + } })