mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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.
This commit is contained in:
parent
b07d1b54f9
commit
205a41205b
@ -31,7 +31,7 @@ from ipaserver.install import dsinstance, replication, installutils, krbinstance
|
||||
from ipaserver.install import bindinstance, httpinstance, ntpinstance, certs
|
||||
from ipaserver import ipaldap
|
||||
from ipapython import version
|
||||
from ipalib import util
|
||||
from ipalib import api, util
|
||||
|
||||
CACERT="/usr/share/ipa/html/ca.crt"
|
||||
|
||||
@ -343,6 +343,12 @@ def main():
|
||||
service.restart("krb5kdc")
|
||||
|
||||
if options.setup_dns:
|
||||
# First bootstrap the plug-in framework
|
||||
api.bootstrap(in_server=True)
|
||||
api.finalize()
|
||||
api.Backend.ldap2.connect(bind_dn="cn=Directory Manager",
|
||||
bind_pw=config.dirman_password)
|
||||
|
||||
install_bind(config, options)
|
||||
|
||||
# Call client install script
|
||||
|
@ -51,7 +51,7 @@ from ipaserver.install.installutils import *
|
||||
|
||||
from ipapython import sysrestore
|
||||
from ipapython.ipautil import *
|
||||
from ipalib import util
|
||||
from ipalib import api, util
|
||||
|
||||
pw_name = None
|
||||
|
||||
@ -646,6 +646,11 @@ def main():
|
||||
bind = bindinstance.BindInstance(fstore, dm_password)
|
||||
bind.setup(host_name, ip_address, realm_name, domain_name, dns_forwarders)
|
||||
if options.setup_dns:
|
||||
# First bootstrap the plug-in framework
|
||||
api.bootstrap(in_server=True)
|
||||
api.finalize()
|
||||
api.Backend.ldap2.connect(bind_dn="cn=Directory Manager", bind_pw=dm_password)
|
||||
|
||||
bind.create_instance()
|
||||
else:
|
||||
bind.create_sample_bind_zone()
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user