Implement "dns-backend" binding

This patchset implements support for "dns-backend" binding. Use the
"dns-backend" relation network space binding to populate the list
of dns master servers in the designate pool configuration,
ensuring that communication between master and slave servers
happens over the correct network space.

Depends-On: I927e3958cf929ace9d43f8b3d9509b90b9eab60f
Depends-On: Icbe0cc790c565f125f0fe8c903e9b755fe764d7c
Change-Id: I2c7b95e630611ac16c19e7f9efb81f54802849e9
Closes-Bug: #1722794
This commit is contained in:
Tytus Kurek 2017-11-13 11:30:12 +01:00
parent 61a89498c5
commit 9bc1b2c05b
4 changed files with 25 additions and 1 deletions

View File

@ -27,6 +27,8 @@ import charmhelpers.core.hookenv as hookenv
import charmhelpers.core.host as host
import charms.reactive as reactive
from charmhelpers.contrib.network import ip as ch_ip
DESIGNATE_DIR = '/etc/designate'
DESIGNATE_DEFAULT = '/etc/default/openstack'
DESIGNATE_CONF = DESIGNATE_DIR + '/designate.conf'
@ -234,6 +236,21 @@ class DesignateConfigurationAdapter(
"""
return os_ip.resolve_address(endpoint_type=os_ip.INTERNAL)
@property
def rndc_master_ips(self):
rndc_master_ips = []
rndc_master_ip = ch_ip.get_relation_ip('dns-backend')
rndc_master_ips.append(rndc_master_ip)
cluster_relid = hookenv.relation_ids('cluster')[0]
if hookenv.related_units(relid=cluster_relid):
for unit in hookenv.related_units(relid=cluster_relid):
rndc_master_ip = hookenv.relation_get('rndc-address',
rid=cluster_relid,
unit=unit)
if rndc_master_ip is not None:
rndc_master_ips.append(rndc_master_ip)
return rndc_master_ips
class DesignateAdapters(openstack_adapters.OpenStackAPIRelationAdapters):
"""

View File

@ -112,6 +112,12 @@ def maybe_setup_endpoint(keystone):
keystone.register_endpoints(*args)
@reactive.when('cluster.connected')
def expose_rndc_address(cluster):
rndc_address = ip.get_relation_ip('dns-backend')
cluster.set_address('rndc', rndc_address)
@reactive.when_not('base-config.rendered')
@reactive.when(*COMPLETE_INTERFACE_STATES)
def configure_designate_basic(*args):

View File

@ -27,7 +27,7 @@
{% for slave in dns_backend.pool_config %}
- type: bind9
masters:
{% for rndc_master_ip in cluster.internal_addresses %}
{% for rndc_master_ip in options.rndc_master_ips %}
- host: {{ rndc_master_ip }}
port: 5354
{% endfor %}

View File

@ -22,6 +22,7 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks):
'setup_amqp_req': ('amqp.connected', ),
'setup_database': ('shared-db.connected', ),
'maybe_setup_endpoint': ('identity-service.connected', ),
'expose_rndc_address': ('cluster.connected', ),
'configure_ssl': ('identity-service.available', ),
'update_peers': ('cluster.available', ),
'config_changed': ('config.changed', ),