Add dnsmasq-flags to charm-neutron-openvswitch
Add a new option to provide the ability to specify flags in the dnsmasq.conf file. This allows users to configure the dnsmasq processes used by the neutron-dhcp-agent when local dhcp and metadata are enabled for provider networks. Change-Id: I2bab8a00322afb0f81986001c86f0ef4fc535651 Closes-Bug: #1684231
This commit is contained in:
parent
0fb6c60db4
commit
9ce4995205
@ -142,6 +142,13 @@ options:
|
|||||||
which do not include a neutron-gateway (do not require l3, lbaas or vpnaas
|
which do not include a neutron-gateway (do not require l3, lbaas or vpnaas
|
||||||
services) and should only be used in-conjunction with flat or VLAN provider
|
services) and should only be used in-conjunction with flat or VLAN provider
|
||||||
networks configurations.
|
networks configurations.
|
||||||
|
dnsmasq-flags:
|
||||||
|
type: string
|
||||||
|
default:
|
||||||
|
description: |
|
||||||
|
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.
|
||||||
prevent-arp-spoofing:
|
prevent-arp-spoofing:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: true
|
||||||
|
@ -30,6 +30,7 @@ from charmhelpers.core.host import (
|
|||||||
)
|
)
|
||||||
from charmhelpers.contrib.openstack import context
|
from charmhelpers.contrib.openstack import context
|
||||||
from charmhelpers.contrib.openstack.utils import get_host_ip
|
from charmhelpers.contrib.openstack.utils import get_host_ip
|
||||||
|
from charmhelpers.contrib.openstack.utils import config_flags_parser
|
||||||
from charmhelpers.contrib.network.ip import get_address_in_network
|
from charmhelpers.contrib.network.ip import get_address_in_network
|
||||||
from charmhelpers.contrib.openstack.context import (
|
from charmhelpers.contrib.openstack.context import (
|
||||||
OSContextGenerator,
|
OSContextGenerator,
|
||||||
@ -164,6 +165,7 @@ class DHCPAgentContext(OSContextGenerator):
|
|||||||
# its principal charm. Thus we can take the 1st (only) element in each
|
# its principal charm. Thus we can take the 1st (only) element in each
|
||||||
# list.
|
# list.
|
||||||
rids = relation_ids('neutron-plugin')
|
rids = relation_ids('neutron-plugin')
|
||||||
|
ctxt = {}
|
||||||
if rids:
|
if rids:
|
||||||
rid = rids[0]
|
rid = rids[0]
|
||||||
units = related_units(rid)
|
units = related_units(rid)
|
||||||
@ -173,8 +175,13 @@ class DHCPAgentContext(OSContextGenerator):
|
|||||||
rid=rid,
|
rid=rid,
|
||||||
unit=units[0])
|
unit=units[0])
|
||||||
if availability_zone:
|
if availability_zone:
|
||||||
return {'availability_zone': availability_zone}
|
ctxt['availability_zone'] = availability_zone
|
||||||
return {}
|
|
||||||
|
dnsmasq_flags = config('dnsmasq-flags')
|
||||||
|
if dnsmasq_flags:
|
||||||
|
ctxt['dnsmasq_flags'] = config_flags_parser(dnsmasq_flags)
|
||||||
|
|
||||||
|
return ctxt
|
||||||
|
|
||||||
|
|
||||||
class L3AgentContext(OSContextGenerator):
|
class L3AgentContext(OSContextGenerator):
|
||||||
|
@ -127,6 +127,7 @@ GIT_PACKAGE_BLACKLIST = [
|
|||||||
VERSION_PACKAGE = 'neutron-common'
|
VERSION_PACKAGE = 'neutron-common'
|
||||||
NOVA_CONF_DIR = "/etc/nova"
|
NOVA_CONF_DIR = "/etc/nova"
|
||||||
NEUTRON_DHCP_AGENT_CONF = "/etc/neutron/dhcp_agent.ini"
|
NEUTRON_DHCP_AGENT_CONF = "/etc/neutron/dhcp_agent.ini"
|
||||||
|
NEUTRON_DNSMASQ_CONF = "/etc/neutron/dnsmasq.conf"
|
||||||
NEUTRON_CONF_DIR = "/etc/neutron"
|
NEUTRON_CONF_DIR = "/etc/neutron"
|
||||||
NEUTRON_CONF = '%s/neutron.conf' % NEUTRON_CONF_DIR
|
NEUTRON_CONF = '%s/neutron.conf' % NEUTRON_CONF_DIR
|
||||||
NEUTRON_DEFAULT = '/etc/default/neutron-server'
|
NEUTRON_DEFAULT = '/etc/default/neutron-server'
|
||||||
@ -191,6 +192,10 @@ DHCP_RESOURCE_MAP = OrderedDict([
|
|||||||
'services': ['neutron-dhcp-agent'],
|
'services': ['neutron-dhcp-agent'],
|
||||||
'contexts': [neutron_ovs_context.DHCPAgentContext()],
|
'contexts': [neutron_ovs_context.DHCPAgentContext()],
|
||||||
}),
|
}),
|
||||||
|
(NEUTRON_DNSMASQ_CONF, {
|
||||||
|
'services': ['neutron-dhcp-agent'],
|
||||||
|
'contexts': [neutron_ovs_context.DHCPAgentContext()],
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
DVR_RESOURCE_MAP = OrderedDict([
|
DVR_RESOURCE_MAP = OrderedDict([
|
||||||
(NEUTRON_L3_AGENT_CONF, {
|
(NEUTRON_L3_AGENT_CONF, {
|
||||||
|
5
templates/dnsmasq.conf
Normal file
5
templates/dnsmasq.conf
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{% if dnsmasq_flags -%}
|
||||||
|
{% for key, value in dnsmasq_flags.iteritems() -%}
|
||||||
|
{{ key }} = {{ value }}
|
||||||
|
{% endfor -%}
|
||||||
|
{% endif -%}
|
@ -10,6 +10,10 @@ interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
|
|||||||
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
|
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
|
||||||
root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
|
root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
|
||||||
|
|
||||||
|
{% if dnsmasq_flags -%}
|
||||||
|
dnsmasq_config_file = /etc/neutron/dnsmasq.conf
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
enable_metadata_network = True
|
enable_metadata_network = True
|
||||||
enable_isolated_metadata = True
|
enable_isolated_metadata = True
|
||||||
|
|
||||||
|
@ -11,6 +11,10 @@ interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
|
|||||||
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
|
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
|
||||||
root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
|
root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
|
||||||
|
|
||||||
|
{% if dnsmasq_flags -%}
|
||||||
|
dnsmasq_config_file = /etc/neutron/dnsmasq.conf
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
enable_metadata_network = True
|
enable_metadata_network = True
|
||||||
enable_isolated_metadata = True
|
enable_isolated_metadata = True
|
||||||
|
|
||||||
|
@ -283,6 +283,24 @@ class DHCPAgentContextTest(CharmTestCase):
|
|||||||
rid='rid1',
|
rid='rid1',
|
||||||
unit='nova-compute/0')
|
unit='nova-compute/0')
|
||||||
|
|
||||||
|
def test_dnsmasq_flags(self):
|
||||||
|
self.relation_ids.return_value = ['rid1']
|
||||||
|
self.related_units.return_value = ['nova-compute/0']
|
||||||
|
self.relation_get.return_value = None
|
||||||
|
self.test_config.set('dnsmasq-flags', 'dhcp-userclass=set:ipxe,iPXE,'
|
||||||
|
'dhcp-match=set:ipxe,175,'
|
||||||
|
'server=1.2.3.4')
|
||||||
|
self.assertEqual(
|
||||||
|
context.DHCPAgentContext()(),
|
||||||
|
{
|
||||||
|
'dnsmasq_flags': {
|
||||||
|
'dhcp-userclass': 'set:ipxe,iPXE',
|
||||||
|
'dhcp-match': 'set:ipxe,175',
|
||||||
|
'server': '1.2.3.4',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class L3AgentContextTest(CharmTestCase):
|
class L3AgentContextTest(CharmTestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user