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.
This commit is contained in:
Martin Nagy
2009-06-26 19:37:49 +02:00
parent a09d2c3498
commit de53d0a26e
4 changed files with 79 additions and 6 deletions

View File

@@ -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())