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>
This commit is contained in:
Martin Basti
2016-06-13 20:41:24 +02:00
parent 2157ea0e6d
commit 52590d6fa5
6 changed files with 78 additions and 7 deletions

View File

@@ -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, []