From 83e72d704630b9cc5a1f713dfee30601950eb5e9 Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka Date: Nov 11 2016 11:13:56 +0000 Subject: Move ds.replica_populate to an update plugin Replica populate can be applied with other update plugins. https://fedorahosted.org/freeipa/ticket/6392 Reviewed-By: Martin Babinsky Reviewed-By: Jan Cholasta --- diff --git a/install/updates/90-post_upgrade_plugins.update b/install/updates/90-post_upgrade_plugins.update index 1208268..860cc41 100644 --- a/install/updates/90-post_upgrade_plugins.update +++ b/install/updates/90-post_upgrade_plugins.update @@ -27,3 +27,4 @@ plugin: update_read_replication_agreements_permission plugin: update_idrange_baserid plugin: update_passync_privilege_update plugin: update_dnsserver_configuration_into_ldap +plugin: update_ldap_server_list diff --git a/ipaserver/install/dsinstance.py b/ipaserver/install/dsinstance.py index f4cb247..49289d4 100644 --- a/ipaserver/install/dsinstance.py +++ b/ipaserver/install/dsinstance.py @@ -1144,22 +1144,6 @@ class DsInstance(service.Service): else: root_logger.debug("extdom plugin is already configured") - def replica_populate(self): - dn = DN(('cn', 'default'), ('ou', 'profile'), self.suffix) - try: - entry = self.admin_conn.get_entry(dn) - srvlist = entry.single_value.get('defaultServerList', '') - srvlist = srvlist.split() - if not self.fqdn in srvlist: - srvlist.append(self.fqdn) - attr = ' '.join(srvlist) - mod = [(ldap.MOD_REPLACE, 'defaultServerList', attr)] - self.admin_conn.modify_s(dn, mod) - except errors.NotFound: - pass - except ldap.TYPE_OR_VALUE_EXISTS: - pass - def find_subject_base(self): """ Try to find the current value of certificate subject base. diff --git a/ipaserver/install/plugins/update_ldap_server_list.py b/ipaserver/install/plugins/update_ldap_server_list.py new file mode 100644 index 0000000..c77a1fe --- /dev/null +++ b/ipaserver/install/plugins/update_ldap_server_list.py @@ -0,0 +1,38 @@ +# +# Copyright (C) 2016 FreeIPA Contributors see COPYING for license +# + +from ipalib import Registry +from ipalib import Updater +from ipalib import errors +from ipapython.dn import DN + +register = Registry() + + +@register() +class update_ldap_server_list(Updater): + """ + Update defaultServerList, an option that helps Solaris + clients discover LDAP server replicas. + """ + def execute(self, **options): + ldap = self.api.Backend.ldap2 + + dn = DN(('cn', 'default'), ('ou', 'profile'), self.api.env.basedn) + try: + entry = ldap.get_entry(dn) + srvlist = entry.single_value.get('defaultServerList', '') + srvlist = srvlist.split() + if not self.api.env.host in srvlist: + srvlist.append(self.api.env.host) + attr = ' '.join(srvlist) + entry['defaultServerList'] = attr + ldap.update_entry(entry) + except errors.NotFound: + pass + except ldap.TYPE_OR_VALUE_EXISTS: + pass + + # no restart, no updates + return False, () diff --git a/ipaserver/install/server/replicainstall.py b/ipaserver/install/server/replicainstall.py index 7e04374..ba9b0f0 100644 --- a/ipaserver/install/server/replicainstall.py +++ b/ipaserver/install/server/replicainstall.py @@ -897,8 +897,6 @@ def install(installer): print("Configuration of client side components failed!") raise RuntimeError("Failed to configure the client") - ds.replica_populate() - # update DNA shared config entry is done as far as possible # from restart to avoid waiting for its creation ds.update_dna_shared_config() @@ -1529,9 +1527,6 @@ def promote(installer): config.dirman_password, kra_cert_bundle=ca_data) - - ds.replica_populate() - # update DNA shared config entry is done as far as possible # from restart to avoid waiting for its creation ds.update_dna_shared_config()