summaryrefslogtreecommitdiffstats
path: root/ipaserver
diff options
context:
space:
mode:
authorMartin Nagy <mnagy@redhat.com>2009-09-02 16:22:50 +0200
committerMartin Nagy <mnagy@redhat.com>2009-09-02 22:04:25 +0200
commit205a41205b152b34b288d63075d33912095d0a84 (patch)
tree2df1d68e54e0e9218b47697c58a795614b8043b3 /ipaserver
parentb07d1b54f9f7d4143e2454908e79dd845ca07468 (diff)
downloadfreeipa-205a41205b152b34b288d63075d33912095d0a84.tar.gz
freeipa-205a41205b152b34b288d63075d33912095d0a84.tar.xz
freeipa-205a41205b152b34b288d63075d33912095d0a84.zip
Add A and PTR records of ourselves during installation
If the DNS zones already exist but don't contain our own records, add them. This patch introduces the ipalib.api into the installers. For now, the code is still little messy. Later patches will abandon the way we create zones now and use ipalib.api exclusively.
Diffstat (limited to 'ipaserver')
-rw-r--r--ipaserver/install/bindinstance.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py
index e2c91f379..2a922a3db 100644
--- a/ipaserver/install/bindinstance.py
+++ b/ipaserver/install/bindinstance.py
@@ -28,7 +28,7 @@ import service
from ipaserver import ipaldap
from ipapython import sysrestore
from ipapython import ipautil
-from ipalib import util
+from ipalib import api, util
def check_inst():
# So far this file is always present in both RHEL5 and Fedora if all the necessary
@@ -122,15 +122,19 @@ class BindInstance(service.Service):
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)
+ a_rr_dn = "idnsName=%s,%s" % (self.host, zone_dn)
+ ptr_rr_dn = "idnsName=%s,%s" % (self.reverse_host, reverse_zone_dn)
server = ldap.initialize("ldap://" + self.fqdn)
server.simple_bind_s()
if object_exists(zone_dn):
- pass # TODO: Add dns records to the zone
+ if not object_exists(a_rr_dn):
+ self.step("adding our A record", self.__setup_a_record)
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
+ if not object_exists(ptr_rr_dn):
+ self.step("adding our PTR record", self.__setup_ptr_record)
else:
self.step("setting up reverse zone", self.__setup_reverse_zone)
@@ -173,6 +177,15 @@ class BindInstance(service.Service):
def __setup_reverse_zone(self):
self._ldap_mod("dns_reverse.ldif", self.sub_dict)
+ def __setup_a_record(self):
+ api.Command.dns_add_rr(unicode(self.domain), unicode(self.host),
+ u'A', unicode(self.ip_address))
+
+ def __setup_ptr_record(self):
+ api.Command.dns_add_rr(unicode(self.reverse_subnet + ".in-addr.arpa"),
+ unicode(self.reverse_host), u'PTR',
+ unicode(self.host))
+
def __setup_principal(self):
dns_principal = "DNS/" + self.fqdn + "@" + self.realm
installutils.kadmin_addprinc(dns_principal)