diff options
author | Martin Basti <mbasti@redhat.com> | 2016-06-13 20:41:24 +0200 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2016-06-17 15:22:24 +0200 |
commit | 52590d6fa581e3b53e2c9350dc307a1f360c40a3 (patch) | |
tree | e7973258e4dbac1d4a4442e6dfc272c5e8c21ce9 /ipaserver | |
parent | 2157ea0e6d0d762bdc71022ddd55045406c4b300 (diff) | |
download | freeipa-52590d6fa581e3b53e2c9350dc307a1f360c40a3.tar.gz freeipa-52590d6fa581e3b53e2c9350dc307a1f360c40a3.tar.xz freeipa-52590d6fa581e3b53e2c9350dc307a1f360c40a3.zip |
DNS Locations: dnsserver: put server_id option into named.conf
The option server_id is required for DNS location feature, otherwise it
will not work.
https://fedorahosted.org/freeipa/ticket/2008
Reviewed-By: Petr Spacek <pspacek@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipaserver')
-rw-r--r-- | ipaserver/install/plugins/dns.py | 52 | ||||
-rw-r--r-- | ipaserver/install/server/upgrade.py | 23 |
2 files changed, 75 insertions, 0 deletions
diff --git a/ipaserver/install/plugins/dns.py b/ipaserver/install/plugins/dns.py index 2399264c2..4fa30661e 100644 --- a/ipaserver/install/plugins/dns.py +++ b/ipaserver/install/plugins/dns.py @@ -28,6 +28,7 @@ from ipalib import Updater from ipapython.dn import DN from ipapython import dnsutil from ipapython.ipa_log_manager import root_logger +from ipaserver.install import sysupgrade from ipaserver.plugins.dns import dns_container_exists register = Registry() @@ -491,3 +492,54 @@ class update_dnsforward_emptyzones(DNSUpdater): self.update_global_ldap_forwarder() return False, [] + + +@register() +class update_dnsserver_configuration_into_ldap(DNSUpdater): + """ + DNS Locations feature requires to have DNS configuration stored in LDAP DB. + Create DNS server configuration in LDAP for each old server + """ + def execute(self, **options): + ldap = self.api.Backend.ldap2 + if sysupgrade.get_upgrade_state('dns', 'server_config_to_ldap'): + self.log.debug('upgrade is not needed') + return False, [] + + dns_container_dn = DN(self.api.env.container_dns, self.api.env.basedn) + try: + ldap.get_entry(dns_container_dn) + except errors.NotFound: + self.log.debug('DNS container not found, nothing to upgrade') + sysupgrade.set_upgrade_state('dns', 'server_config_to_ldap', True) + return False, [] + + result = self.api.Command.server_show(self.api.env.host)['result'] + if not 'DNS server' in result.get('enabled_role_servrole', []): + self.log.debug('This server is not DNS server, nothing to upgrade') + sysupgrade.set_upgrade_state('dns', 'server_config_to_ldap', True) + return False, [] + + # create container first, if doesn't exist + entry = ldap.make_entry( + DN(self.api.env.container_dnsservers, self.api.env.basedn), + { + u'objectclass': [u'top', u'nsContainer'], + u'cn': [u'servers'] + } + ) + try: + ldap.add_entry(entry) + except errors.DuplicateEntry: + self.log.debug('cn=dnsservers container already exists') + + try: + self.api.Command.dnsserver_add(self.api.env.host) + except errors.DuplicateEntry: + self.log.debug("DNS server configuration already exists " + "in LDAP database") + else: + self.log.debug("DNS server configuration has been sucessfully " + "created in LDAP database") + sysupgrade.set_upgrade_state('dns', 'server_config_to_ldap', True) + return False, [] diff --git a/ipaserver/install/server/upgrade.py b/ipaserver/install/server/upgrade.py index eacd43939..b4b6243ac 100644 --- a/ipaserver/install/server/upgrade.py +++ b/ipaserver/install/server/upgrade.py @@ -842,6 +842,28 @@ def named_update_global_forwarder_policy(): return True +def named_add_server_id(): + """ + DNS Locations feature requires to have configured server_id in IPA section + of named.conf + :return: if named.conf has been changed + """ + bind = bindinstance.BindInstance() + if not bindinstance.named_conf_exists() or not bind.is_configured(): + # DNS service may not be configured + root_logger.info('DNS is not configured') + return False + + if sysupgrade.get_upgrade_state('named.conf', 'add_server_id'): + # upgrade was done already + return False + + root_logger.info('[Adding server_id to named.conf]') + bindinstance.named_conf_set_directive('server_id', api.env.host) + sysupgrade.set_upgrade_state('named.conf', 'add_server_id', True) + return True + + def certificate_renewal_update(ca, ds, http): """ Update certmonger certificate renewal configuration. @@ -1680,6 +1702,7 @@ def upgrade_configuration(): named_update_global_forwarder_policy(), mask_named_regular(), fix_dyndb_ldap_workdir_permissions(), + named_add_server_id(), ) if any(named_conf_changes): |