diff options
author | Zuul <zuul@review.opendev.org> | 2021-03-04 23:47:19 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-03-04 23:47:19 +0000 |
commit | f101fab29540ba11481abbf9c7558f976d14b26b (patch) | |
tree | 6500f56de228060deca4c948a726a0b68dda4d2a /designate/backend/impl_bind9.py | |
parent | 39c2566fcd70f8e38ff898bb411aa6a63fe11a2c (diff) | |
parent | 953492904772933f5f8e265d1ae6cc1e6385fcc6 (diff) | |
download | designate-stable/train.tar.gz |
Merge "Update zones masters using pool target masters." into stable/trainstable/train
Diffstat (limited to 'designate/backend/impl_bind9.py')
-rw-r--r-- | designate/backend/impl_bind9.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/designate/backend/impl_bind9.py b/designate/backend/impl_bind9.py index 0c1c853c..b27d1835 100644 --- a/designate/backend/impl_bind9.py +++ b/designate/backend/impl_bind9.py @@ -127,6 +127,43 @@ class Bind9Backend(base.Backend): LOG.warning('RNDC call failure: %s', e) raise + def update_zone(self, context, zone): + """ + Update a DNS zone. + + This will execute a rndc modzone as the zone + already exists but masters might need to be refreshed. + + :param context: Security context information. + :param zone: the DNS zone. + """ + LOG.debug('Update Zone') + + masters = [] + for master in self.masters: + host = master['host'] + port = master['port'] + masters.append('%s port %s' % (host, port)) + + # Ensure different MiniDNS instances are targeted for AXFRs + random.shuffle(masters) + + view = 'in %s' % self._view if self._view else '' + + rndc_op = [ + 'modzone', + '%s %s { type slave; masters { %s;}; file "slave.%s%s"; };' % + (zone['name'].rstrip('.'), view, '; '.join(masters), zone['name'], + zone['id']), + ] + + try: + self._execute_rndc(rndc_op) + except exceptions.Backend as e: + LOG.warning("Error updating zone: %s", e) + pass + super(Bind9Backend, self).update_zone(context, zone) + def _execute_rndc(self, rndc_op): """Execute rndc |