Merge "Add "also-notifies" option"

This commit is contained in:
Zuul 2018-05-09 14:06:45 +00:00 committed by Gerrit Code Review
commit 00a1b7debd
4 changed files with 37 additions and 10 deletions

View File

@ -67,3 +67,10 @@ options:
type: boolean
default: false
description: Enables host request headers.
also-notifies:
type: string
default:
description: |
Space delimited list of DNS servers which should be notified on every
zone change in addition to the backend servers. List is of the form
also_notify_ip:also_notify_port

View File

@ -270,6 +270,15 @@ class DesignateConfigurationAdapter(
"""
return self.nameservers.split()
@property
def also_notifies_hosts(self):
also_notifies_hosts = []
if hookenv.config('also-notifies'):
for entry in hookenv.config('also-notifies').split():
address, port = entry.split(':')
also_notifies_hosts.append({'address': address, 'port': port})
return also_notifies_hosts
class DesignateAdapters(openstack_adapters.OpenStackAPIRelationAdapters):
"""

View File

@ -54,16 +54,13 @@
{% endfor %}
{% endif %}
{% if options.also_notifies_hosts %}
also_notifies:
{% if dns_backend and dns_backend.pool_config %}
{% for slave in dns_backend.pool_config %}
- host: {{ slave.address }}
port: 53
{% endfor %}
{% endif %}
{% if options.pool_config %}
{% for slave in options.pool_config %}
- host: {{ slave.address }}
port: 53
{% for also_notify_host in options.also_notifies_hosts %}
- host: {{ also_notify_host.address }}
port: {{ also_notify_host.port }}
{% endfor %}
# Workaround for https://bugs.launchpad.net/designate/+bug/1758013
{% else %}
also_notifies: []
{% endif %}

View File

@ -194,6 +194,20 @@ class TestDesignateConfigurationAdapter(Helper):
a = designate.DesignateConfigurationAdapter(relation)
self.assertEqual(a.rndc_master_ip, 'intip')
def test_also_notifies_hosts(self):
relation = mock.MagicMock
test_config = {
'also-notifies': '10.0.0.1:53 10.0.0.2:10053',
}
with mock.patch.object(designate.hookenv, 'config',
side_effect=FakeConfig(test_config)):
expect = [{'address': '10.0.0.1',
'port': '53'},
{'address': '10.0.0.2',
'port': '10053'}]
a = designate.DesignateConfigurationAdapter(relation)
self.assertEqual(a.also_notifies_hosts, expect)
class TestDesignateCharm(Helper):