From cdedb2f39a655033d7385410b2268db322965d5e Mon Sep 17 00:00:00 2001 From: Tom Walsh Date: Tue, 22 Mar 2016 10:56:13 -0500 Subject: [PATCH] Added "view" option to bind9 rndc options Change-Id: I53fb454e785bf45be2860d32416e99efe6ca3b3f --- designate/backend/impl_bind9.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) mode change 100644 => 100755 designate/backend/impl_bind9.py diff --git a/designate/backend/impl_bind9.py b/designate/backend/impl_bind9.py old mode 100644 new mode 100755 index c17b5b492..662ddad24 --- a/designate/backend/impl_bind9.py +++ b/designate/backend/impl_bind9.py @@ -44,6 +44,7 @@ class Bind9Backend(base.Backend): # TODO(Federico): make attributes private, run _rndc_base at init time self.host = self.options.get('host', '127.0.0.1') self.port = int(self.options.get('port', 53)) + self.view = self.options.get('view') self.rndc_host = self.options.get('rndc_host', '127.0.0.1') self.rndc_port = int(self.options.get('rndc_port', 953)) self.rndc_config_file = self.options.get('rndc_config_file') @@ -68,10 +69,15 @@ class Bind9Backend(base.Backend): # Ensure different MiniDNS instances are targeted for AXFRs random.shuffle(masters) + if self.view: + view = 'in %s' % self.view + else: + view = '' + rndc_op = [ 'addzone', - '%s { type slave; masters { %s;}; file "slave.%s%s"; };' % - (zone['name'].rstrip('.'), '; '.join(masters), zone['name'], + '%s %s { type slave; masters { %s;}; file "slave.%s%s"; };' % + (zone['name'].rstrip('.'), view, '; '.join(masters), zone['name'], zone['id']), ] @@ -91,9 +97,15 @@ class Bind9Backend(base.Backend): Do not raise exceptions if the zone does not exist. """ LOG.debug('Delete Zone') + + if self.view: + view = 'in %s' % self.view + else: + view = '' + rndc_op = [ 'delzone', - '%s' % zone['name'].rstrip('.'), + '%s %s' % (zone['name'].rstrip('.'), view), ] if self.clean_zonefile: rndc_op.insert(1, '-clean')