Add final dot when missing in nameservers
The configuration option nameserver expects each value to have a dot (.) at the end, currently when this dot is missing the servers creation fail, the error doesn't bubble up. On the neutron-api charm adds the dot automatically when it's missing in the dns-domain config option, this change makes the Designate charm behave in the same way. Change-Id: If335c9b5b1b2adca3e39fa4f1d182dfbe362f874 Closes-Bug: #1952656
This commit is contained in:
parent
1e7035e2f0
commit
81c8cbf4a6
|
@ -543,7 +543,13 @@ class DesignateCharm(ch_plugins.PolicydOverridePlugin,
|
|||
with cls.check_zone_ids(nova_domain_name, neutron_domain_name):
|
||||
if hookenv.config('nameservers'):
|
||||
for ns in hookenv.config('nameservers').split():
|
||||
cls.create_server(ns)
|
||||
ns_ = ns
|
||||
if not ns.endswith('.'):
|
||||
ns_ = ns + '.'
|
||||
hookenv.log(("Missing dot (.) at the end of '%s', "
|
||||
"adding it automatically." % ns),
|
||||
level=hookenv.WARNING)
|
||||
cls.create_server(ns_)
|
||||
else:
|
||||
hookenv.log('No nameserver specified, skipping creation of'
|
||||
'nova and neutron domains',
|
||||
|
|
|
@ -311,7 +311,7 @@ class TestDesignateCharm(Helper):
|
|||
|
||||
def test_create_initial_servers_and_domains(self):
|
||||
test_config = {
|
||||
'nameservers': 'dnsserverrec1',
|
||||
'nameservers': 'dnsserverrec1. dnsserverrec2',
|
||||
'nova-domain': 'novadomain',
|
||||
'nova-domain-email': 'novaemail',
|
||||
'neutron-domain': 'neutrondomain',
|
||||
|
@ -333,7 +333,8 @@ class TestDesignateCharm(Helper):
|
|||
with mock.patch.object(designate.hookenv, 'config',
|
||||
side_effect=FakeConfig(test_config)):
|
||||
designate.DesignateCharm.create_initial_servers_and_domains()
|
||||
self.create_server.assert_called_once_with('dnsserverrec1')
|
||||
self.create_server.assert_has_calls([mock.call('dnsserverrec1.'),
|
||||
mock.call('dnsserverrec2.')])
|
||||
calls = [
|
||||
mock.call('novadomain', 'novaemail'),
|
||||
mock.call('neutrondomain', 'neutronemail')]
|
||||
|
|
Loading…
Reference in New Issue