URL: https://github.com/freeipa/freeipa/pull/324 Author: tbordaz Title: #324: Check for conflict entries before raising domain level Action: opened
PR body: """ Checking of conflicts is not only done in topology container as tests showed it can occurs elsewhere https://fedorahosted.org/freeipa/ticket/6534 """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/324/head:pr324 git checkout pr324
From 617cb8e8f6040316eb2bf3e54a1bed93d502542b Mon Sep 17 00:00:00 2001 From: Ludwig Krispenz <lkris...@redhat.com> Date: Fri, 9 Dec 2016 15:04:21 +0100 Subject: [PATCH] Check for conflict entries before raising domain level Checking of conflicts is not only done in topology container as tests showed it can occurs elsewhere https://fedorahosted.org/freeipa/ticket/6534 --- ipaserver/plugins/domainlevel.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/ipaserver/plugins/domainlevel.py b/ipaserver/plugins/domainlevel.py index 42603d7..9713046 100644 --- a/ipaserver/plugins/domainlevel.py +++ b/ipaserver/plugins/domainlevel.py @@ -48,6 +48,30 @@ def get_domainlevel_range(master_entry): return DomainLevelRange(0, 0) +def check_conflict_entries(ldap, api): + """ + Returns true if conflict entries exist in topology subtree + """ + + container_dn = DN( + ('cn', 'ipa'), + ('cn', 'etc'), + api.env.basedn + ) + + try: + conflicts, _dummy = ldap.find_entries( + filter="(&(nsds5replconflict=*)(|(objectclass=ldapsubentry)(objectclass=*)))", + base_dn=container_dn, + scope=ldap.SCOPE_SUBTREE) + except errors.EmptyResult: + conflicts = None + + if conflicts: + return True + else: + return False + def get_master_entries(ldap, api): """ Returns list of LDAPEntries representing IPA masters. @@ -131,6 +155,13 @@ def execute(self, *args, **options): .format(desired_value, master['cn'][0])) raise errors.InvalidDomainLevelError(reason=message) + # Check if conflict entries exist in topology subtree, should be resolved first + if check_conflict_entries(ldap, self.api): + message = _("Domain Level cannot be raised to {0}, " + "existing replication conflicts have to be resolved." + .format(desired_value)) + raise errors.InvalidDomainLevelError(reason=message) + current_entry.single_value['ipaDomainLevel'] = desired_value ldap.update_entry(current_entry)
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code