|
|
403b09 |
From caceb3a08644dae0ecae05a5b1f18b91a522356d Mon Sep 17 00:00:00 2001
|
|
|
403b09 |
From: Martin Babinsky <mbabinsk@redhat.com>
|
|
|
403b09 |
Date: Thu, 14 Jul 2016 17:14:59 +0200
|
|
|
403b09 |
Subject: [PATCH] DNS install: Ensure that DNS servers container exists
|
|
|
403b09 |
|
|
|
403b09 |
during DNS installation it is assumed that the cn=servers,cn=dns container is
|
|
|
403b09 |
always present in LDAP backend when migrating DNS server info to LDAP.
|
|
|
403b09 |
|
|
|
403b09 |
This may not always be the case (e.g. when a new replica is set up against
|
|
|
403b09 |
older master) so the code must take additional steps to ensure this container
|
|
|
403b09 |
is present.
|
|
|
403b09 |
|
|
|
403b09 |
https://fedorahosted.org/freeipa/ticket/6083
|
|
|
403b09 |
|
|
|
403b09 |
Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
|
|
|
403b09 |
---
|
|
|
403b09 |
ipaserver/install/bindinstance.py | 21 +++++++++++++++++++++
|
|
|
403b09 |
ipaserver/install/plugins/dns.py | 13 ++-----------
|
|
|
403b09 |
2 files changed, 23 insertions(+), 11 deletions(-)
|
|
|
403b09 |
|
|
|
403b09 |
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py
|
|
|
403b09 |
index f4ed63141cf25dfcfdc72d37d6ff4563e4acccf1..844fb04a9d9feca936211964b75a0b3468ba663b 100644
|
|
|
403b09 |
--- a/ipaserver/install/bindinstance.py
|
|
|
403b09 |
+++ b/ipaserver/install/bindinstance.py
|
|
|
403b09 |
@@ -546,6 +546,26 @@ def remove_master_dns_records(hostname, realm):
|
|
|
403b09 |
bind.remove_server_ns_records(hostname)
|
|
|
403b09 |
|
|
|
403b09 |
|
|
|
403b09 |
+def ensure_dnsserver_container_exists(ldap, api_instance, logger=None):
|
|
|
403b09 |
+ """
|
|
|
403b09 |
+ Create cn=servers,cn=dns,$SUFFIX container. If logger is not None, emit a
|
|
|
403b09 |
+ message that the container already exists when DuplicateEntry is raised
|
|
|
403b09 |
+ """
|
|
|
403b09 |
+
|
|
|
403b09 |
+ entry = ldap.make_entry(
|
|
|
403b09 |
+ DN(api_instance.env.container_dnsservers, api_instance.env.basedn),
|
|
|
403b09 |
+ {
|
|
|
403b09 |
+ u'objectclass': [u'top', u'nsContainer'],
|
|
|
403b09 |
+ u'cn': [u'servers']
|
|
|
403b09 |
+ }
|
|
|
403b09 |
+ )
|
|
|
403b09 |
+ try:
|
|
|
403b09 |
+ ldap.add_entry(entry)
|
|
|
403b09 |
+ except errors.DuplicateEntry:
|
|
|
403b09 |
+ if logger is not None:
|
|
|
403b09 |
+ logger.debug('cn=servers,cn=dns container already exists')
|
|
|
403b09 |
+
|
|
|
403b09 |
+
|
|
|
403b09 |
class DnsBackup(object):
|
|
|
403b09 |
def __init__(self, service):
|
|
|
403b09 |
self.service = service
|
|
|
403b09 |
@@ -942,6 +962,7 @@ class BindInstance(service.Service):
|
|
|
403b09 |
)
|
|
|
403b09 |
|
|
|
403b09 |
def __setup_server_configuration(self):
|
|
|
403b09 |
+ ensure_dnsserver_container_exists(self.admin_conn, self.api)
|
|
|
403b09 |
try:
|
|
|
403b09 |
self.api.Command.dnsserver_add(
|
|
|
403b09 |
self.fqdn, idnssoamname=DNSName(self.fqdn).make_absolute(),
|
|
|
403b09 |
diff --git a/ipaserver/install/plugins/dns.py b/ipaserver/install/plugins/dns.py
|
|
|
403b09 |
index 4fa30661e40748cd32cb25c232168191db20c461..32247eedbac7fc7e00c7277ef0bc593a74cd22e4 100644
|
|
|
403b09 |
--- a/ipaserver/install/plugins/dns.py
|
|
|
403b09 |
+++ b/ipaserver/install/plugins/dns.py
|
|
|
403b09 |
@@ -29,6 +29,7 @@ from ipapython.dn import DN
|
|
|
403b09 |
from ipapython import dnsutil
|
|
|
403b09 |
from ipapython.ipa_log_manager import root_logger
|
|
|
403b09 |
from ipaserver.install import sysupgrade
|
|
|
403b09 |
+from ipaserver.install.bindinstance import ensure_dnsserver_container_exists
|
|
|
403b09 |
from ipaserver.plugins.dns import dns_container_exists
|
|
|
403b09 |
|
|
|
403b09 |
register = Registry()
|
|
|
403b09 |
@@ -521,17 +522,7 @@ class update_dnsserver_configuration_into_ldap(DNSUpdater):
|
|
|
403b09 |
return False, []
|
|
|
403b09 |
|
|
|
403b09 |
# create container first, if doesn't exist
|
|
|
403b09 |
- entry = ldap.make_entry(
|
|
|
403b09 |
- DN(self.api.env.container_dnsservers, self.api.env.basedn),
|
|
|
403b09 |
- {
|
|
|
403b09 |
- u'objectclass': [u'top', u'nsContainer'],
|
|
|
403b09 |
- u'cn': [u'servers']
|
|
|
403b09 |
- }
|
|
|
403b09 |
- )
|
|
|
403b09 |
- try:
|
|
|
403b09 |
- ldap.add_entry(entry)
|
|
|
403b09 |
- except errors.DuplicateEntry:
|
|
|
403b09 |
- self.log.debug('cn=dnsservers container already exists')
|
|
|
403b09 |
+ ensure_dnsserver_container_exists(ldap, self.api, logger=self.log)
|
|
|
403b09 |
|
|
|
403b09 |
try:
|
|
|
403b09 |
self.api.Command.dnsserver_add(self.api.env.host)
|
|
|
403b09 |
--
|
|
|
403b09 |
2.7.4
|
|
|
403b09 |
|