From de53d0a26e1ad7ae20368967f81b7e6391b7198d Mon Sep 17 00:00:00 2001 From: Martin Nagy Date: Fri, 26 Jun 2009 19:37:49 +0200 Subject: Make --setup-dns work on replica installation The ipa-replica-install script will setup the DNS if user specifies the --setup-dns option. It will only add the zone into LDAP if the cn=dns,$SUFFIX container doesn't exist. For now, however, we do not add the records. --- ipaserver/install/bindinstance.py | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'ipaserver/install/bindinstance.py') diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py index f8fc2a98..cadab10e 100644 --- a/ipaserver/install/bindinstance.py +++ b/ipaserver/install/bindinstance.py @@ -93,10 +93,7 @@ class BindInstance(service.Service): except: pass - # FIXME: this need to be split off, as only the first server can do - # this operation - self.step("Setting up our zone", self.__setup_zone) - self.step("setting up reverse zone", self.__setup_reverse_zone) + self.__add_zone_steps() self.step("setting up kerberos principal", self.__setup_principal) self.step("setting up named.conf", self.__setup_named_conf) @@ -107,6 +104,39 @@ class BindInstance(service.Service): self.step("changing resolv.conf to point to ourselves", self.__setup_resolv_conf) self.start_creation("Configuring named:") + def __add_zone_steps(self): + """ + Add steps necessary to add records and zones, if they don't exist + already. + """ + + def object_exists(dn): + """ + Test whether the given object exists in LDAP. + """ + try: + server.search_ext_s(dn, ldap.SCOPE_BASE) + except ldap.NO_SUCH_OBJECT: + return False + else: + return True + + zone_dn = "idnsName=%s,cn=dns,%s" % (self.domain, self.suffix) + reverse_zone_dn = "idnsName=%s.in-addr.arpa,cn=dns,%s" % (self.reverse_subnet, self.suffix) + + server = ldap.initialize("ldap://" + self.fqdn) + server.simple_bind_s() + if object_exists(zone_dn): + pass # TODO: Add dns records to the zone + else: + self.step("setting up our zone", self.__setup_zone) + if object_exists(reverse_zone_dn): + pass # TODO: Add dns records to the reverse zone + else: + self.step("setting up reverse zone", self.__setup_reverse_zone) + + server.unbind_s() + def __start(self): try: self.backup_state("running", self.is_running()) -- cgit