On 06/08/2012 12:31 PM, Petr Viktorin wrote:
On 06/08/2012 04:39 AM, Rob Crittenden wrote:
Petr Viktorin wrote:
While messing with the ipa-ldap-updater, I found the order method was
using an algorithm that could give incorrect results. I'm submitting a
fix in an extra patch, as it's largely unrelated and shouldn't be so
controversial.
Can you open a ticket on this? We like to have a ticket for every commit
(minus a random one-liner here and there).
thanks
rob
Created a ticket, and added a link to the commit message.
https://fedorahosted.org/freeipa/ticket/2820
... and forgot to attach the patch.
--
PetrĀ³
From 5a632211bef20bf4d473d8877f6c7c784f8e8c2b Mon Sep 17 00:00:00 2001
From: Petr Viktorin pvikt...@redhat.com
Date: Wed, 30 May 2012 08:03:49 -0400
Subject: [PATCH] Fix update plugin order
Sort a filtered list in the update plugin ordering method.
Unlike the previous algorithm, this always gives a correct order.
It should also be faster and more readable.
https://fedorahosted.org/freeipa/ticket/2820
---
ipaserver/install/plugins/updateclient.py | 20 +---
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/ipaserver/install/plugins/updateclient.py b/ipaserver/install/plugins/updateclient.py
index a2a2ce2aa7f2411c97f2b4961423f4e952af6596..10d899abcad091a3396d4315d877b5656068775e 100644
--- a/ipaserver/install/plugins/updateclient.py
+++ b/ipaserver/install/plugins/updateclient.py
@@ -106,22 +106,12 @@ def create_context(self, dm_password):
self.Backend.ldap2.connect(bind_dn='cn=Directory Manager', bind_pw=dm_password, autobind=autobind)
def order(self, updatetype):
+Return plugins of the given updatetype in sorted order.
-Calculate rough order of plugins.
-
-order = []
-for plugin in api.Updater(): #pylint: disable=E1101
-if plugin.updatetype != updatetype:
-continue
-if plugin.order == FIRST:
-order.insert(0, plugin)
-elif plugin.order == MIDDLE:
-order.insert(len(order)/2, plugin)
-else:
-order.append(plugin)
-
-for o in order:
-yield o
+ordered = [plugin for plugin in api.Updater() # pylint: disable=E1101
+ if plugin.updatetype == updatetype]
+ordered.sort(key=lambda p: p.order)
+return ordered
def update(self, updatetype, dm_password, ldapi, live_run):
--
1.7.10.2
___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel