DNS install: Ensure that DNS servers container exists

during DNS installation it is assumed that the cn=servers,cn=dns container is
always present in LDAP backend when migrating DNS server info to LDAP.

This may not always be the case (e.g. when a new replica is set up against
older master) so the code must take additional steps to ensure this container
is present.

https://fedorahosted.org/freeipa/ticket/6083

Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
Martin Babinsky
2016-07-14 17:14:59 +02:00
committed by Petr Vobornik
parent 49389ed1e0
commit 37bfd1fdde
2 changed files with 23 additions and 11 deletions

View File

@@ -29,6 +29,7 @@ from ipapython.dn import DN
from ipapython import dnsutil
from ipapython.ipa_log_manager import root_logger
from ipaserver.install import sysupgrade
from ipaserver.install.bindinstance import ensure_dnsserver_container_exists
from ipaserver.plugins.dns import dns_container_exists
register = Registry()
@@ -521,17 +522,7 @@ class update_dnsserver_configuration_into_ldap(DNSUpdater):
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')
ensure_dnsserver_container_exists(ldap, self.api, logger=self.log)
try:
self.api.Command.dnsserver_add(self.api.env.host)