Specify dns_domain in dhcp_agent.ini from neutron-api
Specify the dns_domain value in dhcp_agent.ini configuration file in order to indicate the dns search domain which should be advertised by the dnsmasq DHCP server. Note, for neutron-openvswitch - this only takes effect when the enable-local-dhcp-and-metadata flag is set to true. Change-Id: If3529cf32a6e10d44c86423151cdacdad50445f8 Implements: blueprint charms-internal-dns
This commit is contained in:
parent
9ce4995205
commit
d78ffcae0a
@ -1393,6 +1393,10 @@ class NeutronAPIContext(OSContextGenerator):
|
|||||||
'rel_key': 'enable-l3ha',
|
'rel_key': 'enable-l3ha',
|
||||||
'default': False,
|
'default': False,
|
||||||
},
|
},
|
||||||
|
'dns_domain': {
|
||||||
|
'rel_key': 'dns-domain',
|
||||||
|
'default': None,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
ctxt = self.get_neutron_options({})
|
ctxt = self.get_neutron_options({})
|
||||||
for rid in relation_ids('neutron-plugin-api'):
|
for rid in relation_ids('neutron-plugin-api'):
|
||||||
|
@ -156,7 +156,8 @@ class DHCPAgentContext(OSContextGenerator):
|
|||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
"""Return the 'default_availability_zone' from the principal that this
|
"""Return the 'default_availability_zone' from the principal that this
|
||||||
ovs unit is attached to (as a subordinate).
|
ovs unit is attached to (as a subordinate) and the 'dns_domain' from
|
||||||
|
the neutron-plugin-api relations (if one is set).
|
||||||
|
|
||||||
:returns: {} if no relation set, or
|
:returns: {} if no relation set, or
|
||||||
{'availability_zone': availability_zone from principal relation}
|
{'availability_zone': availability_zone from principal relation}
|
||||||
@ -181,6 +182,10 @@ class DHCPAgentContext(OSContextGenerator):
|
|||||||
if dnsmasq_flags:
|
if dnsmasq_flags:
|
||||||
ctxt['dnsmasq_flags'] = config_flags_parser(dnsmasq_flags)
|
ctxt['dnsmasq_flags'] = config_flags_parser(dnsmasq_flags)
|
||||||
|
|
||||||
|
neutron_api_settings = NeutronAPIContext()()
|
||||||
|
if neutron_api_settings.get('dns_domain'):
|
||||||
|
ctxt['dns_domain'] = neutron_api_settings.get('dns_domain')
|
||||||
|
|
||||||
return ctxt
|
return ctxt
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,14 @@ root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
|
|||||||
dnsmasq_config_file = /etc/neutron/dnsmasq.conf
|
dnsmasq_config_file = /etc/neutron/dnsmasq.conf
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
|
{% if dns_domain -%}
|
||||||
|
dns_domain = {{ dns_domain }}
|
||||||
|
# Per LP#1583769, dhcp_domain needs to be configured in mitaka as well. Additional
|
||||||
|
# testing shows that this has not been changed in newton, so will also
|
||||||
|
# specify the dhcp_domain field.
|
||||||
|
dhcp_domain = {{ dns_domain }}
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
enable_metadata_network = True
|
enable_metadata_network = True
|
||||||
enable_isolated_metadata = True
|
enable_isolated_metadata = True
|
||||||
|
|
||||||
|
@ -255,13 +255,28 @@ class DHCPAgentContextTest(CharmTestCase):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(DHCPAgentContextTest, self).tearDown()
|
super(DHCPAgentContextTest, self).tearDown()
|
||||||
|
|
||||||
def test_default_availability_zone_not_provided(self):
|
@patch.object(charmhelpers.contrib.openstack.context, 'relation_get')
|
||||||
|
@patch.object(charmhelpers.contrib.openstack.context, 'relation_ids')
|
||||||
|
@patch.object(charmhelpers.contrib.openstack.context, 'related_units')
|
||||||
|
def test_default_availability_zone_not_provided(self, _runits, _rids,
|
||||||
|
_rget):
|
||||||
|
_runits.return_value = ['neutron-api/0']
|
||||||
|
_rids.return_value = ['rid2']
|
||||||
|
rdata = {
|
||||||
|
'neutron-security-groups': 'True',
|
||||||
|
'enable-dvr': 'True',
|
||||||
|
'l2-population': 'True',
|
||||||
|
'overlay-netweork-type': 'vxlan',
|
||||||
|
'network-device-mtu': 1500,
|
||||||
|
'dns-domain': 'openstack.example.'
|
||||||
|
}
|
||||||
|
_rget.side_effect = lambda *args, **kwargs: rdata
|
||||||
self.relation_ids.return_value = ['rid1']
|
self.relation_ids.return_value = ['rid1']
|
||||||
self.related_units.return_value = ['nova-compute/0']
|
self.related_units.return_value = ['nova-compute/0']
|
||||||
self.relation_get.return_value = None
|
self.relation_get.return_value = None
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
context.DHCPAgentContext()(),
|
context.DHCPAgentContext()(),
|
||||||
{}
|
{'dns_domain': 'openstack.example.'}
|
||||||
)
|
)
|
||||||
self.relation_ids.assert_called_with('neutron-plugin')
|
self.relation_ids.assert_called_with('neutron-plugin')
|
||||||
self.relation_get.assert_called_once_with(
|
self.relation_get.assert_called_once_with(
|
||||||
@ -269,7 +284,49 @@ class DHCPAgentContextTest(CharmTestCase):
|
|||||||
rid='rid1',
|
rid='rid1',
|
||||||
unit='nova-compute/0')
|
unit='nova-compute/0')
|
||||||
|
|
||||||
def test_default_availability_zone_provided(self):
|
@patch.object(charmhelpers.contrib.openstack.context, 'relation_get')
|
||||||
|
@patch.object(charmhelpers.contrib.openstack.context, 'relation_ids')
|
||||||
|
@patch.object(charmhelpers.contrib.openstack.context, 'related_units')
|
||||||
|
def test_default_availability_zone_provided(self, _runits, _rids, _rget):
|
||||||
|
_runits.return_value = ['neutron-api/0']
|
||||||
|
_rids.return_value = ['rid2']
|
||||||
|
rdata = {
|
||||||
|
'neutron-security-groups': 'True',
|
||||||
|
'enable-dvr': 'True',
|
||||||
|
'l2-population': 'True',
|
||||||
|
'overlay-netweork-type': 'vxlan',
|
||||||
|
'network-device-mtu': 1500,
|
||||||
|
'dns-domain': 'openstack.example.'
|
||||||
|
}
|
||||||
|
_rget.side_effect = lambda *args, **kwargs: rdata
|
||||||
|
self.relation_ids.return_value = ['rid1']
|
||||||
|
self.related_units.return_value = ['nova-compute/0']
|
||||||
|
self.relation_get.return_value = 'nova'
|
||||||
|
self.assertEqual(
|
||||||
|
context.DHCPAgentContext()(),
|
||||||
|
{'availability_zone': 'nova',
|
||||||
|
'dns_domain': 'openstack.example.'}
|
||||||
|
)
|
||||||
|
self.relation_ids.assert_called_with('neutron-plugin')
|
||||||
|
self.relation_get.assert_called_once_with(
|
||||||
|
'default_availability_zone',
|
||||||
|
rid='rid1',
|
||||||
|
unit='nova-compute/0')
|
||||||
|
|
||||||
|
@patch.object(charmhelpers.contrib.openstack.context, 'relation_get')
|
||||||
|
@patch.object(charmhelpers.contrib.openstack.context, 'relation_ids')
|
||||||
|
@patch.object(charmhelpers.contrib.openstack.context, 'related_units')
|
||||||
|
def test_no_dns_domain(self, _runits, _rids, _rget):
|
||||||
|
_runits.return_value = ['neutron-api/0']
|
||||||
|
_rids.return_value = ['rid2']
|
||||||
|
rdata = {
|
||||||
|
'neutron-security-groups': 'True',
|
||||||
|
'enable-dvr': 'True',
|
||||||
|
'l2-population': 'True',
|
||||||
|
'overlay-netweork-type': 'vxlan',
|
||||||
|
'network-device-mtu': 1500,
|
||||||
|
}
|
||||||
|
_rget.side_effect = lambda *args, **kwargs: rdata
|
||||||
self.relation_ids.return_value = ['rid1']
|
self.relation_ids.return_value = ['rid1']
|
||||||
self.related_units.return_value = ['nova-compute/0']
|
self.related_units.return_value = ['nova-compute/0']
|
||||||
self.relation_get.return_value = 'nova'
|
self.relation_get.return_value = 'nova'
|
||||||
@ -283,7 +340,20 @@ class DHCPAgentContextTest(CharmTestCase):
|
|||||||
rid='rid1',
|
rid='rid1',
|
||||||
unit='nova-compute/0')
|
unit='nova-compute/0')
|
||||||
|
|
||||||
def test_dnsmasq_flags(self):
|
@patch.object(charmhelpers.contrib.openstack.context, 'relation_get')
|
||||||
|
@patch.object(charmhelpers.contrib.openstack.context, 'relation_ids')
|
||||||
|
@patch.object(charmhelpers.contrib.openstack.context, 'related_units')
|
||||||
|
def test_dnsmasq_flags(self, _runits, _rids, _rget):
|
||||||
|
_runits.return_value = ['neutron-api/0']
|
||||||
|
_rids.return_value = ['rid2']
|
||||||
|
rdata = {
|
||||||
|
'neutron-security-groups': 'True',
|
||||||
|
'enable-dvr': 'True',
|
||||||
|
'l2-population': 'True',
|
||||||
|
'overlay-netweork-type': 'vxlan',
|
||||||
|
'network-device-mtu': 1500,
|
||||||
|
}
|
||||||
|
_rget.side_effect = lambda *args, **kwargs: rdata
|
||||||
self.relation_ids.return_value = ['rid1']
|
self.relation_ids.return_value = ['rid1']
|
||||||
self.related_units.return_value = ['nova-compute/0']
|
self.related_units.return_value = ['nova-compute/0']
|
||||||
self.relation_get.return_value = None
|
self.relation_get.return_value = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user