diff options
author | Martin Kosek <mkosek@redhat.com> | 2012-09-25 10:36:01 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-09-26 13:44:11 +0200 |
commit | c49bc80494938a41d2c34c7ac1cde1fe3a14ddd5 (patch) | |
tree | d184696f792b1966373604157c2cc916b6940d4b /ipaserver/install/bindinstance.py | |
parent | ba5248135c0ca9d64deddc9d11ea1a606d87bc27 (diff) | |
download | freeipa-c49bc80494938a41d2c34c7ac1cde1fe3a14ddd5.tar.gz freeipa-c49bc80494938a41d2c34c7ac1cde1fe3a14ddd5.tar.xz freeipa-c49bc80494938a41d2c34c7ac1cde1fe3a14ddd5.zip |
Use custom zonemgr for reverse zones
When DNS is being installed during ipa-{server,dns,replica}-install,
forward and reverse zone is created. However, reverse zone was always
created with default zonemgr even when a custom zonemgr was passed
to the installer as this functionality was missing in function
creating reverse zone.
Consolidate functions creating forward and reverse zones to avoid
code duplication and errors like this one. Reverse zones are now
created with custom zonemgr (when entered by user).
https://fedorahosted.org/freeipa/ticket/2790
Diffstat (limited to 'ipaserver/install/bindinstance.py')
-rw-r--r-- | ipaserver/install/bindinstance.py | 61 |
1 files changed, 12 insertions, 49 deletions
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py index c2c4a86b4..9f6dca525 100644 --- a/ipaserver/install/bindinstance.py +++ b/ipaserver/install/bindinstance.py @@ -34,7 +34,7 @@ from ipapython import ipautil from ipalib.parameters import IA5Str from ipalib.util import (validate_zonemgr, normalize_zonemgr, get_dns_forward_zone_update_policy, get_dns_reverse_zone_update_policy, - normalize_zone, get_reverse_zone_default) + normalize_zone, get_reverse_zone_default, zone_is_reverse) from ipapython.ipa_log_manager import * from ipalib.text import _ @@ -252,8 +252,15 @@ def read_reverse_zone(default, ip_address): def add_zone(name, zonemgr=None, dns_backup=None, ns_hostname=None, ns_ip_address=None, update_policy=None): + if zone_is_reverse(name): + # always normalize reverse zones + name = normalize_zone(name) + if update_policy is None: - update_policy = get_dns_forward_zone_update_policy(api.env.realm) + if zone_is_reverse(name): + update_policy = get_dns_reverse_zone_update_policy(api.env.realm, name) + else: + update_policy = get_dns_forward_zone_update_policy(api.env.realm) if zonemgr is None: zonemgr = 'hostmaster.%s' % name @@ -276,13 +283,14 @@ def add_zone(name, zonemgr=None, dns_backup=None, ns_hostname=None, ns_ip_addres else: ns_main = ns_hostname ns_replicas = [] + ns_main = normalize_zone(ns_main) if ns_ip_address is not None: ns_ip_address = unicode(ns_ip_address) try: api.Command.dnszone_add(unicode(name), - idnssoamname=unicode(ns_main+'.'), + idnssoamname=unicode(ns_main), idnssoarname=unicode(zonemgr), ip_address=ns_ip_address, idnsallowdynupdate=True, @@ -296,51 +304,6 @@ def add_zone(name, zonemgr=None, dns_backup=None, ns_hostname=None, ns_ip_addres for hostname in nameservers: add_ns_rr(name, hostname, dns_backup=None, force=True) - -def add_reverse_zone(zone, ns_hostname=None, ns_ip_address=None, - ns_replicas=[], update_policy=None, dns_backup=None): - zone = normalize_zone(zone) - if update_policy is None: - update_policy = get_dns_reverse_zone_update_policy(api.env.realm, zone) - - if ns_hostname is None: - # automatically retrieve list of DNS masters - dns_masters = api.Object.dnsrecord.get_dns_masters() - if not dns_masters: - raise installutils.ScriptError( - "No IPA server with DNS support found!") - ns_main = dns_masters.pop(0) - ns_replicas = dns_masters - addresses = resolve_host(ns_main) - - if len(addresses) > 0: - # use the first address - ns_ip_address = addresses[0] - else: - ns_ip_address = None - else: - ns_main = ns_hostname - ns_replicas = [] - - if ns_ip_address is not None: - ns_ip_address = unicode(ns_ip_address) - - try: - api.Command.dnszone_add(unicode(zone), - idnssoamname=unicode(ns_main+'.'), - idnsallowdynupdate=True, - ip_address=ns_ip_address, - idnsupdatepolicy=unicode(update_policy), - idnsallowquery=u'any', - idnsallowtransfer=u'none',) - except (errors.DuplicateEntry, errors.EmptyModlist): - pass - - nameservers = ns_replicas + [ns_main] - for hostname in nameservers: - add_ns_rr(zone, hostname, dns_backup=None, force=True) - - def add_rr(zone, name, type, rdata, dns_backup=None, **kwargs): addkw = { '%srecord' % str(type.lower()) : unicode(rdata) } addkw.update(kwargs) @@ -639,7 +602,7 @@ class BindInstance(service.Service): add_ptr_rr(self.reverse_zone, self.ip_address, self.fqdn) def __setup_reverse_zone(self): - add_reverse_zone(self.reverse_zone, ns_hostname=api.env.host, + add_zone(self.reverse_zone, self.zonemgr, ns_hostname=api.env.host, ns_ip_address=self.ip_address, dns_backup=self.dns_backup) def __setup_principal(self): |