URL: https://github.com/freeipa/freeipa/pull/784
Author: flo-renaud
 Title: #784: ipa-replica-manage del (dl 0): remove server from 
defaultServerList
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/784/head:pr784
git checkout pr784
From b56b626ea5a10564d7eee99c6747cb2fbc051d9f Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <f...@redhat.com>
Date: Fri, 12 May 2017 09:54:40 +0200
Subject: [PATCH] ipa-replica-manage del (dl 0): remove server from
 defaultServerList

ipa-replica-manage del should remove the server from the entry
cn=default,ou=profile,$BASE
The entry contains an attribute
defaultServerList: srv1.domain.com srv2.domain.com srv3.domain.com

The code calls srvlist = ret.single_value.get('defaultServerList') which means
that srvlist contains a single value (string) containing all the servers
separated by a space, and not a list of attribute values. Because of that,
srvlist[0] corresponds to the first character of the value.
The fix splits srvlist and not srvlist[0].

https://pagure.io/freeipa/issue/6946
---
 ipaserver/install/replication.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ipaserver/install/replication.py b/ipaserver/install/replication.py
index 3cd871e5df..1c7955c7cb 100644
--- a/ipaserver/install/replication.py
+++ b/ipaserver/install/replication.py
@@ -1336,17 +1336,17 @@ def replica_cleanup(self, replica, realm, force=False):
             dn = DN(('cn', 'default'), ('ou', 'profile'), self.suffix)
             ret = self.conn.get_entry(dn)
             srvlist = ret.single_value.get('defaultServerList', '')
-            srvlist = srvlist[0].split()
+            srvlist = srvlist.split()
             if replica in srvlist:
                 srvlist.remove(replica)
                 attr = ' '.join(srvlist)
-                mod = [(ldap.MOD_REPLACE, 'defaultServerList', attr)]
-                self.conn.modify_s(dn, mod)
+                ret['defaultServerList'] = attr
+                self.conn.update_entry(ret)
         except errors.NotFound:
             pass
-        except ldap.NO_SUCH_ATTRIBUTE:
+        except errors.MidairCollision:
             pass
-        except ldap.TYPE_OR_VALUE_EXISTS:
+        except errors.EmptyModlist:
             pass
         except Exception as e:
             if force and err:
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to